dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21791
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10414: Changed version number for India modules, added ihrissyncmanger module
------------------------------------------------------------
revno: 10414
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-03-25 06:08:43 +0100
message:
Changed version number for India modules, added ihrissyncmanger module
added:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/
local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/AggDataService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SyncIHRISOrgUnitService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SynciHRISUserService.java
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/pom.xml
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultAggDataService.java
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSyncIHRISOrgUnitService.java
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSynciHRISUserService.java
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks/SyncIHRISOrgTreeService.java
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis/
local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-ihrissyncmanager/
local/in/dhis-web-ihrissyncmanager/pom.xml
local/in/dhis-web-ihrissyncmanager/src/
local/in/dhis-web-ihrissyncmanager/src/main/
local/in/dhis-web-ihrissyncmanager/src/main/java/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/DeleteAggDataElementAction.java
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/RecordAggDataElementAction.java
local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/SynciHRISUserAction.java
local/in/dhis-web-ihrissyncmanager/src/main/resources/
local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/
local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis/
local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-ihrissyncmanager/src/main/resources/struts.xml
local/in/dhis-web-ihrissyncmanager/src/main/webapp/
local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF/
local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF/web.xml
modified:
local/in/dhis-in-api/pom.xml
local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml
local/in/dhis-in-services/dhis-in-service-configuration/pom.xml
local/in/dhis-in-services/dhis-in-service-dataentrystatus/pom.xml
local/in/dhis-in-services/dhis-in-service-dbmanager/pom.xml
local/in/dhis-in-services/dhis-in-service-linelisting/pom.xml
local/in/dhis-in-services/dhis-in-service-reports/pom.xml
local/in/dhis-in-services/dhis-in-service-scheduler/pom.xml
local/in/dhis-in-services/dhis-in-service-survey/pom.xml
local/in/dhis-in-services/pom.xml
local/in/dhis-mobile/dhis-service-mobile/pom.xml
local/in/dhis-mobile/dhis-web-mobile/pom.xml
local/in/dhis-mobile/pom.xml
local/in/dhis-mobile/smsclient/pom.xml
local/in/dhis-web-alert/pom.xml
local/in/dhis-web-coldchain/pom.xml
local/in/dhis-web-dashboard/pom.xml
local/in/dhis-web-dataentry-linelisting/pom.xml
local/in/dhis-web-excelimport/pom.xml
local/in/dhis-web-leprosy/pom.xml
local/in/dhis-web-linelisting-in/pom.xml
local/in/dhis-web-maintenance-in/pom.xml
local/in/dhis-web-reports-in/pom.xml
local/in/dhis-web-reports-national/pom.xml
local/in/dhis-web-sandbox/pom.xml
local/in/dhis-web-sandboxbk/pom.xml
local/in/dhis-web-survey/pom.xml
local/in/dhis-web-validationrule-in/pom.xml
local/in/pom.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-in-api/pom.xml'
--- local/in/dhis-in-api/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-api/pom.xml 2013-03-25 05:08:43 +0000
@@ -4,7 +4,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-api</artifactId>
=== added directory 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager'
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/AggDataService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/AggDataService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/AggDataService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,20 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 8/27/12 [2:07 PM]
+ */
+public interface AggDataService {
+
+ String ID = AggDataService.class.getName();
+
+ public DataElement createNewAggDataElement(String aggDataElementName);
+
+ public void addNewEntries(String aggDataElementName,OrganisationUnit orgUnit,Period period, Double aggValue);
+
+ public void deleteAggDataElement(String nameOfDataElement);
+
+}
\ No newline at end of file
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SyncIHRISOrgUnitService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SyncIHRISOrgUnitService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SyncIHRISOrgUnitService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,13 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 8/29/12 [3:10 PM]
+ */
+public interface SyncIHRISOrgUnitService {
+
+ String ID = SyncIHRISOrgUnitService.class.getName();
+
+ public OrganisationUnit createNewOrgUnit(String orgUnitName, String parentOrgUnitName);
+}
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SynciHRISUserService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SynciHRISUserService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/ihrissyncmanager/SynciHRISUserService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,19 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.user.User;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: Mohit
+ * Date: 29/8/12
+ * Time: 1:44 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface SynciHRISUserService
+{
+ String ID = SynciHRISUserService.class.getName();
+
+ public User createNewiHRISUser(String ihrisUsername, String firstName, String lastName, String email, String password);
+
+
+}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-coldchain</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-configuration/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-configuration/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-configuration/pom.xml 2013-03-25 05:08:43 +0000
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-configuration</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-dataentrystatus/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-dataentrystatus/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-dataentrystatus/pom.xml 2013-03-25 05:08:43 +0000
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-dataentrystatus</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-dbmanager/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-dbmanager/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-dbmanager/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-dbmanager</artifactId>
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager'
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/pom.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/pom.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,70 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-services</artifactId>
+ <version>2.12-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>dhis-in-service-ihrissyncmanager</artifactId>
+ <packaging>jar</packaging>
+ <name>DHIS-IHRIS India Synchronisation Service</name>
+
+ <dependencies>
+
+ <!-- DHIS -->
+
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-service-configuration</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-aggregationengine-default</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-system</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-reporting</artifactId>
+ </dependency>
+
+
+ <!-- Other -->
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-math</groupId>
+ <artifactId>commons-math</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+
+ </dependencies>
+</project>
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager'
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultAggDataService.java'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultAggDataService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultAggDataService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,115 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 8/27/12 [2:24 PM]
+**/
+
+public class DefaultAggDataService implements AggDataService {
+
+ DataElementService dataElementService;
+
+ public void setDataElementService(DataElementService dataElementService) {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService(DataElementCategoryService categoryService) {
+ this.categoryService = categoryService;
+ }
+
+ private DataValueService dataValueService;
+
+ public void setDataValueService(DataValueService dataValueService) {
+ this.dataValueService = dataValueService;
+ }
+
+ public OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService(OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ public PeriodService periodService;
+
+ public void setPeriodService(PeriodService periodService) {
+ this.periodService = periodService;
+ }
+
+
+ public DataElement createNewAggDataElement(String aggDataElementName)
+ {
+ DataElement checkIfDataElementExists = dataElementService.getDataElementByName(aggDataElementName);
+
+ if(checkIfDataElementExists == null)
+ {
+ DataElement newAggDataElement = new DataElement();
+
+ newAggDataElement.setName(aggDataElementName);
+
+ newAggDataElement.setShortName(aggDataElementName);
+
+ newAggDataElement.setActive(true);
+
+ newAggDataElement.setType("string");
+
+ newAggDataElement.setAggregationOperator("sum");
+
+ newAggDataElement.setZeroIsSignificant(false);
+
+ dataElementService.addDataElement(newAggDataElement);
+
+ return newAggDataElement;
+ }
+
+ return checkIfDataElementExists;
+ }
+
+ public void addNewEntries(String aggDataElementName,OrganisationUnit orgUnit,Period period, Double aggValue)
+ {
+ DataElement aggDataElement = createNewAggDataElement(aggDataElementName);
+
+ DataElementCategoryOptionCombo OptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+
+ DataValue dataValue = dataValueService.getDataValue(orgUnit,aggDataElement,period,OptionCombo);
+
+ if ((dataValue == null) && period != null )
+ {
+
+ DataValue newDataValue = new DataValue(aggDataElement,period,orgUnit,aggValue.toString(),OptionCombo);
+ dataValueService.addDataValue(newDataValue);
+
+ }
+ else if( dataValue.getPeriod().getStartDate().before(period.getStartDate()) && period != null)
+ {
+
+ dataValue.setValue(aggValue.toString());
+ dataValue.setPeriod(period);
+ dataValue.setSource(orgUnit);
+
+ dataValueService.updateDataValue(dataValue);
+ }
+ }
+
+ @Override
+ public void deleteAggDataElement(String nameOfDataElement) {
+
+
+ DataElement dataElementToDelete = dataElementService.getDataElementByName(nameOfDataElement);
+
+ dataValueService.deleteDataValuesByDataElement(dataElementToDelete);
+ dataElementService.deleteDataElement(dataElementToDelete);
+ }
+}
+
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSyncIHRISOrgUnitService.java'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSyncIHRISOrgUnitService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSyncIHRISOrgUnitService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,55 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 8/29/12 [5:06 PM]
+**/
+
+public class DefaultSyncIHRISOrgUnitService implements SyncIHRISOrgUnitService {
+
+ DataElementService dataElementService;
+
+ public void setDataElementService(DataElementService dataElementService) {
+ this.dataElementService = dataElementService;
+ }
+
+ public OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService(OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ public OrganisationUnit createNewOrgUnit(String orgUnitName, String parentOrgUnitName)
+ {
+ OrganisationUnit checkIfOrgUnitExists = organisationUnitService.getOrganisationUnitByName(orgUnitName);
+
+ OrganisationUnit checkIfParentOrgUnitExists = organisationUnitService.getOrganisationUnitByName(parentOrgUnitName);
+
+ if(checkIfParentOrgUnitExists == null)
+ {
+ return null;
+ }
+ else if(checkIfOrgUnitExists == null && checkIfParentOrgUnitExists!= null)
+ {
+ OrganisationUnit newIHRISOrgUnit = new OrganisationUnit();
+
+ newIHRISOrgUnit.setName(orgUnitName);
+
+ newIHRISOrgUnit.setShortName(orgUnitName);
+
+ newIHRISOrgUnit.setActive(true);
+
+ newIHRISOrgUnit.setParent(checkIfParentOrgUnitExists);
+
+ organisationUnitService.addOrganisationUnit(newIHRISOrgUnit);
+
+ return newIHRISOrgUnit;
+ }
+
+ return checkIfOrgUnitExists;
+ }
+
+}
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSynciHRISUserService.java'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSynciHRISUserService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/DefaultSynciHRISUserService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,111 @@
+package org.hisp.dhis.ihrissyncmanager;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.security.PasswordManager;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserService;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: Mohit
+ * Date: 29/8/12
+ * Time: 2:00 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DefaultSynciHRISUserService implements SynciHRISUserService {
+ UserService userService;
+
+ public void setUserService(UserService userService) {
+ this.userService = userService;
+ }
+
+ CurrentUserService currentUserService;
+
+ public void setCurrentUserService(CurrentUserService currentUserService) {
+ this.currentUserService = currentUserService;
+ }
+
+ PasswordManager passwordManager;
+
+ public void setPasswordManager(PasswordManager passwordManager) {
+ this.passwordManager = passwordManager;
+ }
+
+
+ OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService(OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ @Override
+ public User createNewiHRISUser(String ihrisUsername, String firstName, String lastName, String email, String password) {
+
+ UserCredentials currentUserCredentials = currentUserService.getCurrentUser() != null ? currentUserService
+ .getCurrentUser().getUserCredentials() : null;
+
+
+ // ---------------------------------------------------------------------
+ // Create userCredentials and user
+ // ---------------------------------------------------------------------
+
+ Collection<OrganisationUnit> orgUnits = organisationUnitService.getAllOrganisationUnits();
+
+ Collection<User> tempUserList = userService.getAllUsers();
+
+ boolean isUpdated = false;
+
+ User user = new User();
+ user.setSurname(lastName);
+ user.setFirstName(firstName);
+ user.setEmail(email);
+
+ user.updateOrganisationUnits(new HashSet<OrganisationUnit>(orgUnits));
+
+ UserCredentials userCredentials = new UserCredentials();
+ userCredentials.setUser(user);
+
+ userCredentials.setUsername(ihrisUsername);
+ userCredentials.setPassword(passwordManager.encodePassword(ihrisUsername, password));
+ user.setUserCredentials(userCredentials);
+
+ if (tempUserList != null) {
+ for (User existingUser : tempUserList) {
+
+ UserCredentials existingUserCredentials = userService.getUserCredentials(existingUser);
+
+ if (existingUserCredentials != null && existingUserCredentials.getUsername().equalsIgnoreCase(ihrisUsername)) {
+ existingUser.setSurname(lastName);
+ existingUser.setFirstName(firstName);
+ existingUser.setEmail(email);
+
+ existingUserCredentials.setUser(existingUser);
+
+ existingUserCredentials.setUsername(ihrisUsername);
+ existingUserCredentials.setPassword(passwordManager.encodePassword(ihrisUsername, password));
+ existingUser.setUserCredentials(existingUserCredentials);
+
+ userService.updateUser(existingUser);
+ userService.updateUserCredentials(existingUserCredentials);
+ isUpdated = true;
+ }
+
+
+ }
+ }
+
+ if (!isUpdated) {
+ userService.addUser(user);
+ userService.addUserCredentials(userCredentials);
+ }
+
+ return user;
+
+ }
+}
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks'
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks/SyncIHRISOrgTreeService.java'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks/SyncIHRISOrgTreeService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/scheduledtasks/SyncIHRISOrgTreeService.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,582 @@
+package org.hisp.dhis.ihrissyncmanager.scheduledtasks;
+
+import org.hisp.dhis.hierarchy.HierarchyViolationException;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.util.Date;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 9/13/12 [1:21 PM]
+ */
+
+public class SyncIHRISOrgTreeService implements Runnable{
+
+
+ private JdbcTemplate jdbcTemplate;
+
+ public void setDataSource(DataSource dataSource) {
+ this.jdbcTemplate = new JdbcTemplate(dataSource);
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService(CurrentUserService currentUserService) {
+ this.currentUserService = currentUserService;
+ }
+
+ public void setOrganisationUnitService(OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+
+ public void createOrgUnitMaps() {
+
+
+ System.out.println("* INFO: CREATING MAPPING TABLES");
+
+ int countTables = 0;
+
+ if (jdbcTemplate.queryForList("SHOW tables LIKE \"country_mapping\"").size() == 0) {
+ jdbcTemplate.update("CREATE TABLE country_mapping (" +
+ "id int AUTO_INCREMENT, " +
+ "ihrisid varchar(20) NOT NULL, " +
+ "dhisid int NOT NULL, " +
+ "status char, " +
+ "PRIMARY KEY (id)" +
+ ")");
+ }
+
+ if (jdbcTemplate.queryForList("SHOW tables LIKE \"region_mapping\"").size() == 0) {
+ jdbcTemplate.update("CREATE TABLE region_mapping (" +
+ "id int AUTO_INCREMENT, " +
+ "ihrisid varchar(20) NOT NULL, " +
+ "dhisid int NOT NULL, " +
+ "status char, " +
+ "PRIMARY KEY (id)" +
+ ")");
+ }
+
+ if (jdbcTemplate.queryForList("SHOW tables LIKE \"district_mapping\"").size() == 0) {
+ jdbcTemplate.update("CREATE TABLE district_mapping (" +
+ "id int AUTO_INCREMENT, " +
+ "ihrisid varchar(20) NOT NULL, " +
+ "dhisid int NOT NULL, " +
+ "status char, " +
+ "PRIMARY KEY (id)" +
+ ")");
+ }
+
+
+ if (jdbcTemplate.queryForList("SHOW tables LIKE \"county_mapping\"").size() == 0) {
+ jdbcTemplate.update("CREATE TABLE county_mapping (" +
+ "id int AUTO_INCREMENT, " +
+ "ihrisid varchar(20) NOT NULL, " +
+ "dhisid int NOT NULL, " +
+ "status char, " +
+ "PRIMARY KEY (id)" +
+ ")");
+
+
+ }
+ }
+
+ public void replicateIhrisOrgTree() {
+
+ System.out.println("\n\n* INFO: Stating the iHRIS tree replication process.\n\n");
+
+ createOrgUnitMaps();
+
+ String countryQuery = "SELECT name,id FROM hippo_country";
+
+ SqlRowSet countryRowSet = jdbcTemplate.queryForRowSet(countryQuery);
+
+ while (countryRowSet.next()) {
+
+ String countryName = countryRowSet.getString(1);
+
+ OrganisationUnit country = organisationUnitService.getOrganisationUnitByName(countryName);
+
+ if (country == null) {
+ OrganisationUnit newIHRISOrgUnit = new OrganisationUnit();
+
+ newIHRISOrgUnit.setName(countryName);
+
+ newIHRISOrgUnit.setShortName(countryName);
+
+ newIHRISOrgUnit.setActive(true);
+
+ organisationUnitService.addOrganisationUnit(newIHRISOrgUnit);
+
+ int newIHRISOrgUnitId = newIHRISOrgUnit.getId();
+
+ jdbcTemplate.update("INSERT INTO country_mapping (ihrisid, dhisid, status) VALUES (" + "\"" + countryRowSet.getString(2) + "\", " + "\"" + newIHRISOrgUnitId + "\", " + " \'S\' )");
+ }
+
+ String regionQuery = "SELECT name,id FROM hippo_region where country=\"" + countryRowSet.getString(2) + "\"";
+
+ SqlRowSet regionRowSet = jdbcTemplate.queryForRowSet(regionQuery);
+
+ while (regionRowSet.next()) {
+
+ String regionName = regionRowSet.getString(1);
+
+ OrganisationUnit region = organisationUnitService.getOrganisationUnitByName(regionName);
+
+ OrganisationUnit regionParent = organisationUnitService.getOrganisationUnitByName(countryName);
+
+ if (region == null) {
+ OrganisationUnit newIHRISOrgUnit = new OrganisationUnit();
+
+ newIHRISOrgUnit.setName(regionName);
+
+ newIHRISOrgUnit.setShortName(regionName);
+
+ newIHRISOrgUnit.setParent(regionParent);
+
+ newIHRISOrgUnit.setActive(true);
+
+ organisationUnitService.addOrganisationUnit(newIHRISOrgUnit);
+
+ int newIHRISOrgUnitId = newIHRISOrgUnit.getId();
+
+ jdbcTemplate.update("INSERT INTO region_mapping (ihrisid, dhisid, status) VALUES (" + "\"" + regionRowSet.getString(2) + "\", " + "\"" + newIHRISOrgUnitId + "\", " + " \'S\' )");
+ }
+
+ String districtQuery = "SELECT name,id FROM hippo_district where region=\"" + regionRowSet.getString(2) + "\"";
+
+ SqlRowSet districtRowSet = jdbcTemplate.queryForRowSet(districtQuery);
+
+ while (districtRowSet.next()) {
+
+ String districtName = districtRowSet.getString(1);
+
+ OrganisationUnit district = organisationUnitService.getOrganisationUnitByName(districtName);
+
+ OrganisationUnit districtParent = organisationUnitService.getOrganisationUnitByName(regionName);
+
+ if (district == null) {
+ OrganisationUnit newIHRISOrgUnit = new OrganisationUnit();
+
+ newIHRISOrgUnit.setName(districtName);
+
+ newIHRISOrgUnit.setShortName(districtName);
+
+ newIHRISOrgUnit.setParent(districtParent);
+
+ newIHRISOrgUnit.setActive(true);
+
+ organisationUnitService.addOrganisationUnit(newIHRISOrgUnit);
+
+ int newIHRISOrgUnitId = newIHRISOrgUnit.getId();
+
+ jdbcTemplate.update("INSERT INTO district_mapping (ihrisid, dhisid, status) VALUES (" + "\"" + districtRowSet.getString(2) + "\", " + "\"" + newIHRISOrgUnitId + "\", " + " \'S\' )");
+ }
+
+ String countyQuery = "SELECT name,id FROM hippo_county where district=\"" + districtRowSet.getString(2) + "\"";
+
+ SqlRowSet countyRowSet = jdbcTemplate.queryForRowSet(countyQuery);
+
+ while (countyRowSet.next()) {
+
+ String countyName = countyRowSet.getString(1);
+
+ OrganisationUnit county = organisationUnitService.getOrganisationUnitByName(countyName);
+
+ OrganisationUnit countyParent = organisationUnitService.getOrganisationUnitByName(districtName);
+
+ if (county == null) {
+ OrganisationUnit newIHRISOrgUnit = new OrganisationUnit();
+
+ newIHRISOrgUnit.setName(countyName);
+
+ newIHRISOrgUnit.setShortName(countyName);
+
+ newIHRISOrgUnit.setParent(countyParent);
+
+ newIHRISOrgUnit.setActive(true);
+
+ organisationUnitService.addOrganisationUnit(newIHRISOrgUnit);
+
+ int newIHRISOrgUnitId = newIHRISOrgUnit.getId();
+
+ jdbcTemplate.update("INSERT INTO county_mapping (ihrisid, dhisid, status) VALUES (" + "\"" + countyRowSet.getString(2) + "\", " + "\"" + newIHRISOrgUnitId + "\", " + " \'S\' )");
+ }
+ }
+
+ }
+ }
+ }
+
+ }
+
+
+ public void deleteIhrisOrgTreeFromDhis() {
+
+ System.out.println("\n\n* INFO: Stating the iHRIS tree truncation process.\n\n");
+
+ String delCounties = "SELECT dhisid FROM county_mapping";
+
+ SqlRowSet delCountySet = jdbcTemplate.queryForRowSet(delCounties);
+
+ while (delCountySet.next())
+ {
+ int dhisID = delCountySet.getInt(1);
+
+ OrganisationUnit organisationUnitToDelete = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if (organisationUnitToDelete != null) {
+ try {
+ organisationUnitService.deleteOrganisationUnit(organisationUnitToDelete);
+ } catch (HierarchyViolationException e) {
+ System.out.println("* ERROR :HierarchyViolationException while deleting [ " + organisationUnitToDelete.getName() + "]");
+ }
+ }
+ }
+
+ jdbcTemplate.update("DROP TABLE county_mapping");
+
+ String delDistricts = "SELECT dhisid FROM district_mapping";
+
+ SqlRowSet delDistrictSet = jdbcTemplate.queryForRowSet(delDistricts);
+
+ while (delDistrictSet.next()) {
+ int dhisID = delDistrictSet.getInt(1);
+
+ OrganisationUnit organisationUnitToDelete = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if (organisationUnitToDelete != null) {
+ try {
+ organisationUnitService.deleteOrganisationUnit(organisationUnitToDelete);
+ } catch (HierarchyViolationException e) {
+ System.out.println("* ERROR :HierarchyViolationException while deleting [ " + organisationUnitToDelete.getName() + "]");
+ }
+ }
+ }
+
+ jdbcTemplate.update("DROP TABLE district_mapping");
+
+ String delRegion = "SELECT dhisid FROM region_mapping";
+
+ SqlRowSet delRegionSet = jdbcTemplate.queryForRowSet(delRegion);
+
+ while (delRegionSet.next()) {
+ int dhisID = delRegionSet.getInt(1);
+
+ OrganisationUnit organisationUnitToDelete = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if (organisationUnitToDelete != null) {
+ try {
+ organisationUnitService.deleteOrganisationUnit(organisationUnitToDelete);
+ } catch (HierarchyViolationException e) {
+ System.out.println("* ERROR :HierarchyViolationException while deleting [ " + organisationUnitToDelete.getName() + "]");
+ }
+ }
+ }
+
+ jdbcTemplate.update("DROP TABLE region_mapping");
+
+ String delCountry = "SELECT dhisid FROM country_mapping";
+
+ SqlRowSet delCountrySet = jdbcTemplate.queryForRowSet(delCountry);
+
+ while (delCountrySet.next()) {
+ int dhisID = delCountrySet.getInt(1);
+
+ OrganisationUnit organisationUnitToDelete = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if (organisationUnitToDelete != null) {
+ try {
+ organisationUnitService.deleteOrganisationUnit(organisationUnitToDelete);
+ } catch (HierarchyViolationException e) {
+ System.out.println("* ERROR :HierarchyViolationException while deleting [ " + organisationUnitToDelete.getName() + "]");
+ }
+ }
+ }
+
+ jdbcTemplate.update("DROP TABLE country_mapping");
+
+ replicateIhrisOrgTree();
+
+ }
+
+
+ public void checkForIhrisOrgTreeUpdate() {
+
+
+ System.out.println("\n* NOTICE: IHRIS ORGANISATION UNIT SYNC PROCESS STARTED @[" + new Date() + "]");
+
+
+ if(jdbcTemplate.queryForList("SHOW tables LIKE \"%_mapping\"").size() < 4)
+ {
+ System.out.println("* NOTE: Mapping tables FOUND.");
+ replicateIhrisOrgTree();
+ }
+
+ else
+ {
+
+ String checkCounty = "SELECT dhisid,ihrisid FROM county_mapping";
+
+ SqlRowSet checkCountySet = jdbcTemplate.queryForRowSet(checkCounty);
+
+ while (checkCountySet.next()) {
+
+ int dhisID = checkCountySet.getInt(1);
+
+ String ihrisID = checkCountySet.getString(2);
+
+ String getIhrisDetailsQuery = "SELECT name,district FROM hippo_county WHERE id=" + "\"" + ihrisID + "\"";
+
+ SqlRowSet ihrisDetailSet = jdbcTemplate.queryForRowSet(getIhrisDetailsQuery);
+
+ String ihrisOUName = null;
+
+ String ihrisParentName = null;
+
+ while (ihrisDetailSet.next()) {
+ ihrisOUName = ihrisDetailSet.getString(1).trim();
+
+ String ihrisOUParentQuery = "SELECT name FROM hippo_district WHERE id=" + "\"" + ihrisDetailSet.getString(2) + "\"";
+
+ SqlRowSet ihrisParentDetailSet = jdbcTemplate.queryForRowSet(ihrisOUParentQuery);
+
+ while (ihrisParentDetailSet.next())
+ {
+ ihrisParentName = ihrisParentDetailSet.getString(1);
+ }
+ }
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if(organisationUnit==null || ihrisOUName==null || ihrisParentName ==null)
+ {
+ System.out.println("* INFO: REFERENCED ORG. UNIT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+
+ String dhisOrgUnitName = organisationUnit.getName();
+
+ OrganisationUnit organisationUnitParent = organisationUnit.getParent();
+
+ String parentName;
+
+ if(organisationUnitParent!=null){
+
+ parentName = organisationUnitParent.getName();
+
+ }
+ else{
+
+ System.out.println("* INFO: REFERENCED ORG. UNIT PARENT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+
+ }
+
+ if (!((dhisOrgUnitName.trim()).equalsIgnoreCase(ihrisOUName.trim()) && (parentName.trim()).equalsIgnoreCase(ihrisParentName.trim()))) {
+
+ System.out.println("* INFO: MIS-MATCH FOUND IN ["+dhisOrgUnitName+"("+ihrisOUName+")"+" ,"+parentName+"("+ihrisParentName+")"+"]");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+
+
+ }
+
+
+ String checkDistrict = "SELECT dhisid,ihrisid FROM district_mapping";
+
+ SqlRowSet checkDistrictSet = jdbcTemplate.queryForRowSet(checkDistrict);
+
+ while (checkDistrictSet.next()) {
+
+ int dhisID = checkDistrictSet.getInt(1);
+
+ String ihrisID = checkDistrictSet.getString(2);
+
+ String getIhrisDetailsQuery = "SELECT name,region FROM hippo_district WHERE id=" + "\"" + ihrisID + "\"";
+
+ SqlRowSet ihrisDetailSet = jdbcTemplate.queryForRowSet(getIhrisDetailsQuery);
+
+ String ihrisOUName = null;
+
+ String ihrisParentName = null;
+
+ while (ihrisDetailSet.next()) {
+ ihrisOUName = ihrisDetailSet.getString(1).trim();
+
+ String ihrisOUParentQuery = "SELECT name FROM hippo_region WHERE id=" + "\"" + ihrisDetailSet.getString(2) + "\"";
+
+ SqlRowSet ihrisParentDetailSet = jdbcTemplate.queryForRowSet(ihrisOUParentQuery);
+
+ while (ihrisParentDetailSet.next()) {
+ ihrisParentName = ihrisParentDetailSet.getString(1);
+ }
+ }
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if(organisationUnit==null || ihrisOUName==null || ihrisParentName ==null)
+ {
+ System.out.println("* INFO: REFERENCED ORG. UNIT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+
+ String dhisOrgUnitName = organisationUnit.getName();
+
+ OrganisationUnit organisationUnitParent = organisationUnit.getParent();
+
+ String parentName;
+
+ if(organisationUnitParent!=null){
+
+ parentName = organisationUnitParent.getName();
+
+ }
+ else{
+
+ System.out.println("* INFO: REFERENCED ORG. UNIT PARENT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+
+ }
+
+ if (!((dhisOrgUnitName.trim()).equalsIgnoreCase(ihrisOUName.trim()) && (parentName.trim()).equalsIgnoreCase(ihrisParentName.trim()))) {
+
+ System.out.println("* INFO: MIS-MATCH FOUND IN ["+dhisOrgUnitName+"("+ihrisOUName+")"+" ,"+parentName+"("+ihrisParentName+")"+"]");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+ }
+
+
+ String checkRegion = "SELECT dhisid,ihrisid FROM region_mapping";
+
+ SqlRowSet checkRegionSet = jdbcTemplate.queryForRowSet(checkRegion);
+
+ while (checkRegionSet.next()) {
+
+ int dhisID = checkRegionSet.getInt(1);
+
+ String ihrisID = checkRegionSet.getString(2);
+
+ String getIhrisDetailsQuery = "SELECT name,country FROM hippo_region WHERE id=" + "\"" + ihrisID + "\"";
+
+ SqlRowSet ihrisDetailSet = jdbcTemplate.queryForRowSet(getIhrisDetailsQuery);
+
+ String ihrisOUName = null;
+
+ String ihrisParentName = null;
+
+ while (ihrisDetailSet.next()) {
+ ihrisOUName = ihrisDetailSet.getString(1).trim();
+
+ String ihrisOUParentQuery = "SELECT name FROM hippo_country WHERE id=" + "\"" + ihrisDetailSet.getString(2) + "\"";
+
+ SqlRowSet ihrisParentDetailSet = jdbcTemplate.queryForRowSet(ihrisOUParentQuery);
+
+ while (ihrisParentDetailSet.next()) {
+ ihrisParentName = ihrisParentDetailSet.getString(1);
+ }
+ }
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if(organisationUnit==null || ihrisOUName==null || ihrisParentName ==null)
+ {
+ System.out.println("* INFO: REFERENCED ORG. UNIT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+
+ String dhisOrgUnitName = organisationUnit.getName();
+
+ OrganisationUnit organisationUnitParent = organisationUnit.getParent();
+
+ String parentName;
+
+ if(organisationUnitParent!=null){
+
+ parentName = organisationUnitParent.getName();
+
+ }
+ else{
+
+ System.out.println("* INFO: REFERENCED ORG. UNIT PARENT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+
+ }
+
+ if (!((dhisOrgUnitName.trim()).equalsIgnoreCase(ihrisOUName.trim()) && (parentName.trim()).equalsIgnoreCase(ihrisParentName.trim()))) {
+
+ System.out.println("* INFO: MIS-MATCH FOUND IN ["+dhisOrgUnitName+"("+ihrisOUName+")"+" ,"+parentName+"("+ihrisParentName+")"+"]");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+ }
+
+
+ String checkCountry = "SELECT dhisid,ihrisid FROM country_mapping";
+
+ SqlRowSet checkCountrySet = jdbcTemplate.queryForRowSet(checkCountry);
+
+ while (checkCountrySet.next()) {
+
+ int dhisID = checkCountrySet.getInt(1);
+
+ String ihrisID = checkCountrySet.getString(2);
+
+ String getIhrisDetailsQuery = "SELECT name FROM hippo_country WHERE id=" + "\"" + ihrisID + "\"";
+
+ SqlRowSet ihrisDetailSet = jdbcTemplate.queryForRowSet(getIhrisDetailsQuery);
+
+ String ihrisOUName = null;
+
+ while (ihrisDetailSet.next()) {
+ ihrisOUName = ihrisDetailSet.getString(1).trim();
+ }
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(dhisID);
+
+ if(organisationUnit==null || ihrisOUName==null)
+ {
+ System.out.println("* INFO: REFERENCED ORG. UNIT MISSING");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+
+ String dhisOrgUnitName = organisationUnit.getName();
+
+ if (!((dhisOrgUnitName.trim()).equalsIgnoreCase(ihrisOUName.trim()))) {
+
+ System.out.println("* INFO: MIS-MATCH FOUND IN ["+dhisOrgUnitName+"("+ihrisOUName+")"+"]");
+ deleteIhrisOrgTreeFromDhis();
+ return;
+ }
+ }
+
+
+ }
+
+ System.out.println("* NOTICE: IHRIS ORGANISATION UNIT SYNC PROCESS FINISHED @[" + new Date() + "]\n");
+ }
+
+
+ @Override
+ @Transactional
+ public void run()
+ {
+ checkForIhrisOrgTreeUpdate();
+ }
+}
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF'
=== added directory 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis'
=== added file 'local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.AggDataService" class="org.hisp.dhis.ihrissyncmanager.DefaultAggDataService">
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService"/>
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
+ <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService"/>
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.SyncIHRISOrgUnitService"
+ class="org.hisp.dhis.ihrissyncmanager.DefaultSyncIHRISOrgUnitService">
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.SynciHRISUserService"
+ class="org.hisp.dhis.ihrissyncmanager.DefaultSynciHRISUserService">
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="userService" ref="org.hisp.dhis.user.UserService"/>
+ <property name="passwordManager" ref="org.hisp.dhis.security.PasswordManager"/>
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+ </bean>
+
+
+ <bean id="ihrisDataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
+ <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+ <property name="url" value="jdbc:mysql://localhost:3306/ihris_manage"/>
+ <property name="username" value="root"/>
+ <property name="password" value="admin"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.scheduledtasks.SyncIHRISOrgTree"
+ class="org.hisp.dhis.ihrissyncmanager.scheduledtasks.SyncIHRISOrgTreeService">
+ <property name="dataSource" ref="ihrisDataSource"/>
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+ </bean>
+
+</beans>
=== modified file 'local/in/dhis-in-services/dhis-in-service-linelisting/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-linelisting/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-linelisting/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-linelisting</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-reports/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-reports</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-scheduler/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-scheduler/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-scheduler/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-scheduler</artifactId>
=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-in-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-survey</artifactId>
=== modified file 'local/in/dhis-in-services/pom.xml'
--- local/in/dhis-in-services/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-in-services/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-services</artifactId>
=== modified file 'local/in/dhis-mobile/dhis-service-mobile/pom.xml'
--- local/in/dhis-mobile/dhis-service-mobile/pom.xml 2013-03-14 08:01:14 +0000
+++ local/in/dhis-mobile/dhis-service-mobile/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-services</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-service-mobile</artifactId>
=== modified file 'local/in/dhis-mobile/dhis-web-mobile/pom.xml'
--- local/in/dhis-mobile/dhis-web-mobile/pom.xml 2013-03-14 08:01:14 +0000
+++ local/in/dhis-mobile/dhis-web-mobile/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-in-web-mobile</artifactId>
=== modified file 'local/in/dhis-mobile/pom.xml'
--- local/in/dhis-mobile/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-mobile/pom.xml 2013-03-25 05:08:43 +0000
@@ -5,7 +5,7 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-sms</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Mobile SMS Modules</name>
=== modified file 'local/in/dhis-mobile/smsclient/pom.xml'
--- local/in/dhis-mobile/smsclient/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-mobile/smsclient/pom.xml 2013-03-25 05:08:43 +0000
@@ -4,7 +4,7 @@
<groupId>org.hisp.dhis.ws</groupId>
<artifactId>smsclient</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
<packaging>war</packaging>
<name>smsclient</name>
=== modified file 'local/in/dhis-web-alert/pom.xml'
--- local/in/dhis-web-alert/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-alert/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-alert</artifactId>
=== modified file 'local/in/dhis-web-coldchain/pom.xml'
--- local/in/dhis-web-coldchain/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-coldchain/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<repositories>
<repository>
=== modified file 'local/in/dhis-web-dashboard/pom.xml'
--- local/in/dhis-web-dashboard/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-dashboard/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-dashboard</artifactId>
=== modified file 'local/in/dhis-web-dataentry-linelisting/pom.xml'
--- local/in/dhis-web-dataentry-linelisting/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-dataentry-linelisting/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-dataentry-national</artifactId>
=== modified file 'local/in/dhis-web-excelimport/pom.xml'
--- local/in/dhis-web-excelimport/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-excelimport/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-excelimport</artifactId>
=== added directory 'local/in/dhis-web-ihrissyncmanager'
=== added file 'local/in/dhis-web-ihrissyncmanager/pom.xml'
--- local/in/dhis-web-ihrissyncmanager/pom.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/pom.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,103 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web</artifactId>
+ <version>2.12-SNAPSHOT</version>
+ </parent>
+
+ <repositories>
+ <repository>
+ <id>fdvsolution.public</id>
+ <url>http://archiva.fdvs.com.ar/repository/public1/</url>
+ </repository>
+ </repositories>
+
+ <artifactId>dhis-web-ihrissyncmanager</artifactId>
+ <packaging>war</packaging>
+ <name>DHIS-IHRIS Synchronisation Management Service</name>
+
+ <build>
+ <finalName>>dhis-web-ihrissyncmanager</finalName>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <!-- DHIS -->
+
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-core</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web-commons</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web-commons-resources</artifactId>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-aggregationengine-default</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-external</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-system</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-service-ihrissyncmanager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- Other -->
+ <dependency>
+ <groupId>net.sourceforge.jexcelapi</groupId>
+ <artifactId>jxl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+
+ <!--Quartz framework-->
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ <version>2.1.5</version>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <rootDir>../../</rootDir>
+ </properties>
+
+</project>
=== added directory 'local/in/dhis-web-ihrissyncmanager/src'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java/org'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action'
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/DeleteAggDataElementAction.java'
--- local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/DeleteAggDataElementAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/DeleteAggDataElementAction.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,65 @@
+package org.hisp.dhis.ihrissyncmanager.action;
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.ihrissyncmanager.AggDataService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: Mohit
+ * Date: 15/9/12
+ * Time: 1:18 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DeleteAggDataElementAction implements Action {
+
+
+
+ //------------------------------------------------------------------------------------------------------
+ // Dependencies
+ //------------------------------------------------------------------------------------------------------
+
+ private AggDataService deleteAggDataService;
+
+ public void setDeleteAggDataService(AggDataService deleteAggDataService) {
+ this.deleteAggDataService = deleteAggDataService;
+ }
+
+
+ //------------------------------------------------------------------------------------------------------
+ // Web-Params
+ //------------------------------------------------------------------------------------------------------
+
+ private String dataElementName;
+
+ public void setDataElementName(String dataElementName) {
+ this.dataElementName = dataElementName;
+ }
+
+ //------------------------------------------------------------------------------------------------------
+ // Implementation
+ //------------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute() throws Exception {
+
+ System.out.println("=======================================================================================================================================================================");
+
+ System.out.println("* TEST Delete-DATAELEMENT ACTION [DataElement Name:"+dataElementName+"]");
+
+ System.out.println("=======================================================================================================================================================================");
+
+ deleteAggDataService.deleteAggDataElement(dataElementName);
+
+ return null;
+ }
+}
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/RecordAggDataElementAction.java'
--- local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/RecordAggDataElementAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/RecordAggDataElementAction.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,152 @@
+package org.hisp.dhis.ihrissyncmanager.action;
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.ihrissyncmanager.AggDataService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Gaurav<gaurav08021@xxxxxxxxx>, 8/27/12 [5:07 PM]
+ */
+public class RecordAggDataElementAction implements Action {
+
+
+ //------------------------------------------------------------------------------------------------------
+ // Dependencies
+ //------------------------------------------------------------------------------------------------------
+
+
+ private PeriodService periodService;
+
+ public void setPeriodService(PeriodService periodService) {
+ this.periodService = periodService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService(OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private AggDataService recordAggDataService;
+
+ public void setRecordAggDataService(AggDataService recordAggDataService)
+ {
+ this.recordAggDataService = recordAggDataService;
+ }
+
+ //------------------------------------------------------------------------------------------------------
+ // Web-Params
+ //------------------------------------------------------------------------------------------------------
+
+
+ private String DataElementName;
+
+ private String AggValue;
+
+ private String OrganisationUnitName;
+
+ private String PeriodStart;
+
+ private String PeriodTypeString;
+
+ public void setDataElementName(String dataElementName) {
+ DataElementName = dataElementName;
+ }
+
+ public void setAggValue(String aggValue) {
+ AggValue = aggValue;
+ }
+
+ public void setOrganisationUnitName(String organisationUnitName) {
+ OrganisationUnitName = organisationUnitName;
+ }
+
+ public void setPeriodStart(String periodStart) {
+ PeriodStart = periodStart;
+ }
+
+ public void setPeriodTypeString(String periodTypeString) {
+ PeriodTypeString = periodTypeString;
+ }
+
+ //------------------------------------------------------------------------------------------------------
+ // Implementation
+ //------------------------------------------------------------------------------------------------------
+
+
+ public Period getSelectedPeriod(Date startDate, PeriodType periodType) throws Exception {
+
+
+ List<Period> periods = new ArrayList<Period>(periodService.getPeriodsByPeriodType(periodType));
+ for (Period period : periods) {
+ Date tempDate = period.getStartDate();
+ if (tempDate.equals(startDate)) {
+ return period;
+ }
+ }
+
+ Period period = periodType.createPeriod(startDate);
+ period = reloadPeriodForceAdd(period);
+
+
+ return period;
+ }
+
+ private final Period reloadPeriod(Period period) {
+ return periodService.getPeriod(period.getStartDate(), period.getEndDate(), period.getPeriodType());
+ }
+
+ private final Period reloadPeriodForceAdd(Period period) {
+ Period storedPeriod = reloadPeriod(period);
+
+ if (storedPeriod == null) {
+
+ periodService.addPeriod(period);
+ return period;
+ }
+
+ return storedPeriod;
+ }
+
+ //------------------------------------------------------------------------------------------------------
+ // Action Implementation
+ //------------------------------------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+
+ PeriodType periodType = PeriodType.getPeriodTypeByName(PeriodTypeString);
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM dd,yyyy");
+
+ Date convertedStartDate = dateFormat.parse(PeriodStart);
+
+ Period period = getSelectedPeriod(convertedStartDate,periodType);
+
+ System.out.println("=======================================================================================================================================================================");
+
+ System.out.println("* TEST AGG-DATAELEMENT ACTION [Org. Unit:"+OrganisationUnitName+" ,DataElement Name:"+DataElementName+" ,Aggregate Value:"+AggValue+" ,Start Date:"+convertedStartDate+" ,PeriodType:"+PeriodTypeString+"]");
+
+ System.out.println("=======================================================================================================================================================================");
+
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnitByName(OrganisationUnitName);
+
+ if(orgUnit==null)
+ {
+ orgUnit = organisationUnitService.getOrganisationUnit(1);
+ }
+
+ recordAggDataService.addNewEntries(DataElementName,orgUnit,period,Double.parseDouble(AggValue));
+
+ return null;
+ }
+}
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/SynciHRISUserAction.java'
--- local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/SynciHRISUserAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/java/org/hisp/dhis/ihrissyncmanager/action/SynciHRISUserAction.java 2013-03-25 05:08:43 +0000
@@ -0,0 +1,77 @@
+package org.hisp.dhis.ihrissyncmanager.action;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: Mohit
+ * Date: 29/8/12
+ * Time: 3:01 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.ihrissyncmanager.SynciHRISUserService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+public class SynciHRISUserAction implements Action {
+
+ //------------------------------------------------------------------------------------------------------
+ // Dependencies
+ //------------------------------------------------------------------------------------------------------
+
+
+ private SynciHRISUserService synciHRISUserService;
+
+ public void setSynciHRISUserService(SynciHRISUserService synciHRISUserService) {
+ this.synciHRISUserService = synciHRISUserService;
+ }
+
+ //------------------------------------------------------------------------------------------------------
+ // Web-Params
+ //------------------------------------------------------------------------------------------------------
+
+ String ihrisUsername;
+ String firstName;
+
+ public void setIhrisUsername(String ihrisUsername) {
+ this.ihrisUsername = ihrisUsername;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ String lastName;
+ String email;
+ String password;
+
+ //------------------------------------------------------------------------------------------------------
+ // Action Implementation
+ //------------------------------------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+
+ System.out.println("=====================================================================================================================================");
+
+ System.out.println("* TEST ihris User ACTION [Username:"+ihrisUsername+" ,First Name:"+firstName+" ,Last Name:"+lastName+" , Email: "+email+", Password: "+password+"]");
+
+ System.out.println("======================================================================================================================================");
+
+ synciHRISUserService.createNewiHRISUser(ihrisUsername,firstName,lastName,email,password);
+
+ return null;
+ }
+}
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/resources'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis'
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/resources/META-INF/dhis/beans.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+
+ <bean id="org.hisp.dhis.organisationunit.OrganisationUnitService" class="org.hisp.dhis.organisationunit.DefaultOrganisationUnitService">
+ <property name="organisationUnitStore" ref="org.hisp.dhis.organisationunit.OrganisationUnitStore" />
+ <property name="organisationUnitLevelStore" ref="org.hisp.dhis.organisationunit.OrganisationUnitLevelStore" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="versionService" ref="org.hisp.dhis.version.VersionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.action.DeleteAggDataElementAction"
+ class="org.hisp.dhis.ihrissyncmanager.action.DeleteAggDataElementAction"
+ scope="prototype">
+ <property name="deleteAggDataService" ref="org.hisp.dhis.ihrissyncmanager.AggDataService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.ihrissyncmanager.action.RecordAggDataElementAction"
+ class="org.hisp.dhis.ihrissyncmanager.action.RecordAggDataElementAction"
+ scope="prototype">
+ <property name="recordAggDataService" ref="org.hisp.dhis.ihrissyncmanager.AggDataService"/>
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService"/>
+ </bean>
+
+</beans>
\ No newline at end of file
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/resources/struts.xml'
--- local/in/dhis-web-ihrissyncmanager/src/main/resources/struts.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/resources/struts.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE struts PUBLIC
+"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+"http://struts.apache.org/dtds/struts-2.0.dtd">
+<struts>
+<include file="dhis-web-commons.xml"/>
+
+<package name="dhis-web-ihrissyncmanager" extends="dhis-web-commons" namespace="/dhis-web-ihrissyncmanager">
+
+
+ <action name="recordAggDataElementAction" class="org.hisp.dhis.ihrissyncmanager.action.RecordAggDataElementAction"></action>
+
+ <action name="syncOrgUnitAction" class="org.hisp.dhis.ihrissyncmanager.action.SyncOrgUnitAction"></action>
+
+ <action name="deleteAggDataElementAction" class="org.hisp.dhis.ihrissyncmanager.action.DeleteAggDataElementAction"></action>
+
+</package>
+</struts>
\ No newline at end of file
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/webapp'
=== added directory 'local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF'
=== added file 'local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF/web.xml'
--- local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF/web.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-ihrissyncmanager/src/main/webapp/WEB-INF/web.xml 2013-03-25 05:08:43 +0000
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <display-name>DHIS IHRIS SYNC MANAGER</display-name>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath*:/META-INF/dhis/beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>automaticAccessType</param-name>
+ <param-value>ghostAdmin</param-value>
+ </context-param>
+ <filter>
+ <filter-name>RedirectFilter</filter-name>
+ <filter-class>org.hisp.dhis.servlet.filter.HttpRedirectFilter</filter-class>
+ <init-param>
+ <param-name>redirectPath</param-name>
+ <param-value>dhis-web-ihrissyncmanager</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>OpenSessionInViewFilter</filter-name>
+ <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
+ </filter>
+ <filter>
+ <filter-name>springSecurityFilterChain</filter-name>
+ <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+ </filter>
+ <filter>
+ <filter-name>Struts</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>RedirectFilter</filter-name>
+ <url-pattern>/</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>OpenSessionInViewFilter</filter-name>
+ <url-pattern>*.action</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>springSecurityFilterChain</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>Struts</filter-name>
+ <url-pattern>*.action</url-pattern>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <listener>
+ <listener-class>org.hisp.dhis.system.startup.StartupListener</listener-class>
+ </listener>
+
+</web-app>
=== modified file 'local/in/dhis-web-leprosy/pom.xml'
--- local/in/dhis-web-leprosy/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-leprosy/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-leprosy</artifactId>
=== modified file 'local/in/dhis-web-linelisting-in/pom.xml'
--- local/in/dhis-web-linelisting-in/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-linelisting-in/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-linelisting-in</artifactId>
=== modified file 'local/in/dhis-web-maintenance-in/pom.xml'
--- local/in/dhis-web-maintenance-in/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-maintenance-in/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-maintenance-in</artifactId>
=== modified file 'local/in/dhis-web-reports-in/pom.xml'
--- local/in/dhis-web-reports-in/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-reports-in/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-reports-in</artifactId>
=== modified file 'local/in/dhis-web-reports-national/pom.xml'
--- local/in/dhis-web-reports-national/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-reports-national/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-reports-national</artifactId>
=== modified file 'local/in/dhis-web-sandbox/pom.xml'
--- local/in/dhis-web-sandbox/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-sandbox/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-sandbox</artifactId>
=== modified file 'local/in/dhis-web-sandboxbk/pom.xml'
--- local/in/dhis-web-sandboxbk/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-sandboxbk/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-sandbox-bk</artifactId>
=== modified file 'local/in/dhis-web-survey/pom.xml'
--- local/in/dhis-web-survey/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-survey/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-survey</artifactId>
=== modified file 'local/in/dhis-web-validationrule-in/pom.xml'
--- local/in/dhis-web-validationrule-in/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/dhis-web-validationrule-in/pom.xml 2013-03-25 05:08:43 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-validationrule-in</artifactId>
=== modified file 'local/in/pom.xml'
--- local/in/pom.xml 2013-03-06 07:11:59 +0000
+++ local/in/pom.xml 2013-03-25 05:08:43 +0000
@@ -5,7 +5,7 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-local</artifactId>
- <version>2.11-SNAPSHOT</version>
+ <version>2.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Local India Modules</name>