From 22317650a17ff68a2252bb5572f8662a36694eb9 Mon Sep 17 00:00:00 2001 From: Paul Thalluri Date: Thu, 3 Mar 2016 02:13:01 +0530 Subject: [PATCH 1/2] MOTECH-2062 --- open-lmis/pom.xml | 134 ++++ .../openlmis/domain/DosageUnit.java | 54 ++ .../openlmis/domain/Facility.java | 361 ++++++++++ .../openlmis/domain/FacilityType.java | 118 ++++ .../openlmis/domain/GeographicLevel.java | 64 ++ .../openlmis/domain/GeographicZone.java | 108 +++ .../openlmis/domain/KitProduct.java | 60 ++ .../openlmis/domain/Product.java | 548 +++++++++++++++ .../openlmis/domain/ProductCategory.java | 65 ++ .../openlmis/domain/Program.java | 64 ++ .../openlmis/domain/StockStatus.java | 161 +++++ .../repository/DosageUnitDataService.java | 20 + .../repository/FacilityDataService.java | 24 + .../repository/FacilityTypeDataService.java | 24 + .../GeographicLevelDataService.java | 24 + .../repository/GeographicZoneDataService.java | 24 + .../ProductCategoryDataService.java | 24 + .../repository/ProductDataService.java | 20 + .../repository/ProgramDataService.java | 24 + .../repository/StockStatusDataService.java | 12 + .../openlmis/rest/domain/DosageUnitDto.java | 13 + .../openlmis/rest/domain/FacilityDto.java | 382 +++++++++++ .../openlmis/rest/domain/FacilityTypeDto.java | 127 ++++ .../rest/domain/GeographicLevelDto.java | 72 ++ .../rest/domain/GeographicZoneDto.java | 118 ++++ .../openlmis/rest/domain/ISADto.java | 127 ++++ .../openlmis/rest/domain/KitProductDto.java | 72 ++ .../domain/LossesAndAdjustmentsTypeDto.java | 82 +++ .../openlmis/rest/domain/MoneyDto.java | 53 ++ .../rest/domain/ProcessingPeriodDto.java | 92 +++ .../rest/domain/ProductAttributeBaseDto.java | 62 ++ .../rest/domain/ProductCategoryDto.java | 72 ++ .../openlmis/rest/domain/ProductDto.java | 643 ++++++++++++++++++ .../openlmis/rest/domain/ProductFormDto.java | 13 + .../openlmis/rest/domain/ProductGroupDto.java | 62 ++ .../openlmis/rest/domain/ProgramDto.java | 72 ++ .../rest/domain/ProgramProductDto.java | 151 ++++ .../rest/domain/ProgramProductISADto.java | 152 +++++ .../rest/domain/ProgramsWithProductDto.java | 63 ++ .../rest/domain/ProgramsWithProductsDto.java | 43 ++ .../openlmis/rest/domain/ResourceListDto.java | 21 + .../openlmis/rest/domain/StockStatusDto.java | 196 ++++++ .../rest/service/OpenlmisWebException.java | 24 + .../rest/service/OpenlmisWebService.java | 35 + .../service/impl/OpenlmisWebServiceImpl.java | 253 +++++++ .../openlmis/service/DosageUnitService.java | 13 + .../openlmis/service/FacilityService.java | 16 + .../openlmis/service/FacilityTypeService.java | 16 + .../openlmis/service/GenericCrudService.java | 10 + .../service/GeographicLevelService.java | 16 + .../service/GeographicZoneService.java | 16 + .../service/ProductCategoryService.java | 16 + .../openlmis/service/ProductService.java | 13 + .../openlmis/service/ProgramService.java | 16 + .../openlmis/service/Settings.java | 45 ++ .../openlmis/service/SettingsService.java | 11 + .../openlmis/service/StockStatusService.java | 11 + .../openlmis/service/SyncService.java | 15 + .../openlmis/service/TasksService.java | 15 + .../service/impl/DosageUnitServiceImpl.java | 62 ++ .../service/impl/FacilityServiceImpl.java | 100 +++ .../service/impl/FacilityTypeServiceImpl.java | 78 +++ .../impl/GeographicLevelServiceImpl.java | 66 ++ .../impl/GeographicZoneServiceImpl.java | 78 +++ .../impl/ProductCategoryServiceImpl.java | 68 ++ .../service/impl/ProductServiceImpl.java | 115 ++++ .../service/impl/ProgramServiceImpl.java | 68 ++ .../service/impl/SettingsServiceImpl.java | 63 ++ .../service/impl/StockStatusServiceImpl.java | 84 +++ .../service/impl/SyncServiceImpl.java | 194 ++++++ .../service/impl/TasksServiceImpl.java | 21 + .../web/OpenlmisSchemaController.java | 12 + .../web/OpenlmisSettingsController.java | 78 +++ .../resources/META-INF/spring/blueprint.xml | 107 +++ open-lmis/src/main/resources/header.html | 10 + .../src/main/resources/openlmis-settings.json | 1 + .../src/main/resources/openlmis.properties | 1 + .../src/main/resources/securityRules.json | 35 + .../main/resources/webapp/css/open-lmis.css | 22 + .../src/main/resources/webapp/index.html | 34 + open-lmis/src/main/resources/webapp/js/app.js | 14 + .../main/resources/webapp/js/controllers.js | 75 ++ .../main/resources/webapp/js/directives.js | 6 + .../src/main/resources/webapp/js/services.js | 8 + .../webapp/messages/messages.properties | 24 + .../resources/webapp/partials/settings.html | 61 ++ .../openlmis/service/it/BaseOpenlmisIT.java | 68 ++ .../service/it/OpenlmisIntegrationTests.java | 10 + .../META-INF/spring/testBlueprint.xml | 13 + open-lmis/src/test/resources/log4j.xml | 30 + 90 files changed, 6768 insertions(+) create mode 100755 open-lmis/pom.xml create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java create mode 100644 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java create mode 100644 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java create mode 100644 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java create mode 100644 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java create mode 100644 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java create mode 100755 open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java create mode 100755 open-lmis/src/main/resources/META-INF/spring/blueprint.xml create mode 100755 open-lmis/src/main/resources/header.html create mode 100755 open-lmis/src/main/resources/openlmis-settings.json create mode 100644 open-lmis/src/main/resources/openlmis.properties create mode 100755 open-lmis/src/main/resources/securityRules.json create mode 100755 open-lmis/src/main/resources/webapp/css/open-lmis.css create mode 100755 open-lmis/src/main/resources/webapp/index.html create mode 100755 open-lmis/src/main/resources/webapp/js/app.js create mode 100755 open-lmis/src/main/resources/webapp/js/controllers.js create mode 100755 open-lmis/src/main/resources/webapp/js/directives.js create mode 100755 open-lmis/src/main/resources/webapp/js/services.js create mode 100755 open-lmis/src/main/resources/webapp/messages/messages.properties create mode 100755 open-lmis/src/main/resources/webapp/partials/settings.html create mode 100644 open-lmis/src/test/java/org/motechproject/openlmis/service/it/BaseOpenlmisIT.java create mode 100644 open-lmis/src/test/java/org/motechproject/openlmis/service/it/OpenlmisIntegrationTests.java create mode 100755 open-lmis/src/test/resources/META-INF/spring/testBlueprint.xml create mode 100755 open-lmis/src/test/resources/log4j.xml diff --git a/open-lmis/pom.xml b/open-lmis/pom.xml new file mode 100755 index 000000000..bda1064b6 --- /dev/null +++ b/open-lmis/pom.xml @@ -0,0 +1,134 @@ + + + + modules + org.motechproject + 1.0-SNAPSHOT + ../ + + + 4.0.0 + open-lmis + bundle + + + ${basedir}/.. + + + + + ${motech.groupId} + motech-platform-dataservices + ${motech.version} + + + commons-logging + commons-logging + + + + + ${motech.groupId} + motech-platform-event + ${motech.version} + + + ${motech.groupId} + motech-platform-web-security + ${motech.version} + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.jackson.version} + + + ${motech.groupId} + motech-tasks + ${motech.version} + true + + + ${motech.groupId} + motech-admin + ${motech.version} + + + org.springframework + spring-test-mvc + test + + + org.apache.httpcomponents + httpclient-osgi + + + org.apache.httpcomponents + httpcore-osgi + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + true + open-lmis + open-lmis/resources + + net.sf.cglib.core, + net.sf.cglib.proxy, + net.sf.cglib.reflect, + org.aopalliance.aop, + org.motechproject.admin.domain, + org.motechproject.admin.messages, + org.motechproject.config.service, + org.motechproject.event.listener, + org.motechproject.mds.service, + org.springframework.aop, + org.springframework.aop.framework, + org.springframework.transaction, + * + + + org.motechproject.openlmis.service;version=${project.version}, + org.motechproject.openlmis.repository;version=${project.version}, + org.motechproject.openlmis.domain;version=${project.version}, + org.motechproject.openlmis.rest.domain;version=${project.version}, + + + + + + maven-resources-plugin + + + copy-bundles + package + + copy-resources + + + ${user.home}/.motech/bundles + + + target + + *.jar + + + + + + + + + + diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java new file mode 100755 index 000000000..1148d61a7 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java @@ -0,0 +1,54 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS DosageUnit + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class DosageUnit { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field(required = true) + @Unique + private String code; + + @Field + private Integer displayOrder; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java new file mode 100755 index 000000000..d88954340 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java @@ -0,0 +1,361 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS Facility + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class Facility { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field(required = true) + @Unique + private String code; + + @Field + private String name; + + @Field + private String description; + + @Field + private String gln; + + @Field + private String mainPhone; + + @Field + private String fax; + + @Field + private String address1; + + @Field + private String address2; + + @Field + private GeographicZone geographicZone; + + @Field + private FacilityType type; + + @Field + private Integer catchmentPopulation; + + @Field + private Double latitude; + + @Field + private Double longitude; + + @Field + private Double altitude; + + @Field + private Integer operatedById; + + @Field + private Double coldStorageGrossCapacity; + + @Field + private Double coldStorageNetCapacity; + + @Field + private Boolean suppliesOthers; + + @Field + private Boolean sdp; + + @Field + private Boolean hasElectricity; + + @Field + private Boolean online; + + @Field + private Boolean hasElectronicScc; + + @Field + private Boolean hasElectronicDar; + + @Field + private Boolean active; + + @Field + private String goLiveDate; + + @Field + private String goDownDate; + + @Field + private Boolean satellite; + + @Field + private String comment; + + @Field + private Integer satelliteParentId; + + @Field + private Boolean dataReportable; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getGln() { + return gln; + } + + public void setGln(String gln) { + this.gln = gln; + } + + public String getMainPhone() { + return mainPhone; + } + + public void setMainPhone(String mainPhone) { + this.mainPhone = mainPhone; + } + + public String getFax() { + return fax; + } + + public void setFax(String fax) { + this.fax = fax; + } + + public String getAddress1() { + return address1; + } + + public void setAddress1(String address1) { + this.address1 = address1; + } + + public String getAddress2() { + return address2; + } + + public void setAddress2(String address2) { + this.address2 = address2; + } + + public GeographicZone getGeographicZone() { + return geographicZone; + } + + public void setGeographicZone(GeographicZone geographicZone) { + this.geographicZone = geographicZone; + } + + public FacilityType getType() { + return type; + } + + public void setType(FacilityType type) { + this.type = type; + } + + public Integer getCatchmentPopulation() { + return catchmentPopulation; + } + + public void setCatchmentPopulation(Integer catchmentPopulation) { + this.catchmentPopulation = catchmentPopulation; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getAltitude() { + return altitude; + } + + public void setAltitude(Double altitude) { + this.altitude = altitude; + } + + public Integer getOperatedById() { + return operatedById; + } + + public void setOperatedById(Integer operatedById) { + this.operatedById = operatedById; + } + + public Double getColdStorageGrossCapacity() { + return coldStorageGrossCapacity; + } + + public void setColdStorageGrossCapacity(Double coldStorageGrossCapacity) { + this.coldStorageGrossCapacity = coldStorageGrossCapacity; + } + + public Double getColdStorageNetCapacity() { + return coldStorageNetCapacity; + } + + public void setColdStorageNetCapacity(Double coldStorageNetCapacity) { + this.coldStorageNetCapacity = coldStorageNetCapacity; + } + + public Boolean getSuppliesOthers() { + return suppliesOthers; + } + + public void setSuppliesOthers(Boolean suppliesOthers) { + this.suppliesOthers = suppliesOthers; + } + + public Boolean getSdp() { + return sdp; + } + + public void setSdp(Boolean sdp) { + this.sdp = sdp; + } + + public Boolean getHasElectricity() { + return hasElectricity; + } + + public void setHasElectricity(Boolean hasElectricity) { + this.hasElectricity = hasElectricity; + } + + public Boolean getOnline() { + return online; + } + + public void setOnline(Boolean online) { + this.online = online; + } + + public Boolean getHasElectronicScc() { + return hasElectronicScc; + } + + public void setHasElectronicScc(Boolean hasElectronicScc) { + this.hasElectronicScc = hasElectronicScc; + } + + public Boolean getHasElectronicDar() { + return hasElectronicDar; + } + + public void setHasElectronicDar(Boolean hasElectronicDar) { + this.hasElectronicDar = hasElectronicDar; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public String getGoLiveDate() { + return goLiveDate; + } + + public void setGoLiveDate(String goLiveDate) { + this.goLiveDate = goLiveDate; + } + + public String getGoDownDate() { + return goDownDate; + } + + public void setGoDownDate(String goDownDate) { + this.goDownDate = goDownDate; + } + + public Boolean getSatellite() { + return satellite; + } + + public void setSatellite(Boolean satellite) { + this.satellite = satellite; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Integer getSatelliteParentId() { + return satelliteParentId; + } + + public void setSatelliteParentId(Integer satelliteParentId) { + this.satelliteParentId = satelliteParentId; + } + + public Boolean getDataReportable() { + return dataReportable; + } + + public void setDataReportable(Boolean dataReportable) { + this.dataReportable = dataReportable; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java new file mode 100755 index 000000000..15dc61d4c --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java @@ -0,0 +1,118 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS FacilityType + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = { "configureOpenlmis" }) +public class FacilityType { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field + private String name; + + @Field + private String code; + + @Field + private String description; + + @Field + private Integer nominalMaxMonth; + + @Field + private Double nominalEop; + + @Field + private GeographicLevel level; + + @Field + private Boolean active; + + @Field + private Integer displayOrder; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getNominalMaxMonth() { + return nominalMaxMonth; + } + + public void setNominalMaxMonth(Integer nominalMaxMonth) { + this.nominalMaxMonth = nominalMaxMonth; + } + + public Double getNominalEop() { + return nominalEop; + } + + public void setNominalEop(Double nominalEop) { + this.nominalEop = nominalEop; + } + + public GeographicLevel getLevel() { + return level; + } + + public void setLevel(GeographicLevel level) { + this.level = level; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java new file mode 100755 index 000000000..a9a5d4267 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java @@ -0,0 +1,64 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS GeographicLevel + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class GeographicLevel { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field(required = true) + @Unique + private String code; + + @Field + private String name; + + @Field + private Integer levelNumber; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getLevelNumber() { + return levelNumber; + } + + public void setLevelNumber(Integer levelNumber) { + this.levelNumber = levelNumber; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java new file mode 100755 index 000000000..3b150a8f6 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java @@ -0,0 +1,108 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS GeographicZone + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class GeographicZone { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field + private String name; + + @Field(required = true) + @Unique + private String code; + + @Field + private GeographicZone parent; + + @Field + private Integer catchmentPopulation; + + @Field + private Double latitude; + + @Field + private Double longitude; + + @Field + private GeographicLevel level; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public GeographicLevel getLevel() { + return level; + } + + public void setLevel(GeographicLevel level) { + this.level = level; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public GeographicZone getParent() { + return parent; + } + + public void setParent(GeographicZone parent) { + this.parent = parent; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getCatchmentPopulation() { + return catchmentPopulation; + } + + public void setCatchmentPopulation(Integer catchmentPopulation) { + this.catchmentPopulation = catchmentPopulation; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java new file mode 100755 index 000000000..ca9fe4f4b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java @@ -0,0 +1,60 @@ +package org.motechproject.openlmis.domain; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS KitProduct + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class KitProduct { + + @Field + private Integer openlmisid; + + @Field + private Product product; + + @Field + private String kitCode; + + @Field + private Integer quantity; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public String getKitCode() { + return kitCode; + } + + public void setKitCode(String kitCode) { + this.kitCode = kitCode; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java new file mode 100755 index 000000000..7b3480ff2 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java @@ -0,0 +1,548 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS Product + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class Product { + + @Field + @Unique + private Integer openlmisid; + + @Field + @Unique + private String code; + + @Field + private String alternateItemCode; + + @Field + private String manufacturer; + + @Field + private String manufacturerCode; + + @Field + private String manufacturerBarCode; + + @Field + private String mohBarCode; + + @Field + private String gtin; + + @Field + private String type; + + @Field + private String primaryName; + + @Field + private String fullName; + + @Field + private String genericName; + + @Field + private String alternateName; + + @Field + private String description; + + @Field + private String strength; + + @Field + private DosageUnit dosageUnit; + + @Field + private String dispensingUnit; + + @Field + private Integer dosesPerDispensingUnit; + + @Field + private Boolean storeRefrigerated; + + @Field + private Boolean storeRoomTemperature; + + @Field + private Boolean hazardous; + + @Field + private Boolean flammable; + + @Field + private Boolean controlledSubstance; + + @Field + private Boolean lightSensitive; + + @Field + private Boolean approvedByWHO; + + @Field + private Double contraceptiveCYP; + + @Field + private Integer packSize; + + @Field + private Integer alternatePackSize; + + @Field + private Double packLength; + + @Field + private Double packWidth; + + @Field + private Double packHeight; + + @Field + private Double packWeight; + + @Field + private Integer packsPerCarton; + + @Field + private Double cartonLength; + + @Field + private Double cartonWidth; + + @Field + private Double cartonHeight; + + @Field + private Integer cartonsPerPallet; + + @Field + private Integer expectedShelfLife; + + @Field + private String specialStorageInstructions; + + @Field + private String specialTransportInstructions; + + @Field + private Boolean active; + + @Field + private Boolean fullSupply; + + @Field + private Boolean tracer; + + @Field + private Integer packRoundingThreshold; + + @Field + private Boolean roundToZero; + + @Field + private Boolean archived; + + @Field + private String formId; + + @Field + private Boolean isKit; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getAlternateItemCode() { + return alternateItemCode; + } + + public void setAlternateItemCode(String alternateItemCode) { + this.alternateItemCode = alternateItemCode; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public String getManufacturerCode() { + return manufacturerCode; + } + + public void setManufacturerCode(String manufacturerCode) { + this.manufacturerCode = manufacturerCode; + } + + public String getManufacturerBarCode() { + return manufacturerBarCode; + } + + public void setManufacturerBarCode(String manufacturerBarCode) { + this.manufacturerBarCode = manufacturerBarCode; + } + + public String getMohBarCode() { + return mohBarCode; + } + + public void setMohBarCode(String mohBarCode) { + this.mohBarCode = mohBarCode; + } + + public String getGtin() { + return gtin; + } + + public void setGtin(String gtin) { + this.gtin = gtin; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPrimaryName() { + return primaryName; + } + + public void setPrimaryName(String primaryName) { + this.primaryName = primaryName; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getGenericName() { + return genericName; + } + + public void setGenericName(String genericName) { + this.genericName = genericName; + } + + public String getAlternateName() { + return alternateName; + } + + public void setAlternateName(String alternateName) { + this.alternateName = alternateName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStrength() { + return strength; + } + + public void setStrength(String strength) { + this.strength = strength; + } + + public DosageUnit getDosageUnit() { + return dosageUnit; + } + + public void setDosageUnit(DosageUnit dosageUnit) { + this.dosageUnit = dosageUnit; + } + + public String getDispensingUnit() { + return dispensingUnit; + } + + public void setDispensingUnit(String dispensingUnit) { + this.dispensingUnit = dispensingUnit; + } + + public Integer getDosesPerDispensingUnit() { + return dosesPerDispensingUnit; + } + + public void setDosesPerDispensingUnit(Integer dosesPerDispensingUnit) { + this.dosesPerDispensingUnit = dosesPerDispensingUnit; + } + + public Boolean getStoreRefrigerated() { + return storeRefrigerated; + } + + public void setStoreRefrigerated(Boolean storeRefrigerated) { + this.storeRefrigerated = storeRefrigerated; + } + + public Boolean getStoreRoomTemperature() { + return storeRoomTemperature; + } + + public void setStoreRoomTemperature(Boolean storeRoomTemperature) { + this.storeRoomTemperature = storeRoomTemperature; + } + + public Boolean getHazardous() { + return hazardous; + } + + public void setHazardous(Boolean hazardous) { + this.hazardous = hazardous; + } + + public Boolean getFlammable() { + return flammable; + } + + public void setFlammable(Boolean flammable) { + this.flammable = flammable; + } + + public Boolean getControlledSubstance() { + return controlledSubstance; + } + + public void setControlledSubstance(Boolean controlledSubstance) { + this.controlledSubstance = controlledSubstance; + } + + public Boolean getLightSensitive() { + return lightSensitive; + } + + public void setLightSensitive(Boolean lightSensitive) { + this.lightSensitive = lightSensitive; + } + + public Boolean getApprovedByWHO() { + return approvedByWHO; + } + + public void setApprovedByWHO(Boolean approvedByWHO) { + this.approvedByWHO = approvedByWHO; + } + + public Double getContraceptiveCYP() { + return contraceptiveCYP; + } + + public void setContraceptiveCYP(Double contraceptiveCYP) { + this.contraceptiveCYP = contraceptiveCYP; + } + + public Integer getPackSize() { + return packSize; + } + + public void setPackSize(Integer packSize) { + this.packSize = packSize; + } + + public Integer getAlternatePackSize() { + return alternatePackSize; + } + + public void setAlternatePackSize(Integer alternatePackSize) { + this.alternatePackSize = alternatePackSize; + } + + public Double getPackLength() { + return packLength; + } + + public void setPackLength(Double packLength) { + this.packLength = packLength; + } + + public Double getPackWidth() { + return packWidth; + } + + public void setPackWidth(Double packWidth) { + this.packWidth = packWidth; + } + + public Double getPackHeight() { + return packHeight; + } + + public void setPackHeight(Double packHeight) { + this.packHeight = packHeight; + } + + public Double getPackWeight() { + return packWeight; + } + + public void setPackWeight(Double packWeight) { + this.packWeight = packWeight; + } + + public Integer getPacksPerCarton() { + return packsPerCarton; + } + + public void setPacksPerCarton(Integer packsPerCarton) { + this.packsPerCarton = packsPerCarton; + } + + public Double getCartonLength() { + return cartonLength; + } + + public void setCartonLength(Double cartonLength) { + this.cartonLength = cartonLength; + } + + public Double getCartonWidth() { + return cartonWidth; + } + + public void setCartonWidth(Double cartonWidth) { + this.cartonWidth = cartonWidth; + } + + public Double getCartonHeight() { + return cartonHeight; + } + + public void setCartonHeight(Double cartonHeight) { + this.cartonHeight = cartonHeight; + } + + public Integer getCartonsPerPallet() { + return cartonsPerPallet; + } + + public void setCartonsPerPallet(Integer cartonsPerPallet) { + this.cartonsPerPallet = cartonsPerPallet; + } + + public Integer getExpectedShelfLife() { + return expectedShelfLife; + } + + public void setExpectedShelfLife(Integer expectedShelfLife) { + this.expectedShelfLife = expectedShelfLife; + } + + public String getSpecialStorageInstructions() { + return specialStorageInstructions; + } + + public void setSpecialStorageInstructions(String specialStorageInstructions) { + this.specialStorageInstructions = specialStorageInstructions; + } + + public String getSpecialTransportInstructions() { + return specialTransportInstructions; + } + + public void setSpecialTransportInstructions(String specialTransportInstructions) { + this.specialTransportInstructions = specialTransportInstructions; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Boolean getFullSupply() { + return fullSupply; + } + + public void setFullSupply(Boolean fullSupply) { + this.fullSupply = fullSupply; + } + + public Boolean getTracer() { + return tracer; + } + + public void setTracer(Boolean tracer) { + this.tracer = tracer; + } + + public Integer getPackRoundingThreshold() { + return packRoundingThreshold; + } + + public void setPackRoundingThreshold(Integer packRoundingThreshold) { + this.packRoundingThreshold = packRoundingThreshold; + } + + public Boolean getRoundToZero() { + return roundToZero; + } + + public void setRoundToZero(Boolean roundToZero) { + this.roundToZero = roundToZero; + } + + public Boolean getArchived() { + return archived; + } + + public void setArchived(Boolean archived) { + this.archived = archived; + } + + public String getFormId() { + return formId; + } + + public void setFormId(String formId) { + this.formId = formId; + } + + public Boolean getIsKit() { + return isKit; + } + + public void setIsKit(Boolean isKit) { + this.isKit = isKit; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java new file mode 100755 index 000000000..d572698de --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java @@ -0,0 +1,65 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS Product Category + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class ProductCategory { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field(required = true) + @Unique + private String code; + + @Field + private String name; + + @Field + private Integer displayOrder; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java new file mode 100755 index 000000000..e90801803 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java @@ -0,0 +1,64 @@ +package org.motechproject.openlmis.domain; + +import javax.jdo.annotations.Unique; + +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS Program + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class Program { + + @Field(required = true) + @Unique + private Integer openlmisid; + + @Field(required = true) + @Unique + private String code; + + @Field + private String name; + + @Field + private String description; + + public Integer getOpenlmisid() { + return openlmisid; + } + + public void setOpenlmisid(Integer openlmisid) { + this.openlmisid = openlmisid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java b/open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java new file mode 100755 index 000000000..69683795b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java @@ -0,0 +1,161 @@ +package org.motechproject.openlmis.domain; + +import org.joda.time.DateTime; +import org.motechproject.mds.annotations.Access; +import org.motechproject.mds.annotations.Entity; +import org.motechproject.mds.annotations.Field; +import org.motechproject.mds.util.SecurityMode; + +/** + * Represents a OpenLMIS StockStatus + */ + +@Entity +@Access(value = SecurityMode.PERMISSIONS, members = {"configureOpenlmis" }) +public class StockStatus { + + @Field + private DateTime reportedDate; + + @Field + private Integer reportedMonth; + + @Field + private Integer reportedYear; + + @Field + private String reportPeriodName; + + @Field + private Facility facility; + + @Field + private Integer reportMonth; + + @Field + private Integer reportYear; + + @Field + private Integer reportQuarter; + + @Field + private Integer amc; + + @Field + private Integer mos; + + @Field + private String district; + + @Field + private Program program; + + @Field + private Product product; + + public DateTime getReportedDate() { + return reportedDate; + } + + public void setReportedDate(DateTime reportedDate) { + this.reportedDate = reportedDate; + } + + public Integer getReportedMonth() { + return reportedMonth; + } + + public void setReportedMonth(Integer reportedMonth) { + this.reportedMonth = reportedMonth; + } + + public Integer getReportedYear() { + return reportedYear; + } + + public void setReportedYear(Integer reportedYear) { + this.reportedYear = reportedYear; + } + + public String getReportPeriodName() { + return reportPeriodName; + } + + public void setReportPeriodName(String reportPeriodName) { + this.reportPeriodName = reportPeriodName; + } + + public Facility getFacility() { + return facility; + } + + public void setFacility(Facility facility) { + this.facility = facility; + } + + public Integer getReportMonth() { + return reportMonth; + } + + public void setReportMonth(Integer reportMonth) { + this.reportMonth = reportMonth; + } + + public Integer getReportYear() { + return reportYear; + } + + public void setReportYear(Integer reportYear) { + this.reportYear = reportYear; + } + + public Integer getReportQuarter() { + return reportQuarter; + } + + public void setReportQuarter(Integer reportQuarter) { + this.reportQuarter = reportQuarter; + } + + public Integer getAmc() { + return amc; + } + + public void setAmc(Integer amc) { + this.amc = amc; + } + + public Integer getMos() { + return mos; + } + + public void setMos(Integer mos) { + this.mos = mos; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public Program getProgram() { + return program; + } + + public void setProgram(Program program) { + this.program = program; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java new file mode 100755 index 000000000..3f3a273a8 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java @@ -0,0 +1,20 @@ +package org.motechproject.openlmis.repository; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.DosageUnit; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.DosageUnit} + */ +public interface DosageUnitDataService extends MotechDataService { + + @Lookup + DosageUnit findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + DosageUnit findByCode(@LookupField(name = "code") String code); + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java new file mode 100755 index 000000000..3fae38b61 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.Facility; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.Facility} + */ +public interface FacilityDataService extends MotechDataService { + + @Lookup + Facility findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + Facility findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java new file mode 100755 index 000000000..446a811e8 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.FacilityType; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.FacilityType} + */ +public interface FacilityTypeDataService extends MotechDataService { + + @Lookup + FacilityType findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + FacilityType findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java new file mode 100755 index 000000000..5eb087879 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.GeographicLevel; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.GeographicLevel} + */ +public interface GeographicLevelDataService extends MotechDataService { + + @Lookup + GeographicLevel findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + GeographicLevel findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java new file mode 100755 index 000000000..26a553ada --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.GeographicZone; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.GeographicZone} + */ +public interface GeographicZoneDataService extends MotechDataService { + + @Lookup + GeographicZone findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + GeographicZone findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java new file mode 100755 index 000000000..9fa09ff17 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.ProductCategory; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.ProductCategory} + */ +public interface ProductCategoryDataService extends MotechDataService { + + @Lookup + ProductCategory findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + ProductCategory findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java new file mode 100755 index 000000000..36ac92f85 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java @@ -0,0 +1,20 @@ +package org.motechproject.openlmis.repository; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.Product; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.Product} + */ +public interface ProductDataService extends MotechDataService { + + @Lookup + Product findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + Product findByCode(@LookupField(name = "code") String code); + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java new file mode 100755 index 000000000..1b30ea3dc --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.repository; + +import java.util.List; + +import org.motechproject.mds.annotations.Lookup; +import org.motechproject.mds.annotations.LookupField; +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.Program; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.Program} + */ +public interface ProgramDataService extends MotechDataService { + + @Lookup + Program findByOpenlmisId(@LookupField(name = "openlmisid") Integer openlmisId); + + @Lookup + Program findByCode(@LookupField(name = "code") String code); + + @Lookup + List findByName(@LookupField(name = "name") String name); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java b/open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java new file mode 100755 index 000000000..6a0b3f89b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java @@ -0,0 +1,12 @@ +package org.motechproject.openlmis.repository; + +import org.motechproject.mds.service.MotechDataService; +import org.motechproject.openlmis.domain.StockStatus; + + +/** + * MDS data service for {@link org.motechproject.openlmis.domain.Program} + */ +public interface StockStatusDataService extends MotechDataService { + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java new file mode 100755 index 000000000..c31ffca9a --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java @@ -0,0 +1,13 @@ +package org.motechproject.openlmis.rest.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's DosageUnit resource. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class DosageUnitDto extends ProductAttributeBaseDto { + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java new file mode 100755 index 000000000..9a3dc9f24 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java @@ -0,0 +1,382 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's Facility resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class FacilityDto { + + private String goDownDate; //(string, optional), + private Boolean satellite; //(boolean, optional), + private Boolean hasElectronicDar; //(boolean, optional), + private Integer geographicZoneId; //(integer, optional), + private Boolean hasElectronicScc; //(boolean, optional), + private Double altitude; //(number, optional), + private Integer operatedById; //(integer, optional), + private String address1; //(string, optional), + private String address2; //(string, optional), + private Double coldStorageGrossCapacity; //(number, optional), + private Boolean online; //(boolean, optional), + private Integer id; //(integer, optional), + private String gln; //(string, optional), + private Boolean hasElectricity; //(boolean, optional), + private String description; //(string, optional), + private String name; //(string, optional), + private Double longitude; //(number, optional), + private Boolean sdp; //(boolean, optional), + private String fax; //(string, optional), + private Integer satelliteParentId; //(integer, optional), + private Double coldStorageNetCapacity; //(number, optional), + private String code; //(string, optional), + private Boolean dataReportable; //(boolean, optional), + private Boolean suppliesOthers; //(boolean, optional), + private String mainPhone; //(string, optional), + private String goLiveDate; //(string, optional), + private Boolean active; //(boolean, optional), + private Double latitude; //(number, optional), + private String comment; //(string, optional), + private Integer catchmentPopulation; //(integer, optional), + private Integer typeId; //(integer, optional) + + public String getGoDownDate() { + return goDownDate; + } + + public void setGoDownDate(String goDownDate) { + this.goDownDate = goDownDate; + } + + public Boolean getSatellite() { + return satellite; + } + + public void setSatellite(Boolean satellite) { + this.satellite = satellite; + } + + public Boolean getHasElectronicDar() { + return hasElectronicDar; + } + + public void setHasElectronicDar(Boolean hasElectronicDar) { + this.hasElectronicDar = hasElectronicDar; + } + + public Integer getGeographicZoneId() { + return geographicZoneId; + } + + public void setGeographicZoneId(Integer geographicZoneId) { + this.geographicZoneId = geographicZoneId; + } + + public Boolean getHasElectronicScc() { + return hasElectronicScc; + } + + public void setHasElectronicScc(Boolean hasElectronicScc) { + this.hasElectronicScc = hasElectronicScc; + } + + public Double getAltitude() { + return altitude; + } + + public void setAltitude(Double altitude) { + this.altitude = altitude; + } + + public Integer getOperatedById() { + return operatedById; + } + + public void setOperatedById(Integer operatedById) { + this.operatedById = operatedById; + } + + public String getAddress1() { + return address1; + } + + public void setAddress1(String address1) { + this.address1 = address1; + } + + public String getAddress2() { + return address2; + } + + public void setAddress2(String address2) { + this.address2 = address2; + } + + public Double getColdStorageGrossCapacity() { + return coldStorageGrossCapacity; + } + + public void setColdStorageGrossCapacity(Double coldStorageGrossCapacity) { + this.coldStorageGrossCapacity = coldStorageGrossCapacity; + } + + public Boolean getOnline() { + return online; + } + + public void setOnline(Boolean online) { + this.online = online; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getGln() { + return gln; + } + + public void setGln(String gln) { + this.gln = gln; + } + + public Boolean getHasElectricity() { + return hasElectricity; + } + + public void setHasElectricity(Boolean hasElectricity) { + this.hasElectricity = hasElectricity; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Boolean getSdp() { + return sdp; + } + + public void setSdp(Boolean sdp) { + this.sdp = sdp; + } + + public String getFax() { + return fax; + } + + public void setFax(String fax) { + this.fax = fax; + } + + public Integer getSatelliteParentId() { + return satelliteParentId; + } + + public void setSatelliteParentId(Integer satelliteParentId) { + this.satelliteParentId = satelliteParentId; + } + + public Double getColdStorageNetCapacity() { + return coldStorageNetCapacity; + } + + public void setColdStorageNetCapacity(Double coldStorageNetCapacity) { + this.coldStorageNetCapacity = coldStorageNetCapacity; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Boolean getDataReportable() { + return dataReportable; + } + + public void setDataReportable(Boolean dataReportable) { + this.dataReportable = dataReportable; + } + + public Boolean getSuppliesOthers() { + return suppliesOthers; + } + + public void setSuppliesOthers(Boolean suppliesOthers) { + this.suppliesOthers = suppliesOthers; + } + + public String getMainPhone() { + return mainPhone; + } + + public void setMainPhone(String mainPhone) { + this.mainPhone = mainPhone; + } + + public String getGoLiveDate() { + return goLiveDate; + } + + public void setGoLiveDate(String goLiveDate) { + this.goLiveDate = goLiveDate; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Integer getCatchmentPopulation() { + return catchmentPopulation; + } + + public void setCatchmentPopulation(Integer catchmentPopulation) { + this.catchmentPopulation = catchmentPopulation; + } + + public Integer getTypeId() { + return typeId; + } + + public void setTypeId(Integer typeId) { + this.typeId = typeId; + } + + @Override + public int hashCode() { + return Objects.hash(goDownDate, satellite, hasElectronicDar, geographicZoneId, + hasElectronicScc, altitude, operatedById, address1, + address2, coldStorageGrossCapacity, online, id, gln, + hasElectricity, description, name, longitude, + sdp, fax, satelliteParentId, coldStorageNetCapacity, + code, dataReportable, suppliesOthers, mainPhone, + goLiveDate, active, latitude, comment, + catchmentPopulation, typeId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final FacilityDto other = (FacilityDto) obj; + return equalsLocationSatelliteBasicDetailsStatus(other) + && equalsCapacity(other) && equalsContact(other) + && equalsOperationalDetails(other) + && equalsBooleanAttributes(other); + } + + private boolean equalsLocationSatelliteBasicDetailsStatus(FacilityDto other) { + return equalsLocation(other) && equalsSatelliteDetails(other) + && equalsBasicDetails(other) && equalsStatus(other); + } + + private boolean equalsLocation(FacilityDto other) { + return Objects.equals(this.address1, other.address1) + && Objects.equals(this.address2, other.address2) + && Objects.equals(this.latitude, other.latitude) + && Objects.equals(this.longitude, other.longitude); + } + + private boolean equalsBasicDetails(FacilityDto other) { + return Objects.equals(this.name, other.name) + && Objects.equals(this.description, other.description) + && Objects.equals(this.id, other.id) + && Objects.equals(this.code, other.code); + } + + private boolean equalsSatelliteDetails(FacilityDto other) { + return Objects.equals(this.satellite, other.satellite) + && Objects.equals(this.satelliteParentId, other.satelliteParentId) + && Objects.equals(this.geographicZoneId, other.geographicZoneId) + && Objects.equals(this.altitude, other.altitude); + } + + private boolean equalsStatus(FacilityDto other) { + return Objects.equals(this.goDownDate, other.goDownDate) + && Objects.equals(this.goLiveDate, other.goLiveDate) + && Objects.equals(this.active, other.active) + && Objects.equals(this.online, other.online); + } + + private boolean equalsCapacity(FacilityDto other) { + return Objects.equals(this.coldStorageGrossCapacity, other.coldStorageGrossCapacity) + && Objects.equals(this.coldStorageNetCapacity, other.coldStorageNetCapacity) + && Objects.equals(this.dataReportable, other.dataReportable) + && Objects.equals(this.suppliesOthers, other.suppliesOthers); + } + + private boolean equalsContact(FacilityDto other) { + return Objects.equals(this.mainPhone, other.mainPhone) + && Objects.equals(this.fax, other.fax) + && Objects.equals(this.sdp, other.sdp) + && Objects.equals(this.gln, other.gln); + } + + private boolean equalsOperationalDetails(FacilityDto other) { + return Objects.equals(this.operatedById, other.operatedById) + && Objects.equals(this.catchmentPopulation, other.catchmentPopulation) + && Objects.equals(this.typeId, other.typeId) + && Objects.equals(this.comment, other.comment); + } + + private boolean equalsBooleanAttributes(FacilityDto other) { + return Objects.equals(this.hasElectronicDar, other.hasElectronicDar) + && Objects.equals(this.hasElectronicScc, other.hasElectronicScc) + && Objects.equals(this.hasElectricity, other.hasElectricity); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java new file mode 100755 index 000000000..ae482b194 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java @@ -0,0 +1,127 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's FacilityType resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class FacilityTypeDto { + + private Integer id; //(integer, optional), + private Double nominalEop; //(number, optional), + private Integer levelId; //(integer, optional), + private String description; //(string, optional), + private String name; //(string, optional), + private Boolean active; //(boolean, optional), + private Integer displayOrder; //(integer, optional), + private String code; //(string, optional), + private Integer nominalMaxMonth; //(integer, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Double getNominalEop() { + return nominalEop; + } + + public void setNominalEop(Double nominalEop) { + this.nominalEop = nominalEop; + } + + public Integer getLevelId() { + return levelId; + } + + public void setLevelId(Integer levelId) { + this.levelId = levelId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getNominalMaxMonth() { + return nominalMaxMonth; + } + + public void setNominalMaxMonth(Integer nominalMaxMonth) { + this.nominalMaxMonth = nominalMaxMonth; + } + + @Override + public int hashCode() { + return Objects.hash(id, nominalEop, levelId, description, + name, active, displayOrder, code, nominalMaxMonth); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final FacilityTypeDto other = (FacilityTypeDto) obj; + return equalsDetails(other) + && Objects.equals(this.nominalEop, other.nominalEop) + && Objects.equals(this.levelId, other.levelId) + && Objects.equals(this.active, other.active) + && Objects.equals(this.displayOrder, other.displayOrder) + && Objects.equals(this.nominalMaxMonth, other.nominalMaxMonth); + } + + private boolean equalsDetails(FacilityTypeDto other) { + return Objects.equals(this.id, other.id) + && Objects.equals(this.description, other.description) + && Objects.equals(this.name, other.name) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java new file mode 100755 index 000000000..f6743925d --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java @@ -0,0 +1,72 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's GeographicLevel resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class GeographicLevelDto { + + private Integer id; //(integer, optional), + private Integer levelNumber; //(integer, optional), + private String name; //(string, optional), + private String code; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getLevelNumber() { + return levelNumber; + } + + public void setLevelNumber(Integer levelNumber) { + this.levelNumber = levelNumber; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public int hashCode() { + return Objects.hash(id, levelNumber, name, code); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final GeographicLevelDto other = (GeographicLevelDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.levelNumber, other.levelNumber) + && Objects.equals(this.name, other.name) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java new file mode 100755 index 000000000..3febe533e --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java @@ -0,0 +1,118 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's GeographicZone resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class GeographicZoneDto { + + private Integer id; //(integer, optional), + private Integer levelId; //(GeographicLevel, optional), + private String name; //(string, optional), + private Integer parentId; + private Double longitude; //(number, optional), + private Double latitude; //(number, optional), + private String code; //(string, optional), + private Integer catchmentPopulation; //(integer, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getLevelId() { + return levelId; + } + + public void setLevelId(Integer levelId) { + this.levelId = levelId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getCatchmentPopulation() { + return catchmentPopulation; + } + + public void setCatchmentPopulation(Integer catchmentPopulation) { + this.catchmentPopulation = catchmentPopulation; + } + + @Override + public int hashCode() { + return Objects.hash(id, levelId, name, parentId, + longitude, latitude, code, catchmentPopulation); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final GeographicZoneDto other = (GeographicZoneDto) obj; + return equalsDetails(other) && Objects.equals(this.id, other.id) + && Objects.equals(this.levelId, other.levelId) + && Objects.equals(this.parentId, other.parentId) + && Objects.equals(this.catchmentPopulation, + other.catchmentPopulation); + } + + private boolean equalsDetails(GeographicZoneDto other) { + return Objects.equals(this.name, other.name) + && Objects.equals(this.longitude, other.longitude) + && Objects.equals(this.latitude, other.latitude) + && Objects.equals(this.code, other.code); + + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java new file mode 100755 index 000000000..54e058d02 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java @@ -0,0 +1,127 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ISA resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ISADto { + + private Integer adjustmentValue; //(integer, optional), + private Integer id; //(integer, optional), + private Integer maximumValue; //(integer, optional), + private Integer populationSource; //(integer, optional), + private Integer minimumValue; //(integer, optional), + private Integer wastageFactor; //(number, optional), + private Integer dosesPerYear; //(integer, optional), + private Double bufferPercentage; //(number, optional), + private Double whoRatio; //(number, optional) + + public Integer getAdjustmentValue() { + return adjustmentValue; + } + + public void setAdjustmentValue(Integer adjustmentValue) { + this.adjustmentValue = adjustmentValue; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getMaximumValue() { + return maximumValue; + } + + public void setMaximumValue(Integer maximumValue) { + this.maximumValue = maximumValue; + } + + public Integer getPopulationSource() { + return populationSource; + } + + public void setPopulationSource(Integer populationSource) { + this.populationSource = populationSource; + } + + public Integer getMinimumValue() { + return minimumValue; + } + + public void setMinimumValue(Integer minimumValue) { + this.minimumValue = minimumValue; + } + + public Integer getWastageFactor() { + return wastageFactor; + } + + public void setWastageFactor(Integer wastageFactor) { + this.wastageFactor = wastageFactor; + } + + public Integer getDosesPerYear() { + return dosesPerYear; + } + + public void setDosesPerYear(Integer dosesPerYear) { + this.dosesPerYear = dosesPerYear; + } + + public Double getBufferPercentage() { + return bufferPercentage; + } + + public void setBufferPercentage(Double bufferPercentage) { + this.bufferPercentage = bufferPercentage; + } + + public Double getWhoRatio() { + return whoRatio; + } + + public void setWhoRatio(Double whoRatio) { + this.whoRatio = whoRatio; + } + + @Override + public int hashCode() { + return Objects.hash(adjustmentValue, id, maximumValue, + populationSource, minimumValue, wastageFactor, + dosesPerYear, bufferPercentage, whoRatio); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ISADto other = (ISADto) obj; + return equalsRange(other) && Objects.equals(this.id, other.id) + && Objects.equals(this.populationSource, other.populationSource) + && Objects.equals(this.dosesPerYear, other.dosesPerYear) + && Objects.equals(this.bufferPercentage, other.bufferPercentage) + && Objects.equals(this.whoRatio, other.whoRatio); + } + + private boolean equalsRange(ISADto other) { + return Objects.equals(this.adjustmentValue, other.adjustmentValue) + && Objects.equals(this.minimumValue, other.minimumValue) + && Objects.equals(this.maximumValue, other.maximumValue) + && Objects.equals(this.wastageFactor, other.wastageFactor); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java new file mode 100755 index 000000000..fd4f45273 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java @@ -0,0 +1,72 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's KitProduct resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class KitProductDto { + + private Integer id; //(integer, optional), + private String productCode; //(string, optional), + private String kitCode; // (string, optional), + private Integer quantity; //(integer, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getKitCode() { + return kitCode; + } + + public void setKitCode(String kitCode) { + this.kitCode = kitCode; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + @Override + public int hashCode() { + return Objects.hash(id, productCode, kitCode, quantity); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final KitProductDto other = (KitProductDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.productCode, other.productCode) + && Objects.equals(this.kitCode, other.kitCode) + && Objects.equals(this.quantity, other.quantity); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java new file mode 100755 index 000000000..c49cc39ab --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java @@ -0,0 +1,82 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's LossesAndAdjustments resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class LossesAndAdjustmentsTypeDto { + + private Integer id; //(integer, optional), + private String description; //(string, optional), + private String name; //(string, optional), + private Integer displayOrder; //(integer, optional), + private Boolean additive; //(boolean, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + public Boolean getAdditive() { + return additive; + } + + public void setAdditive(Boolean additive) { + this.additive = additive; + } + + @Override + public int hashCode() { + return Objects.hash(id, description, name, displayOrder, additive); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final LossesAndAdjustmentsTypeDto other = (LossesAndAdjustmentsTypeDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.description, other.description) + && Objects.equals(this.name, other.name) + && Objects.equals(this.displayOrder, other.displayOrder) + && Objects.equals(this.additive, other.additive); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java new file mode 100755 index 000000000..abc9ad414 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java @@ -0,0 +1,53 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's Money resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class MoneyDto { + + private Double value; //(number, optional), + private Boolean negative; //(boolean, optional) + + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public Boolean getNegative() { + return negative; + } + + public void setNegative(Boolean negative) { + this.negative = negative; + } + + @Override + public int hashCode() { + return Objects.hash(value, negative); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final MoneyDto other = (MoneyDto) obj; + return Objects.equals(this.value, other.value) + && Objects.equals(this.negative, other.negative); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java new file mode 100755 index 000000000..d7896a32b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java @@ -0,0 +1,92 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProcessingPeriod resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProcessingPeriodDto { + + private Integer id; //(integer, optional), + private Integer scheduleId; //(integer, optional), + private String startdate; //(string, optional), + private String description; //(string, optional), + private String name; //(string, optional), + private String enddate; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getScheduleId() { + return scheduleId; + } + + public void setScheduleId(Integer scheduleId) { + this.scheduleId = scheduleId; + } + + public String getStartdate() { + return startdate; + } + + public void setStartdate(String startdate) { + this.startdate = startdate; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnddate() { + return enddate; + } + + public void setEnddate(String enddate) { + this.enddate = enddate; + } + + @Override + public int hashCode() { + return Objects.hash(id, scheduleId, startdate, description, name, enddate); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProcessingPeriodDto other = (ProcessingPeriodDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.scheduleId, other.scheduleId) + && Objects.equals(this.startdate, other.startdate) + && Objects.equals(this.description, other.description) + && Objects.equals(this.name, other.name) + && Objects.equals(this.enddate, other.enddate); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java new file mode 100644 index 000000000..ba7174995 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java @@ -0,0 +1,62 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's DosageUnit resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductAttributeBaseDto { + + private Integer id; //(integer, optional), + private Integer displayOrder; //(integer, optional), + private String code; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public int hashCode() { + return Objects.hash(id, displayOrder, code); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProductAttributeBaseDto other = (ProductAttributeBaseDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.displayOrder, other.displayOrder) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java new file mode 100755 index 000000000..17cfd6453 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java @@ -0,0 +1,72 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's product category resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductCategoryDto { + + private Integer id; //(integer, optional), + private String name; //(string, optional), + private Integer displayOrder; //(integer, optional), + private String code; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public int hashCode() { + return Objects.hash(id, name, displayOrder, code); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProductCategoryDto other = (ProductCategoryDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.name, other.name) + && Objects.equals(this.displayOrder, other.displayOrder) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java new file mode 100755 index 000000000..ec2f42cbb --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java @@ -0,0 +1,643 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's Product resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductDto { + + private Double packWidth; // (number, optional), + private Double contraceptiveCYP; // (number, optional), + private DosageUnitDto dosageUnit; // (DosageUnit, optional), + private String manufacturerCode; // (string, optional), + private Boolean lightSensitive; // (boolean, optional), + private String type; // (string, optional), + private Double cartonLength; // (number, optional), + private String alternateName; // (string, optional), + private Integer formId; // (integer, optional), + private String description; // (string, optional), + private Boolean hazardous; // (boolean, optional), + private Integer packsPerCarton; // (integer, optional), + private Double cartonWidth; // (number, optional), + private ProductFormDto form; // (ProductForm, optional), + private String specialTransportInstructions; // (string, optional), + private String code; // (string, optional), + private String genericName; // (string, optional), + private Boolean approvedByWHO; // (boolean, optional), + private Double cartonHeight; // (number, optional), + private Integer alternatePackSize; // (integer, optional), + private String alternateItemCode; // (string, optional), + private Integer dosesPerDispensingUnit; // (integer, optional), + private Boolean isKit; // (boolean, optional), + private Double packLength; // (number, optional), + private String manufacturerBarCode; // (string, optional), + private String manufacturer; // (string, optional), + private List kitProductList; // (List[KitProduct], optional), + private Boolean active; // (boolean, optional), + private Double packHeight; // (number, optional), + private Integer packRoundingThreshold; // (integer, optional), + private String mohBarCode; // (string, optional), + private Integer dosageUnitId; // (integer, optional), + private ProductGroupDto productGroup; // (ProductGroup, optional), + private Boolean tracer; // (boolean, optional), + private Boolean fullSupply; // (boolean, optional), + private Boolean roundToZero; // (boolean, optional), + private String specialStorageInstructions; // (string, optional), + private Integer productGroupId; // (integer, optional), + private Boolean flammable; // (boolean, optional), + private String dispensingUnit; // (string, optional), + private Integer id; // (integer, optional), + private Integer expectedShelfLife; // (integer, optional), + private Boolean archived; // (boolean, optional), + private Integer packSize; // (integer, optional), + private Boolean storeRefrigerated; // (boolean, optional), + private String strength; // (string, optional), + private String gtin; // (string, optional), + private Boolean storeRoomTemperature; // (boolean, optional), + private String primaryName; // (string, optional), + private Double packWeight; // (number, optional), + private Boolean controlledSubstance; // (boolean, optional), + private Integer cartonsPerPallet; // (integer, optional), + private String fullName; // (string, optional) + + public Double getPackWidth() { + return packWidth; + } + + public void setPackWidth(Double packWidth) { + this.packWidth = packWidth; + } + + public Double getContraceptiveCYP() { + return contraceptiveCYP; + } + + public void setContraceptiveCYP(Double contraceptiveCYP) { + this.contraceptiveCYP = contraceptiveCYP; + } + + public DosageUnitDto getDosageUnit() { + return dosageUnit; + } + + public void setDosageUnit(DosageUnitDto dosageUnit) { + this.dosageUnit = dosageUnit; + } + + public String getManufacturerCode() { + return manufacturerCode; + } + + public void setManufacturerCode(String manufacturerCode) { + this.manufacturerCode = manufacturerCode; + } + + public Boolean getLightSensitive() { + return lightSensitive; + } + + public void setLightSensitive(Boolean lightSensitive) { + this.lightSensitive = lightSensitive; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Double getCartonLength() { + return cartonLength; + } + + public void setCartonLength(Double cartonLength) { + this.cartonLength = cartonLength; + } + + public String getAlternateName() { + return alternateName; + } + + public void setAlternateName(String alternateName) { + this.alternateName = alternateName; + } + + public Integer getFormId() { + return formId; + } + + public void setFormId(Integer formId) { + this.formId = formId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean getHazardous() { + return hazardous; + } + + public void setHazardous(Boolean hazardous) { + this.hazardous = hazardous; + } + + public Integer getPacksPerCarton() { + return packsPerCarton; + } + + public void setPacksPerCarton(Integer packsPerCarton) { + this.packsPerCarton = packsPerCarton; + } + + public Double getCartonWidth() { + return cartonWidth; + } + + public void setCartonWidth(Double cartonWidth) { + this.cartonWidth = cartonWidth; + } + + public ProductFormDto getForm() { + return form; + } + + public void setForm(ProductFormDto form) { + this.form = form; + } + + public String getSpecialTransportInstructions() { + return specialTransportInstructions; + } + + public void setSpecialTransportInstructions(String specialTransportInstructions) { + this.specialTransportInstructions = specialTransportInstructions; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getGenericName() { + return genericName; + } + + public void setGenericName(String genericName) { + this.genericName = genericName; + } + + public Boolean getApprovedByWHO() { + return approvedByWHO; + } + + public void setApprovedByWHO(Boolean approvedByWHO) { + this.approvedByWHO = approvedByWHO; + } + + public Double getCartonHeight() { + return cartonHeight; + } + + public void setCartonHeight(Double cartonHeight) { + this.cartonHeight = cartonHeight; + } + + public Integer getAlternatePackSize() { + return alternatePackSize; + } + + public void setAlternatePackSize(Integer alternatePackSize) { + this.alternatePackSize = alternatePackSize; + } + + public String getAlternateItemCode() { + return alternateItemCode; + } + + public void setAlternateItemCode(String alternateItemCode) { + this.alternateItemCode = alternateItemCode; + } + + public Integer getDosesPerDispensingUnit() { + return dosesPerDispensingUnit; + } + + public void setDosesPerDispensingUnit(Integer dosesPerDispensingUnit) { + this.dosesPerDispensingUnit = dosesPerDispensingUnit; + } + + public Boolean getIsKit() { + return isKit; + } + + public void setIsKit(Boolean isKit) { + this.isKit = isKit; + } + + public Double getPackLength() { + return packLength; + } + + public void setPackLength(Double packLength) { + this.packLength = packLength; + } + + public String getManufacturerBarCode() { + return manufacturerBarCode; + } + + public void setManufacturerBarCode(String manufacturerBarCode) { + this.manufacturerBarCode = manufacturerBarCode; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public List getKitProductList() { + return kitProductList; + } + + public void setKitProductList(List kitProductList) { + this.kitProductList = kitProductList; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Double getPackHeight() { + return packHeight; + } + + public void setPackHeight(Double packHeight) { + this.packHeight = packHeight; + } + + public Integer getPackRoundingThreshold() { + return packRoundingThreshold; + } + + public void setPackRoundingThreshold(Integer packRoundingThreshold) { + this.packRoundingThreshold = packRoundingThreshold; + } + + public String getMohBarCode() { + return mohBarCode; + } + + public void setMohBarCode(String mohBarCode) { + this.mohBarCode = mohBarCode; + } + + public Integer getDosageUnitId() { + return dosageUnitId; + } + + public void setDosageUnitId(Integer dosageUnitId) { + this.dosageUnitId = dosageUnitId; + } + + public ProductGroupDto getProductGroup() { + return productGroup; + } + + public void setProductGroup(ProductGroupDto productGroup) { + this.productGroup = productGroup; + } + + public Boolean getTracer() { + return tracer; + } + + public void setTracer(Boolean tracer) { + this.tracer = tracer; + } + + public Boolean getFullSupply() { + return fullSupply; + } + + public void setFullSupply(Boolean fullSupply) { + this.fullSupply = fullSupply; + } + + public Boolean getRoundToZero() { + return roundToZero; + } + + public void setRoundToZero(Boolean roundToZero) { + this.roundToZero = roundToZero; + } + + public String getSpecialStorageInstructions() { + return specialStorageInstructions; + } + + public void setSpecialStorageInstructions(String specialStorageInstructions) { + this.specialStorageInstructions = specialStorageInstructions; + } + + public Integer getProductGroupId() { + return productGroupId; + } + + public void setProductGroupId(Integer productGroupId) { + this.productGroupId = productGroupId; + } + + public Boolean getFlammable() { + return flammable; + } + + public void setFlammable(Boolean flammable) { + this.flammable = flammable; + } + + public String getDispensingUnit() { + return dispensingUnit; + } + + public void setDispensingUnit(String dispensingUnit) { + this.dispensingUnit = dispensingUnit; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getExpectedShelfLife() { + return expectedShelfLife; + } + + public void setExpectedShelfLife(Integer expectedShelfLife) { + this.expectedShelfLife = expectedShelfLife; + } + + public Boolean getArchived() { + return archived; + } + + public void setArchived(Boolean archived) { + this.archived = archived; + } + + public Integer getPackSize() { + return packSize; + } + + public void setPackSize(Integer packSize) { + this.packSize = packSize; + } + + public Boolean getStoreRefrigerated() { + return storeRefrigerated; + } + + public void setStoreRefrigerated(Boolean storeRefrigerated) { + this.storeRefrigerated = storeRefrigerated; + } + + public String getStrength() { + return strength; + } + + public void setStrength(String strength) { + this.strength = strength; + } + + public String getGtin() { + return gtin; + } + + public void setGtin(String gtin) { + this.gtin = gtin; + } + + public Boolean getStoreRoomTemperature() { + return storeRoomTemperature; + } + + public void setStoreRoomTemperature(Boolean storeRoomTemperature) { + this.storeRoomTemperature = storeRoomTemperature; + } + + public String getPrimaryName() { + return primaryName; + } + + public void setPrimaryName(String primaryName) { + this.primaryName = primaryName; + } + + public Double getPackWeight() { + return packWeight; + } + + public void setPackWeight(Double packWeight) { + this.packWeight = packWeight; + } + + public Boolean getControlledSubstance() { + return controlledSubstance; + } + + public void setControlledSubstance(Boolean controlledSubstance) { + this.controlledSubstance = controlledSubstance; + } + + public Integer getCartonsPerPallet() { + return cartonsPerPallet; + } + + public void setCartonsPerPallet(Integer cartonsPerPallet) { + this.cartonsPerPallet = cartonsPerPallet; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + @Override + public int hashCode() { + return Objects.hash(packWidth, contraceptiveCYP, dosageUnit, manufacturerCode, lightSensitive, type, + cartonLength, alternateName, formId, description, hazardous, packsPerCarton, cartonWidth, form, + specialTransportInstructions, code, genericName, approvedByWHO, cartonHeight, alternatePackSize, + alternateItemCode, dosesPerDispensingUnit, isKit, packLength, manufacturerBarCode, manufacturer, + kitProductList, active, packHeight, packRoundingThreshold, mohBarCode, dosageUnitId, productGroup, + tracer, fullSupply, roundToZero, specialStorageInstructions, productGroupId, flammable, dispensingUnit, + id, expectedShelfLife, archived, packSize, storeRefrigerated, strength, gtin, storeRoomTemperature, + primaryName, packWeight, controlledSubstance, cartonsPerPallet, fullName); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProductDto other = (ProductDto) obj; + return equalsDimensionsNameDescription(other) && + equalsQuantityCodeAndManufacturer(other) && + equalsBooleanAttributes(other) && equalsMappingAndDetails(other); + } + + private boolean equalsDimensionsNameDescription(ProductDto other) { + return equalsPackDimensions(other) && + equalsCartonDimensions(other) && + equalsName(other) && equalsDescription(other); + } + + private boolean equalsQuantityCodeAndManufacturer(ProductDto other) { + return equalsQuantity(other) && equalsCode(other) && + equalsManufacturer(other); + } + + private boolean equalsBooleanAttributes(ProductDto other) { + return equalsBooleanAttributesOne(other) + && equalsBooleanAttributesTwo(other) + && equalsBooleanAttributesThree(other) + && equalsBooleanAttributesFour(other); + } + + private boolean equalsMappingAndDetails(ProductDto other) { + return equalsMappingDto(other) && equalsMappingIds(other) + && equalsInstructionDetails(other) + && equalsNumericalDetails(other); + } + + private boolean equalsPackDimensions(ProductDto other) { + return Objects.equals(this.packLength, other.packLength) + && Objects.equals(this.packWidth, other.packWidth) + && Objects.equals(this.packHeight, other.packHeight) + && Objects.equals(this.packWeight, other.packWeight); + } + + private boolean equalsCartonDimensions(ProductDto other) { + return Objects.equals(this.cartonLength, other.cartonLength) + && Objects.equals(this.cartonWidth, other.cartonWidth) + && Objects.equals(this.cartonHeight, other.cartonHeight); + } + + private boolean equalsName(ProductDto other) { + return Objects.equals(this.fullName, other.fullName) + && Objects.equals(this.primaryName, other.primaryName) + && Objects.equals(this.genericName, other.genericName) + && Objects.equals(this.alternateName, other.alternateName); + } + + private boolean equalsDescription(ProductDto other) { + return Objects.equals(this.description, other.description) + && Objects.equals(this.id, other.id) + && Objects.equals(this.type, other.type); + } + + private boolean equalsQuantity(ProductDto other) { + return Objects.equals(this.packsPerCarton, other.packsPerCarton) + && Objects.equals(this.packSize, other.packSize) + && Objects.equals(this.alternatePackSize, other.alternatePackSize) + && Objects.equals(this.cartonsPerPallet, other.cartonsPerPallet); + } + + private boolean equalsCode(ProductDto other) { + return Objects.equals(this.alternateItemCode, other.alternateItemCode) + && Objects.equals(this.code, other.code) + && Objects.equals(this.mohBarCode, other.mohBarCode) + && Objects.equals(this.gtin, other.gtin); + } + + private boolean equalsManufacturer(ProductDto other) { + return Objects.equals(this.manufacturerCode, other.manufacturerCode) + && Objects.equals(this.manufacturerBarCode, other.manufacturerBarCode) + && Objects.equals(this.manufacturer, other.manufacturer) + && Objects.equals(this.gtin, other.gtin); + } + + private boolean equalsBooleanAttributesOne(ProductDto other) { + return Objects.equals(this.lightSensitive, other.lightSensitive) + && Objects.equals(this.hazardous, other.hazardous) + && Objects.equals(this.approvedByWHO, other.approvedByWHO) + && Objects.equals(this.isKit, other.isKit); + } + + private boolean equalsBooleanAttributesTwo(ProductDto other) { + return Objects.equals(this.active, other.active) + && Objects.equals(this.tracer, other.tracer) + && Objects.equals(this.fullSupply, other.fullSupply); + } + + private boolean equalsBooleanAttributesThree(ProductDto other) { + return Objects.equals(this.roundToZero, other.roundToZero) + && Objects.equals(this.flammable, other.flammable) + && Objects.equals(this.archived, other.archived); + } + + private boolean equalsBooleanAttributesFour(ProductDto other) { + return Objects.equals(this.storeRefrigerated, other.storeRefrigerated) + && Objects.equals(this.storeRoomTemperature, other.storeRoomTemperature) + && Objects.equals(this.controlledSubstance, other.controlledSubstance); + } + + private boolean equalsMappingIds(ProductDto other) { + return Objects.equals(this.dosageUnitId, other.dosageUnitId) + && Objects.equals(this.productGroupId, other.productGroupId) + && Objects.equals(this.formId, other.formId); + } + + private boolean equalsMappingDto(ProductDto other) { + return Objects.equals(this.dosageUnit, other.dosageUnit) + && Objects.equals(this.kitProductList, other.kitProductList) + && Objects.equals(this.productGroup, other.productGroup) + && Objects.equals(this.form, other.form); + } + + private boolean equalsInstructionDetails(ProductDto other) { + return Objects.equals(this.specialTransportInstructions, other.specialTransportInstructions) + && Objects.equals(this.specialStorageInstructions, other.specialStorageInstructions) + && Objects.equals(this.expectedShelfLife, other.expectedShelfLife) + && Objects.equals(this.strength, other.strength); + } + + private boolean equalsNumericalDetails(ProductDto other) { + return Objects.equals(this.contraceptiveCYP, other.contraceptiveCYP) + && Objects.equals(this.packRoundingThreshold, other.packRoundingThreshold) + && Objects.equals(this.dispensingUnit, other.dispensingUnit) + && Objects.equals(this.dosesPerDispensingUnit, other.dosesPerDispensingUnit); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java new file mode 100755 index 000000000..cac7eee9e --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java @@ -0,0 +1,13 @@ +package org.motechproject.openlmis.rest.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProductForm resource. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductFormDto extends ProductAttributeBaseDto { + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java new file mode 100755 index 000000000..b1caa848e --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java @@ -0,0 +1,62 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProductGroup resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductGroupDto { + + private Integer id; //(integer, optional), + private String name; //(string, optional), + private String code; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public int hashCode() { + return Objects.hash(id, name, code); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProductGroupDto other = (ProductGroupDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.name, other.name) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java new file mode 100755 index 000000000..6893ff9cc --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java @@ -0,0 +1,72 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's program resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProgramDto { + + private Integer id; //(integer, optional), + private String description; //(string, optional), + private String name; //(string, optional), + private String code; //(string, optional) + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public int hashCode() { + return Objects.hash(id, description, name, code); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProgramDto other = (ProgramDto) obj; + return Objects.equals(this.id, other.id) + && Objects.equals(this.description, other.description) + && Objects.equals(this.name, other.name) + && Objects.equals(this.code, other.code); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java new file mode 100755 index 000000000..42d23b00f --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java @@ -0,0 +1,151 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProgramProduct resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProgramProductDto { + + private ProductDto product; //(Product, optional), + private Integer id; //(integer, optional), + private ProgramProductISADto programProductIsa; //(ProgramProductISA, optional), + private Boolean fullSupply; //(boolean, optional), + private ProgramDto program; //(Program, optional), + private ProductCategoryDto productCategory; //(ProductCategory, optional), + private Integer dosesPerMonth; //(integer, optional), + private Integer displayOrder; //(integer, optional), + private Boolean active; //(boolean, optional), + private MoneyDto currentPrice; //(Money, optional), + private Integer productCategoryId; //(integer, optional) + + public ProductDto getProduct() { + return product; + } + + public void setProduct(ProductDto product) { + this.product = product; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public ProgramProductISADto getProgramProductIsa() { + return programProductIsa; + } + + public void setProgramProductIsa(ProgramProductISADto programProductIsa) { + this.programProductIsa = programProductIsa; + } + + public Boolean getFullSupply() { + return fullSupply; + } + + public void setFullSupply(Boolean fullSupply) { + this.fullSupply = fullSupply; + } + + public ProgramDto getProgram() { + return program; + } + + public void setProgram(ProgramDto program) { + this.program = program; + } + + public ProductCategoryDto getProductCategory() { + return productCategory; + } + + public void setProductCategory(ProductCategoryDto productCategory) { + this.productCategory = productCategory; + } + + public Integer getDosesPerMonth() { + return dosesPerMonth; + } + + public void setDosesPerMonth(Integer dosesPerMonth) { + this.dosesPerMonth = dosesPerMonth; + } + + public Integer getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public MoneyDto getCurrentPrice() { + return currentPrice; + } + + public void setCurrentPrice(MoneyDto currentPrice) { + this.currentPrice = currentPrice; + } + + public Integer getProductCategoryId() { + return productCategoryId; + } + + public void setProductCategoryId(Integer productCategoryId) { + this.productCategoryId = productCategoryId; + } + + @Override + public int hashCode() { + return Objects.hash(product, id, programProductIsa, fullSupply, + program, productCategory, dosesPerMonth, displayOrder, + active, currentPrice, productCategoryId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProgramProductDto other = (ProgramProductDto) obj; + return equalsProduct(other) && equalsDetails(other) + && Objects.equals(this.programProductIsa, other.programProductIsa) + && Objects.equals(this.dosesPerMonth, other.dosesPerMonth) + && Objects.equals(this.displayOrder, other.displayOrder) + && Objects.equals(this.currentPrice, other.currentPrice); + } + + private boolean equalsProduct(ProgramProductDto other) { + return Objects.equals(this.product, other.product) + && Objects.equals(this.productCategory, other.productCategory) + && Objects.equals(this.productCategoryId, other.productCategoryId); + } + + private boolean equalsDetails(ProgramProductDto other) { + return Objects.equals(this.id, other.id) + && Objects.equals(this.program, other.program) + && Objects.equals(this.active, other.active) + && Objects.equals(this.fullSupply, other.fullSupply); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java new file mode 100755 index 000000000..2c5283364 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java @@ -0,0 +1,152 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProgramProductISA resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProgramProductISADto { + + private Integer adjustmentValue; //(integer, optional), + private Integer programProductId; //(integer, optional), + private Integer id; //(integer, optional), + private Integer maximumValue; //(integer, optional), + private Integer populationSource; //(integer, optional), + private Integer minimumValue; //(integer, optional), + private ISADto isa; //(ISA, optional), + private Double wastageFactor; //(number, optional), + private Integer dosesPerYear; //(integer, optional), + private Double bufferPercentage; //(number, optional), + private Double whoRatio; //(number, optional) + + public Integer getAdjustmentValue() { + return adjustmentValue; + } + + public void setAdjustmentValue(Integer adjustmentValue) { + this.adjustmentValue = adjustmentValue; + } + + public Integer getProgramProductId() { + return programProductId; + } + + public void setProgramProductId(Integer programProductId) { + this.programProductId = programProductId; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getMaximumValue() { + return maximumValue; + } + + public void setMaximumValue(Integer maximumValue) { + this.maximumValue = maximumValue; + } + + public Integer getPopulationSource() { + return populationSource; + } + + public void setPopulationSource(Integer populationSource) { + this.populationSource = populationSource; + } + + public Integer getMinimumValue() { + return minimumValue; + } + + public void setMinimumValue(Integer minimumValue) { + this.minimumValue = minimumValue; + } + + public ISADto getIsa() { + return isa; + } + + public void setIsa(ISADto isa) { + this.isa = isa; + } + + public Double getWastageFactor() { + return wastageFactor; + } + + public void setWastageFactor(Double wastageFactor) { + this.wastageFactor = wastageFactor; + } + + public Integer getDosesPerYear() { + return dosesPerYear; + } + + public void setDosesPerYear(Integer dosesPerYear) { + this.dosesPerYear = dosesPerYear; + } + + public Double getBufferPercentage() { + return bufferPercentage; + } + + public void setBufferPercentage(Double bufferPercentage) { + this.bufferPercentage = bufferPercentage; + } + + public Double getWhoRatio() { + return whoRatio; + } + + public void setWhoRatio(Double whoRatio) { + this.whoRatio = whoRatio; + } + + @Override + public int hashCode() { + return Objects.hash(adjustmentValue, programProductId, id, + maximumValue, populationSource, minimumValue, isa, + wastageFactor, dosesPerYear, bufferPercentage, whoRatio); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProgramProductISADto other = (ProgramProductISADto) obj; + return equalsMappings(other) && equalsRange(other) + && Objects.equals(this.id, other.id) + && Objects.equals(this.populationSource, other.populationSource) + && Objects.equals(this.dosesPerYear, other.dosesPerYear) + && Objects.equals(this.bufferPercentage, other.bufferPercentage) + && Objects.equals(this.whoRatio, other.whoRatio); + } + + private boolean equalsMappings(ProgramProductISADto other) { + return Objects.equals(this.programProductId, other.programProductId) + && Objects.equals(this.isa, other.isa); + + } + + private boolean equalsRange(ProgramProductISADto other) { + return Objects.equals(this.adjustmentValue, other.adjustmentValue) + && Objects.equals(this.minimumValue, other.minimumValue) + && Objects.equals(this.maximumValue, other.maximumValue) + && Objects.equals(this.wastageFactor, other.wastageFactor); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java new file mode 100755 index 000000000..891b8d24a --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java @@ -0,0 +1,63 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProgramsWithProduct resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProgramsWithProductDto { + + private String programName; //(string, optional), + private String programCode; //(string, optional), + private List products; // + + public String getProgramName() { + return programName; + } + + public void setProgramName(String programName) { + this.programName = programName; + } + + public String getProgramCode() { + return programCode; + } + + public void setProgramCode(String programCode) { + this.programCode = programCode; + } + + public List getProducts() { + return products; + } + + public void setProducts(List products) { + this.products = products; + } + + @Override + public int hashCode() { + return Objects.hash(programName, programCode, products); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProgramsWithProductDto other = (ProgramsWithProductDto) obj; + return Objects.equals(this.programName, other.programName) + && Objects.equals(this.programCode, other.programCode) + && Objects.equals(this.products, other.products); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java new file mode 100755 index 000000000..8aefa723d --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java @@ -0,0 +1,43 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's ProgramsWithProducts resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProgramsWithProductsDto { + + private List programsWithProducts; //(ProgramWithProduct, optional), + + public List getProgramsWithProducts() { + return programsWithProducts; + } + + public void setProgramsWithProducts(List programsWithProducts) { + this.programsWithProducts = programsWithProducts; + } + + @Override + public int hashCode() { + return Objects.hash(programsWithProducts.toArray()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ProgramsWithProductsDto other = (ProgramsWithProductsDto) obj; + return Objects.equals(this.programsWithProducts, other.programsWithProducts); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java new file mode 100755 index 000000000..0841e4aa8 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java @@ -0,0 +1,21 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; + +public class ResourceListDto { + + private List resources; + + @JsonAnySetter + public void setResources(String name, List resources) { + this.resources = resources; + } + + @JsonAnyGetter + public List getResources() { + return resources; + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java new file mode 100755 index 000000000..e917182a0 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java @@ -0,0 +1,196 @@ +package org.motechproject.openlmis.rest.domain; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * A class to model the Open LMIS API's StockStatus resource. + */ + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class StockStatusDto { + + private Integer reportedMonth; //(integer, optional), + private String reportPeriodName; //(string, optional), + private String facilityName; //(string, optional), + private String productCode; //(string, optional), + private Integer reportYear; //(integer, optional), + private Integer reportQuarter; //(integer, optional), + private Integer amc; //(integer, optional), + private String programCode; //(string, optional), + private Integer reportedYear; //(integer, optional), + private String product; //(string, optional), + private String reportedDate; //(string, optional), + private Integer mos; //(integer, optional), + private String district; //(string, optional), + private Integer reportMonth; //(integer, optional), + private String programName; //(string, optional) + + public Integer getReportedMonth() { + return reportedMonth; + } + + public void setReportedMonth(Integer reportedMonth) { + this.reportedMonth = reportedMonth; + } + + public String getReportPeriodName() { + return reportPeriodName; + } + + public void setReportPeriodName(String reportPeriodName) { + this.reportPeriodName = reportPeriodName; + } + + public String getFacilityName() { + return facilityName; + } + + public void setFacilityName(String facilityName) { + this.facilityName = facilityName; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public Integer getReportYear() { + return reportYear; + } + + public void setReportYear(Integer reportYear) { + this.reportYear = reportYear; + } + + public Integer getReportQuarter() { + return reportQuarter; + } + + public void setReportQuarter(Integer reportQuarter) { + this.reportQuarter = reportQuarter; + } + + public Integer getAmc() { + return amc; + } + + public void setAmc(Integer amc) { + this.amc = amc; + } + + public String getProgramCode() { + return programCode; + } + + public void setProgramCode(String programCode) { + this.programCode = programCode; + } + + public Integer getReportedYear() { + return reportedYear; + } + + public void setReportedYear(Integer reportedYear) { + this.reportedYear = reportedYear; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public String getReportedDate() { + return reportedDate; + } + + public void setReportedDate(String reportedDate) { + this.reportedDate = reportedDate; + } + + public Integer getMos() { + return mos; + } + + public void setMos(Integer mos) { + this.mos = mos; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public Integer getReportMonth() { + return reportMonth; + } + + public void setReportMonth(Integer reportMonth) { + this.reportMonth = reportMonth; + } + + public String getProgramName() { + return programName; + } + + public void setProgramName(String programName) { + this.programName = programName; + } + + @Override + public int hashCode() { + return Objects.hash(reportedMonth, reportPeriodName, facilityName, + productCode, reportYear, reportQuarter, amc, programCode, + reportedYear, product, reportedDate, mos, district, + reportMonth, programName); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final StockStatusDto other = (StockStatusDto) obj; + return equalsReport(other) && equalsPeriod(other) + && equalsProgramProduct(other) + && Objects.equals(this.facilityName, other.facilityName) + && Objects.equals(this.amc, other.amc) + && Objects.equals(this.mos, other.mos) + && Objects.equals(this.district, other.district); + } + + private boolean equalsReport(StockStatusDto other) { + return Objects.equals(this.reportPeriodName, other.reportPeriodName) + && Objects.equals(this.reportYear, other.reportYear) + && Objects.equals(this.reportQuarter, other.reportQuarter) + && Objects.equals(this.reportMonth, other.reportMonth); + } + + private boolean equalsPeriod(StockStatusDto other) { + return Objects.equals(this.reportedYear, other.reportedYear) + && Objects.equals(this.reportedMonth, other.reportedMonth) + && Objects.equals(this.reportedDate, other.reportedDate); + } + + private boolean equalsProgramProduct(StockStatusDto other) { + return Objects.equals(this.programName, other.programName) + && Objects.equals(this.programCode, other.programCode) + && Objects.equals(this.productCode, other.productCode) + && Objects.equals(this.product, other.product); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java new file mode 100755 index 000000000..dc64f3da7 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java @@ -0,0 +1,24 @@ +package org.motechproject.openlmis.rest.service; + +/** + * Thrown if there is an error with an HTTP request or if there is an error marshalling + * to or from a data transfer object + */ +public class OpenlmisWebException extends RuntimeException { + /** + * + */ + private static final long serialVersionUID = -1284054460384833359L; + + /** + * + */ + + public OpenlmisWebException(String message) { + super(message); + } + + public OpenlmisWebException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java new file mode 100755 index 000000000..d6362c875 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java @@ -0,0 +1,35 @@ +package org.motechproject.openlmis.rest.service; + +import java.util.List; + +import org.motechproject.openlmis.rest.domain.DosageUnitDto; +import org.motechproject.openlmis.rest.domain.FacilityDto; +import org.motechproject.openlmis.rest.domain.FacilityTypeDto; +import org.motechproject.openlmis.rest.domain.GeographicLevelDto; +import org.motechproject.openlmis.rest.domain.GeographicZoneDto; +import org.motechproject.openlmis.rest.domain.ProductCategoryDto; +import org.motechproject.openlmis.rest.domain.ProductDto; +import org.motechproject.openlmis.rest.domain.ProgramDto; +import org.motechproject.openlmis.rest.domain.StockStatusDto; + +public interface OpenlmisWebService { + + List getPrograms(); + + List getProductCategories(); + + List getDosageUnits(); + + List getProducts(); + + List getGeographicLevels(); + + List getGeographicZones(); + + List getFacilityTypes(); + + List getFacilities(); + + List getStockStatus(int month, int year, String program); + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java new file mode 100755 index 000000000..8499a568b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java @@ -0,0 +1,253 @@ +package org.motechproject.openlmis.rest.service.impl; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.http.Header; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.StatusLine; +import org.apache.http.auth.AuthenticationException; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.osgi.services.HttpClientBuilderFactory; +import org.motechproject.admin.service.StatusMessageService; +import org.motechproject.openlmis.rest.domain.DosageUnitDto; +import org.motechproject.openlmis.rest.domain.FacilityDto; +import org.motechproject.openlmis.rest.domain.FacilityTypeDto; +import org.motechproject.openlmis.rest.domain.GeographicLevelDto; +import org.motechproject.openlmis.rest.domain.GeographicZoneDto; +import org.motechproject.openlmis.rest.domain.ProductCategoryDto; +import org.motechproject.openlmis.rest.domain.ProductDto; +import org.motechproject.openlmis.rest.domain.ProgramDto; +import org.motechproject.openlmis.rest.domain.ResourceListDto; +import org.motechproject.openlmis.rest.domain.StockStatusDto; +import org.motechproject.openlmis.rest.service.OpenlmisWebException; +import org.motechproject.openlmis.rest.service.OpenlmisWebService; +import org.motechproject.openlmis.service.Settings; +import org.motechproject.openlmis.service.SettingsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Implementation of {@link org.motechproject.openlmis.rest.service.OpenlmisWebService} + */ +@Service("openlmisWebService") +public class OpenlmisWebServiceImpl implements OpenlmisWebService { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenlmisWebServiceImpl.class); + + private static final String MODULE_NAME = "open-lmis"; + private static final String LOOKUP_API_ENDPOINT = "/rest-api/lookup/"; + private static final String STOCK_STATUS_ENDPOINT = "/rest-api/stock-status/"; + + private static final String PROGRAMS = "programs"; + + private static final String PRODUCT_CATEGORIES = "product-categories"; + private static final String DOSAGE_UNITS = "dosage-units"; + private static final String PRODUCTS = "products?paging=false"; + + private static final String GEOGRAPHIC_LEVELS = "geographic-levels"; + private static final String GEOGRAPHIC_ZONES = "geographic-zones"; + private static final String FACILITY_TYPES = "facility-types"; + private static final String FACILITIES = "facilities?paging=false"; + + private static final String STOCK_STATUS_MONTHLY = "monthly?month=%s&year=%s&program=%s"; + + private SettingsService settingsService; + private StatusMessageService statusMessageService; + private HttpClient client; + + public static final List ACCEPTABLE_OPEN_LMIS_RESPONSE_STATUSES = Arrays.asList(HttpStatus.SC_OK, + HttpStatus.SC_ACCEPTED, HttpStatus.SC_CREATED); + + @Override + public List getPrograms() { + return getResources(LOOKUP_API_ENDPOINT, PROGRAMS, ProgramDto.class); + } + + @Override + public List getProductCategories() { + return getResources(LOOKUP_API_ENDPOINT, PRODUCT_CATEGORIES, ProductCategoryDto.class); + } + + @Override + public List getDosageUnits() { + return getResources(LOOKUP_API_ENDPOINT, DOSAGE_UNITS, DosageUnitDto.class); + } + + @Override + public List getProducts() { + return getResources(LOOKUP_API_ENDPOINT, PRODUCTS, ProductDto.class); + } + + @Override + public List getGeographicLevels() { + return getResources(LOOKUP_API_ENDPOINT, GEOGRAPHIC_LEVELS, GeographicLevelDto.class); + } + + @Override + public List getGeographicZones() { + return getResources(LOOKUP_API_ENDPOINT, GEOGRAPHIC_ZONES, GeographicZoneDto.class); + } + + @Override + public List getFacilityTypes() { + return getResources(LOOKUP_API_ENDPOINT, FACILITY_TYPES, FacilityTypeDto.class); + } + + @Override + public List getFacilities() { + return getResources(LOOKUP_API_ENDPOINT, FACILITIES, FacilityDto.class); + } + + @Override + public List getStockStatus(int month, int year, String program) { + return getResources(STOCK_STATUS_ENDPOINT, STOCK_STATUS_MONTHLY, StockStatusDto.class, month, year, program); + } + + @Autowired + public OpenlmisWebServiceImpl(@Qualifier("openlmisSettingsService") SettingsService settingsService, + StatusMessageService statusMessageService, + HttpClientBuilderFactory httpClientBuilderFactory) { + this.settingsService = settingsService; + this.statusMessageService = statusMessageService; + BasicCookieStore cookieStore = new BasicCookieStore(); + this.client = httpClientBuilderFactory.newBuilder().setDefaultCookieStore(cookieStore).build(); + } + + /*Gets a list of dtos*/ + private List getResources(String controllerName, String resourceName, Class clazz, Object... queryparams) { + Settings settings = settingsService.getSettings(); + HttpUriRequest request = generateHttpRequest(settings, getURIForResource(settings.getServerURI(), + controllerName, resourceName, queryparams)); + + LOGGER.debug(String.format("Initiating request for resource: %s, request: %s", resourceName, request.getRequestLine())); + + HttpResponse response = getResponseForRequest(request); + + LOGGER.debug(String.format("Received response for request: %s, response: %s", request.getURI(), response.getStatusLine())); + + List resources = new ArrayList(); + + try (InputStream content = getContentForResponse(response)) { + ObjectMapper mapper = new ObjectMapper(); + JavaType type = mapper.getTypeFactory().constructParametricType(ResourceListDto.class, clazz); + ResourceListDto resourceList = mapper.reader(type).readValue(content); + resources.addAll(resourceList.getResources()); + + } catch (Exception e) { + String msg = String.format("Error parsing %s resources, exception: %s", resourceName, e.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg, e); + } + + return resources; + } + + /*Converts the object to json*/ + @SuppressWarnings("unused") + private String writeToJson(Object object) { + try { + return new ObjectMapper().writeValueAsString(object); + } catch (Exception e) { + String msg = String.format("Error parsing object: %s to json, exception: %s", object.toString(), e.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg, e); + } + } + + /*Generates an HTTP get request*/ + private HttpUriRequest generateHttpRequest(Settings settings, String url) { + HttpGet request = new HttpGet(url); + request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); + request.addHeader(generateBasicAuthHeader(request, settings)); + return request; + } + + /*Generates an HTTP post request*/ + @SuppressWarnings("unused") + private HttpUriRequest generatePostRequest(Settings settings, String url, String body) { + HttpPost request = new HttpPost(url); + request.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); + request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); + request.addHeader(generateBasicAuthHeader(request, settings)); + StringEntity entity = new StringEntity(body, "UTF-8"); + + request.setEntity(entity); + + return request; + } + + /*Attempts an HTTP request. Returns the response*/ + private HttpResponse getResponseForRequest(HttpUriRequest request) { + HttpResponse response; + + try { + response = client.execute(request); + } catch (Exception e) { + String msg = String.format("Error receiving response for request: %s", request.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg, e); + } + + StatusLine statusLine = response.getStatusLine(); + + if (!ACCEPTABLE_OPEN_LMIS_RESPONSE_STATUSES.contains(statusLine.getStatusCode())) { + String msg = String.format("Error making OpenLMIS request: %s", statusLine.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg); + } + + return response; + } + + /*Gets an input stream from the HTTP response*/ + private InputStream getContentForResponse(HttpResponse response) { + try { + return response.getEntity().getContent(); + } catch (Exception e) { + String msg = String.format("Error accessing content for response: %s", response.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg, e); + } + } + + /*Builds the URL for a particular resource*/ + private String getURIForResource(String baseURI, String controllerName, String resourceName, Object... queryparams) { + return String.format(baseURI + controllerName + resourceName, queryparams); + } + + private Header generateBasicAuthHeader(HttpUriRequest request, Settings settings) { + Header basicAuthHeader; + BasicScheme basicScheme = new BasicScheme(); + try { + basicAuthHeader = basicScheme.authenticate( + new UsernamePasswordCredentials(settings.getUsername(), settings.getPassword()), + request, + HttpClientContext.create()); + } catch (AuthenticationException e) { + String msg = String.format("Error generating basic auth header for request: %s", request.toString()); + statusMessageService.warn(msg, MODULE_NAME); + throw new OpenlmisWebException(msg, e); + } + return basicAuthHeader; + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java new file mode 100755 index 000000000..a52405a76 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java @@ -0,0 +1,13 @@ +package org.motechproject.openlmis.service; + +import org.motechproject.openlmis.domain.DosageUnit; +import org.motechproject.openlmis.rest.domain.DosageUnitDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.DosageUnit} + */ +public interface DosageUnitService extends GenericCrudService { + DosageUnit findByCode(String code); + DosageUnit findByOpenlmisId(Integer id); + DosageUnit createFromDetails(DosageUnitDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java new file mode 100755 index 000000000..c1b221d29 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.Facility; +import org.motechproject.openlmis.rest.domain.FacilityDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.Facility} + */ +public interface FacilityService extends GenericCrudService { + Facility findByCode(String code); + Facility findByOpenlmisId(Integer id); + List findByName(String name); + Facility createFromDetails(FacilityDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java new file mode 100755 index 000000000..c231f74cd --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.FacilityType; +import org.motechproject.openlmis.rest.domain.FacilityTypeDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.ProgramDto.domain.FacilityType} + */ +public interface FacilityTypeService extends GenericCrudService { + FacilityType findByCode(String code); + FacilityType findByOpenlmisId(Integer id); + List findByName(String name); + FacilityType createFromDetails(FacilityTypeDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java new file mode 100755 index 000000000..25e48319f --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java @@ -0,0 +1,10 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +public interface GenericCrudService { + List findAll(); + void update(T dataElement); + void delete(T dataElement); + void deleteAll(); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java new file mode 100755 index 000000000..4024d533b --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.GeographicLevel; +import org.motechproject.openlmis.rest.domain.GeographicLevelDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.GeographicLevel} + */ +public interface GeographicLevelService extends GenericCrudService { + GeographicLevel findByCode(String code); + GeographicLevel findByOpenlmisId(Integer id); + List findByName(String name); + GeographicLevel createFromDetails(GeographicLevelDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java new file mode 100755 index 000000000..110d55994 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.GeographicZone; +import org.motechproject.openlmis.rest.domain.GeographicZoneDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.GeographicZone} + */ +public interface GeographicZoneService extends GenericCrudService { + GeographicZone findByCode(String code); + GeographicZone findByOpenlmisId(Integer id); + List findByName(String name); + GeographicZone createFromDetails(GeographicZoneDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java new file mode 100755 index 000000000..9b96a2e60 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.ProductCategory; +import org.motechproject.openlmis.rest.domain.ProductCategoryDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.ProductCategory} + */ +public interface ProductCategoryService extends GenericCrudService { + ProductCategory findByCode(String code); + ProductCategory findByOpenlmisId(Integer id); + List findByName(String name); + ProductCategory createFromDetails(ProductCategoryDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java new file mode 100755 index 000000000..fb0befc26 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java @@ -0,0 +1,13 @@ +package org.motechproject.openlmis.service; + +import org.motechproject.openlmis.domain.Product; +import org.motechproject.openlmis.rest.domain.ProductDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.Product} + */ +public interface ProductService extends GenericCrudService { + Product findByCode(String code); + Product findByOpenlmisId(Integer id); + Product createFromDetails(ProductDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java new file mode 100755 index 000000000..ccb2497e2 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java @@ -0,0 +1,16 @@ +package org.motechproject.openlmis.service; + +import java.util.List; + +import org.motechproject.openlmis.domain.Program; +import org.motechproject.openlmis.rest.domain.ProgramDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.ProgramDto.domain.Program} + */ +public interface ProgramService extends GenericCrudService { + Program findByCode(String code); + Program findByOpenlmisId(Integer id); + List findByName(String name); + Program createFromDetails(ProgramDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java new file mode 100755 index 000000000..da3813929 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java @@ -0,0 +1,45 @@ +package org.motechproject.openlmis.service; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +/** + * OpenLMIS server configuration details. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Settings { + private String serverURI; + private String username; + private String password; + + public Settings() { } + + public Settings(String serverURI, String username, String password) { + this.serverURI = serverURI; + this.username = username; + this.password = password; + } + + public String getServerURI() { + return serverURI; + } + + public void setServerURI(String serverURI) { + this.serverURI = serverURI; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java new file mode 100755 index 000000000..b5511f5f6 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java @@ -0,0 +1,11 @@ +package org.motechproject.openlmis.service; + + +/** + * Retrieves and updates settings for the module + * @see Settings + */ +public interface SettingsService { + Settings getSettings(); + void updateSettings(Settings settings); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java new file mode 100755 index 000000000..85e7a318c --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java @@ -0,0 +1,11 @@ +package org.motechproject.openlmis.service; + +import org.motechproject.openlmis.domain.StockStatus; +import org.motechproject.openlmis.rest.domain.StockStatusDto; + +/** + * Manages CRUD operations for a {@link org.motechproject.openlmis.domain.StockStatus} + */ +public interface StockStatusService extends GenericCrudService { + StockStatus createFromDetails(StockStatusDto details); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java new file mode 100755 index 000000000..8d341bbde --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java @@ -0,0 +1,15 @@ +package org.motechproject.openlmis.service; + +/** + * Used to synchronize this module with the Open LMIS server schema + */ +public interface SyncService { + + /** + * Queries the Open LMIS server to get the current schema and then persists that + * information in MDS. If the process fails, all of the records pertaining to the Open LMIS schema + * are deleted. + * @return true if successful; false otherwise + */ + boolean sync(); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java new file mode 100755 index 000000000..c691a6eda --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java @@ -0,0 +1,15 @@ +package org.motechproject.openlmis.service; + +/** + * Processes Task channel updates for this module + * @see org.motechproject.tasks.service.ChannelService + * @see org.motechproject.openlmis.tasks.ChannelRequestBuilder + * */ +public interface TasksService { + + /** + * Builds a channel request from the information saved in MDS and then updates the channel for this + * module. + */ + void updateChannel(); +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java new file mode 100755 index 000000000..1acba4b1c --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java @@ -0,0 +1,62 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.DosageUnit; +import org.motechproject.openlmis.repository.DosageUnitDataService; +import org.motechproject.openlmis.rest.domain.DosageUnitDto; +import org.motechproject.openlmis.service.DosageUnitService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.DosageUnitService} + */ +@Service("dosageUnitService") +public class DosageUnitServiceImpl implements DosageUnitService { + @Autowired + private DosageUnitDataService dosageUnitDataService; + + @Override + public DosageUnit findByOpenlmisId(Integer id) { + return dosageUnitDataService.findByOpenlmisId(id); + } + + @Override + public void update(DosageUnit dosageUnit) { + dosageUnitDataService.update(dosageUnit); + } + + @Override + public void delete(DosageUnit dosageUnit) { + dosageUnitDataService.delete(dosageUnit); + } + + @Override + public DosageUnit createFromDetails(DosageUnitDto details) { + DosageUnit dosageUnit = new DosageUnit(); + dosageUnit.setCode(details.getCode()); + dosageUnit.setDisplayOrder(details.getDisplayOrder()); + dosageUnit.setOpenlmisid(details.getId()); + return dosageUnitDataService.create(dosageUnit); + } + + @Override + public void deleteAll() { + dosageUnitDataService.deleteAll(); + } + + @Override + public List findAll() { + return dosageUnitDataService.retrieveAll(); + } + + @Override + public DosageUnit findByCode(String code) { + return dosageUnitDataService.findByCode(code); + } + + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java new file mode 100644 index 000000000..b0f514947 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java @@ -0,0 +1,100 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.Facility; +import org.motechproject.openlmis.repository.FacilityDataService; +import org.motechproject.openlmis.repository.FacilityTypeDataService; +import org.motechproject.openlmis.repository.GeographicZoneDataService; +import org.motechproject.openlmis.rest.domain.FacilityDto; +import org.motechproject.openlmis.service.FacilityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.FacilityService} + */ +@Service("facilityService") +public class FacilityServiceImpl implements FacilityService { + @Autowired + private FacilityDataService facilityDataService; + + @Autowired + private FacilityTypeDataService facilityTypeDataService; + + @Autowired + private GeographicZoneDataService geographicZoneDataService; + + @Override + public Facility findByOpenlmisId(Integer id) { + return facilityDataService.findByOpenlmisId(id); + } + + @Override + public List findByName(String name) { + return facilityDataService.findByName(name); + } + + @Override + public void update(Facility program) { + facilityDataService.update(program); + } + + @Override + public void delete(Facility program) { + facilityDataService.delete(program); + } + + @Override + public Facility createFromDetails(FacilityDto details) { + Facility facility = new Facility(); + facility.setActive(details.getActive()); + facility.setAddress1(details.getAddress1()); + facility.setAddress2(details.getAddress2()); + facility.setAltitude(details.getAltitude()); + facility.setCatchmentPopulation(details.getCatchmentPopulation()); + facility.setCode(details.getCode()); + facility.setColdStorageGrossCapacity(details.getColdStorageGrossCapacity()); + facility.setComment(details.getComment()); + facility.setDataReportable(details.getDataReportable()); + facility.setDescription(details.getDescription()); + facility.setFax(details.getFax()); + facility.setGeographicZone(geographicZoneDataService.findByOpenlmisId(details.getGeographicZoneId())); + facility.setGln(details.getGln()); + facility.setGoDownDate(details.getGoDownDate()); + facility.setGoLiveDate(details.getGoLiveDate()); + facility.setHasElectricity(details.getHasElectricity()); + facility.setHasElectronicDar(details.getHasElectronicDar()); + facility.setHasElectronicScc(details.getHasElectronicScc()); + facility.setLatitude(details.getLatitude()); + facility.setLongitude(details.getLongitude()); + facility.setMainPhone(details.getMainPhone()); + facility.setName(details.getName()); + facility.setOnline(details.getOnline()); + facility.setOpenlmisid(details.getId()); + facility.setOperatedById(details.getOperatedById()); + facility.setSatellite(details.getSatellite()); + facility.setSatelliteParentId(details.getSatelliteParentId()); + facility.setSdp(details.getSdp()); + facility.setSuppliesOthers(details.getSuppliesOthers()); + facility.setType(facilityTypeDataService.findByOpenlmisId(details.getTypeId())); + return facilityDataService.create(facility); + } + + @Override + public void deleteAll() { + facilityDataService.deleteAll(); + } + + @Override + public List findAll() { + return facilityDataService.retrieveAll(); + } + + @Override + public Facility findByCode(String code) { + return facilityDataService.findByCode(code); + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java new file mode 100644 index 000000000..0b80f5cba --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java @@ -0,0 +1,78 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.FacilityType; +import org.motechproject.openlmis.repository.FacilityTypeDataService; +import org.motechproject.openlmis.repository.GeographicLevelDataService; +import org.motechproject.openlmis.rest.domain.FacilityTypeDto; +import org.motechproject.openlmis.service.FacilityTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.FacilityTypeService} + */ +@Service("facilityTypeService") +public class FacilityTypeServiceImpl implements FacilityTypeService { + + @Autowired + private FacilityTypeDataService facilityTypeDataService; + + @Autowired + private GeographicLevelDataService geographicLevelDataService; + + @Override + public FacilityType findByOpenlmisId(Integer id) { + return facilityTypeDataService.findByOpenlmisId(id); + } + + @Override + public List findByName(String name) { + return facilityTypeDataService.findByName(name); + } + + @Override + public void update(FacilityType facilityType) { + facilityTypeDataService.update(facilityType); + } + + @Override + public void delete(FacilityType facilityType) { + facilityTypeDataService.delete(facilityType); + } + + @Override + public FacilityType createFromDetails(FacilityTypeDto details) { + FacilityType facilityType = new FacilityType(); + facilityType.setActive(details.getActive()); + facilityType.setCode(details.getCode()); + facilityType.setDescription(details.getDescription()); + facilityType.setDisplayOrder(details.getDisplayOrder()); + if (details.getLevelId() != null) { + facilityType.setLevel(geographicLevelDataService.findById((long) details.getLevelId())); + } + facilityType.setName(details.getName()); + facilityType.setNominalEop(details.getNominalEop()); + facilityType.setNominalMaxMonth(details.getNominalMaxMonth()); + facilityType.setOpenlmisid(details.getId()); + return facilityTypeDataService.create(facilityType); + } + + @Override + public void deleteAll() { + facilityTypeDataService.deleteAll(); + } + + @Override + public List findAll() { + return facilityTypeDataService.retrieveAll(); + } + + @Override + public FacilityType findByCode(String code) { + return facilityTypeDataService.findByCode(code); + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java new file mode 100644 index 000000000..b3902903c --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java @@ -0,0 +1,66 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.GeographicLevel; +import org.motechproject.openlmis.repository.GeographicLevelDataService; +import org.motechproject.openlmis.rest.domain.GeographicLevelDto; +import org.motechproject.openlmis.service.GeographicLevelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.GeographicLevelService} + */ +@Service("geographicLevelService") +public class GeographicLevelServiceImpl implements GeographicLevelService { + @Autowired + private GeographicLevelDataService geographicLevelDataService; + + @Override + public GeographicLevel findByOpenlmisId(Integer id) { + return geographicLevelDataService.findByOpenlmisId(id); + } + + @Override + public List findByName(String name) { + return geographicLevelDataService.findByName(name); + } + + @Override + public void update(GeographicLevel program) { + geographicLevelDataService.update(program); + } + + @Override + public void delete(GeographicLevel program) { + geographicLevelDataService.delete(program); + } + + @Override + public GeographicLevel createFromDetails(GeographicLevelDto details) { + GeographicLevel geographicLevel = new GeographicLevel(); + geographicLevel.setCode(details.getCode()); + geographicLevel.setLevelNumber(details.getLevelNumber()); + geographicLevel.setName(details.getName()); + geographicLevel.setOpenlmisid(details.getId()); + return geographicLevelDataService.create(geographicLevel); + } + + @Override + public void deleteAll() { + geographicLevelDataService.deleteAll(); + } + + @Override + public List findAll() { + return geographicLevelDataService.retrieveAll(); + } + + @Override + public GeographicLevel findByCode(String code) { + return geographicLevelDataService.findByCode(code); + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java new file mode 100644 index 000000000..1461547ea --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java @@ -0,0 +1,78 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.GeographicZone; +import org.motechproject.openlmis.repository.GeographicLevelDataService; +import org.motechproject.openlmis.repository.GeographicZoneDataService; +import org.motechproject.openlmis.rest.domain.GeographicZoneDto; +import org.motechproject.openlmis.service.GeographicZoneService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.GeographicZoneService} + */ +@Service("geographicZoneService") +public class GeographicZoneServiceImpl implements GeographicZoneService { + + @Autowired + private GeographicZoneDataService geographicZoneDataService; + + @Autowired + private GeographicLevelDataService geographicLevelDataService; + + @Override + public GeographicZone findByOpenlmisId(Integer id) { + return geographicZoneDataService.findByOpenlmisId(id); + } + + @Override + public List findByName(String name) { + return geographicZoneDataService.findByName(name); + } + + @Override + public void update(GeographicZone program) { + geographicZoneDataService.update(program); + } + + @Override + public void delete(GeographicZone program) { + geographicZoneDataService.delete(program); + } + + @Override + public GeographicZone createFromDetails(GeographicZoneDto details) { + GeographicZone geographicZone = new GeographicZone(); + geographicZone.setCatchmentPopulation(details.getCatchmentPopulation()); + geographicZone.setCode(details.getCode()); + geographicZone.setLatitude(details.getLatitude()); + geographicZone.setLevel(geographicLevelDataService.findById((long) details.getLevelId())); + geographicZone.setLongitude(details.getLongitude()); + geographicZone.setName(details.getName()); + geographicZone.setOpenlmisid(details.getId()); + if (details.getParentId() != null) { + Long parentId = (long) details.getParentId(); + geographicZone.setParent(geographicZoneDataService.findById(parentId)); + } + return geographicZoneDataService.create(geographicZone); + } + + @Override + public void deleteAll() { + geographicZoneDataService.deleteAll(); + } + + @Override + public List findAll() { + return geographicZoneDataService.retrieveAll(); + } + + @Override + public GeographicZone findByCode(String code) { + return geographicZoneDataService.findByCode(code); + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java new file mode 100755 index 000000000..8b6067c99 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java @@ -0,0 +1,68 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.ProductCategory; +import org.motechproject.openlmis.repository.ProductCategoryDataService; +import org.motechproject.openlmis.rest.domain.ProductCategoryDto; +import org.motechproject.openlmis.service.ProductCategoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.ProductCategoryService} + */ +@Service("productCategoryService") +public class ProductCategoryServiceImpl implements ProductCategoryService { + @Autowired + private ProductCategoryDataService productCategoryDataService; + + @Override + public ProductCategory findByOpenlmisId(Integer id) { + return productCategoryDataService.findByOpenlmisId(id); + } + + @Override + public void update(ProductCategory productCategory) { + productCategoryDataService.update(productCategory); + } + + @Override + public void delete(ProductCategory productCategory) { + productCategoryDataService.delete(productCategory); + } + + @Override + public ProductCategory createFromDetails(ProductCategoryDto details) { + ProductCategory productCategory = new ProductCategory(); + productCategory.setCode(details.getCode()); + productCategory.setOpenlmisid(details.getId()); + productCategory.setDisplayOrder(details.getDisplayOrder()); + productCategory.setName(details.getName()); + return productCategoryDataService.create(productCategory); + } + + @Override + public void deleteAll() { + productCategoryDataService.deleteAll(); + } + + @Override + public List findAll() { + return productCategoryDataService.retrieveAll(); + } + + @Override + public ProductCategory findByCode(String code) { + return productCategoryDataService.findByCode(code); + } + + @Override + public List findByName(String name) { + return productCategoryDataService.findByName(name); + } + + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java new file mode 100755 index 000000000..ce6790e63 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java @@ -0,0 +1,115 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.DosageUnit; +import org.motechproject.openlmis.domain.Product; +import org.motechproject.openlmis.repository.ProductDataService; +import org.motechproject.openlmis.rest.domain.ProductDto; +import org.motechproject.openlmis.service.DosageUnitService; +import org.motechproject.openlmis.service.ProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.ProductService} + */ +@Service("productService") +public class ProductServiceImpl implements ProductService { + + @Autowired + private ProductDataService productDataService; + + @Autowired + private DosageUnitService dosageUnitService; + + @Override + public Product findByOpenlmisId(Integer id) { + return productDataService.findByOpenlmisId(id); + } + + @Override + public void update(Product product) { + productDataService.update(product); + } + + @Override + public void delete(Product product) { + productDataService.delete(product); + } + + @Override + public Product createFromDetails(ProductDto details) { + Product product = new Product(); + DosageUnit dosageUnit = dosageUnitService.findByOpenlmisId(details.getDosageUnitId()); + product.setActive(details.getActive()); + product.setAlternateItemCode(details.getAlternateItemCode()); + product.setAlternateName(details.getAlternateName()); + product.setAlternatePackSize(details.getAlternatePackSize()); + product.setApprovedByWHO(details.getApprovedByWHO()); + product.setArchived(details.getArchived()); + product.setCartonHeight(details.getCartonHeight()); + product.setCartonLength(details.getCartonLength()); + product.setCartonsPerPallet(details.getCartonsPerPallet()); + product.setCartonWidth(details.getCartonWidth()); + product.setCode(details.getCode()); + product.setContraceptiveCYP(details.getContraceptiveCYP()); + product.setControlledSubstance(details.getControlledSubstance()); + product.setDescription(details.getDescription()); + product.setDispensingUnit(details.getDispensingUnit()); + product.setDosageUnit(dosageUnit); + product.setDosesPerDispensingUnit(details.getDosesPerDispensingUnit()); + product.setExpectedShelfLife(details.getExpectedShelfLife()); + product.setFlammable(details.getFlammable()); + product.setFullName(details.getFullName()); + product.setFullSupply(details.getFullSupply()); + product.setGenericName(details.getGenericName()); + product.setGtin(details.getGtin()); + product.setHazardous(details.getHazardous()); + product = addMoreFromDetails(product, details); + return productDataService.create(product); + } + + private Product addMoreFromDetails(Product product, ProductDto details) { + product.setIsKit(details.getIsKit()); + product.setLightSensitive(details.getLightSensitive()); + product.setManufacturer(details.getManufacturer()); + product.setManufacturerBarCode(details.getManufacturerBarCode()); + product.setManufacturerCode(details.getManufacturerCode()); + product.setMohBarCode(details.getMohBarCode()); + product.setOpenlmisid(details.getId()); + product.setPackHeight(details.getPackHeight()); + product.setPackLength(details.getPackLength()); + product.setPackRoundingThreshold(details.getPackRoundingThreshold()); + product.setPackSize(details.getPackSize()); + product.setPacksPerCarton(details.getPacksPerCarton()); + product.setPackWeight(details.getPackWeight()); + product.setPackWidth(details.getPackWidth()); + product.setPrimaryName(details.getPrimaryName()); + product.setRoundToZero(details.getRoundToZero()); + product.setSpecialStorageInstructions(details.getSpecialStorageInstructions()); + product.setSpecialTransportInstructions(details.getSpecialTransportInstructions()); + product.setStoreRefrigerated(details.getStoreRefrigerated()); + product.setStrength(details.getStrength()); + product.setTracer(details.getTracer()); + product.setType(details.getType()); + return product; + } + + @Override + public void deleteAll() { + productDataService.deleteAll(); + } + + @Override + public List findAll() { + return productDataService.retrieveAll(); + } + + @Override + public Product findByCode(String code) { + return productDataService.findByCode(code); + } + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java new file mode 100755 index 000000000..bbc7e2c36 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java @@ -0,0 +1,68 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.motechproject.openlmis.domain.Program; +import org.motechproject.openlmis.repository.ProgramDataService; +import org.motechproject.openlmis.rest.domain.ProgramDto; +import org.motechproject.openlmis.service.ProgramService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.ProgramService} + */ +@Service("programService") +public class ProgramServiceImpl implements ProgramService { + @Autowired + private ProgramDataService programDataService; + + @Override + public Program findByOpenlmisId(Integer id) { + return programDataService.findByOpenlmisId(id); + } + + @Override + public List findByName(String name) { + return programDataService.findByName(name); + } + + @Override + public void update(Program program) { + programDataService.update(program); + } + + @Override + public void delete(Program program) { + programDataService.delete(program); + } + + @Override + public Program createFromDetails(ProgramDto details) { + Program program = new Program(); + program.setOpenlmisid(details.getId()); + program.setName(details.getName()); + program.setDescription(details.getDescription()); + program.setCode(details.getCode()); + return programDataService.create(program); + } + + @Override + public void deleteAll() { + programDataService.deleteAll(); + } + + @Override + public List findAll() { + return programDataService.retrieveAll(); + } + + @Override + public Program findByCode(String code) { + return programDataService.findByCode(code); + } + + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java new file mode 100755 index 000000000..e204a74e5 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java @@ -0,0 +1,63 @@ +package org.motechproject.openlmis.service.impl; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.motechproject.config.SettingsFacade; +import org.motechproject.openlmis.service.Settings; +import org.motechproject.openlmis.service.SettingsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.stereotype.Service; + +import com.google.gson.Gson; +import com.google.gson.JsonIOException; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.SettingsService} + */ +@Service("openlmisSettingsService") +public class SettingsServiceImpl implements SettingsService { + private static final String SETTINGS_FILE_NAME = "openlmis-settings.json"; + private static final Logger LOGGER = LoggerFactory.getLogger(SettingsServiceImpl.class); + + private SettingsFacade settingsFacade; + private Settings settings; + + private synchronized void loadSettings() { + try (InputStream is = settingsFacade.getRawConfig(SETTINGS_FILE_NAME)) { + String jsonText = IOUtils.toString(is); + LOGGER.debug("Loading OpenLMIS settings..."); + Gson gson = new Gson(); + settings = gson.fromJson(jsonText, Settings.class); + } catch (Exception e) { + String message = "There was an error loading json from the OpenLMIS settings."; + LOGGER.debug(message); + throw new JsonIOException(message, e); + } + } + + @Autowired + public SettingsServiceImpl(@Qualifier("openlmisSettings") SettingsFacade settingsFacade) { + this.settingsFacade = settingsFacade; + loadSettings(); + } + + @Override + public Settings getSettings() { + return settings; + } + + @Override + public void updateSettings(Settings settings) { + Gson gson = new Gson(); + String jsonText = gson.toJson(settings); + ByteArrayResource resource = new ByteArrayResource(jsonText.getBytes()); + settingsFacade.saveRawConfig(SETTINGS_FILE_NAME, resource); + loadSettings(); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java new file mode 100755 index 000000000..6e5e9d448 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java @@ -0,0 +1,84 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; + +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; +import org.motechproject.openlmis.domain.Facility; +import org.motechproject.openlmis.domain.Product; +import org.motechproject.openlmis.domain.Program; +import org.motechproject.openlmis.domain.StockStatus; +import org.motechproject.openlmis.repository.StockStatusDataService; +import org.motechproject.openlmis.rest.domain.StockStatusDto; +import org.motechproject.openlmis.service.FacilityService; +import org.motechproject.openlmis.service.ProductService; +import org.motechproject.openlmis.service.ProgramService; +import org.motechproject.openlmis.service.StockStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.StockStatusService} + */ +@Service("stockStatusService") +public class StockStatusServiceImpl implements StockStatusService { + + @Autowired + private StockStatusDataService stockStatusDataService; + + @Autowired + private ProductService productService; + + @Autowired + private ProgramService programService; + + @Autowired + private FacilityService facilityService; + + private static final DateTimeFormatter DATE_TIME_FORMAT = ISODateTimeFormat.basicDate(); + + @Override + public void update(StockStatus stockStatus) { + stockStatusDataService.update(stockStatus); + } + + @Override + public void delete(StockStatus stockStatus) { + stockStatusDataService.delete(stockStatus); + } + + @Override + public StockStatus createFromDetails(StockStatusDto details) { + StockStatus stockStatus = new StockStatus(); + Product product = productService.findByCode(details.getProductCode()); + Program program = programService.findByCode(details.getProgramCode()); + List facilities = facilityService.findByName(details.getFacilityName()); + stockStatus.setAmc(details.getAmc()); + stockStatus.setDistrict(details.getDistrict()); + if (facilities.size() > 0) { + stockStatus.setFacility(facilities.get(0)); + } + stockStatus.setMos(details.getMos()); + stockStatus.setProduct(product); + stockStatus.setProgram(program); + stockStatus.setReportedDate(DATE_TIME_FORMAT.parseDateTime(details.getReportedDate())); + stockStatus.setReportedMonth(details.getReportedMonth()); + stockStatus.setReportedYear(details.getReportedYear()); + stockStatus.setReportMonth(details.getReportMonth()); + stockStatus.setReportPeriodName(details.getReportPeriodName()); + stockStatus.setReportQuarter(details.getReportQuarter()); + stockStatus.setReportYear(details.getReportYear()); + return stockStatusDataService.create(stockStatus); + } + + @Override + public void deleteAll() { + stockStatusDataService.deleteAll(); + } + + @Override + public List findAll() { + return stockStatusDataService.retrieveAll(); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java new file mode 100755 index 000000000..c33f0b497 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java @@ -0,0 +1,194 @@ +package org.motechproject.openlmis.service.impl; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeConstants; +import org.motechproject.openlmis.domain.Program; +import org.motechproject.openlmis.rest.domain.DosageUnitDto; +import org.motechproject.openlmis.rest.domain.FacilityDto; +import org.motechproject.openlmis.rest.domain.FacilityTypeDto; +import org.motechproject.openlmis.rest.domain.GeographicLevelDto; +import org.motechproject.openlmis.rest.domain.GeographicZoneDto; +import org.motechproject.openlmis.rest.domain.ProductCategoryDto; +import org.motechproject.openlmis.rest.domain.ProductDto; +import org.motechproject.openlmis.rest.domain.ProgramDto; +import org.motechproject.openlmis.rest.domain.StockStatusDto; +import org.motechproject.openlmis.rest.service.OpenlmisWebService; +import org.motechproject.openlmis.service.DosageUnitService; +import org.motechproject.openlmis.service.FacilityService; +import org.motechproject.openlmis.service.FacilityTypeService; +import org.motechproject.openlmis.service.GeographicLevelService; +import org.motechproject.openlmis.service.GeographicZoneService; +import org.motechproject.openlmis.service.ProductCategoryService; +import org.motechproject.openlmis.service.ProductService; +import org.motechproject.openlmis.service.ProgramService; +import org.motechproject.openlmis.service.StockStatusService; +import org.motechproject.openlmis.service.SyncService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Implementation of {@link org.motechproject.openlmis.service.SyncService} + */ +@Service("syncService") +@PropertySource("classpath:openlmis.properties") +public class SyncServiceImpl implements SyncService { + @Autowired + private OpenlmisWebService openlmisWebService; + + @Autowired + private ProgramService programService; + + @Autowired + private ProductCategoryService productCategoryService; + + @Autowired + private DosageUnitService dosageUnitService; + + @Autowired + private ProductService productService; + + @Autowired + private GeographicLevelService geographicLevelService; + + @Autowired + private GeographicZoneService geographicZoneService; + + @Autowired + private FacilityTypeService facilityTypeService; + + @Autowired + private FacilityService facilityService; + + @Autowired + private StockStatusService stockStatusService; + + private static final Logger LOGGER = LoggerFactory.getLogger(SyncServiceImpl.class); + + @Value("${openlmis.stockstatus.fromyear}") + private int fromYear; + + @Override + @Transactional + public boolean sync() { + LOGGER.debug("Starting Sync"); + try { + long startTime = System.nanoTime(); + dropExistingData(); + // add new data + addPrograms(); + + addProductCategories(); + addDosageUnits(); + addProducts(); + + addGeographicLevels(); + addGeographicZones(); + addFacilityTypes(); + addFacilites(); + + addStockStatus(); + + long endTime = System.nanoTime(); + + LOGGER.debug("Sync successful."); + LOGGER.debug("Time for sync: " + TimeUnit.SECONDS.convert(endTime - startTime, + TimeUnit.NANOSECONDS) + "seconds"); + return true; + } catch (RuntimeException e) { + LOGGER.error("Problem with OpenLMIS application Schema. Sync unsuccessful.", e); + return false; + } + } + + private void addPrograms() { + List programDtos = openlmisWebService.getPrograms(); + for (ProgramDto dto : programDtos) { + programService.createFromDetails(dto); + } + } + + private void addProductCategories() { + List productCategories = openlmisWebService.getProductCategories(); + for (ProductCategoryDto dto : productCategories) { + productCategoryService.createFromDetails(dto); + } + } + + private void addDosageUnits() { + List dosageUnitDtos = openlmisWebService.getDosageUnits(); + for (DosageUnitDto dto : dosageUnitDtos) { + dosageUnitService.createFromDetails(dto); + } + } + + private void addProducts() { + List productDtos = openlmisWebService.getProducts(); + for (ProductDto dto : productDtos) { + productService.createFromDetails(dto); + } + } + + private void addGeographicLevels() { + List geographicLevelDtos = openlmisWebService.getGeographicLevels(); + for (GeographicLevelDto dto : geographicLevelDtos) { + geographicLevelService.createFromDetails(dto); + } + } + + private void addGeographicZones() { + List geographicZoneDtos = openlmisWebService.getGeographicZones(); + for (GeographicZoneDto dto : geographicZoneDtos) { + geographicZoneService.createFromDetails(dto); + } + } + + private void addFacilityTypes() { + List facilityTypeDtos = openlmisWebService.getFacilityTypes(); + for (FacilityTypeDto dto : facilityTypeDtos) { + facilityTypeService.createFromDetails(dto); + } + } + + private void addFacilites() { + List facilityDtos = openlmisWebService.getFacilities(); + for (FacilityDto dto : facilityDtos) { + facilityService.createFromDetails(dto); + } + } + + private void addStockStatus() { + DateTime now = new DateTime(); + List programs = programService.findAll(); + for (Program program : programs) { + for (int year = fromYear; year <= now.getYear(); year++) { + int lastMonth = (year == now.getYear() ? now.getMonthOfYear() : DateTimeConstants.DECEMBER); + for (int month = DateTimeConstants.JANUARY; month <= lastMonth; month++) { + List stockStatusDtos = openlmisWebService.getStockStatus(month, year, program.getCode()); + for (StockStatusDto dto : stockStatusDtos) { + stockStatusService.createFromDetails(dto); + } + } + } + } + } + + private void dropExistingData() { + geographicLevelService.deleteAll(); + geographicZoneService.deleteAll(); + facilityTypeService.deleteAll(); + facilityService.deleteAll(); + dosageUnitService.deleteAll(); + productCategoryService.deleteAll(); + productService.deleteAll(); + programService.deleteAll(); + stockStatusService.deleteAll(); + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java new file mode 100755 index 000000000..50fdae5ed --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java @@ -0,0 +1,21 @@ +package org.motechproject.openlmis.service.impl; + +import org.motechproject.openlmis.service.TasksService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + + +/** + * Implementation of {@link org.motechproject.openlmis.service.TasksService} + */ +@Service +public class TasksServiceImpl implements TasksService { + private static final Logger LOGGER = LoggerFactory.getLogger(TasksServiceImpl.class); + + @Override + public void updateChannel() { + LOGGER.debug("Updating OpenLMIS task channel..."); + + } +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java b/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java new file mode 100755 index 000000000..1ba33ed92 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java @@ -0,0 +1,12 @@ +package org.motechproject.openlmis.web; + +import org.springframework.stereotype.Controller; + +/** + * The controller that handles requests for information about the OpenLMIS schema. + */ +@Controller +public class OpenlmisSchemaController { + + +} diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java b/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java new file mode 100755 index 000000000..af06ddc08 --- /dev/null +++ b/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java @@ -0,0 +1,78 @@ +package org.motechproject.openlmis.web; + +import org.motechproject.openlmis.service.Settings; +import org.motechproject.openlmis.service.SettingsService; +import org.motechproject.openlmis.service.SyncService; +import org.motechproject.openlmis.service.TasksService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpStatus; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The controller that handles both changes to module settings and syncing to the Open LMIS server. + * @see org.motechproject.open-lmis.service.SyncService + * @see org.motechproject.open-lmis.service.SettingsService + */ +@Controller +public class OpenlmisSettingsController { + @Autowired + @Qualifier("openlmisSettingsService") + private SettingsService settingsService; + + @Autowired + private SyncService syncService; + + @Autowired + private TasksService tasksService; + + /** + * Returns the settings for the module + * @return an {@link Settings} object for the Open LMIS module + */ + @RequestMapping(value = "/settings", method = RequestMethod.GET) + @ResponseBody + @PreAuthorize("hasRole('configureOpenlmis')") + public Settings getSettings() { + return settingsService.getSettings(); + } + + /** + * Updates the settings to the configuration specified in the parameters + * @param settings the new settings configuration + * @return the new settings configuration + */ + @RequestMapping(value = "/settings", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.OK) + @ResponseBody + @PreAuthorize("hasRole('configureOpenlmis')") + public Settings updateSettings(@RequestBody Settings settings) { + settingsService.updateSettings(settings); + return settingsService.getSettings(); + } + + /** + * Attempts to sync the module to the Open LMIS server. If successful, updates + * the task channel to reflect any changes to the Open LMIS schema + * @return a boolean value indicating success or failure + */ + @RequestMapping(value = "/sync", method = RequestMethod.GET) + @ResponseStatus(HttpStatus.OK) + @ResponseBody + @PreAuthorize("hasRole('syncOpenlmis')") + public boolean sync() { + boolean success = syncService.sync(); + + if (success) { + tasksService.updateChannel(); + } + + return success; + } +} diff --git a/open-lmis/src/main/resources/META-INF/spring/blueprint.xml b/open-lmis/src/main/resources/META-INF/spring/blueprint.xml new file mode 100755 index 000000000..a28f8ff4a --- /dev/null +++ b/open-lmis/src/main/resources/META-INF/spring/blueprint.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + classpath:openlmis-settings.json + + + + + + + + + + open-lmis + + + + + + + + + + configureOpenlmis + syncOpenlmis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/open-lmis/src/main/resources/header.html b/open-lmis/src/main/resources/header.html new file mode 100755 index 000000000..293c2ae11 --- /dev/null +++ b/open-lmis/src/main/resources/header.html @@ -0,0 +1,10 @@ + + + + + + diff --git a/open-lmis/src/main/resources/openlmis-settings.json b/open-lmis/src/main/resources/openlmis-settings.json new file mode 100755 index 000000000..9e26dfeeb --- /dev/null +++ b/open-lmis/src/main/resources/openlmis-settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/open-lmis/src/main/resources/openlmis.properties b/open-lmis/src/main/resources/openlmis.properties new file mode 100644 index 000000000..28a7c390b --- /dev/null +++ b/open-lmis/src/main/resources/openlmis.properties @@ -0,0 +1 @@ +openlmis.stockstatus.fromyear=2014 diff --git a/open-lmis/src/main/resources/securityRules.json b/open-lmis/src/main/resources/securityRules.json new file mode 100755 index 000000000..4c5b2fed6 --- /dev/null +++ b/open-lmis/src/main/resources/securityRules.json @@ -0,0 +1,35 @@ +[ + { + "active": true, + "pattern": "/**/open-lmis/openlmis-settings/**", + "supportedSchemes": [ + "BASIC" + ], + "protocol": "HTTP", + "priority": 2, + "rest": true, + "origin": "SYSTEM_MODULE_OPEN_LMIS", + "version": "0.26", + "methodsRequired": [ + "GET", + "POST" + ], + "permissionAccess": ["configureOpenlmis"] + }, + { + "active": true, + "pattern": "/**/open-lmis/sync/**", + "supportedSchemes": [ + "BASIC" + ], + "protocol": "HTTP", + "priority": 2, + "rest": true, + "origin": "SYSTEM_MODULE_OPEN_LMIS", + "version": "0.26", + "methodsRequired": [ + "GET" + ], + "permissionAccess": ["syncOpenlmis"] + } +] diff --git a/open-lmis/src/main/resources/webapp/css/open-lmis.css b/open-lmis/src/main/resources/webapp/css/open-lmis.css new file mode 100755 index 000000000..5164ae378 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/css/open-lmis.css @@ -0,0 +1,22 @@ +/* put your custom styles here */ +.open-lmis-program .list-group li button { + position: absolute; + top: 5px; + right: 5px; +} + +.open-lmis-program-panel-heading { + height: 75px; +} + +.open-lmis-program-subelement-panel-headng { + height: 50px; +} + +.alignleft { + float: left; +} + +.alignright { + float: right; +} \ No newline at end of file diff --git a/open-lmis/src/main/resources/webapp/index.html b/open-lmis/src/main/resources/webapp/index.html new file mode 100755 index 000000000..5ccaddf2e --- /dev/null +++ b/open-lmis/src/main/resources/webapp/index.html @@ -0,0 +1,34 @@ +
+ + +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
diff --git a/open-lmis/src/main/resources/webapp/js/app.js b/open-lmis/src/main/resources/webapp/js/app.js new file mode 100755 index 000000000..fb24ca366 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/js/app.js @@ -0,0 +1,14 @@ +(function () { +'use strict'; + +/* App Module */ + +angular.module('open-lmis', ['motech-dashboard', 'open-lmis.controllers', 'open-lmis.directives', 'open-lmis.services', 'ngCookies']) + .config(['$routeProvider', function ($routeProvider) { + + $routeProvider. + when('/open-lmis/settings', { + templateUrl: '../open-lmis/resources/partials/settings.html', + controller: 'OpenLMISSettingsCtrl' }) + }]); +}()); \ No newline at end of file diff --git a/open-lmis/src/main/resources/webapp/js/controllers.js b/open-lmis/src/main/resources/webapp/js/controllers.js new file mode 100755 index 000000000..7d4205a6f --- /dev/null +++ b/open-lmis/src/main/resources/webapp/js/controllers.js @@ -0,0 +1,75 @@ +(function () { + 'use strict'; + + /* Controllers */ + var controllers = angular.module('open-lmis.controllers', []); + + controllers.controller('OpenLMISSettingsCtrl', function ($scope, $http) { + + $scope.retrievalError = false; + $scope.updateError = false; + $scope.configOutdated = true; + $http.get('../open-lmis/settings') + .success(function (response) { + $scope.settings = response; + $scope.originalSettings = angular.copy($scope.settings); + }) + .error(function (response) { + $scope.retrievalError = true; + }); + + $scope.sync = function () { + $scope.blocked = true; + $scope.success = null; + $http.get('../open-lmis/sync') + + .success(function (response) { + $scope.blocked = false; + $scope.success = response; + }) + + .error(function (response) { + $scope.blocked = false; + $scope.success = false; + }) + }; + + $scope.submit = function () { + $http.post('../open-lmis/settings', $scope.settings) + .success(function (response) { + $scope.verifySuccessMessage = $scope.msg('open-lmis.web.settings.save.success'); + $scope.verifyErrorMessage = ''; + $scope.settings = response; + $scope.originalSettings = angular.copy($scope.configs); + $scope.configOutdated = false; + $scope.updateError = false; + }) + .error(function (response) { + $scope.verifySuccessMessage = ''; + $scope.verifyErrorMessage = $scope.msg('open-lmis.web.settings.save.fail') + ' ' + response.data; + $scope.configOutdated = false; + $scope.updateError = true; + }); + }; + + $scope.isVerifyError = function() { + return $scope.updateError && !$scope.configOutdated; + }; + + $scope.isVerifySuccess = function() { + return !$scope.updateError && !$scope.configOutdated; + }; + + $scope.draftChanged = function() { + $scope.configOutdated = true; + $scope.clearMessages(); + }; + + $scope.clearMessages = function() { + $scope.updateError = false; + $scope.verifySuccessMessage = ''; + $scope.verifyErrorMessage = ''; + }; + }); + +}()); diff --git a/open-lmis/src/main/resources/webapp/js/directives.js b/open-lmis/src/main/resources/webapp/js/directives.js new file mode 100755 index 000000000..159de3326 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/js/directives.js @@ -0,0 +1,6 @@ +(function () { + 'use strict'; + + var directives = angular.module('open-lmis.directives', []); + +}()); diff --git a/open-lmis/src/main/resources/webapp/js/services.js b/open-lmis/src/main/resources/webapp/js/services.js new file mode 100755 index 000000000..35c430bf2 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/js/services.js @@ -0,0 +1,8 @@ +(function () { + 'use strict'; + + /* Services */ + + var services = angular.module('open-lmis.services', ['ngResource']); + +}()); diff --git a/open-lmis/src/main/resources/webapp/messages/messages.properties b/open-lmis/src/main/resources/webapp/messages/messages.properties new file mode 100755 index 000000000..5379c8a20 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/messages/messages.properties @@ -0,0 +1,24 @@ +#Module link title in admin ui +open-lmis=OpenLMIS +# put your ui elements' texts here +open-lmis.welcome.heading=Welcome Screen +open-lmis.settings=Settings + +open-lmis.sync = Sync +open-lmis.sync.wait = Sync in progress... +open-lmis.sync.success = Sync successful. +open-lmis.sync.fail = Sync failed. +open-lmis.web.settings.configPanelTitle = OpenLMIS Configuration +open-lmis.web.settings.serverURI = Server URI +open-lmis.web.settings.username = Username +open-lmis.web.settings.password = Password +open-lmis.web.settings.save = Save +open-lmis.web.settings.save.success = Settings have been successfully saved. +open-lmis.web.settings.save.fail = Save failed. +open-lmis.web.settings.cancel = Cancel +open-lmis.web.settings.syncHeader = Synchronize open-lmis +open-lmis.web.settings.error.retrieval = Error retrieving settings +open-lmis.web.settings.error.update = Error updating settings + +open-lmis.stockstatus.startMonth=1 +open-lmis.stockstatus.startYear=2014 \ No newline at end of file diff --git a/open-lmis/src/main/resources/webapp/partials/settings.html b/open-lmis/src/main/resources/webapp/partials/settings.html new file mode 100755 index 000000000..de8c62830 --- /dev/null +++ b/open-lmis/src/main/resources/webapp/partials/settings.html @@ -0,0 +1,61 @@ +
+
+
+
+
+
+ {{msg('open-lmis.web.settings.configPanelTitle')}}
+
+
+
+ {{verifyErrorMessage}} +
+
+ {{verifySuccessMessage}} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + +
+
{{msg('open-lmis.web.settings.error.retrieval')}}
+
{{msg('open-lmis.web.settings.error.update')}}
+
+
+
+
+
+ +
{{msg('open-lmis.web.settings.syncHeader')}}
+
+ +
{{msg('open-lmis.sync.wait')}}
+
{{msg('open-lmis.sync.success')}}
+
{{msg('open-lmis.sync.fail')}}
+
+
+
\ No newline at end of file diff --git a/open-lmis/src/test/java/org/motechproject/openlmis/service/it/BaseOpenlmisIT.java b/open-lmis/src/test/java/org/motechproject/openlmis/service/it/BaseOpenlmisIT.java new file mode 100644 index 000000000..eab4a9506 --- /dev/null +++ b/open-lmis/src/test/java/org/motechproject/openlmis/service/it/BaseOpenlmisIT.java @@ -0,0 +1,68 @@ +package org.motechproject.openlmis.service.it; + +import org.junit.After; +import org.junit.Before; +import org.motechproject.openlmis.service.DosageUnitService; +import org.motechproject.openlmis.service.FacilityService; +import org.motechproject.openlmis.service.FacilityTypeService; +import org.motechproject.openlmis.service.GeographicLevelService; +import org.motechproject.openlmis.service.GeographicZoneService; +import org.motechproject.openlmis.service.ProductCategoryService; +import org.motechproject.openlmis.service.ProductService; +import org.motechproject.openlmis.service.ProgramService; +import org.motechproject.openlmis.service.StockStatusService; +import org.motechproject.testing.osgi.BasePaxIT; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.inject.Inject; + +public abstract class BaseOpenlmisIT extends BasePaxIT { + + @Inject + private ProgramService programService; + + @Inject + private ProductCategoryService productCategoryService; + + @Inject + private DosageUnitService dosageUnitService; + + @Inject + private ProductService productService; + + @Inject + private GeographicLevelService geographicLevelService; + + @Inject + private GeographicZoneService geographicZoneService; + + @Autowired + private FacilityTypeService facilityTypeService; + + @Inject + private FacilityService facilityService; + + @Inject + private StockStatusService stockStatusService; + + @Before + public void baseSetUp() { + clearDatabase(); + } + + @After + public void baseTearDown () { + clearDatabase(); + } + + private void clearDatabase () { + geographicLevelService.deleteAll(); + geographicZoneService.deleteAll(); + facilityTypeService.deleteAll(); + facilityService.deleteAll(); + dosageUnitService.deleteAll(); + productCategoryService.deleteAll(); + productService.deleteAll(); + programService.deleteAll(); + } +} diff --git a/open-lmis/src/test/java/org/motechproject/openlmis/service/it/OpenlmisIntegrationTests.java b/open-lmis/src/test/java/org/motechproject/openlmis/service/it/OpenlmisIntegrationTests.java new file mode 100644 index 000000000..ca61fd748 --- /dev/null +++ b/open-lmis/src/test/java/org/motechproject/openlmis/service/it/OpenlmisIntegrationTests.java @@ -0,0 +1,10 @@ +package org.motechproject.openlmis.service.it; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({}) +public class OpenlmisIntegrationTests { + // add other tests to the suite +} diff --git a/open-lmis/src/test/resources/META-INF/spring/testBlueprint.xml b/open-lmis/src/test/resources/META-INF/spring/testBlueprint.xml new file mode 100755 index 000000000..598c404d2 --- /dev/null +++ b/open-lmis/src/test/resources/META-INF/spring/testBlueprint.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/open-lmis/src/test/resources/log4j.xml b/open-lmis/src/test/resources/log4j.xml new file mode 100755 index 000000000..2265d92d9 --- /dev/null +++ b/open-lmis/src/test/resources/log4j.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c6eb97528bdfa5ab20f8f3b0b76b580c6387c69e Mon Sep 17 00:00:00 2001 From: shanmukhm Date: Thu, 19 May 2016 14:32:41 +0530 Subject: [PATCH 2/2] MOTECH-2062 Fixed dependency issues and renamed the module --- {open-lmis => openlmis}/pom.xml | 28 +++++++++---- .../openlmis/domain/DosageUnit.java | 0 .../openlmis/domain/Facility.java | 0 .../openlmis/domain/FacilityType.java | 0 .../openlmis/domain/GeographicLevel.java | 0 .../openlmis/domain/GeographicZone.java | 0 .../openlmis/domain/KitProduct.java | 0 .../openlmis/domain/Product.java | 0 .../openlmis/domain/ProductCategory.java | 0 .../openlmis/domain/Program.java | 0 .../openlmis/domain/StockStatus.java | 0 .../repository/DosageUnitDataService.java | 0 .../repository/FacilityDataService.java | 0 .../repository/FacilityTypeDataService.java | 0 .../GeographicLevelDataService.java | 0 .../repository/GeographicZoneDataService.java | 0 .../ProductCategoryDataService.java | 0 .../repository/ProductDataService.java | 0 .../repository/ProgramDataService.java | 0 .../repository/StockStatusDataService.java | 0 .../openlmis/rest/domain/DosageUnitDto.java | 0 .../openlmis/rest/domain/FacilityDto.java | 0 .../openlmis/rest/domain/FacilityTypeDto.java | 0 .../rest/domain/GeographicLevelDto.java | 0 .../rest/domain/GeographicZoneDto.java | 0 .../openlmis/rest/domain/ISADto.java | 0 .../openlmis/rest/domain/KitProductDto.java | 0 .../domain/LossesAndAdjustmentsTypeDto.java | 0 .../openlmis/rest/domain/MoneyDto.java | 0 .../rest/domain/ProcessingPeriodDto.java | 0 .../rest/domain/ProductAttributeBaseDto.java | 0 .../rest/domain/ProductCategoryDto.java | 0 .../openlmis/rest/domain/ProductDto.java | 0 .../openlmis/rest/domain/ProductFormDto.java | 0 .../openlmis/rest/domain/ProductGroupDto.java | 0 .../openlmis/rest/domain/ProgramDto.java | 0 .../rest/domain/ProgramProductDto.java | 0 .../rest/domain/ProgramProductISADto.java | 0 .../rest/domain/ProgramsWithProductDto.java | 0 .../rest/domain/ProgramsWithProductsDto.java | 0 .../openlmis/rest/domain/ResourceListDto.java | 0 .../openlmis/rest/domain/StockStatusDto.java | 0 .../rest/service/OpenlmisWebException.java | 0 .../rest/service/OpenlmisWebService.java | 0 .../service/impl/OpenlmisWebServiceImpl.java | 0 .../openlmis/service/DosageUnitService.java | 0 .../openlmis/service/FacilityService.java | 0 .../openlmis/service/FacilityTypeService.java | 0 .../openlmis/service/GenericCrudService.java | 0 .../service/GeographicLevelService.java | 0 .../service/GeographicZoneService.java | 0 .../service/ProductCategoryService.java | 0 .../openlmis/service/ProductService.java | 0 .../openlmis/service/ProgramService.java | 0 .../openlmis/service/Settings.java | 0 .../openlmis/service/SettingsService.java | 0 .../openlmis/service/StockStatusService.java | 0 .../openlmis/service/SyncService.java | 0 .../openlmis/service/TasksService.java | 0 .../service/impl/DosageUnitServiceImpl.java | 0 .../service/impl/FacilityServiceImpl.java | 0 .../service/impl/FacilityTypeServiceImpl.java | 0 .../impl/GeographicLevelServiceImpl.java | 0 .../impl/GeographicZoneServiceImpl.java | 0 .../impl/ProductCategoryServiceImpl.java | 0 .../service/impl/ProductServiceImpl.java | 0 .../service/impl/ProgramServiceImpl.java | 0 .../service/impl/SettingsServiceImpl.java | 0 .../service/impl/StockStatusServiceImpl.java | 0 .../service/impl/SyncServiceImpl.java | 4 +- .../service/impl/TasksServiceImpl.java | 0 .../web/OpenlmisSchemaController.java | 0 .../web/OpenlmisSettingsController.java | 0 .../resources/META-INF/spring/blueprint.xml | 41 +++++++++---------- .../src/main/resources/header.html | 0 .../src/main/resources/openlmis-settings.json | 0 .../src/main/resources/openlmis.properties | 0 .../src/main/resources/securityRules.json | 0 .../main/resources/webapp/css/open-lmis.css | 0 .../src/main/resources/webapp/index.html | 0 .../src/main/resources/webapp/js/app.js | 0 .../main/resources/webapp/js/controllers.js | 0 .../main/resources/webapp/js/directives.js | 0 .../src/main/resources/webapp/js/services.js | 0 .../webapp/messages/messages.properties | 0 .../resources/webapp/partials/settings.html | 0 .../openlmis/service/it/BaseOpenlmisIT.java | 0 .../service/it/OpenlmisIntegrationTests.java | 0 .../META-INF/spring/testBlueprint.xml | 0 .../src/test/resources/log4j.xml | 0 90 files changed, 41 insertions(+), 32 deletions(-) rename {open-lmis => openlmis}/pom.xml (82%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/Facility.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/FacilityType.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/KitProduct.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/Product.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/Program.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/domain/StockStatus.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/FacilityService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/ProductService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/ProgramService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/Settings.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/SettingsService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/StockStatusService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/SyncService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/TasksService.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java (98%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java (100%) rename {open-lmis => openlmis}/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java (100%) rename {open-lmis => openlmis}/src/main/resources/META-INF/spring/blueprint.xml (67%) rename {open-lmis => openlmis}/src/main/resources/header.html (100%) rename {open-lmis => openlmis}/src/main/resources/openlmis-settings.json (100%) rename {open-lmis => openlmis}/src/main/resources/openlmis.properties (100%) rename {open-lmis => openlmis}/src/main/resources/securityRules.json (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/css/open-lmis.css (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/index.html (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/js/app.js (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/js/controllers.js (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/js/directives.js (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/js/services.js (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/messages/messages.properties (100%) rename {open-lmis => openlmis}/src/main/resources/webapp/partials/settings.html (100%) rename {open-lmis => openlmis}/src/test/java/org/motechproject/openlmis/service/it/BaseOpenlmisIT.java (100%) rename {open-lmis => openlmis}/src/test/java/org/motechproject/openlmis/service/it/OpenlmisIntegrationTests.java (100%) rename {open-lmis => openlmis}/src/test/resources/META-INF/spring/testBlueprint.xml (100%) rename {open-lmis => openlmis}/src/test/resources/log4j.xml (100%) diff --git a/open-lmis/pom.xml b/openlmis/pom.xml similarity index 82% rename from open-lmis/pom.xml rename to openlmis/pom.xml index bda1064b6..95d0e8c6e 100755 --- a/open-lmis/pom.xml +++ b/openlmis/pom.xml @@ -4,13 +4,14 @@ modules org.motechproject - 1.0-SNAPSHOT + 0.29-SNAPSHOT ../ 4.0.0 - open-lmis + openlmis bundle + OpenLMIS module ${basedir}/.. @@ -38,10 +39,19 @@ motech-platform-web-security ${motech.version} + + ${motech.groupId} + motech-platform-server-config + ${motech.version} + com.fasterxml.jackson.core jackson-databind - ${fasterxml.jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${fasterxml.jackson.version} ${motech.groupId} @@ -67,21 +77,18 @@ org.apache.httpcomponents httpcore-osgi - - - org.apache.felix maven-bundle-plugin true - open-lmis - open-lmis/resources + openlmis + openlmis/resources net.sf.cglib.core, net.sf.cglib.proxy, @@ -92,9 +99,14 @@ org.motechproject.config.service, org.motechproject.event.listener, org.motechproject.mds.service, + org.motechproject.config, org.springframework.aop, org.springframework.aop.framework, + org.springframework.cglib.core, + org.springframework.cglib.proxy, + org.springframework.cglib.reflect, org.springframework.transaction, + org.springframework.validation.beanvalidation, * diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/DosageUnit.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/Facility.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/Facility.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/Facility.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/FacilityType.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/GeographicLevel.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/GeographicZone.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/KitProduct.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/Product.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/Product.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/Product.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/ProductCategory.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/Program.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/Program.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/Program.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java b/openlmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java rename to openlmis/src/main/java/org/motechproject/openlmis/domain/StockStatus.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/DosageUnitDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/FacilityDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/FacilityTypeDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/GeographicLevelDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/GeographicZoneDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/ProductCategoryDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/ProductDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/ProgramDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java b/openlmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java rename to openlmis/src/main/java/org/motechproject/openlmis/repository/StockStatusDataService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/DosageUnitDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/FacilityTypeDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicLevelDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/GeographicZoneDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ISADto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/KitProductDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/LossesAndAdjustmentsTypeDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/MoneyDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProcessingPeriodDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductAttributeBaseDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductCategoryDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductFormDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProductGroupDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramProductISADto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ProgramsWithProductsDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/ResourceListDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/domain/StockStatusDto.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebException.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/service/OpenlmisWebService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/rest/service/impl/OpenlmisWebServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/DosageUnitService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/FacilityService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/FacilityTypeService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/GenericCrudService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/GeographicLevelService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/GeographicZoneService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/ProductCategoryService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/ProductService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/ProductService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/ProductService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/ProgramService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java b/openlmis/src/main/java/org/motechproject/openlmis/service/Settings.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/Settings.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/Settings.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/SettingsService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/StockStatusService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/SyncService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/SyncService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/SyncService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java b/openlmis/src/main/java/org/motechproject/openlmis/service/TasksService.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/TasksService.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/TasksService.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/DosageUnitServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/FacilityTypeServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicLevelServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/GeographicZoneServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProductCategoryServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProductServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/ProgramServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/SettingsServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/StockStatusServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java similarity index 98% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java index c33f0b497..5f72c6224 100755 --- a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java +++ b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/SyncServiceImpl.java @@ -73,7 +73,7 @@ public class SyncServiceImpl implements SyncService { private static final Logger LOGGER = LoggerFactory.getLogger(SyncServiceImpl.class); @Value("${openlmis.stockstatus.fromyear}") - private int fromYear; + private String fromYear; @Override @Transactional @@ -168,7 +168,7 @@ private void addStockStatus() { DateTime now = new DateTime(); List programs = programService.findAll(); for (Program program : programs) { - for (int year = fromYear; year <= now.getYear(); year++) { + for (int year = Integer.parseInt(fromYear); year <= now.getYear(); year++) { int lastMonth = (year == now.getYear() ? now.getMonthOfYear() : DateTimeConstants.DECEMBER); for (int month = DateTimeConstants.JANUARY; month <= lastMonth; month++) { List stockStatusDtos = openlmisWebService.getStockStatus(month, year, program.getCode()); diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java b/openlmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java rename to openlmis/src/main/java/org/motechproject/openlmis/service/impl/TasksServiceImpl.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java b/openlmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java rename to openlmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSchemaController.java diff --git a/open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java b/openlmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java similarity index 100% rename from open-lmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java rename to openlmis/src/main/java/org/motechproject/openlmis/web/OpenlmisSettingsController.java diff --git a/open-lmis/src/main/resources/META-INF/spring/blueprint.xml b/openlmis/src/main/resources/META-INF/spring/blueprint.xml similarity index 67% rename from open-lmis/src/main/resources/META-INF/spring/blueprint.xml rename to openlmis/src/main/resources/META-INF/spring/blueprint.xml index a28f8ff4a..e1eecde90 100755 --- a/open-lmis/src/main/resources/META-INF/spring/blueprint.xml +++ b/openlmis/src/main/resources/META-INF/spring/blueprint.xml @@ -1,30 +1,27 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:tx="http://www.springframework.org/schema/tx" + xmlns:mvc="http://www.springframework.org/schema/mvc" + xmlns:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint" + xmlns:security="http://www.springframework.org/schema/security" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd + http://www.eclipse.org/gemini/blueprint/schema/blueprint http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint.xsd + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> - + - @@ -35,16 +32,16 @@ + value="../openlmis/resources/index.html" /> - open-lmis + openlmis - + @@ -53,8 +50,8 @@ syncOpenlmis - - + +