tidy up by moving mifosng-data files back into platform project.

This commit is contained in:
Keith Woodlock
2012-05-30 16:50:45 +01:00
parent 6a0f4b3f6f
commit bdb549253c
66 changed files with 76 additions and 96 deletions
@@ -1,32 +0,0 @@
package org.mifosng.data;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="messageArg")
public class ApiErrorMessageArg {
/**
* The actual value of the parameter (if any) as passed to API.
*/
private Object value;
public static ApiErrorMessageArg from(Object object) {
return new ApiErrorMessageArg(object);
}
protected ApiErrorMessageArg() {
//
}
public ApiErrorMessageArg(Object object) {
this.value = object;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
}
@@ -1,205 +0,0 @@
package org.mifosng.data;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
*/
@XmlRootElement
public class ApiGlobalErrorResponse {
/**
* A developer friendly plain English description of why the HTTP error response was returned from the API.
*/
private String developerMessage;
/**
* A link to a URL which provides more information on the details of this type of error.
*/
private String developerDocLink;
/**
* The HTTP status code of the response.
*/
private String httpStatusCode;
/**
* A user friendly plain English description of why the HTTP error response was returned from the API that can be presented to end users.
*/
private String defaultUserMessage;
/**
* A code that can be used for globalisation support by client applications of the API.
*/
private String userMessageGlobalisationCode;
/**
* A list of zero or more of the actual reasons for the HTTP error should they be needed. Typically used to express data validation errors with parameters passed to API.
*/
private List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
public static ApiGlobalErrorResponse unAuthenticated() {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("401");
globalErrorResponse.setDeveloperMessage("Invalid authentication details were passed in api request.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authenticated");
globalErrorResponse.setDefaultUserMessage("Unauthenticated. Please login.");
return globalErrorResponse;
}
public static ApiGlobalErrorResponse unAuthorized() {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("403");
globalErrorResponse.setDeveloperMessage("The user associated with credentials passed on this request does not have sufficient privileges to perform this action.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authorized");
globalErrorResponse.setDefaultUserMessage("Insufficient priviledges to perform this action.");
return globalErrorResponse;
}
public static ApiGlobalErrorResponse domainRuleViolation(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("403");
globalErrorResponse.setDeveloperMessage("Request was understoon but caused a domain rule violation.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("validation.msg.domain.rule.violation");
globalErrorResponse.setDefaultUserMessage("Errors contain reason for domain rule violation.");
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
globalErrorResponse.setErrors(errors);
return globalErrorResponse;
}
public static ApiGlobalErrorResponse notFound(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("404");
globalErrorResponse.setDeveloperMessage("The requested resource is not available.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.resource.not.found");
globalErrorResponse.setDefaultUserMessage("The requested resource is not available.");
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
errors.add(ApiParameterError.resourceIdentifierNotFound(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
globalErrorResponse.setErrors(errors);
return globalErrorResponse;
}
public static ApiGlobalErrorResponse dataIntegrityError(final String globalisationMessageCode, final String defaultUserMessage, final String parameterName, final Object... defaultUserMessageArgs) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("400");
globalErrorResponse.setDeveloperMessage("The request caused a data integrity issue to be fired by the database.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode(globalisationMessageCode);
globalErrorResponse.setDefaultUserMessage(defaultUserMessage);
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
errors.add(ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, parameterName, defaultUserMessageArgs));
globalErrorResponse.setErrors(errors);
return globalErrorResponse;
}
public static ApiGlobalErrorResponse badClientRequest(final String globalisationMessageCode, final String defaultUserMessage,
List<ApiParameterError> errors) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("400");
globalErrorResponse.setDeveloperMessage("The request was invalid. This typically will happen due to validation errors which are provided.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode(globalisationMessageCode);
globalErrorResponse.setDefaultUserMessage(defaultUserMessage);
globalErrorResponse.setErrors(errors);
return globalErrorResponse;
}
public static ApiGlobalErrorResponse serverSideError(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("500");
globalErrorResponse.setDeveloperMessage("An unexpected error occured on the platform server.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.server.side.error");
globalErrorResponse.setDefaultUserMessage("An unexpected error occured on the platform server.");
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
globalErrorResponse.setErrors(errors);
return globalErrorResponse;
}
protected ApiGlobalErrorResponse() {
//
}
public ApiGlobalErrorResponse(final List<ApiParameterError> errors) {
this.errors = errors;
}
@XmlElementWrapper(name="errors")
@XmlElement(name="errorResponse")
public List<ApiParameterError> getErrors() {
return errors;
}
public void setErrors(List<ApiParameterError> errors) {
this.errors = errors;
}
public String getDeveloperMessage() {
return developerMessage;
}
public void setDeveloperMessage(String developerMessage) {
this.developerMessage = developerMessage;
}
public String getHttpStatusCode() {
return httpStatusCode;
}
public void setHttpStatusCode(String httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
public String getDefaultUserMessage() {
return defaultUserMessage;
}
public void setDefaultUserMessage(String defaultUserMessage) {
this.defaultUserMessage = defaultUserMessage;
}
public String getUserMessageGlobalisationCode() {
return userMessageGlobalisationCode;
}
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
}
public String getDeveloperDocLink() {
return developerDocLink;
}
public void setDeveloperDocLink(String developerDocLink) {
this.developerDocLink = developerDocLink;
}
}
@@ -1,123 +0,0 @@
package org.mifosng.data;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="apiParameterError")
public class ApiParameterError {
/**
* A developer friendly plain English description of why the HTTP error response was returned from the API.
*/
private String developerMessage;
/**
* A user friendly plain English description of why the HTTP error response was returned from the API that can be presented to end users.
*/
private String defaultUserMessage;
/**
* A code that can be used for globalisation support by client applications of the API.
*/
private String userMessageGlobalisationCode;
/**
* The name of the field or parameter passed to the API that this error relates to.
*/
private String parameterName;
/**
* The actual value of the parameter (if any) as passed to API.
*/
private Object value;
/**
* Arguments related to the user error message.
*/
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
public static ApiParameterError generalError(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
}
public static ApiParameterError resourceIdentifierNotFound(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
}
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
final String parameterName, final Object... defaultUserMessageArgs) {
ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
error.setParameterName(parameterName);
return error;
}
protected ApiParameterError() {
//
}
private ApiParameterError(final String globalisationMessageCode, final String defaultUserMessage, final Object[] defaultUserMessageArgs) {
this.userMessageGlobalisationCode = globalisationMessageCode;
this.developerMessage = defaultUserMessage;
this.defaultUserMessage = defaultUserMessage;
List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
if (defaultUserMessageArgs != null) {
for (Object object : defaultUserMessageArgs) {
messageArgs.add(ApiErrorMessageArg.from(object));
}
}
this.args = messageArgs;
this.parameterName="id";
}
public String getDeveloperMessage() {
return developerMessage;
}
public void setDeveloperMessage(String developerMessage) {
this.developerMessage = developerMessage;
}
public String getDefaultUserMessage() {
return defaultUserMessage;
}
public void setDefaultUserMessage(String defaultUserMessage) {
this.defaultUserMessage = defaultUserMessage;
}
public String getUserMessageGlobalisationCode() {
return userMessageGlobalisationCode;
}
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
}
public String getParameterName() {
return parameterName;
}
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public List<ApiErrorMessageArg> getArgs() {
return args;
}
public void setArgs(List<ApiErrorMessageArg> args) {
this.args = args;
}
}
@@ -1,35 +0,0 @@
package org.mifosng.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.map.annotate.JsonFilter;
@JsonFilter("myFilter")
public class ConfigurationData implements Serializable {
private List<CurrencyData> selectedCurrencyOptions = new ArrayList<CurrencyData>();
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>();
public ConfigurationData() {
//
}
public List<CurrencyData> getSelectedCurrencyOptions() {
return selectedCurrencyOptions;
}
public void setSelectedCurrencyOptions(
List<CurrencyData> selectedCurrencyOptions) {
this.selectedCurrencyOptions = selectedCurrencyOptions;
}
public List<CurrencyData> getCurrencyOptions() {
return currencyOptions;
}
public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
this.currencyOptions = currencyOptions;
}
}
@@ -1,25 +0,0 @@
package org.mifosng.data;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "identifier")
public class EntityIdentifier {
private Long entityId;
public EntityIdentifier() {
//
}
public EntityIdentifier(final Long entityId) {
this.entityId = entityId;
}
public Long getEntityId() {
return this.entityId;
}
public void setEntityId(final Long entityId) {
this.entityId = entityId;
}
}
@@ -1,44 +0,0 @@
package org.mifosng.data;
import java.io.Serializable;
public class EnumOptionData implements Serializable {
private Long id;
private String code;
private String value;
protected EnumOptionData() {
//
}
public EnumOptionData(final Long id, final String code, final String value) {
this.id = id;
this.code = code;
this.value = value;
}
public Long getId() {
return this.id;
}
public void setId(final Long id) {
this.id = id;
}
public String getValue() {
return this.value;
}
public void setValue(final String value) {
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
@@ -1,135 +0,0 @@
package org.mifosng.data;
import javax.xml.bind.annotation.XmlRootElement;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
@XmlRootElement
public class LoanPayoffReadModel {
private String reference;
private String acutalDisbursementDate;
private String expectedMaturityDate;
private String projectedMaturityDate;
private Integer expectedLoanTermInDays;
private Integer projectedLoanTermInDays;
private MoneyData totalPaidToDate;
private MoneyData totalOutstandingBasedOnExpectedMaturityDate;
private MoneyData totalOutstandingBasedOnPayoffDate;
private MoneyData interestRebateOwed;
protected LoanPayoffReadModel() {
//
}
public LoanPayoffReadModel(
final String reference,
final LocalDate acutalDisbursementDate,
final LocalDate expectedMaturityDate,
final LocalDate projectedMaturityDate,
final Integer expectedLoanTermInDays,
final Integer projectedLoanTermInDays,
final MoneyData totalPaidToDate,
final MoneyData totalOutstandingBasedOnExpectedMaturityDate,
final MoneyData totalOutstandingBasedOnPayoffDate,
final MoneyData interestRebateOwed) {
this.reference = reference;
DateTimeFormatter formatter = org.joda.time.format.DateTimeFormat
.forPattern("yyyy-MM-dd");
this.acutalDisbursementDate = formatter.print(acutalDisbursementDate);
this.expectedMaturityDate = formatter.print(expectedMaturityDate);
this.projectedMaturityDate = formatter.print(projectedMaturityDate);
this.expectedLoanTermInDays = expectedLoanTermInDays;
this.projectedLoanTermInDays = projectedLoanTermInDays;
this.totalPaidToDate = totalPaidToDate;
this.totalOutstandingBasedOnExpectedMaturityDate = totalOutstandingBasedOnExpectedMaturityDate;
this.totalOutstandingBasedOnPayoffDate = totalOutstandingBasedOnPayoffDate;
this.interestRebateOwed = interestRebateOwed;
}
public String getReference() {
return this.reference;
}
public void setReference(final String reference) {
this.reference = reference;
}
public String getAcutalDisbursementDate() {
return this.acutalDisbursementDate;
}
public void setAcutalDisbursementDate(final String acutalDisbursementDate) {
this.acutalDisbursementDate = acutalDisbursementDate;
}
public String getExpectedMaturityDate() {
return this.expectedMaturityDate;
}
public void setExpectedMaturityDate(final String expectedMaturityDate) {
this.expectedMaturityDate = expectedMaturityDate;
}
public String getProjectedMaturityDate() {
return this.projectedMaturityDate;
}
public void setProjectedMaturityDate(final String projectedMaturityDate) {
this.projectedMaturityDate = projectedMaturityDate;
}
public Integer getExpectedLoanTermInDays() {
return this.expectedLoanTermInDays;
}
public void setExpectedLoanTermInDays(final Integer expectedLoanTermInDays) {
this.expectedLoanTermInDays = expectedLoanTermInDays;
}
public Integer getProjectedLoanTermInDays() {
return this.projectedLoanTermInDays;
}
public void setProjectedLoanTermInDays(final Integer projectedLoanTermInDays) {
this.projectedLoanTermInDays = projectedLoanTermInDays;
}
public MoneyData getTotalPaidToDate() {
return this.totalPaidToDate;
}
public void setTotalPaidToDate(final MoneyData totalPaidToDate) {
this.totalPaidToDate = totalPaidToDate;
}
public MoneyData getInterestRebateOwed() {
return this.interestRebateOwed;
}
public void setInterestRebateOwed(final MoneyData interestRebateOwed) {
this.interestRebateOwed = interestRebateOwed;
}
public MoneyData getTotalOutstandingBasedOnExpectedMaturityDate() {
return this.totalOutstandingBasedOnExpectedMaturityDate;
}
public void setTotalOutstandingBasedOnExpectedMaturityDate(
final MoneyData totalOutstandingBasedOnExpectedMaturityDate) {
this.totalOutstandingBasedOnExpectedMaturityDate = totalOutstandingBasedOnExpectedMaturityDate;
}
public MoneyData getTotalOutstandingBasedOnPayoffDate() {
return this.totalOutstandingBasedOnPayoffDate;
}
public void setTotalOutstandingBasedOnPayoffDate(
final MoneyData totalOutstandingBasedOnPayoffDate) {
this.totalOutstandingBasedOnPayoffDate = totalOutstandingBasedOnPayoffDate;
}
}
@@ -1,15 +0,0 @@
package org.mifosng.data;
import java.util.Comparator;
import org.mifosng.data.LoanRepaymentData;
public class LoanRepaymentDataComparator implements Comparator<LoanRepaymentData> {
@Override
public int compare(final LoanRepaymentData o1, final LoanRepaymentData o2) {
return o2.getDate().compareTo(o1.getDate());
}
}
@@ -1,144 +0,0 @@
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;
private Long clientId;
private Long loanId;
private Long loanTransactionId;
private Integer noteTypeId;
private String note;
private Long createdById;
private String createdByUsername;
private DateTime createdOn;
private Long updatedById;
private String updatedByUsername;
private DateTime updatedOn;
public NoteData() {
//
}
public NoteData(Long id, Long clientId, Long loanId,
Long transactionId, Integer noteTypeId, String note,
DateTime createdDate, Long createdById, String createdByUsername,
DateTime lastModifiedDate, Long lastModifiedById, String updatedByUsername) {
this.id = id;
this.clientId = clientId;
this.loanId = loanId;
this.loanTransactionId = transactionId;
this.noteTypeId = noteTypeId;
this.note = note;
this.createdOn = createdDate;
this.createdById = createdById;
this.createdByUsername = createdByUsername;
this.updatedOn = lastModifiedDate;
this.updatedById = lastModifiedById;
this.updatedByUsername = updatedByUsername;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getClientId() {
return clientId;
}
public void setClientId(Long clientId) {
this.clientId = clientId;
}
public Long getLoanId() {
return loanId;
}
public void setLoanId(Long loanId) {
this.loanId = loanId;
}
public Long getLoanTransactionId() {
return loanTransactionId;
}
public void setLoanTransactionId(Long loanTransactionId) {
this.loanTransactionId = loanTransactionId;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public Long getCreatedById() {
return createdById;
}
public void setCreatedById(Long createdById) {
this.createdById = createdById;
}
public String getCreatedByUsername() {
return createdByUsername;
}
public void setCreatedByUsername(String createdByUsername) {
this.createdByUsername = createdByUsername;
}
public DateTime getCreatedOn() {
return createdOn;
}
public void setCreatedOn(DateTime createdOn) {
this.createdOn = createdOn;
}
public Long getUpdatedById() {
return updatedById;
}
public void setUpdatedById(Long updatedById) {
this.updatedById = updatedById;
}
public String getUpdatedByUsername() {
return updatedByUsername;
}
public void setUpdatedByUsername(String updatedByUsername) {
this.updatedByUsername = updatedByUsername;
}
public DateTime getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(DateTime updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getNoteTypeId() {
return noteTypeId;
}
public void setNoteTypeId(Integer noteTypeId) {
this.noteTypeId = noteTypeId;
}
}