ensure retrieval of head office returns no allowedParents.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosng.platform.api;
|
package org.mifosng.platform.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -81,6 +82,9 @@ public class OfficesApiResource {
|
|||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate();
|
OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate();
|
||||||
|
List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>(this.readPlatformService.retrieveAllOfficesForLookup());
|
||||||
|
office = OfficeData.appendedTemplate(office, allowedParents);
|
||||||
|
typicalResponseParameters.add("allowedParents");
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, typicalResponseParameters, office);
|
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, typicalResponseParameters, office);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-10
@@ -141,24 +141,26 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>();
|
||||||
retrieveAllOfficesForLookup());
|
|
||||||
|
|
||||||
return OfficeData.template(parentLookups, new LocalDate());
|
return OfficeData.template(parentLookups, new LocalDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OfficeLookup> retrieveAllowedParents(Long officeId) {
|
public List<OfficeLookup> retrieveAllowedParents(final Long officeId) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(retrieveAllOfficesForLookup());
|
|
||||||
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
||||||
|
|
||||||
for (OfficeLookup office : parentLookups) {
|
if (isNotHeadOffice(officeId)) {
|
||||||
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(retrieveAllOfficesForLookup());
|
||||||
if (!office.getId().equals(officeId)) {
|
|
||||||
filterParentLookups.add(office);
|
|
||||||
|
for (OfficeLookup office : parentLookups) {
|
||||||
|
|
||||||
|
if (!office.getId().equals(officeId)) {
|
||||||
|
filterParentLookups.add(office);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +168,10 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isNotHeadOffice(final Long officeId) {
|
||||||
|
return !Long.valueOf(1).equals(officeId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OfficeTransactionData retrieveNewOfficeTransactionDetails() {
|
public OfficeTransactionData retrieveNewOfficeTransactionDetails() {
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user