dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23758
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11569: versioned optionSets, wip
------------------------------------------------------------
revno: 11569
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-05 15:23:16 +0700
message:
versioned optionSets, wip
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionSetAction.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2013-02-28 15:20:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2013-08-05 08:23:16 +0000
@@ -54,6 +54,11 @@
private List<String> options = new ArrayList<String>();
+ /**
+ * Indicating version number.
+ */
+ private Integer version = 1;
+
public OptionSet()
{
}
@@ -105,6 +110,18 @@
this.options = options;
}
+ @JsonProperty
+ @JacksonXmlProperty( localName = "version", namespace = DxfNamespaces.DXF_2_0 )
+ public Integer getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( Integer version )
+ {
+ this.version = version;
+ }
+
public static String optionEncode( String option )
{
return option != null ? ("[" + option.replaceAll( " ", "_" ) + "]") : null;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2013-05-31 04:56:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2013-08-05 08:23:16 +0000
@@ -27,15 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import org.hisp.dhis.i18n.I18nService;
+import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import org.hisp.dhis.i18n.I18nService;
-import org.springframework.transaction.annotation.Transactional;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
/**
* @author Lars Helge Overland
@@ -78,17 +78,17 @@
public OptionSet getOptionSet( int id )
{
- return i18n( i18nService, optionStore.get( id ));
+ return i18n( i18nService, optionStore.get( id ) );
}
public OptionSet getOptionSet( String uid )
{
- return i18n( i18nService, optionStore.getByUid( uid ));
+ return i18n( i18nService, optionStore.getByUid( uid ) );
}
public OptionSet getOptionSetByName( String name )
{
- return i18n( i18nService, optionStore.getByName( name ));
+ return i18n( i18nService, optionStore.getByName( name ) );
}
public void deleteOptionSet( OptionSet optionSet )
@@ -98,7 +98,7 @@
public Collection<OptionSet> getAllOptionSets()
{
- return i18n( i18nService, optionStore.getAll());
+ return i18n( i18nService, optionStore.getAll() );
}
public List<String> getOptions( int optionSetId, String key, Integer max )
@@ -122,7 +122,7 @@
return options;
}
-
+
public Integer getOptionSetsCountByName( String name )
{
return optionStore.getCountLikeName( name );
@@ -130,14 +130,14 @@
public Collection<OptionSet> getOptionSetsBetweenByName( String name, int first, int max )
{
- return new HashSet<OptionSet>( i18n( i18nService, optionStore.getAllLikeNameOrderedName( name, first, max ) ));
+ return new HashSet<OptionSet>( i18n( i18nService, optionStore.getAllLikeNameOrderedName( name, first, max ) ) );
}
public Collection<OptionSet> getOptionSetsBetween( int first, int max )
{
- return new HashSet<OptionSet>( i18n( i18nService, optionStore.getAllOrderedName( first, max ) ));
+ return new HashSet<OptionSet>( i18n( i18nService, optionStore.getAllOrderedName( first, max ) ) );
}
-
+
public Integer getOptionSetCount()
{
return optionStore.getCount();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-07-26 03:52:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-08-05 08:23:16 +0000
@@ -622,7 +622,9 @@
executeSql( "alter table validationrulegroup rename column validationgroupid to validationrulegroupid" );
executeSql( "alter table sqlview rename column viewid to sqlviewid" );
-
+
+ executeSql( "UPDATE optionset SET version=1 WHERE version IS NULL" );
+
log.info( "Tables updated" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml 2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml 2013-08-05 08:23:16 +0000
@@ -17,6 +17,8 @@
<property name="name" column="name" not-null="true" unique="true" length="230" />
+ <property name="version" />
+
<list name="options" table="optionsetmembers">
<cache usage="read-write" />
<key column="optionsetid" foreign-key="fk_optionsetmembers_optionsetid" />
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2012-02-08 04:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2013-08-05 08:23:16 +0000
@@ -27,16 +27,14 @@
package org.hisp.dhis.dataadmin.action.option;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import com.opensymphony.xwork2.Action;
+import java.util.List;
/**
* @author Chau Thu Tran
- *
* @version $AddOptionSetAction.java Feb 3, 2012 9:28:11 PM$
*/
public class AddOptionSetAction
@@ -56,10 +54,12 @@
private List<String> options;
+ private Integer version;
+
// -------------------------------------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------------------------------------
-
+
public void setOptionService( OptionService optionService )
{
this.optionService = optionService;
@@ -75,6 +75,11 @@
this.options = options;
}
+ public void setVersion( Integer version )
+ {
+ this.version = version;
+ }
+
// -------------------------------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------------------------------
@@ -83,11 +88,12 @@
public String execute()
throws Exception
{
- OptionSet optionSet = new OptionSet(name);
+ OptionSet optionSet = new OptionSet( name );
optionSet.setOptions( options );
-
+ optionSet.setVersion( 1 );
+
optionService.saveOptionSet( optionSet );
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetAction.java 2012-02-06 02:56:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetAction.java 2013-08-05 08:23:16 +0000
@@ -27,14 +27,12 @@
package org.hisp.dhis.dataadmin.action.option;
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Chau Thu Tran
- *
* @version $GetOptionSetAction.java Feb 3, 2012 9:28:11 PM$
*/
public class GetOptionSetAction
@@ -53,16 +51,16 @@
private Integer id;
private OptionSet optionSet;
-
+
// -------------------------------------------------------------------------------------------------
// Getters && Setters
// -------------------------------------------------------------------------------------------------
-
+
public void setOptionService( OptionService optionService )
{
this.optionService = optionService;
}
-
+
public OptionSet getOptionSet()
{
return optionSet;
@@ -82,7 +80,7 @@
throws Exception
{
optionSet = optionService.getOptionSet( id );
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetListAction.java 2013-05-31 05:52:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionSetListAction.java 2013-08-05 08:23:16 +0000
@@ -27,21 +27,20 @@
package org.hisp.dhis.dataadmin.action.option;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.paging.ActionPagingSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
/**
* @author Chau Thu Tran
- *
* @version $GetOptionSetListAction.java Feb 3, 2012 9:28:11 PM$
*/
public class GetOptionSetListAction
@@ -103,8 +102,8 @@
optionSets = new ArrayList<OptionSet>( optionService.getOptionSetsBetween( paging.getStartPos(), paging.getPageSize() ) );
}
- Collections.sort( optionSets, IdentifiableObjectNameComparator.INSTANCE );
-
+ Collections.sort( optionSets, IdentifiableObjectNameComparator.INSTANCE );
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionSetAction.java 2012-02-08 04:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionSetAction.java 2013-08-05 08:23:16 +0000
@@ -27,15 +27,13 @@
package org.hisp.dhis.dataadmin.action.option;
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.common.DeleteNotAllowedException;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.option.OptionService;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Chau Thu Tran
- *
* @version $RemoveOptionSetAction.java Feb 3, 2012 9:28:11 PM$
*/
public class RemoveOptionSetAction
@@ -52,11 +50,11 @@
// -------------------------------------------------------------------------------------------------
private Integer id;
-
+
private String message;
-
+
private I18n i18n;
-
+
// -------------------------------------------------------------------------------------------------
// Setters/Getters
// -------------------------------------------------------------------------------------------------
@@ -80,7 +78,7 @@
{
this.i18n = i18n;
}
-
+
// -------------------------------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2012-02-08 04:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2013-08-05 08:23:16 +0000
@@ -27,16 +27,14 @@
package org.hisp.dhis.dataadmin.action.option;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import com.opensymphony.xwork2.Action;
+import java.util.List;
/**
* @author Chau Thu Tran
- *
* @version $UpdateOptionSetAction.java Feb 3, 2012 9:28:11 PM$
*/
public class UpdateOptionSetAction
@@ -53,7 +51,7 @@
// -------------------------------------------------------------------------------------------------
private Integer id;
-
+
private String name;
private List<String> options;
@@ -61,12 +59,12 @@
// -------------------------------------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------------------------------------
-
+
public void setOptionService( OptionService optionService )
{
this.optionService = optionService;
}
-
+
public void setId( Integer id )
{
this.id = id;
@@ -92,10 +90,16 @@
{
OptionSet optionSet = optionService.getOptionSet( id );
optionSet.setName( name );
+
+ if ( !optionSet.getOptions().equals( options ) )
+ {
+ optionSet.setVersion( optionSet.getVersion() + 1 );
+ }
+
optionSet.setOptions( options );
-
+
optionService.updateOptionSet( optionSet );
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionSetAction.java 2012-02-08 04:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionSetAction.java 2013-08-05 08:23:16 +0000
@@ -27,15 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Chau Thu Tran
- *
* @version $ValidateOptionSetAction.java Feb 3, 2012 9:28:11 PM$
*/
public class ValidateOptionSetAction
@@ -45,9 +43,8 @@
// Dependencies
// -------------------------------------------------------------------------
- private OptionService optionService;
+ private OptionService optionService;
-
public void setOptionService( OptionService optionService )
{
this.optionService = optionService;