dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11784
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3447: Merged DataSet and DataSetLock from using Source to OrganisationUnit
------------------------------------------------------------
revno: 3447
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-04-22 19:02:27 +0200
message:
Merged DataSet and DataSetLock from using Source to OrganisationUnit
removed:
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockTest.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLock.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLockService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
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-administration/src/main/java/org/hisp/dhis/datalock/DataSetLockDeletionHandler.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DefaultDataSetLockService.java
dhis-2/dhis-services/dhis-service-administration/src/main/resources/org/hisp/dhis/datalock/hibernate/DataSetLock.hbm.xml
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.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/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
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/test/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedAssociationEditorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedMultiAssociationsEditorAction.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/datalock/DataSetLock.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLock.java 2011-03-24 16:58:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLock.java 2011-04-22 17:02:27 +0000
@@ -31,8 +31,8 @@
import java.util.Set;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.source.Source;
/**
* @author Brajesh Murari
@@ -58,7 +58,7 @@
/**
* All Sources that are associated with DataSetLock.
*/
- private Set<Source> sources = new HashSet<Source>();
+ private Set<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
/**
* All DataSetLocks applied by users.
@@ -85,7 +85,7 @@
this.period = period;
}
- public DataSetLock( DataSet dataSet, Period period, Set<Source> sources )
+ public DataSetLock( DataSet dataSet, Period period, Set<OrganisationUnit> sources )
{
this.dataSet = dataSet;
this.period = period;
@@ -128,7 +128,7 @@
final DataSetLock other = (DataSetLock) o;
- return dataSet.equals( other.getDataSet() ) && period.equals( other.getPeriod() ) ;
+ return dataSet.equals( other.dataSet ) && period.equals( other.period );
}
@@ -167,12 +167,12 @@
this.period = period;
}
- public Set<Source> getSources()
+ public Set<OrganisationUnit> getSources()
{
return sources;
}
- public void setSources( Set<Source> sources )
+ public void setSources( Set<OrganisationUnit> sources )
{
this.sources = sources;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLockService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLockService.java 2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datalock/DataSetLockService.java 2011-04-22 17:02:27 +0000
@@ -30,8 +30,8 @@
import java.util.Set;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.source.Source;
/**
* @author Brajesh Murari
@@ -106,23 +106,23 @@
* @param dataSet, period, source The DataSetLock.
* @return The DataSetLock with the given DataSetLock.
*/
- DataSetLock getDataSetLockByDataSetPeriodAndSource( DataSet dataSet, Period period, Source source );
+ DataSetLock getDataSetLockByDataSetPeriodAndSource( DataSet dataSet, Period period, OrganisationUnit source );
/**
* Returns all DataSetLocks associated with the specified source.
*/
- Collection<DataSetLock> getDataSetLocksBySource( Source source );
+ Collection<DataSetLock> getDataSetLocksBySource( OrganisationUnit source );
/**
* Returns all DataSetLocks associated with the specified sources.
*/
- Collection<DataSetLock> getDataSetLocksBySources( Collection<? extends Source> sources );
+ Collection<DataSetLock> getDataSetLocksBySources( Collection<OrganisationUnit> sources );
/**
* Returns the number of Sources among the specified Sources associated with
* the specified DataSetLock.
*/
- int getSourcesAssociatedWithDataSetLock( DataSetLock dataSetLock, Collection<? extends Source> sources );
+ int getSourcesAssociatedWithDataSetLock( DataSetLock dataSetLock, Collection<OrganisationUnit> sources );
/**
* Get all DataSetLocks.
@@ -156,7 +156,7 @@
* @param selectedSources The selected organization unit from tree.
* @param userName The user name.
*/
- void applyCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods, Set<Source> selectedSources, String userName );
+ void applyCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods, Set<OrganisationUnit> selectedSources, String userName );
/**
* Remove lock from data sets.
@@ -166,6 +166,6 @@
* @param selectedSources The selected organization unit from tree.
* @param userName The user name.
*/
- void removeCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods, Set<Source> selectedSources, String userName );
+ void removeCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods, Set<OrganisationUnit> selectedSources, String userName );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-04-01 09:57:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-04-22 17:02:27 +0000
@@ -68,7 +68,7 @@
/**
* All Sources that register data with this DataSet.
*/
- private Set<Source> sources = new HashSet<Source>();
+ private Set<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
/**
* Property indicating whether the DataSet is locked for data entry.
@@ -236,12 +236,12 @@
this.compulsoryDataElementOperands = compulsoryDataElementOperands;
}
- public Set<Source> getSources()
+ public Set<OrganisationUnit> getSources()
{
return sources;
}
- public void setSources( Set<Source> sources )
+ public void setSources( Set<OrganisationUnit> sources )
{
this.sources = sources;
}
=== 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-04-10 13:48:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2011-04-22 17:02:27 +0000
@@ -31,8 +31,8 @@
import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
/**
* @author Lars Helge Overland
@@ -111,13 +111,13 @@
/**
* Returns all DataSets associated with the specified sources.
*/
- Collection<DataSet> getDataSetsBySources( Collection<? extends Source> sources );
+ Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources );
/**
* Returns the number of Sources among the specified Sources associated with
* the specified DataSet.
*/
- int getSourcesAssociatedWithDataSet( DataSet dataSet, Collection<? extends Source> sources );
+ int getSourcesAssociatedWithDataSet( DataSet dataSet, Collection<OrganisationUnit> sources );
/**
* Get all DataSets.
@@ -200,7 +200,7 @@
/**
* Returns all DataSets that can be collected through mobile (one organisation unit).
*/
- Collection<DataSet> getDataSetsForMobile(Source source);
+ Collection<DataSet> getDataSetsForMobile( OrganisationUnit source );
/**
* Returns all DataSets that can be collected through mobile (all organisation unit).
=== 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-04-10 13:48:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2011-04-22 17:02:27 +0000
@@ -29,8 +29,8 @@
import java.util.Collection;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
/**
* @author Kristian Nordal
@@ -125,11 +125,11 @@
/**
* Returns all DataSets that can be collected through mobile.
*/
- Collection<DataSet> getDataSetsForMobile(Source source);
+ Collection<DataSet> getDataSetsForMobile( OrganisationUnit source );
Collection<DataSet> getDataSetsForMobile();
- Collection<DataSet> getDataSetsBySources( Collection<? extends Source> sources );
+ Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources );
Collection<DataSet> getMobileDataSetsFromCategoryOption(int categoryOptionId);
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DataSetLockDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DataSetLockDeletionHandler.java 2010-02-10 18:04:44 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DataSetLockDeletionHandler.java 2011-04-22 17:02:27 +0000
@@ -28,8 +28,8 @@
*/
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.source.Source;
import org.hisp.dhis.system.deletion.DeletionHandler;
public class DataSetLockDeletionHandler
@@ -66,9 +66,9 @@
}
@Override
- public void deleteSource( Source source )
+ public void deleteOrganisationUnit( OrganisationUnit unit )
{
- for ( DataSetLock dataSetLock : dataSetLockService.getDataSetLocksBySource( source ) )
+ for ( DataSetLock dataSetLock : dataSetLockService.getDataSetLocksBySource( unit ) )
{
dataSetLockService.deleteDataSetLock( dataSetLock );
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DefaultDataSetLockService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DefaultDataSetLockService.java 2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/DefaultDataSetLockService.java 2011-04-22 17:02:27 +0000
@@ -33,8 +33,8 @@
import java.util.Set;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.source.Source;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -104,7 +104,7 @@
return dataSetLockStore.getDataSetLockByDataSetAndPeriod( dataSet, period );
}
- public DataSetLock getDataSetLockByDataSetPeriodAndSource( DataSet dataSet, Period period, Source source )
+ public DataSetLock getDataSetLockByDataSetPeriodAndSource( DataSet dataSet, Period period, OrganisationUnit source )
{
return dataSetLockStore.getDataSetLockByDataSetPeriodAndSource( dataSet, period, source );
}
@@ -126,16 +126,16 @@
return objects;
}
- public Collection<DataSetLock> getDataSetLocksBySource( Source source )
+ public Collection<DataSetLock> getDataSetLocksBySource( OrganisationUnit source )
{
return dataSetLockStore.getDataSetLocksBySource( source );
}
- public Collection<DataSetLock> getDataSetLocksBySources( Collection<? extends Source> sources )
+ public Collection<DataSetLock> getDataSetLocksBySources( Collection<OrganisationUnit> sources )
{
Set<DataSetLock> dataSetLocks = new HashSet<DataSetLock>();
- for ( Source source : sources )
+ for ( OrganisationUnit source : sources )
{
dataSetLocks.addAll( dataSetLockStore.getDataSetLocksBySource( source ) );
}
@@ -157,11 +157,11 @@
return dataSets;
}
- public int getSourcesAssociatedWithDataSetLock( DataSetLock dataSetLock, Collection<? extends Source> sources )
+ public int getSourcesAssociatedWithDataSetLock( DataSetLock dataSetLock, Collection<OrganisationUnit> sources )
{
int count = 0;
- for ( Source source : sources )
+ for ( OrganisationUnit source : sources )
{
if ( dataSetLock.getSources().contains( source ) )
{
@@ -173,12 +173,12 @@
}
public void applyCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods,
- Set<Source> selectedSources, String userName )
+ Set<OrganisationUnit> selectedSources, String userName )
{
for ( DataSet dataSet : dataSets )
{
- Set<Source> dataSetOrganisationUnits = dataSet.getSources();
- Set<Source> selOrgUnitSource = new HashSet<Source>();
+ Set<OrganisationUnit> dataSetOrganisationUnits = dataSet.getSources();
+ Set<OrganisationUnit> selOrgUnitSource = new HashSet<OrganisationUnit>();
selOrgUnitSource.addAll( selectedSources );
selOrgUnitSource.retainAll( dataSetOrganisationUnits );
@@ -188,7 +188,7 @@
DataSetLock dataSetLock = this.getDataSetLockByDataSetAndPeriod( dataSet, period );
if ( dataSetLock != null )
{
- Set<Source> lockedOrganisationUnitsSource = dataSetLock.getSources();
+ Set<OrganisationUnit> lockedOrganisationUnitsSource = dataSetLock.getSources();
selOrgUnitSource.removeAll( lockedOrganisationUnitsSource );
dataSetLock.getSources().addAll( selOrgUnitSource );
dataSetLock.setTimestamp( new Date() );
@@ -211,12 +211,12 @@
}
public void removeCollectiveDataLock( Collection<DataSet> dataSets, Collection<Period> periods,
- Set<Source> selectedSources, String userName )
+ Set<OrganisationUnit> selectedSources, String userName )
{
for ( DataSet dataSet : dataSets )
{
- Set<Source> dataSetOrganisationUnits = dataSet.getSources();
- Set<Source> selOrgUnitSource = new HashSet<Source>();
+ Set<OrganisationUnit> dataSetOrganisationUnits = dataSet.getSources();
+ Set<OrganisationUnit> selOrgUnitSource = new HashSet<OrganisationUnit>();
selOrgUnitSource.addAll( selectedSources );
selOrgUnitSource.retainAll( dataSetOrganisationUnits );
@@ -226,7 +226,7 @@
DataSetLock dataSetLock = this.getDataSetLockByDataSetAndPeriod( dataSet, period );
if ( dataSetLock != null )
{
- Set<Source> lockedOrganisationUnitsSource = dataSetLock.getSources();
+ Set<OrganisationUnit> lockedOrganisationUnitsSource = dataSetLock.getSources();
selOrgUnitSource.retainAll( lockedOrganisationUnitsSource );
dataSetLock.getSources().removeAll( selOrgUnitSource );
dataSetLock.setTimestamp( new Date() );
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/org/hisp/dhis/datalock/hibernate/DataSetLock.hbm.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/org/hisp/dhis/datalock/hibernate/DataSetLock.hbm.xml 2011-04-12 13:31:21 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/org/hisp/dhis/datalock/hibernate/DataSetLock.hbm.xml 2011-04-22 17:02:27 +0000
@@ -18,7 +18,7 @@
<set name="sources" table="datasetlocksource">
<key column="datasetlockid" />
- <many-to-many column="sourceid" class="org.hisp.dhis.source.Source" />
+ <many-to-many column="sourceid" class="org.hisp.dhis.organisationunit.OrganisationUnit" foreign-key="fk_datasetlock_organisationunit"/>
</set>
<property name="storedBy" column="storedby" length="31" />
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java 2010-10-11 10:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java 2011-04-22 17:02:27 +0000
@@ -31,17 +31,22 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
-import static org.junit.Assert.assertNotSame;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.source.Source;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
import org.junit.Test;
/**
@@ -49,20 +54,149 @@
* @version $Id$
*/
public class DataSetLockServiceTest
- extends DataSetLockTest
+ extends DhisSpringTest
{
+ protected DataSetLockService dataSetLockService;
+
+ protected DataSet dataSetA;
+
+ protected DataSet dataSetB;
+
+ protected DataSet dataSetC;
+
+ protected Period periodA;
+
+ protected Period periodB;
+
+ protected Period periodC;
+
+ protected Period periodD;
+
+ protected OrganisationUnit unitA;
+
+ protected OrganisationUnit unitB;
+
+ protected OrganisationUnit unitC;
+
+ protected OrganisationUnit unitD;
+
+ protected OrganisationUnit unitE;
+
+ protected OrganisationUnit unitF;
+
+ protected OrganisationUnit unitG;
+
+ protected OrganisationUnit unitH;
+
+ protected OrganisationUnit unitI;
+
+ protected String user1;
+
+ protected String user2;
+
+ protected String user3;
+
+ protected String user4;
+
+ protected String user5;
+
@Override
public void setUpTest()
throws Exception
{
- setUpDataSetLockTest();
+ dataSetService = (DataSetService) getBean( DataSetService.ID );
+
+ dataSetLockService = (DataSetLockService) getBean( DataSetLockService.ID );
+
+ periodService = (PeriodService) getBean( PeriodService.ID );
+
+ organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
+
+ // ---------------------------------------------------------------------
+ // Setup Periods
+ // ---------------------------------------------------------------------
+
+ Iterator<PeriodType> periodTypeIt = periodService.getAllPeriodTypes().iterator();
+ PeriodType periodTypeA = periodTypeIt.next(); // Daily
+ PeriodType periodTypeB = periodTypeIt.next(); // Weekly
+
+ Date mar01 = super.getDate( 2005, 3, 1 );
+ Date mar31 = super.getDate( 2005, 3, 31 );
+ Date apr01 = super.getDate( 2005, 4, 1 );
+ Date apr30 = super.getDate( 2005, 4, 30 );
+ Date may01 = super.getDate( 2005, 5, 1 );
+ Date may31 = super.getDate( 2005, 5, 31 );
+
+ periodA = super.createPeriod( periodTypeA, mar01, mar31 );
+ periodB = super.createPeriod( periodTypeA, apr01, apr30 );
+ periodC = super.createPeriod( periodTypeB, mar01, may31 );
+ periodD = super.createPeriod( periodTypeB, may01, may31 );
+
+ periodService.addPeriod( periodA );
+ periodService.addPeriod( periodB );
+ periodService.addPeriod( periodC );
+ periodService.addPeriod( periodD );
+
+ // ---------------------------------------------------------------------
+ // Setup DataSets
+ // ---------------------------------------------------------------------
+
+ dataSetA = super.createDataSet( 'A', periodTypeA );
+ dataSetB = super.createDataSet( 'B', periodTypeB );
+ dataSetC = super.createDataSet( 'C', periodTypeB );
+
+ dataSetService.addDataSet( dataSetA );
+ dataSetService.addDataSet( dataSetB );
+ dataSetService.addDataSet( dataSetC );
+
+ // ---------------------------------------------------------------------
+ // Setup OrganisationUnits
+ // ---------------------------------------------------------------------
+
+ unitA = super.createOrganisationUnit( 'A' );
+ unitB = super.createOrganisationUnit( 'B', unitA );
+ unitC = super.createOrganisationUnit( 'C', unitA );
+ unitD = super.createOrganisationUnit( 'D', unitB );
+ unitE = super.createOrganisationUnit( 'E', unitB );
+ unitF = super.createOrganisationUnit( 'F', unitB );
+ unitG = super.createOrganisationUnit( 'G', unitF );
+ unitH = super.createOrganisationUnit( 'H', unitF );
+ unitI = super.createOrganisationUnit( 'I' );
+
+ organisationUnitService.addOrganisationUnit( unitA );
+ organisationUnitService.addOrganisationUnit( unitB );
+ organisationUnitService.addOrganisationUnit( unitC );
+ organisationUnitService.addOrganisationUnit( unitD );
+ organisationUnitService.addOrganisationUnit( unitE );
+ organisationUnitService.addOrganisationUnit( unitF );
+ organisationUnitService.addOrganisationUnit( unitG );
+ organisationUnitService.addOrganisationUnit( unitH );
+ organisationUnitService.addOrganisationUnit( unitI );
+
+ // ---------------------------------------------------------------------
+ // Setup Users
+ // ---------------------------------------------------------------------
+
+ user1 = "admin";
+ user2 = "User2";
+ user3 = "User3";
+ user4 = "User4";
+ user5 = "User5";
}
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
- private void assertEq( DataSetLock dataSetLock, DataSet dataSet, Period period, Set<Source> sources )
+ public void initOrgunitSet( Set<OrganisationUnit> units, OrganisationUnit... sources )
+ {
+ for ( OrganisationUnit s : sources )
+ {
+ units.add( s );
+ }
+ }
+
+ private void assertEq( DataSetLock dataSetLock, DataSet dataSet, Period period, Set<OrganisationUnit> sources )
{
assertEquals( dataSet, dataSetLock.getDataSet() );
assertEquals( period, dataSetLock.getPeriod() );
@@ -76,7 +210,7 @@
@Test
public void testAddDataSetLock()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -109,7 +243,7 @@
@Test
public void testUpdateDataSetLock()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC );
DataSetLock dataSetLock = createDataSetLock( dataSetC, periodC, lockSources, user2, new Date() );
@@ -131,7 +265,7 @@
@Test
public void testDeleteAndGetDataSetLock()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -158,7 +292,7 @@
public void testGetDataSetLockByDataSet()
throws Exception
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAB = createDataSetLock( dataSetA, periodB, lockSources, user1, new Date() );
@@ -187,7 +321,7 @@
public void testGetDataSetLockByPeriod()
throws Exception
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAB = createDataSetLock( dataSetA, periodB, lockSources, user1, new Date() );
@@ -216,7 +350,7 @@
@Test
public void testGetAllDataSetLocks()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -244,7 +378,7 @@
@Test
public void testGetDataSetLocks()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -271,7 +405,7 @@
@Test
public void testGetDataSetLockByDataSetAndPeriod()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLock = createDataSetLock( dataSetA, periodB, lockSources, user1, new Date() );
@@ -287,7 +421,7 @@
@Test
public void testGetDataSetLockByDataSetPeriodAndSource()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -295,10 +429,7 @@
int idAA = dataSetLockService.addDataSetLock( dataSetLockAA );
dataSetLockAA = dataSetLockService.getDataSetLock( idAA );
- // assertSame( dataSetLockAA,
- // dataSetLockService.getDataSetLockByDataSetPeriodAndSource( dataSetA,
- // periodA, unitC ) );
- assertNull( dataSetLockService.getDataSetLockByDataSetPeriodAndSource( dataSetA, periodA, unitC ) );
+ assertNotNull( dataSetLockService.getDataSetLockByDataSetPeriodAndSource( dataSetA, periodA, unitC ) );
lockSources.add( unitI );
lockSources.remove( unitC );
@@ -311,7 +442,7 @@
@Test
public void testGetDataSetLocksBySource()
{
- Set<Source> lockSources = new HashSet<Source>();
+ Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
initOrgunitSet( lockSources, unitB, unitC, unitI );
DataSetLock dataSetLockAA = createDataSetLock( dataSetA, periodA, lockSources, user1, new Date() );
@@ -325,10 +456,9 @@
Collection<DataSetLock> dataSetLocks = new HashSet<DataSetLock>( dataSetLockService
.getDataSetLocksBySource( unitI ) );
- //assertEquals( 3, dataSetLocks.size() );
- assertNotSame( 3, dataSetLocks.size() );
- assertTrue( !dataSetLocks.contains( dataSetLockService.getDataSetLock( idAA ) ) );
- assertTrue( !dataSetLocks.contains( dataSetLockService.getDataSetLock( idBB ) ) );
- assertTrue( !dataSetLocks.contains( dataSetLockService.getDataSetLock( idCC ) ) );
+ assertEquals( 3, dataSetLocks.size() );
+ assertTrue( dataSetLocks.contains( dataSetLockService.getDataSetLock( idAA ) ) );
+ assertTrue( dataSetLocks.contains( dataSetLockService.getDataSetLock( idBB ) ) );
+ assertTrue( dataSetLocks.contains( dataSetLockService.getDataSetLock( idCC ) ) );
}
}
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockTest.java 2010-10-11 10:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockTest.java 1970-01-01 00:00:00 +0000
@@ -1,185 +0,0 @@
-package org.hisp.dhis.datalock;
-
-/*
- * Copyright (c) 2004-2008, 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.Date;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-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 org.hisp.dhis.source.Source;
-
-/**
- * @author Dang Duy Hieu
- * @version $Id$
- */
-public abstract class DataSetLockTest
- extends DhisSpringTest
-{
- protected DataSetLockService dataSetLockService;
-
- protected DataSet dataSetA;
-
- protected DataSet dataSetB;
-
- protected DataSet dataSetC;
-
- protected Period periodA;
-
- protected Period periodB;
-
- protected Period periodC;
-
- protected Period periodD;
-
- protected OrganisationUnit unitA;
-
- protected OrganisationUnit unitB;
-
- protected OrganisationUnit unitC;
-
- protected OrganisationUnit unitD;
-
- protected OrganisationUnit unitE;
-
- protected OrganisationUnit unitF;
-
- protected OrganisationUnit unitG;
-
- protected OrganisationUnit unitH;
-
- protected OrganisationUnit unitI;
-
- protected String user1;
-
- protected String user2;
-
- protected String user3;
-
- protected String user4;
-
- protected String user5;
-
- public void setUpDataSetLockTest()
- throws Exception
- {
- dataSetService = (DataSetService) getBean( DataSetService.ID );
-
- dataSetLockService = (DataSetLockService) getBean( DataSetLockService.ID );
-
- periodService = (PeriodService) getBean( PeriodService.ID );
-
- organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
- // ---------------------------------------------------------------------
- // Setup Periods
- // ---------------------------------------------------------------------
-
- Iterator<PeriodType> periodTypeIt = periodService.getAllPeriodTypes().iterator();
- PeriodType periodTypeA = periodTypeIt.next(); // Daily
- PeriodType periodTypeB = periodTypeIt.next(); // Weekly
-
- Date mar01 = super.getDate( 2005, 3, 1 );
- Date mar31 = super.getDate( 2005, 3, 31 );
- Date apr01 = super.getDate( 2005, 4, 1 );
- Date apr30 = super.getDate( 2005, 4, 30 );
- Date may01 = super.getDate( 2005, 5, 1 );
- Date may31 = super.getDate( 2005, 5, 31 );
-
- periodA = super.createPeriod( periodTypeA, mar01, mar31 );
- periodB = super.createPeriod( periodTypeA, apr01, apr30 );
- periodC = super.createPeriod( periodTypeB, mar01, may31 );
- periodD = super.createPeriod( periodTypeB, may01, may31 );
-
- periodService.addPeriod( periodA );
- periodService.addPeriod( periodB );
- periodService.addPeriod( periodC );
- periodService.addPeriod( periodD );
-
- // ---------------------------------------------------------------------
- // Setup DataSets
- // ---------------------------------------------------------------------
-
- dataSetA = super.createDataSet( 'A', periodTypeA );
- dataSetB = super.createDataSet( 'B', periodTypeB );
- dataSetC = super.createDataSet( 'C', periodTypeB );
-
- dataSetService.addDataSet( dataSetA );
- dataSetService.addDataSet( dataSetB );
- dataSetService.addDataSet( dataSetC );
-
- // ---------------------------------------------------------------------
- // Setup OrganisationUnits
- // ---------------------------------------------------------------------
-
- unitA = super.createOrganisationUnit( 'A' );
- unitB = super.createOrganisationUnit( 'B', unitA );
- unitC = super.createOrganisationUnit( 'C', unitA );
- unitD = super.createOrganisationUnit( 'D', unitB );
- unitE = super.createOrganisationUnit( 'E', unitB );
- unitF = super.createOrganisationUnit( 'F', unitB );
- unitG = super.createOrganisationUnit( 'G', unitF );
- unitH = super.createOrganisationUnit( 'H', unitF );
- unitI = super.createOrganisationUnit( 'I' );
-
- organisationUnitService.addOrganisationUnit( unitA );
- organisationUnitService.addOrganisationUnit( unitB );
- organisationUnitService.addOrganisationUnit( unitC );
- organisationUnitService.addOrganisationUnit( unitD );
- organisationUnitService.addOrganisationUnit( unitE );
- organisationUnitService.addOrganisationUnit( unitF );
- organisationUnitService.addOrganisationUnit( unitG );
- organisationUnitService.addOrganisationUnit( unitH );
- organisationUnitService.addOrganisationUnit( unitI );
-
- // ---------------------------------------------------------------------
- // Setup Users
- // ---------------------------------------------------------------------
-
- user1 = "admin";
- user2 = "User2";
- user3 = "User3";
- user4 = "User4";
- user5 = "User5";
- }
-
- public void initOrgunitSet( Set<Source> units, Source... sources )
- {
- for ( Source s : sources )
- {
- units.add( s );
- }
- }
-}
=== 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-04-19 14:37:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2011-04-22 17:02:27 +0000
@@ -41,8 +41,8 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
import org.hisp.dhis.system.util.AuditLogUtil;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
@@ -153,16 +153,16 @@
return i18n( i18nService, dataSetStore.getDataSetByCode( code ) );
}
- public Collection<DataSet> getDataSetsBySources( Collection<? extends Source> sources )
+ public Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources )
{
return i18n( i18nService, dataSetStore.getDataSetsBySources( sources ) );
}
- public int getSourcesAssociatedWithDataSet( DataSet dataSet, Collection<? extends Source> sources )
+ public int getSourcesAssociatedWithDataSet( DataSet dataSet, Collection<OrganisationUnit> sources )
{
int count = 0;
- for ( Source source : sources )
+ for ( OrganisationUnit source : sources )
{
if ( dataSet.getSources().contains( source ) )
{
@@ -283,7 +283,7 @@
return i18n( i18nService, dataSet.getDataElements() );
}
- public Collection<DataSet> getDataSetsForMobile(Source source)
+ public Collection<DataSet> getDataSetsForMobile( OrganisationUnit source )
{
return i18n( i18nService, dataSetStore.getDataSetsForMobile(source) );
}
=== 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-04-10 13:48:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2011-04-22 17:02:27 +0000
@@ -44,9 +44,9 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetStore;
import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
import org.hisp.dhis.system.util.ConversionUtils;
/**
@@ -180,16 +180,16 @@
}
@SuppressWarnings( "unchecked" )
- public Collection<DataSet> getDataSetsBySources( Collection<? extends Source> sources )
+ public Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources )
{
String hql = "select distinct d from DataSet d join d.sources s where s.id in (:ids)";
return sessionFactory.getCurrentSession().createQuery( hql )
- .setParameterList( "ids", ConversionUtils.getIdentifiers( Source.class, sources ) ).list();
+ .setParameterList( "ids", ConversionUtils.getIdentifiers( OrganisationUnit.class, sources ) ).list();
}
@SuppressWarnings( "unchecked" )
- public Collection<DataSet> getDataSetsForMobile( Source source )
+ public Collection<DataSet> getDataSetsForMobile( OrganisationUnit source )
{
String hql = "from DataSet d where :source in elements(d.sources) and d.mobile = true";
Query query = sessionFactory.getCurrentSession().createQuery( hql );
=== 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 2011-04-22 08:01:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2011-04-22 17:02:27 +0000
@@ -266,6 +266,11 @@
executeSql( "ALTER TABLE datamartexport DROP COLUMN individualmonthsthisyear" );
executeSql( "ALTER TABLE datamartexport DROP COLUMN individualquartersthisyear" );
+ // remove source
+
+ executeSql( "ALTER TABLE datasetsource DROP CONSTRAINT fk766ae2938fd8026a" );
+ executeSql( "ALTER TABLE datasetlocksource DROP CONSTRAINT fk582fdf7e8fd8026a" );
+
log.info( "Tables updated" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2011-02-10 23:09:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2011-04-22 17:02:27 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.source.Source;
@@ -173,7 +174,14 @@
{
Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
- Collection<DataSet> dataSets = dataSetService.getDataSetsBySources( sources );
+ Collection<OrganisationUnit> units = new HashSet<OrganisationUnit>(); //TODO fix
+
+ for ( Source source : sources )
+ {
+ units.add( (OrganisationUnit) source );
+ }
+
+ Collection<DataSet> dataSets = dataSetService.getDataSetsBySources( units );
Collection<DataElement> dataElements = dataElementService.getDataElementsByDataSets( dataSets );
=== 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 2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2011-04-22 17:02:27 +0000
@@ -22,7 +22,7 @@
<property name="code" unique="true" length="60" />
- <many-to-one name="periodType" class="org.hisp.dhis.period.PeriodType" lazy="false" column="periodtypeid"
+ <many-to-one name="periodType" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
not-null="true" foreign-key="fk_dataset_periodtypeid" />
<set name="dataElements" table="datasetmembers">
@@ -38,7 +38,7 @@
<set name="sources" table="datasetsource">
<key column="datasetid" />
- <many-to-many column="sourceid" class="org.hisp.dhis.source.Source" />
+ <many-to-many column="sourceid" class="org.hisp.dhis.organisationunit.OrganisationUnit" foreign-key="fk_dataset_organisationunit"/>
</set>
<set name="sections" order-by="sortorder" inverse="true" cascade="all">
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationServiceTest.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationServiceTest.java 2011-04-22 17:02:27 +0000
@@ -38,7 +38,7 @@
import java.util.Date;
import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.mock.MockSource;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -73,9 +73,9 @@
private Period periodA;
private Period periodB;
- private Source sourceA;
- private Source sourceB;
- private Source sourceC;
+ private OrganisationUnit sourceA;
+ private OrganisationUnit sourceB;
+ private OrganisationUnit sourceC;
private Date onTimeA;
private Date onTimeB;
@@ -99,9 +99,9 @@
sourceStore = (SourceStore) getBean( SourceStore.ID );
- sourceA = new MockSource( "SourceA" );
- sourceB = new MockSource( "SourceB" );
- sourceC = new MockSource( "SourceC" );
+ sourceA = createOrganisationUnit( 'A' );
+ sourceB = createOrganisationUnit( 'B' );
+ sourceC = createOrganisationUnit( 'C' );
sourceStore.addSource( sourceA );
sourceStore.addSource( sourceB );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java 2011-04-03 10:25:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java 2011-04-22 17:02:27 +0000
@@ -39,7 +39,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
import org.junit.Test;
/**
@@ -211,7 +210,7 @@
dataSetService.addDataSet( dataSetC );
dataSetService.addDataSet( dataSetD );
- Collection<Source> sources = new HashSet<Source>();
+ Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
sources.add( unitA );
sources.add( unitB );
@@ -222,7 +221,7 @@
assertTrue( dataSets.contains( dataSetB ) );
assertTrue( dataSets.contains( dataSetC ) );
- sources = new HashSet<Source>();
+ sources = new HashSet<OrganisationUnit>();
sources.add( unitA );
dataSets = dataSetService.getDataSetsBySources( sources );
@@ -263,7 +262,7 @@
dataSetService.addDataSet( dataSetA );
dataSetService.addDataSet( dataSetB );
- Collection<Source> sources = new HashSet<Source>();
+ Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
sources.add( sourceA );
sources.add( sourceB );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java 2011-04-12 11:04:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java 2011-04-22 17:02:27 +0000
@@ -39,7 +39,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.source.Source;
import org.junit.Test;
/**
@@ -103,7 +102,7 @@
dataSetStore.addDataSet( dataSetC );
dataSetStore.addDataSet( dataSetD );
- Collection<Source> sources = new HashSet<Source>();
+ Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
sources.add( unitA );
sources.add( unitB );
@@ -114,7 +113,7 @@
assertTrue( dataSets.contains( dataSetB ) );
assertTrue( dataSets.contains( dataSetC ) );
- sources = new HashSet<Source>();
+ sources = new HashSet<OrganisationUnit>();
sources.add( unitA );
dataSets = dataSetStore.getDataSetsBySources( sources );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java 2010-12-29 10:06:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java 2011-04-22 17:02:27 +0000
@@ -33,7 +33,10 @@
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.hisp.dhis.expression.Expression.SEPARATOR;
-import static org.hisp.dhis.expression.Operator.*;
+import static org.hisp.dhis.expression.Operator.equal_to;
+import static org.hisp.dhis.expression.Operator.greater_than;
+import static org.hisp.dhis.expression.Operator.less_than;
+import static org.hisp.dhis.expression.Operator.less_than_or_equal_to;
import java.util.ArrayList;
import java.util.Collection;
@@ -57,7 +60,7 @@
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
-import org.hisp.dhis.mock.MockSource;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -114,9 +117,9 @@
private Period periodB;
- private Source sourceA;
+ private OrganisationUnit sourceA;
- private Source sourceB;
+ private OrganisationUnit sourceB;
private Set<Source> sourcesA = new HashSet<Source>();
@@ -198,8 +201,8 @@
dataSet = createDataSet( 'A', periodType );
- sourceA = new MockSource( "SourceA" );
- sourceB = new MockSource( "SourceB" );
+ sourceA = createOrganisationUnit( 'A' );
+ sourceB = createOrganisationUnit( 'B' );
sourceA.getDataSets().add( dataSet );
sourceB.getDataSets().add( dataSet );
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2011-02-18 16:50:17 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2011-04-22 17:02:27 +0000
@@ -100,7 +100,6 @@
emptyTable( "orgunitgroupset" );
emptyTable( "orgunitgroupmembers" );
emptyTable( "orgunitgroup" );
- emptyTable( "organisationunit" );
emptyTable( "datadictionarydataelements" );
emptyTable( "datadictionaryindicators" );
@@ -133,6 +132,7 @@
emptyTable( "dataelementcategory" );
emptyTable( "dataelementcategoryoption" );
+ emptyTable( "organisationunit" );
emptyTable( "mocksource" );
emptyTable( "source" );
emptyTable( "period" );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2011-04-10 13:48:29 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2011-04-22 17:02:27 +0000
@@ -56,6 +56,7 @@
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.minmax.MinMaxDataElement;
import org.hisp.dhis.olap.OlapURL;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -335,6 +336,15 @@
return true;
}
+ public void deleteOrganisationUnit( OrganisationUnit unit )
+ {
+ }
+
+ public boolean allowDeleteOrganisationUnit( OrganisationUnit unit )
+ {
+ return true;
+ }
+
public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
{
}
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2011-03-30 16:14:30 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2011-04-22 17:02:27 +0000
@@ -972,7 +972,7 @@
*
* @return a dataSetLock instance
*/
- protected static DataSetLock createDataSetLock( DataSet dataSet, Period period, Set<Source> sources,
+ protected static DataSetLock createDataSetLock( DataSet dataSet, Period period, Set<OrganisationUnit> sources,
String storedBy, Date timestamp )
{
DataSetLock dataSetLock = new DataSetLock();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java 2010-10-07 09:39:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java 2011-04-22 17:02:27 +0000
@@ -36,11 +36,9 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.source.Source;
import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -82,13 +80,6 @@
this.dataSetService = dataSetService;
}
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
private DataSetLockService dataSetLockService;
public void setDataSetLockService( DataSetLockService dataSetLockService )
@@ -167,13 +158,10 @@
}
String currentUserName = currentUserService.getCurrentUsername();
- Collection<OrganisationUnit> selectedOrganisationUnits = new HashSet<OrganisationUnit>();
- Set<Source> selectedSources = new HashSet<Source>();
-
- selectedOrganisationUnits = selectionTreeManager.getSelectedOrganisationUnits();
- selectedSources = organisationUnitService.convert( selectedOrganisationUnits );
-
- this.executeCollectiveDataLock( selectedSources, currentUserName );
+
+ Collection<OrganisationUnit> selectedOrganisationUnits = selectionTreeManager.getSelectedOrganisationUnits();
+
+ this.executeCollectiveDataLock( new HashSet<OrganisationUnit>( selectedOrganisationUnits ), currentUserName );
return SUCCESS;
}
@@ -182,7 +170,7 @@
// Supportive methods
// -------------------------------------------------------------------------
- private void executeCollectiveDataLock( Set<Source> sources, String currentUserName )
+ private void executeCollectiveDataLock( Set<OrganisationUnit> sources, String currentUserName )
{
if ( selectBetweenLockUnlock )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-03-14 05:16:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-04-22 17:02:27 +0000
@@ -20,8 +20,6 @@
ref="org.hisp.dhis.period.PeriodService"/>
<property name="dataSetService"
ref="org.hisp.dhis.dataset.DataSetService"/>
- <property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
<property name="dataSetLockService"
ref="org.hisp.dhis.datalock.DataSetLockService"/>
<property name="currentUserService"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2010-09-29 07:05:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2011-04-22 17:02:27 +0000
@@ -36,7 +36,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.source.Source;
import com.opensymphony.xwork2.Action;
@@ -101,14 +100,14 @@
DataSet dataSet = dataSetService.getDataSet( dataSetId );
- Set<Source> assignedSources = dataSet.getSources();
+ Set<OrganisationUnit> assignedSources = dataSet.getSources();
assignedSources.removeAll( organisationUnitService.convert( unitsInTheTree ) );
Collection<OrganisationUnit> selectedOrganisationUnits = selectionTreeManager
.getReloadedSelectedOrganisationUnits();
- assignedSources.addAll( organisationUnitService.convert( selectedOrganisationUnits ) );
+ assignedSources.addAll( selectedOrganisationUnits );
dataSet.setSources( assignedSources );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedAssociationEditorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedAssociationEditorAction.java 2011-04-01 08:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedAssociationEditorAction.java 2011-04-22 17:02:27 +0000
@@ -30,8 +30,8 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.source.Source;
import com.opensymphony.xwork2.Action;
@@ -132,7 +132,7 @@
throws Exception
{
DataSet dataSet = dataSetService.getDataSet( dataSetId );
- Source source = organisationUnitService.getOrganisationUnit( orgUnitId );
+ OrganisationUnit source = organisationUnitService.getOrganisationUnit( orgUnitId );
title = SEPERATE + dataSet.getName() + SEPERATE + source.getName();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedMultiAssociationsEditorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedMultiAssociationsEditorAction.java 2011-04-01 08:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/DefinedMultiAssociationsEditorAction.java 2011-04-22 17:02:27 +0000
@@ -36,8 +36,8 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.source.Source;
import com.opensymphony.xwork2.Action;
@@ -91,7 +91,7 @@
private boolean checked;
- private Source source;
+ private OrganisationUnit source;
private List<MetaValue> metaItems = new ArrayList<MetaValue>();
@@ -140,7 +140,7 @@
return itemMaps;
}
- public Source getSource()
+ public OrganisationUnit getSource()
{
return source;
}