diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index cdef2fb9d..dfc30a8c6 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -8435,10 +8435,7 @@ Request Body:
Delete Entry(s) in Data Table
- Deletes the entry (if it exists) for data tables that are one to
- one with the application table.
Deletes the entries (if
- they exist) for data tables that are one to many with the
- application table.
+ Deletes the entry (if it exists) for data tables that are one-to-one with the application table.
Deletes the entries (if they exist) for data tables that are one-to-many with the application table.
@@ -8446,14 +8443,17 @@ Request Body:
DELETE https://DomainName/api/v1/datatables/{datatable}/{apptableId}
-DELETE datatables/Additional Client Fields Data/1
+DELETE datatables/extra_client_details/1
Content-Type: application/json
-
Request Body:
{}
- { "resourceId": 1 }
+
+{
+ "resourceId": 1
+}
+
@@ -8461,7 +8461,7 @@ Request Body:
class="old-syle-anchor">
-
Delete Entry in Data Table (One to Many)
+
Delete Entry in Datatable (One to Many)
Deletes the entry (if it exists) for data tables that are
one to many with the application table.
@@ -8470,13 +8470,17 @@ Request Body:
DELETE https://DomainName/api/v1/datatables/{datatable}/{apptableId}/{datatableId}
-DELETE datatables/Extra Family Details Data/1/2
+DELETE datatables/extra_family_details/1/2
Content-Type: application/json
Request Body:
{}
-
{ "resourceId": 1 }
+
+{
+ "resourceId": 1
+}
+
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
index 564131fd2..552e68575 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
@@ -23,8 +23,8 @@ public class CommandWrapper {
private final Long datatableId;
private final Long codeId;
private final String transactionId;
- private String supportedEntityType;
- private Long supportedEntityId;
+ private final String supportedEntityType;
+ private final Long supportedEntityId;
public static CommandWrapper wrap(final String actionName, final String enityName, final Long resourceId) {
return new CommandWrapper(null, actionName, enityName, resourceId);
@@ -163,7 +163,7 @@ public class CommandWrapper {
|| (isUpdateOperation() && this.entityId != null);
}
- private boolean isUpdateOperation() {
+ public boolean isUpdateOperation() {
return this.actionName.equalsIgnoreCase("UPDATE");
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
index a64ee7bcb..dc539f5cb 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
@@ -77,7 +77,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
commandSourceResult.updateJsonTo(changesOnlyJson);
}
- if (!result.hasChanges() && wrapper.isUpdate()) {
+ if (!result.hasChanges() && wrapper.isUpdateOperation()) {
commandSourceResult.updateJsonTo(null);
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DatatablesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DatatablesApiResource.java
index f8eea1764..39a9771d8 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DatatablesApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DatatablesApiResource.java
@@ -79,7 +79,6 @@ public class DatatablesApiResource {
this.readWriteNonCoreDataService.registerDatatable(datatable, apptable);
final CommandProcessingResult result = new CommandProcessingResultBuilder().withResourceIdAsString(datatable).build();
-
return this.toApiJsonSerializer.serialize(result);
}
@@ -151,8 +150,10 @@ public class DatatablesApiResource {
public String createDatatableEntry(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId,
final String apiRequestBodyAsJson) {
- final CommandWrapper commandRequest = new CommandWrapperBuilder().createDatatable(datatable, apptableId, null)
- .withJson(apiRequestBodyAsJson).build();
+ final CommandWrapper commandRequest = new CommandWrapperBuilder() //
+ .createDatatable(datatable, apptableId, null) //
+ .withJson(apiRequestBodyAsJson) //
+ .build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -166,8 +167,10 @@ public class DatatablesApiResource {
public String updateDatatableEntryOnetoOne(@PathParam("datatable") final String datatable,
@PathParam("apptableId") final Long apptableId, final String apiRequestBodyAsJson) {
- final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, null)
- .withJson(apiRequestBodyAsJson).build();
+ final CommandWrapper commandRequest = new CommandWrapperBuilder() //
+ .updateDatatable(datatable, apptableId, null) //
+ .withJson(apiRequestBodyAsJson) //
+ .build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -182,8 +185,10 @@ public class DatatablesApiResource {
@PathParam("apptableId") final Long apptableId, @PathParam("datatableId") final Long datatableId,
final String apiRequestBodyAsJson) {
- final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, datatableId)
- .withJson(apiRequestBodyAsJson).build();
+ final CommandWrapper commandRequest = new CommandWrapperBuilder() //
+ .updateDatatable(datatable, apptableId, datatableId) //
+ .withJson(apiRequestBodyAsJson) //
+ .build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -196,7 +201,9 @@ public class DatatablesApiResource {
@Produces({ MediaType.APPLICATION_JSON })
public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId) {
- final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, null).build();
+ final CommandWrapper commandRequest = new CommandWrapperBuilder() //
+ .deleteDatatable(datatable, apptableId, null) //
+ .build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -210,7 +217,9 @@ public class DatatablesApiResource {
public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId,
@PathParam("datatableId") final Long datatableId) {
- final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, datatableId).build();
+ final CommandWrapper commandRequest = new CommandWrapperBuilder() //
+ .deleteDatatable(datatable, apptableId, datatableId) //
+ .build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java
index 16dfa67f8..034d60fe8 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Immutable data object for generic resultset data.
*/
-public class GenericResultsetData {
+public final class GenericResultsetData {
private final List columnHeaders;
private final List data;
@@ -28,4 +28,28 @@ public class GenericResultsetData {
public List getData() {
return data;
}
+
+ public String getColTypeOfColumnNamed(final String columnName) {
+
+ String colType = null;
+ for (ResultsetColumnHeaderData columnHeader : this.columnHeaders) {
+ if (columnHeader.isNamed(columnName)) {
+ colType = columnHeader.getColumnType();
+ }
+ }
+
+ return colType;
+ }
+
+ public boolean hasNoEntries() {
+ return this.data.isEmpty();
+ }
+
+ public boolean hasEntries() {
+ return !hasNoEntries();
+ }
+
+ public boolean hasMoreThanOneEntry() {
+ return this.data.size() > 1;
+ }
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
index aa9ba795b..ae1fa104b 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java
@@ -80,6 +80,10 @@ public final class ResultsetColumnHeaderData {
this.columnDisplayType = displayType;
}
+ public boolean isNamed(final String columnName) {
+ return this.columnName.equalsIgnoreCase(columnName);
+ }
+
private boolean isAnyText() {
return isText() || isTinyText() || isMediumText() || isLongText();
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java
index 08f5de1ff..b3801a3ea 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java
@@ -30,6 +30,9 @@ public class DeleteOneToOneDatatableEntryCommandHandler implements NewCommandSou
this.writePlatformService.deleteDatatableEntries(command.entityName(), command.getApptableId());
- return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getApptableId()).build();
+ return new CommandProcessingResultBuilder() //
+ .withCommandId(command.commandId()) //
+ .withEntityId(command.getApptableId()) //
+ .build();
}
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java
index bd0d3a12e..2193bcd21 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java
@@ -242,29 +242,26 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
@Override
public Map updateDatatableEntryOneToOne(final String datatable, final Long appTableId, final JsonCommand command) {
- GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable, appTableId, null, null);
+ final GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable, appTableId, null, null);
- if (grs.getData().size() == 0) throw new DatatableNotFoundException(datatable, appTableId);
+ if (grs.hasNoEntries()) { throw new DatatableNotFoundException(datatable, appTableId); }
- if (grs.getData().size() > 1)
- throw new PlatformDataIntegrityException("error.msg.attempting.multiple.update", "Application Table: " + datatable
- + " Foreign Key Id: " + appTableId);
+ if (grs.hasMoreThanOneEntry()) { throw new PlatformDataIntegrityException("error.msg.attempting.multiple.update",
+ "Application table: " + datatable + " Foreign key id: " + appTableId); }
- String fkName = getFKField(queryForApplicationTableName(datatable));
+ final String fkName = getFKField(queryForApplicationTableName(datatable));
final Type typeOfMap = new TypeToken