filtering - rest of client gets

This commit is contained in:
John Woodlock
2012-05-27 13:38:19 +10:00
parent 7608ba4b90
commit e79cb4581c
6 changed files with 42 additions and 60 deletions
@@ -13,7 +13,7 @@ import org.joda.time.Days;
import org.joda.time.LocalDate;
@XmlRootElement(name = "client")
@JsonIgnoreProperties({ "organisationId","organisationName" })
@JsonIgnoreProperties({ "organisationId", "organisationName" })
@JsonFilter("myFilter")
public class ClientData implements Serializable {
@@ -27,18 +27,17 @@ public class ClientData implements Serializable {
private String displayName;
private String externalId;
private LocalDate joinedDate;
private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
public ClientData() {
//
}
public ClientData(final Long organisationId,
final String organisationName, final Long officeId,
final String officeName, final Long id, final String firstname,
final String lastname, final String externalId,
final LocalDate joinedDate) {
public ClientData(final Long organisationId, final String organisationName,
final Long officeId, final String officeName, final Long id,
final String firstname, final String lastname,
final String externalId, final LocalDate joinedDate) {
this.organisationId = organisationId;
this.organisationName = organisationName;
this.officeId = officeId;
@@ -46,15 +45,15 @@ public class ClientData implements Serializable {
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
this.displayName = new StringBuilder(this.firstname).append(' ').append(this.lastname).toString();
this.displayName = new StringBuilder(this.firstname).append(' ')
.append(this.lastname).toString();
this.externalId = externalId;
this.joinedDate = joinedDate;
}
public int getMaxJoinedOnOffsetFromToday() {
return Days.daysBetween(new DateTime(),
this.getJoinedDate().toDateMidnight().toDateTime())
.getDays();
this.getJoinedDate().toDateMidnight().toDateTime()).getDays();
}
public Long getId() {
@@ -5,7 +5,10 @@ import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.map.annotate.JsonFilter;
@XmlRootElement
@JsonFilter("myFilter")
public class ClientLoanAccountSummaryCollectionData {
private List<ClientLoanAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientLoanAccountSummaryData>();
@@ -19,19 +19,19 @@ public class ClientLoanAccountSummaryData implements Serializable {
private boolean waitingForDisbursal;
private boolean open;
private boolean closed;
private String lifeCycleStatusText;
private LocalDate lifeCycleStatusDate;
// private LocalDate submittedOnDate;
// private LocalDate approvedOnDate;
// private LocalDate expectedDisbursementDate;
// private LocalDate actualDisbursementDate;
// private LocalDate expectedFirstRepaymentOnDate;
// private LocalDate interestCalculatedFromDate;
// private LocalDate expectedMaturityDate;
// private LocalDate closedOnDate;
// private LocalDate submittedOnDate;
// private LocalDate approvedOnDate;
// private LocalDate expectedDisbursementDate;
// private LocalDate actualDisbursementDate;
// private LocalDate expectedFirstRepaymentOnDate;
// private LocalDate interestCalculatedFromDate;
// private LocalDate expectedMaturityDate;
// private LocalDate closedOnDate;
public ClientLoanAccountSummaryData() {
//
}
@@ -2,9 +2,11 @@ package org.mifosng.data;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.map.annotate.JsonFilter;
import org.joda.time.DateTime;
@XmlRootElement(name = "note")
@JsonFilter("myFilter")
public class NoteData {
private Long id;
@@ -1,28 +0,0 @@
package org.mifosng.data;
import java.util.ArrayList;
import java.util.Collection;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class NoteDataList {
private Collection<NoteData> notes = new ArrayList<NoteData>();
public NoteDataList() {
//
}
public NoteDataList(final Collection<NoteData> notes) {
this.notes = notes;
}
public Collection<NoteData> getNotes() {
return notes;
}
public void setNotes(Collection<NoteData> notes) {
this.notes = notes;
}
}
@@ -21,7 +21,6 @@ import org.mifosng.data.ClientData;
import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
import org.mifosng.data.EntityIdentifier;
import org.mifosng.data.NoteData;
import org.mifosng.data.NoteDataList;
import org.mifosng.data.OfficeLookup;
import org.mifosng.data.command.ClientCommand;
import org.mifosng.data.command.NoteCommand;
@@ -146,26 +145,31 @@ public class ClientApiResource {
@Path("{clientId}/loans")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON })
public Response retrieveClientAccount(
@PathParam("clientId") final Long clientId) {
public String retrieveClientAccount(
@PathParam("clientId") final Long clientId, @Context UriInfo uriInfo) {
ClientLoanAccountSummaryCollectionData clientAccount = this.clientReadPlatformService
.retrieveClientAccountDetails(clientId);
return Response.ok().entity(clientAccount).build();
String selectedFields = "";
return this.jsonFormattingService.convertRequest(clientAccount,
filterName, allowedFieldList, selectedFields,
uriInfo.getQueryParameters());
}
@GET
@Path("{clientId}/notes")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON })
public Response retrieveAllClientNotes(
@PathParam("clientId") final Long clientId) {
public String retrieveAllClientNotes(
@PathParam("clientId") final Long clientId, @Context UriInfo uriInfo) {
Collection<NoteData> notes = this.clientReadPlatformService
.retrieveAllClientNotes(clientId);
return Response.ok().entity(new NoteDataList(notes)).build();
String selectedFields = "";
return this.jsonFormattingService.convertRequest(notes, filterName,
allowedFieldList, selectedFields, uriInfo.getQueryParameters());
}
@POST
@@ -188,14 +192,16 @@ public class ClientApiResource {
@Path("{clientId}/notes/{noteId}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON })
public Response retrieveClientNote(
public String retrieveClientNote(
@PathParam("clientId") final Long clientId,
@PathParam("noteId") final Long noteId) {
@PathParam("noteId") final Long noteId, @Context UriInfo uriInfo) {
NoteData note = this.clientReadPlatformService.retrieveClientNote(
clientId, noteId);
return Response.ok().entity(note).build();
String selectedFields = "";
return this.jsonFormattingService.convertRequest(note, filterName,
allowedFieldList, selectedFields, uriInfo.getQueryParameters());
}
@PUT