This page I disclose the potential of SDD while developing REST application.
Regarding the technologies I take:
- REST with CXF
- Spring Bean for DAO
- JPA2 as persistence layer
Original WYSIWYG is revisited into What You STATE Is What You Get.
As fundamentals you need a Statement with is surrounding I/O.
The model against which the statement is applied is important but secundary.
As example for SQL, I take 3 queries:
- select * from address where latitude between ? and ? and longitude between ? and ? and lcase(city) like ?
- select * from address where addressid between ? and ?
- select * from address where lcase(city) like ?
Those queries must be given
- a name
- an input (replace question marks by sample value and provide name)
- an output (deduce from the metadata recieved after executing the query)
This information is translated into minuteproject inside the statement-model node.
<statement-model> <queries> <query name="get addresses by criteria"> <query-body><value> <![CDATA[select * from address where latitude between ? and ? and longitude between ? and ? and lcase(city) like ?]]> </value></query-body> <query-params> <query-param name="latitude_lower_limit" is-mandatory="false" type="DOUBLE" sample="37"></query-param> <query-param name="latitude_upper_limit" is-mandatory="false" type="DOUBLE" sample="38"></query-param> <query-param name="longitude_lower_limit" is-mandatory="false" type="DOUBLE" sample="-122"></query-param> <query-param name="longitude_upper_limit" is-mandatory="false" type="DOUBLE" sample="-123"></query-param> <query-param name="city" is-mandatory="false" type="STRING" sample="'S'"></query-param> </query-params> </query> <query name="get address street"> <query-body><value><![CDATA[select * from address where addressid between ? and ?]]></value></query-body> <query-params> <query-param name="identifier_Address" is-mandatory="false" type="INT" sample="1"></query-param> <query-param name="identifier_Address2" is-mandatory="false" type="INT" sample="1"></query-param> </query-params> </query> <query name="get address"> <query-body><value> <![CDATA[select * from address where lcase(city) like ?]]> </value></query-body> <query-params> <query-param name="city" is-mandatory="false" type="STRING" sample="'S'"></query-param> </query-params>
What you can expect after generating for the REST CXF track and deploying on Tomcat is to have for each statement 2 REST URL (one for XML format, one for JSON format).
So 6 paths altogether:
/rest/json/getaddressesbycriterias
/rest/xml/getaddressesbycriterias
/rest/json/getaddresses
/rest/xml/getaddresses
/rest/json/getaddressesstreets
/rest/xml/getaddressesstreets
Examples
For JSONhttp://localhost:8080/petshopRestCxfApp/rest/json/getaddressesbycriterias?latitudeLowerLimit=30.1&latitudeUpperLimit=40.555&longitudeLowerLimit=-123&longitudeUpperLimit=-122&city=mil%25
http://localhost:8080/petshopRestCxfApp/rest/json/getaddresses?city=%25m%25
http://localhost:8080/petshopRestCxfApp/rest/json/getaddressstreets?identifierAddress=1&identifierAddress2=200
For XML
http://localhost:8080/petshopRestCxfApp/rest/xml/getaddressesbycriterias?latitudeLowerLimit=30.1&latitudeUpperLimit=40.555&longitudeLowerLimit=-123&longitudeUpperLimit=-122&city=mil%25
http://localhost:8080/petshopRestCxfApp/rest/xml/getaddresses?city=%25m%25
http://localhost:8080/petshopRestCxfApp/rest/xml/getaddressstreets?identifierAddress=1&identifierAddress2=200
Sample
This feature is provided in the release 0.8.1 of minuteproject.Prerequisits:
- Java version = 1.6+
- Maven installed
- Tomcat installed
- download MP 0.8.1+
- start sample database
- In
/sample - > start-petshop.cmd/sh
- Generate
- In
/demo/config - >demo-JSF-Spring-primefaces.cmd/sh
- Package
- Add dependency: There is a maven dependency to install
- In
/target/bsla - >maven_install.cmd/sh
- Generated code goes to
/demo/output/cxf - >mvn package
- Deploy
- Start tomcat
- Drop generated artifact into
/webapps
Enjoy!
Artefacts
The generated artefacts for SDD are similar to those generated by minuteproject as a reverse engineering for track CXF.
FAQ
Why use JPA2 if you go native?
MinuteProject already have a track available for REST CXF with Spring and JPA2 as backend so it was less changes to adapt this track, and then issue JDBC statements.Is SDD limited to JPA2?
No, SDD can be spread to other tracks of minuteproject so it is not linked to JPA2.
I want this a little more complex?
You are write!
In future release, some input parameters can be considered as mandatory or not and have some validation.
No comments:
Post a Comment