← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13266: Light, added interfaces for util classes mapped as spring beans

 

------------------------------------------------------------
revno: 13266
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-16 18:34:32 +0100
message:
  Light, added interfaces for util classes mapped as spring beans
added:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java
renamed:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java => dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java => dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtilsImpl.java
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtilsImpl.java


--
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
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2013-12-16 17:34:32 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.light.utils;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.datavalue.DeflatedDataValue;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+
+public interface FormUtils
+{
+    Map<String, DeflatedDataValue> getValidationViolations( OrganisationUnit organisationUnit,
+        Collection<DataElement> dataElements, Period period );
+    
+    List<String> getValidationRuleViolations( OrganisationUnit organisationUnit, DataSet dataSet, Period period );
+    
+    Map<String, String> getDataValueMap( OrganisationUnit organisationUnit, DataSet dataSet, Period period );
+    
+    List<OrganisationUnit> organisationUnitWithDataSetsFilter( Collection<OrganisationUnit> organisationUnits );
+    
+    List<OrganisationUnit> getSortedOrganisationUnitsForCurrentUser();
+    
+    List<DataSet> getDataSetsForCurrentUser( Integer organisationUnitId );
+    
+    List<Period> getPeriodsForDataSet( Integer dataSetId );
+    
+    List<Period> getPeriodsForDataSet( Integer dataSetId, int first, int max );
+}

=== renamed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java' => 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2013-12-16 17:25:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java	2013-12-16 17:34:32 +0000
@@ -1,5 +1,33 @@
 package org.hisp.dhis.light.utils;
 
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -40,7 +68,8 @@
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-public class FormUtils
+public class FormUtilsImpl
+    implements FormUtils
 {
     public static final Integer DEFAULT_MAX_PERIODS = 10;
 

=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java	2013-12-16 17:34:32 +0000
@@ -0,0 +1,51 @@
+package org.hisp.dhis.light.utils;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageInstance;
+
+public interface NamebasedUtils
+{
+    ProgramStage getProgramStage( int programId, int programStageId );
+    
+    String getTypeViolation( DataElement dataElement, String value );
+    
+    ProgramStageInstance getNextStage( Set<ProgramStageInstance> programStageInstances );
+    
+    List<org.hisp.dhis.api.mobile.model.DataElement> transformDataElementsToMobileModel( Integer programStageId );
+    
+    List<org.hisp.dhis.api.mobile.model.DataElement> transformDataElementsToMobileModel( List<ProgramStageDataElement> programStageDataElements );
+
+}

=== renamed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java' => 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtilsImpl.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java	2013-12-16 17:25:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtilsImpl.java	2013-12-16 17:34:32 +0000
@@ -43,13 +43,13 @@
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.system.util.MathUtils;
 
-public class NamebasedUtils
+public class NamebasedUtilsImpl
+    implements NamebasedUtils
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-
-    //private IProgramService IprgramService;   
+  
     private ProgramService programService;
 
     public void setProgramService( ProgramService programService )
@@ -66,7 +66,6 @@
     
     public ProgramStage getProgramStage( int programId, int programStageId )
     {
-        //Program program = programService.getProgram( programId, "" );
         Program program = programService.getProgram( programId );
 
         Collection<ProgramStage> stages = program.getProgramStages();
@@ -167,7 +166,7 @@
         return des;
     }
     
-    public List<org.hisp.dhis.api.mobile.model.DataElement> transformDataElementsToMobileModel( List<ProgramStageDataElement> programStageDataElements)
+    public List<org.hisp.dhis.api.mobile.model.DataElement> transformDataElementsToMobileModel( List<ProgramStageDataElement> programStageDataElements )
     {
         List<org.hisp.dhis.api.mobile.model.DataElement> des = new ArrayList<org.hisp.dhis.api.mobile.model.DataElement>();
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2013-12-16 17:21:39 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2013-12-16 17:34:32 +0000
@@ -3,6 +3,31 @@
   xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd";>
 
+    <!-- Utils / services -->
+
+    <bean id="org.hisp.dhis.light.utils.NamebasedUtils" class="org.hisp.dhis.light.utils.NamebasedUtilsImpl">
+        <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+        <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.light.dataentry.utils.FormUtils" class="org.hisp.dhis.light.utils.FormUtilsImpl">
+        <property name="organisationUnitService"
+            ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+        <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+        <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+        <property name="stdDevOutlierAnalysisService"
+            ref="org.hisp.dhis.dataanalysis.StdDevOutlierAnalysisService" />
+        <property name="minMaxOutlierAnalysisService"
+            ref="org.hisp.dhis.dataanalysis.MinMaxOutlierAnalysisService" />
+        <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
+        <property name="validationRuleService"
+            ref="org.hisp.dhis.validation.ValidationRuleService" />
+        <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
+    </bean>
+
+    <!-- Menu -->
+
 	<bean id="org.hisp.dhis.light.action.NoAction" class="org.hisp.dhis.light.action.NoAction"
 		scope="prototype" />
 
@@ -18,23 +43,6 @@
 	
 	<!-- Data entry -->
 
-	<bean id="org.hisp.dhis.light.dataentry.utils.FormUtils" class="org.hisp.dhis.light.utils.FormUtils"
-    scope="prototype">
-		<property name="organisationUnitService"
-			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
-		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-		<property name="stdDevOutlierAnalysisService"
-			ref="org.hisp.dhis.dataanalysis.StdDevOutlierAnalysisService" />
-		<property name="minMaxOutlierAnalysisService"
-			ref="org.hisp.dhis.dataanalysis.MinMaxOutlierAnalysisService" />
-		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
-		<property name="validationRuleService"
-			ref="org.hisp.dhis.validation.ValidationRuleService" />
-		<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
-	</bean>
-
 	<bean id="org.hisp.dhis.light.dataentry.action.GetOrganisationUnitsAction"
 		class="org.hisp.dhis.light.dataentry.action.GetOrganisationUnitsAction"
 		scope="prototype">
@@ -43,7 +51,8 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.light.dataentry.action.GetDataSetsAction"
-		class="org.hisp.dhis.light.dataentry.action.GetDataSetsAction" scope="prototype">
+		class="org.hisp.dhis.light.dataentry.action.GetDataSetsAction" 
+		scope="prototype">
 		<property name="formUtils"
 			ref="org.hisp.dhis.light.dataentry.utils.FormUtils" />
 		<property name="organisationUnitService"
@@ -51,7 +60,8 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.light.dataentry.action.GetPeriodsAction"
-		class="org.hisp.dhis.light.dataentry.action.GetPeriodsAction" scope="prototype">
+		class="org.hisp.dhis.light.dataentry.action.GetPeriodsAction" 
+		scope="prototype">
 		<property name="formUtils"
 			ref="org.hisp.dhis.light.dataentry.utils.FormUtils" />
 		<property name="organisationUnitService"
@@ -75,7 +85,8 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.light.dataentry.action.MarkComplete"
-		class="org.hisp.dhis.light.dataentry.action.MarkComplete" scope="prototype">
+		class="org.hisp.dhis.light.dataentry.action.MarkComplete" 
+		scope="prototype">
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
@@ -86,7 +97,8 @@
 	</bean>
 	
 	<bean id="org.hisp.dhis.light.dataentry.action.UndoCompleteAction"
-		class="org.hisp.dhis.light.dataentry.action.UndoCompleteAction" scope="prototype">
+		class="org.hisp.dhis.light.dataentry.action.UndoCompleteAction" 
+		scope="prototype">
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
@@ -193,11 +205,6 @@
 			ref="org.hisp.dhis.user.UserService"/>
 	</bean>
 
-	<bean id="org.hisp.dhis.light.utils.NamebasedUtils" class="org.hisp.dhis.light.utils.NamebasedUtils">
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-	</bean>
-
 	<bean
 		id="org.hisp.dhis.light.namebaseddataentry.action.SaveProgramStageFormAction"
 		class="org.hisp.dhis.light.namebaseddataentry.action.SaveProgramStageFormAction"
@@ -507,7 +514,8 @@
 	<!-- Settings -->
 
 	<bean id="org.hisp.dhis.light.settings.action.GetSettingsAction"
-		class="org.hisp.dhis.light.settings.action.GetSettingsAction" scope="prototype">
+		class="org.hisp.dhis.light.settings.action.GetSettingsAction" 
+		scope="prototype">
 		<property name="resourceBundleManager"
 			ref="org.hisp.dhis.i18n.resourcebundle.ResourceBundleManager" />
 		<property name="localeManager" ref="org.hisp.dhis.i18n.locale.LocaleManager" />
@@ -525,23 +533,27 @@
 	<!-- Messages -->
 
 	<bean id="org.hisp.dhis.light.message.action.GetMessagesAction"
-		class="org.hisp.dhis.light.message.action.GetMessagesAction" scope="prototype">
+		class="org.hisp.dhis.light.message.action.GetMessagesAction" 
+		scope="prototype">
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.light.message.action.GetMessageAction"
-		class="org.hisp.dhis.light.message.action.GetMessageAction" scope="prototype">
+		class="org.hisp.dhis.light.message.action.GetMessageAction" 
+		scope="prototype">
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.light.message.action.SendReplyAction"
-		class="org.hisp.dhis.light.message.action.SendReplyAction" scope="prototype">
+		class="org.hisp.dhis.light.message.action.SendReplyAction" 
+		scope="prototype">
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.light.message.action.SendFeedbackAction"
-		class="org.hisp.dhis.light.message.action.SendFeedbackAction" scope="prototype">
+		class="org.hisp.dhis.light.message.action.SendFeedbackAction" 
+		scope="prototype">
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>