data tables api docs and remove fiedls option from data tables api
This commit is contained in:
+212
-82
@@ -2417,12 +2417,12 @@ Request Body:
|
|||||||
|
|
||||||
<h5>Arguments</h5>
|
<h5>Arguments</h5>
|
||||||
<dl class="argument-list">
|
<dl class="argument-list">
|
||||||
<dt>appTable</dt>
|
<dt>apptable</dt>
|
||||||
<dd><span>optional</span></dd>
|
<dd><span>optional</span></dd>
|
||||||
<dd>The Mifos X core application table.</dd>
|
<dd>The Mifos X core application table.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>Example Requests: </p>
|
<p>Example Requests: </p>
|
||||||
<div class=apiClick>datatables?appTable=m_client</div>
|
<div class=apiClick>datatables?apptable=m_client</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div class=apiClick>datatables</div>
|
<div class=apiClick>datatables</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2451,112 +2451,242 @@ Request Body:
|
|||||||
<div class="method-description">
|
<div class="method-description">
|
||||||
<h4>Register Data Table</h4>
|
<h4>Register Data Table</h4>
|
||||||
<p>
|
<p>
|
||||||
Registers a data table with the Mifos X Core application table.
|
Registers a data table with the Mifos X Core application table. This allows the data table to be maintained through the API.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="method-example">
|
<div class="method-example">
|
||||||
<code class="method-declaration">POST https://Domain Name/api/v1/datatable/{datatable}/{set}/{id}</code>
|
<code class="method-declaration">POST https://Domain Name/api/v1/datatables/register/{datatable}/{apptable}</code>
|
||||||
<code class="method-request">POST additionalfields/portfolio_client/Additional Information/2
|
<code class="method-request">POST datatables/register/New Table/m_client
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Request Body:
|
Request Body:
|
||||||
{
|
{
|
||||||
"Ethnic_Group":"Berber",
|
|
||||||
"Ethnic_Group_Other":"",
|
|
||||||
"Household_Location":"East Sikkim",
|
|
||||||
"Household_Location_Other":"",
|
|
||||||
"Religion":"Animist",
|
|
||||||
"Religion_Other":"jjjjjjj",
|
|
||||||
"Knowledge_of_Person":"Son/daughter of staff member",
|
|
||||||
"Gender":"Female",
|
|
||||||
"Whois":"its\r\nme of\r\ncourse\r\nyes\r\nend and the end of it all"
|
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
<code class="method-response">{
|
<code class="method-response">{
|
||||||
"entityId": 2
|
"entityId": null
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<a id="additionalfields_retrieve" name="additionalfields_retrieve" class="old-syle-anchor"> </a>
|
<a id="datatables_deregister" name="datatables_deregister" class="old-syle-anchor"> </a>
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
<div class="method-description">
|
<div class="method-description">
|
||||||
<h4>Retrieve Additional Fields</h4>
|
<h4>Deregister Data Table</h4>
|
||||||
<p>
|
<p>
|
||||||
Returns the Set of Additional Fields data for the ID provided. The ID is the id field of the Type table e.g. portfolio_client might have an id value of 4. The output is a JSON formatted "Generic Resultset". The Generic Resultset contains Column Heading as well as Data information. The Column Heading information may include allowed values (columnValues array).
|
Deregisters a data table. It will no longer be available through the API.
|
||||||
</p>
|
</p>
|
||||||
<p>Example Request:
|
|
||||||
<div class=apiClick>additionalfields/m_client/Additional Information/2</div>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="method-example">
|
<div class="method-example">
|
||||||
<code class="method-declaration">GET https://Domain Name/api/v1/additionalfields/{type}/{set}/{id}</code>
|
<code class="method-declaration">POST https://Domain Name/api/v1/datatables/deregister/{datatable}</code>
|
||||||
|
<code class="method-request">POST datatables/register/New Table
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
</code>
|
||||||
<code class="method-response">{
|
<code class="method-response">{
|
||||||
"columnHeaders" : [ {
|
"entityId": null
|
||||||
"columnName" : "Ethnic Group",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : "List",
|
|
||||||
"columnValues" : [ "Bedouin", "Berber", "Italian", "Miknasa", "Mrazig", "Other", "Unknown" ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Ethnic Group Other",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : null,
|
|
||||||
"columnValues" : [ ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Household Location",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : "List",
|
|
||||||
"columnValues" : [ "East Sikkim", "North Sikkim", "South Sikkim", "West Sikkim", "Other" ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Household Location Other",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : null,
|
|
||||||
"columnValues" : [ ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Religion",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : "List",
|
|
||||||
"columnValues" : [ "Protestant", "Catholic", "Muslim", "Animist", "Atheist", "Other", "Unknown" ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Religion Other",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : null,
|
|
||||||
"columnValues" : [ ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Knowledge of Person",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 50,
|
|
||||||
"columnDisplayType" : "List",
|
|
||||||
"columnValues" : [ "Staff member", "Spouse of staff member", "Son/daughter of staff member", "Friend of staff member", "Not known by any staff member", "Other" ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Gender",
|
|
||||||
"columnType" : "String",
|
|
||||||
"columnLength" : 10,
|
|
||||||
"columnDisplayType" : "List",
|
|
||||||
"columnValues" : [ "Female", "Male" ]
|
|
||||||
}, {
|
|
||||||
"columnName" : "Whois",
|
|
||||||
"columnType" : "Text",
|
|
||||||
"columnLength" : null,
|
|
||||||
"columnDisplayType" : null,
|
|
||||||
"columnValues" : [ ]
|
|
||||||
} ],
|
|
||||||
"data" : [ {
|
|
||||||
"row" : [ "Bedouin", null, "East Sikkim", null, "Animist", "Agnostic", "Friend of staff member", "Female", "A person of honesty & clear thought" ]
|
|
||||||
} ]
|
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<a id="datatables_create" name="datatables_create" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Create Entry in Data Table</h4>
|
||||||
|
<p>
|
||||||
|
Adds a row to the data table.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Note that the default datatable UI functionality converts any field name containing spaces to underscores when using the API.
|
||||||
|
This means the field name "Business Description" is considered the same as "Business_Description".
|
||||||
|
So you shouldn't have both "versions" in any data table.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">POST https://Domain Name/api/v1/datatables/{datatable}/{apptableId}</code>
|
||||||
|
<code class="method-request">POST datatables/Additional Client Fields Data/1
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
"Business Description": "Livestock sales",
|
||||||
|
Comment: "First comment\nmade",
|
||||||
|
Education_cv: "Trade",
|
||||||
|
Gender_cd: "21",
|
||||||
|
"Highest Rate Paid": "8.5",
|
||||||
|
"Next Visit": "01 October 2012",
|
||||||
|
"Years in Business": "5",
|
||||||
|
dateFormat: "dd MMMM yyyy",
|
||||||
|
locale: "en"
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">{
|
||||||
|
"entityId": 1
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="datatables_retrieve" name="datatables_retrieve" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Retrieve Entry(s) from Data Table</h4>
|
||||||
|
<p>
|
||||||
|
Gets the entry (if it exists) for data tables that are one to one with the application table. <br>
|
||||||
|
Gets the entries (if they exist) for data tables that are one to many with the application table.
|
||||||
|
</p>
|
||||||
|
<p>Note: The 'fields' parameter is not available for datatables.</p>
|
||||||
|
|
||||||
|
<h5>Arguments</h5>
|
||||||
|
<dl class="argument-list">
|
||||||
|
<dt>order</dt>
|
||||||
|
<dd><span>optional</span></dd>
|
||||||
|
<dd>Specifies the order in which data is returned.</dd>
|
||||||
|
<dt>genericResultSet</dt>
|
||||||
|
<dd><span>optional</span></dd>
|
||||||
|
<dd>If 'true' a Generic Result Set JSON format is returned.
|
||||||
|
This format is used by the default data tables UI functionality.</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<p>Example Requests: </p>
|
||||||
|
<div class=apiClick>datatables/Additional Client Fields Data/1</div>
|
||||||
|
<br><br>
|
||||||
|
<div class=apiClick>datatables/Extra Family Details Data/1?order=`Date of Birth` desc</div>
|
||||||
|
<br><br>
|
||||||
|
<div class=apiClick>datatables/Additional Client Fields Data/1?genericResultSet=true</div>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">GET https://Domain Name/api/v1/datatables/{datatable}/{apptableId}</code>
|
||||||
|
<code class="method-response">[
|
||||||
|
{"client_id": 1,
|
||||||
|
"Business Description": "Livestock sales",
|
||||||
|
"Years in Business": 5,
|
||||||
|
"Gender_cd": "21",
|
||||||
|
"Education_cv": "Trade",
|
||||||
|
"Next Visit": [2012, 10, 1],
|
||||||
|
"Highest Rate Paid": 8.500000,
|
||||||
|
"Comment": "First comment
|
||||||
|
made"}
|
||||||
|
]
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<a id="datatables_update" name="datatables_update" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Update Entry in Data Table (One to One)</h4>
|
||||||
|
<p>
|
||||||
|
Updates the row (if it exists) of the data table.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">PUT https://Domain Name/api/v1/datatables/{datatable}/{apptableId}</code>
|
||||||
|
<code class="method-request">PUT datatables/Additional Client Fields Data/1
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
"Business Description": "Livestock sales updated",
|
||||||
|
Comment: "First comment\nmade",
|
||||||
|
Education_cv: "Trade",
|
||||||
|
Gender_cd: "21",
|
||||||
|
"Highest Rate Paid": "8.5",
|
||||||
|
"Next Visit": "01 October 2012",
|
||||||
|
"Years in Business": "5",
|
||||||
|
dateFormat: "dd MMMM yyyy",
|
||||||
|
locale: "en"
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">{
|
||||||
|
"entityId": 1
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="datatables_update_1M" name="datatables_update_1M" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Update Entry in Data Table (One to Many)</h4>
|
||||||
|
<p>
|
||||||
|
Updates the row (if it exists) of the data table.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">PUT https://Domain Name/api/v1/datatables/{datatable}/{apptableId}/{datatableId}</code>
|
||||||
|
<code class="method-request">PUT datatables/Extra Family Details Data/1/2
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
"Date of Birth": "01 June 1982",
|
||||||
|
Education_cdHighest: "5",
|
||||||
|
Name: "June",
|
||||||
|
"Other Notes": "More\nnotes",
|
||||||
|
"Points Score": "20",
|
||||||
|
dateFormat: "dd MMMM yyyy",
|
||||||
|
locale: "en"
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">{
|
||||||
|
"entityId": 1
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="datatables_delete" name="datatables_delete" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Delete Entry(s) in Data Table</h4>
|
||||||
|
<p>
|
||||||
|
Deletes the entry (if it exists) for data tables that are one to one with the application table. <br>
|
||||||
|
Deletes the entries (if they exist) for data tables that are one to many with the application table.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">DELETE https://Domain Name/api/v1/datatables/{datatable}/{apptableId}</code>
|
||||||
|
<code class="method-request">DELETE datatables/Additional Client Fields Data/1
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">{
|
||||||
|
"entityId": 1
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="datatables_delete_1M" name="datatables_delete_1M" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Delete Entry in Data Table (One to Many)</h4>
|
||||||
|
<p>
|
||||||
|
Deletes the entry (if it exists) for data tables that are one to many with the application table.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">DELETE https://Domain Name/api/v1/datatables/{datatable}/{apptableId}/{datatableId}</code>
|
||||||
|
<code class="method-request">DELETE datatables/Extra Family Details Data/1/2
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">{
|
||||||
|
"entityId": 1
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- start of reports api docs -->
|
<!-- start of reports api docs -->
|
||||||
<a id="reports" name="reports" class="old-syle-anchor"> </a>
|
<a id="reports" name="reports" class="old-syle-anchor"> </a>
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ public class DataTableApiResource {
|
|||||||
@GET
|
@GET
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String getDatatables(@QueryParam("appTable") final String appTable,
|
public String getDatatables(@QueryParam("apptable") final String apptable,
|
||||||
@Context final UriInfo uriInfo) {
|
@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
List<DatatableData> result = this.readWriteNonCoreDataService
|
List<DatatableData> result = this.readWriteNonCoreDataService
|
||||||
.retrieveDatatableNames(appTable);
|
.retrieveDatatableNames(apptable);
|
||||||
|
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||||
.getQueryParameters());
|
.getQueryParameters());
|
||||||
@@ -79,14 +79,14 @@ public class DataTableApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("register/{datatable}/{appTable}")
|
@Path("register/{datatable}/{apptable}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response registerDatatable(
|
public Response registerDatatable(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTable") final String appTable) {
|
@PathParam("apptable") final String apptable) {
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.registerDatatable(datatable, appTable);
|
this.readWriteNonCoreDataService.registerDatatable(datatable, apptable);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier();
|
EntityIdentifier entityIdentifier = new EntityIdentifier();
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
@@ -106,20 +106,19 @@ public class DataTableApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{datatable}/{appTableId}")
|
@Path("{datatable}/{apptableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String getDatatable(@PathParam("datatable") final String datatable,
|
public String getDatatable(@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId,
|
@PathParam("apptableId") final Long apptableId,
|
||||||
@QueryParam("sqlFields") final String sqlFields,
|
@QueryParam("order") final String order,
|
||||||
@QueryParam("sqlOrder") final String sqlOrder,
|
|
||||||
@Context final UriInfo uriInfo) {
|
@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
checkUserPermissionForDatatable(datatable, "READ");
|
checkUserPermissionForDatatable(datatable, "READ");
|
||||||
|
|
||||||
GenericResultsetData results = this.readWriteNonCoreDataService
|
GenericResultsetData results = this.readWriteNonCoreDataService
|
||||||
.retrieveDataTableGenericResultSet(datatable, appTableId,
|
.retrieveDataTableGenericResultSet(datatable, apptableId,
|
||||||
sqlFields, sqlOrder, null);
|
order, null);
|
||||||
|
|
||||||
String json = "";
|
String json = "";
|
||||||
final boolean genericResultSet = ApiParameterHelper.genericResultSet(uriInfo.getQueryParameters());
|
final boolean genericResultSet = ApiParameterHelper.genericResultSet(uriInfo.getQueryParameters());
|
||||||
@@ -134,34 +133,34 @@ public class DataTableApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{datatable}/{appTableId}")
|
@Path("{datatable}/{apptableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response newDatatableEntry(
|
public Response newDatatableEntry(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId,
|
@PathParam("apptableId") final Long apptableId,
|
||||||
final String jsonRequestBody) {
|
final String jsonRequestBody) {
|
||||||
|
|
||||||
checkUserPermissionForDatatable(datatable, "CREATE");
|
checkUserPermissionForDatatable(datatable, "CREATE");
|
||||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.newDatatableEntry(datatable,
|
this.readWriteNonCoreDataService.newDatatableEntry(datatable,
|
||||||
appTableId, queryParams);
|
apptableId, queryParams);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||||
Long.valueOf(appTableId));
|
Long.valueOf(apptableId));
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{datatable}/{appTableId}")
|
@Path("{datatable}/{apptableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response updateDatatableEntryOnetoOne(
|
public Response updateDatatableEntryOnetoOne(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId,
|
@PathParam("apptableId") final Long apptableId,
|
||||||
final String jsonRequestBody) {
|
final String jsonRequestBody) {
|
||||||
/*
|
/*
|
||||||
* for updating one to one relationships (where foreign key is the
|
* for updating one to one relationships (where foreign key is the
|
||||||
@@ -171,22 +170,22 @@ public class DataTableApiResource {
|
|||||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.updateDatatableEntryOnetoOne(
|
this.readWriteNonCoreDataService.updateDatatableEntryOnetoOne(
|
||||||
datatable, appTableId, queryParams);
|
datatable, apptableId, queryParams);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||||
Long.valueOf(appTableId));
|
Long.valueOf(apptableId));
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{datatable}/{appTableId}/{datatableId}")
|
@Path("{datatable}/{apptableId}/{datatableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response updateDatatableEntryOnetoOne(
|
public Response updateDatatableEntryOnetoOne(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId,
|
@PathParam("apptableId") final Long apptableId,
|
||||||
@PathParam("datatableId") final Long datatableId,
|
@PathParam("datatableId") final Long datatableId,
|
||||||
final String jsonRequestBody) {
|
final String jsonRequestBody) {
|
||||||
/*
|
/*
|
||||||
@@ -197,51 +196,51 @@ public class DataTableApiResource {
|
|||||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.updateDatatableEntryOnetoMany(
|
this.readWriteNonCoreDataService.updateDatatableEntryOnetoMany(
|
||||||
datatable, appTableId, datatableId, queryParams);
|
datatable, apptableId, datatableId, queryParams);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||||
Long.valueOf(appTableId));
|
Long.valueOf(apptableId));
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{datatable}/{appTableId}")
|
@Path("{datatable}/{apptableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response deleteDatatableEntries(
|
public Response deleteDatatableEntries(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId) {
|
@PathParam("apptableId") final Long apptableId) {
|
||||||
|
|
||||||
checkUserPermissionForDatatable(datatable, "DELETE");
|
checkUserPermissionForDatatable(datatable, "DELETE");
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.deleteDatatableEntries(datatable,
|
this.readWriteNonCoreDataService.deleteDatatableEntries(datatable,
|
||||||
appTableId);
|
apptableId);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||||
Long.valueOf(appTableId));
|
Long.valueOf(apptableId));
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{datatable}/{appTableId}/{datatableId}")
|
@Path("{datatable}/{apptableId}/{datatableId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response deleteDatatableEntries(
|
public Response deleteDatatableEntries(
|
||||||
@PathParam("datatable") final String datatable,
|
@PathParam("datatable") final String datatable,
|
||||||
@PathParam("appTableId") final Long appTableId,
|
@PathParam("apptableId") final Long apptableId,
|
||||||
@PathParam("datatableId") final Long datatableId) {
|
@PathParam("datatableId") final Long datatableId) {
|
||||||
|
|
||||||
checkUserPermissionForDatatable(datatable, "DELETE");
|
checkUserPermissionForDatatable(datatable, "DELETE");
|
||||||
|
|
||||||
this.readWriteNonCoreDataService.deleteDatatableEntry(datatable,
|
this.readWriteNonCoreDataService.deleteDatatableEntry(datatable,
|
||||||
appTableId, datatableId);
|
apptableId, datatableId);
|
||||||
|
|
||||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||||
Long.valueOf(appTableId));
|
Long.valueOf(apptableId));
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return Response.ok().entity(entityIdentifier).build();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ public interface ReadWriteNonCoreDataService {
|
|||||||
void deregisterDatatable(String datatable);
|
void deregisterDatatable(String datatable);
|
||||||
|
|
||||||
GenericResultsetData retrieveDataTableGenericResultSet(String datatable,
|
GenericResultsetData retrieveDataTableGenericResultSet(String datatable,
|
||||||
Long appTableId, String sqlFields, String sqlOrder, Long id);
|
Long appTableId, String order, Long id);
|
||||||
|
|
||||||
void newDatatableEntry(String datatable, Long appTableId,
|
void newDatatableEntry(String datatable, Long appTableId,
|
||||||
Map<String, String> queryParams);
|
Map<String, String> queryParams);
|
||||||
|
|||||||
+12
-15
@@ -203,7 +203,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable,
|
GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable,
|
||||||
appTableId, null, null, null);
|
appTableId, null, null);
|
||||||
|
|
||||||
if (grs.getData().size() == 0)
|
if (grs.getData().size() == 0)
|
||||||
throw new DataTableNotFoundException(datatable, appTableId);
|
throw new DataTableNotFoundException(datatable, appTableId);
|
||||||
@@ -240,7 +240,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable,
|
GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable,
|
||||||
appTableId, null, null, datatableId);
|
appTableId, null, datatableId);
|
||||||
|
|
||||||
if (grs.getData().size() == 0)
|
if (grs.getData().size() == 0)
|
||||||
throw new DataTableNotFoundException(datatable, appTableId);
|
throw new DataTableNotFoundException(datatable, appTableId);
|
||||||
@@ -302,8 +302,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenericResultsetData retrieveDataTableGenericResultSet(
|
public GenericResultsetData retrieveDataTableGenericResultSet(
|
||||||
String datatable, Long appTableId, String sqlFields,
|
String datatable, Long appTableId, String order, Long id) {
|
||||||
String sqlOrder, Long id) {
|
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -312,23 +311,19 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
|
|
||||||
List<ResultsetColumnHeader> columnHeaders = getDatatableResultsetColumnHeaders(datatable);
|
List<ResultsetColumnHeader> columnHeaders = getDatatableResultsetColumnHeaders(datatable);
|
||||||
|
|
||||||
String sql = "select ";
|
String sql = "";
|
||||||
if (sqlFields != null)
|
|
||||||
sql = sql + sqlFields;
|
|
||||||
else
|
|
||||||
sql = sql + " * ";
|
|
||||||
|
|
||||||
// id only used for reading a specific entry in a one to many datatable
|
// id only used for reading a specific entry in a one to many datatable
|
||||||
// (when updating)
|
// (when updating)
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
sql = sql + " from `" + datatable + "` where "
|
sql = sql + "select * from `" + datatable + "` where "
|
||||||
+ getFKField(appTable) + " = " + appTableId;
|
+ getFKField(appTable) + " = " + appTableId;
|
||||||
} else {
|
} else {
|
||||||
sql = sql + " from `" + datatable + "` where id = " + id;
|
sql = sql + "select * from `" + datatable + "` where id = " + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqlOrder != null)
|
if (order != null)
|
||||||
sql = sql + " order by " + sqlOrder;
|
sql = sql + " order by " + order;
|
||||||
|
|
||||||
List<ResultsetDataRow> result = fillDatatableResultSetDataRows(sql);
|
List<ResultsetDataRow> result = fillDatatableResultSetDataRows(sql);
|
||||||
|
|
||||||
@@ -806,7 +801,8 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
ApiParameterError error = ApiParameterError.parameterError(
|
ApiParameterError error = ApiParameterError.parameterError(
|
||||||
"error.msg.invalid.columnValue",
|
"error.msg.invalid.columnValue",
|
||||||
"Value not found in Allowed Value list", columnHeader.getColumnName(), paramValue);
|
"Value not found in Allowed Value list",
|
||||||
|
columnHeader.getColumnName(), paramValue);
|
||||||
dataValidationErrors.add(error);
|
dataValidationErrors.add(error);
|
||||||
throw new PlatformApiDataValidationException(
|
throw new PlatformApiDataValidationException(
|
||||||
"validation.msg.validation.errors.exist",
|
"validation.msg.validation.errors.exist",
|
||||||
@@ -822,7 +818,8 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
ApiParameterError error = ApiParameterError.parameterError(
|
ApiParameterError error = ApiParameterError.parameterError(
|
||||||
"error.msg.invalid.columnValue",
|
"error.msg.invalid.columnValue",
|
||||||
"Value not found in Allowed Value list", columnHeader.getColumnName(), paramValue);
|
"Value not found in Allowed Value list",
|
||||||
|
columnHeader.getColumnName(), paramValue);
|
||||||
dataValidationErrors.add(error);
|
dataValidationErrors.add(error);
|
||||||
throw new PlatformApiDataValidationException(
|
throw new PlatformApiDataValidationException(
|
||||||
"validation.msg.validation.errors.exist",
|
"validation.msg.validation.errors.exist",
|
||||||
|
|||||||
Reference in New Issue
Block a user