dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10362
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2848: Added uuid to DataSet, and methods to retrieve by uuid
------------------------------------------------------------
revno: 2848
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-02-15 12:06:28 +0530
message:
Added uuid to DataSet, and methods to retrieve by uuid
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetShortNamePopulator.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/AbstractStartupRoutine.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/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2011-01-25 19:26:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2011-02-15 06:36:28 +0000
@@ -77,6 +77,14 @@
DataSet getDataSet( int id );
/**
+ * Returns the DataSet with the given UUID.
+ *
+ * @param uuid the UUID.
+ * @return the DataSet with the given UUID, or null if no match.
+ */
+ DataSet getDataSet( String uuid );
+
+ /**
* Returns a DataSets with the given name.
*
* @param name The name.
@@ -278,4 +286,5 @@
Collection<DataSet> getDataSetsBetween(int first, int max );
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2011-01-25 19:26:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2011-02-15 06:36:28 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
+import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
@@ -75,6 +76,15 @@
DataSet getDataSet( int id );
/**
+ * Returns the DataSet with the given UUID.
+ *
+ * @param uuid the UUID.
+ * @return the DataSet with the given UUID, or null if no match.
+ */
+ DataSet getDataSet( String uuid );
+
+
+ /**
* Returns the DataSet with the given name.
*
* @param name The name.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetShortNamePopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetShortNamePopulator.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetShortNamePopulator.java 2011-02-15 06:36:28 +0000
@@ -33,6 +33,7 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.system.startup.AbstractStartupRoutine;
import org.hisp.dhis.system.util.TextUtils;
+import org.hisp.dhis.system.util.UUIdUtils;
/**
* @author Lars Helge Overland
@@ -83,6 +84,13 @@
changed = true;
}
+ if ( dataSet.getUuid() == null )
+ {
+ dataSet.setUuid( UUIdUtils.getUUId() );
+ log.info( "Adding uuid to dataset '" + dataSet.getName() + "'");
+ changed = true;
+ }
+
if ( changed )
{
try
@@ -91,13 +99,13 @@
}
catch ( Exception ex )
{
- log.warn( "Could not set short name or code of DataSet: '" + dataSet.getName()
+ log.warn( "Could not set short name, code or uuid of DataSet: '" + dataSet.getName()
+ "', please do it manually" );
}
}
}
- log.info( "Populated DataSet short name and code" );
+ log.info( "Populated DataSet short name, code and uuid" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2011-01-25 19:26:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2011-02-15 06:36:28 +0000
@@ -46,6 +46,7 @@
import org.hisp.dhis.system.util.AuditLogUtil;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
+import org.hisp.dhis.system.util.UUIdUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.springframework.transaction.annotation.Transactional;
@@ -90,6 +91,11 @@
public int addDataSet( DataSet dataSet )
{
+ if ( dataSet.getUuid() == null )
+ {
+ dataSet.setUuid( UUIdUtils.getUUId() );
+ }
+
int id = dataSetStore.addDataSet( dataSet );
i18nService.addObject( dataSet );
@@ -124,6 +130,13 @@
{
return i18n( i18nService, dataSetStore.getDataSet( id ) );
}
+
+ @Override
+ public DataSet getDataSet( String uuid )
+ {
+ return i18n( i18nService, dataSetStore.getDataSet( uuid ) );
+ }
+
public DataSet getDataSetByName( String name )
{
@@ -344,4 +357,5 @@
{
return dataSetStore.getDataSetsBetweenByName( name, first, max );
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2011-01-25 19:26:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2011-02-15 06:36:28 +0000
@@ -118,6 +118,17 @@
return (DataSet) session.get( DataSet.class, id );
}
+ public DataSet getDataSet( String uuid )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DataSet.class );
+ criteria.add( Restrictions.eq( "uuid", uuid ) );
+
+ return (DataSet) criteria.uniqueResult();
+ }
+
+
public DataSet getDataSetByName( String name )
{
Session session = sessionFactory.getCurrentSession();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-01-31 19:47:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-02-15 06:36:28 +0000
@@ -1166,7 +1166,6 @@
<property name="organisationUnitGroupService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="runlevel" value="5" />
- <property name="name" value="OrganisationUnitGroupSetPopulator" />
<property name="skipInTests" value="true" />
</bean>
@@ -1174,14 +1173,12 @@
<property name="categoryService"
ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="name" value="UuidPopulator" />
<property name="runlevel" value="5" />
<property name="skipInTests" value="true" />
</bean>
<bean id="org.hisp.dhis.dataset.DataSetShortNamePopulator" class="org.hisp.dhis.dataset.DataSetShortNamePopulator">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="name" value="DataSetShortNamePopulator" />
<property name="runlevel" value="5" />
<property name="skipInTests" value="true" />
</bean>
@@ -1190,7 +1187,6 @@
class="org.hisp.dhis.dataentryform.DataEntryFormPopulator">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="statementBuilder" ref="statementBuilder" />
- <property name="name" value="DataEntryFormPopulator" />
<property name="runlevel" value="5" />
<property name="skipInTests" value="true" />
</bean>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2011-02-15 06:36:28 +0000
@@ -9,6 +9,10 @@
<generator class="native"/>
</id>
+ <property name="uuid">
+ <column name="uuid" length="40"/>
+ </property>
+
<property name="name" not-null="true" unique="true" length="230"/>
<property name="shortName" unique="true" length="60"/>
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java 2011-02-02 17:56:01 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java 2011-02-15 06:36:28 +0000
@@ -59,6 +59,7 @@
private static final String FIELD_SHORT_NAME = "shortName";
private static final String FIELD_CODE = "code";
private static final String FIELD_PERIOD_TYPE = "periodType";
+ private static final String FIELD_UUID = "uuid";
// -------------------------------------------------------------------------
// Properties
@@ -150,6 +151,7 @@
dataSet.setName( values.get( FIELD_NAME ) );
dataSet.setShortName( values.get( FIELD_SHORT_NAME ) );
dataSet.setCode( values.get( FIELD_CODE ) );
+ dataSet.setUuid( values.get( FIELD_UUID) );
dataSet.getPeriodType().setId( periodTypeMapping.get( values.get( FIELD_PERIOD_TYPE ) ) );
importObject( dataSet, params );
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java 2010-12-23 11:56:44 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java 2011-02-15 06:36:28 +0000
@@ -90,6 +90,7 @@
protected void setColumns()
{
+ statementBuilder.setColumn( "uuid" );
statementBuilder.setColumn( "name" );
statementBuilder.setColumn( "shortName" );
statementBuilder.setColumn( "code" );
@@ -100,6 +101,7 @@
protected void setValues( DataSet dataSet )
{
+ statementBuilder.setValue( dataSet.getUuid() );
statementBuilder.setValue( dataSet.getName() );
statementBuilder.setValue( dataSet.getShortName() );
statementBuilder.setValue( dataSet.getCode() );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/AbstractStartupRoutine.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/AbstractStartupRoutine.java 2010-06-23 17:50:25 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/AbstractStartupRoutine.java 2011-02-15 06:36:28 +0000
@@ -37,21 +37,21 @@
public abstract class AbstractStartupRoutine
implements StartupRoutine
{
- private String name;
+ private String name = this.getClass().getSimpleName();
public void setName( String name )
{
this.name = name;
}
- private int runlevel;
+ private int runlevel = 0;
public void setRunlevel( int runlevel )
{
this.runlevel = runlevel;
}
- private boolean skipInTests;
+ private boolean skipInTests = false;
public void setSkipInTests( boolean skipInTests )
{