dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20934
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9785: removed name/shortName uniqueness on report, dataDictionary, userGroup
------------------------------------------------------------
revno: 9785
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-12 13:55:14 +0700
message:
removed name/shortName uniqueness on report, dataDictionary, userGroup
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.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/user/DefaultUserGroupService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datadictionary/hibernate/DataDictionary.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datadictionary/DataDictionaryServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserGroupServiceTest.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataDictionaryImporter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ReportImporter.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/ValidateDataDictionaryAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataDictionaryForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataDictionaryForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserGroupForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.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/datadictionary/DataDictionaryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java 2012-01-22 08:05:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java 2013-02-12 06:55:14 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
@@ -73,7 +74,7 @@
* @param name the name of the DataDictionary.
* @return the DataDictionary.
*/
- DataDictionary getDataDictionaryByName( String name );
+ List<DataDictionary> getDataDictionaryByName( String name );
/**
* Deteles the DataDictionary.
@@ -87,13 +88,13 @@
*
* @return a collection of DataDictionaries.
*/
- Collection<DataDictionary> getAllDataDictionaries();
-
- Collection<DataElement> getDataElementsByDictionaryId( int dictionaryId );
-
- Collection<DataDictionary> getDataDictionarysBetween( int first, int max );
-
- Collection<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max );
+ List<DataDictionary> getAllDataDictionaries();
+
+ List<DataElement> getDataElementsByDictionaryId( int dictionaryId );
+
+ List<DataDictionary> getDataDictionarysBetween( int first, int max );
+
+ List<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max );
int getDataDictionaryCount();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2012-11-14 16:20:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2013-02-12 06:55:14 +0000
@@ -29,6 +29,7 @@
import java.io.OutputStream;
import java.util.Collection;
+import java.util.List;
import net.sf.jasperreports.engine.JasperPrint;
@@ -119,7 +120,7 @@
* @param max the maximum number of reports.
* @return a collection of reports.
*/
- Collection<Report> getReportsBetween( int first, int max );
+ List<Report> getReportsBetween( int first, int max );
/**
* Retrieves the given number of maximum reports starting at the given start
@@ -129,7 +130,7 @@
* @param max the maximum number of reports.
* @return a collection of reports.
*/
- Collection<Report> getReportsBetweenByName( String name, int first, int max );
+ List<Report> getReportsBetweenByName( String name, int first, int max );
/**
* Deletes a Report.
@@ -143,7 +144,7 @@
*
* @return a Collection of Reports.
*/
- Collection<Report> getAllReports();
+ List<Report> getAllReports();
/**
* Retrieves the Report with the given name.
@@ -151,7 +152,7 @@
* @param name the name.
* @return the Report.
*/
- Report getReportByName( String name );
+ List<Report> getReportByName( String name );
/**
* Retrieves all Reports with the given identifiers.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java 2012-12-27 19:01:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java 2013-02-12 06:55:14 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.List;
public interface UserGroupService
{
@@ -45,11 +46,11 @@
Collection<UserGroup> getAllUserGroups();
- UserGroup getUserGroupByName( String name );
-
- Collection<UserGroup> getUserGroupsBetween( int first, int max );
-
- Collection<UserGroup> getUserGroupsBetweenByName( String name, int first, int max );
+ List<UserGroup> getUserGroupByName( String name );
+
+ List<UserGroup> getUserGroupsBetween( int first, int max );
+
+ List<UserGroup> getUserGroupsBetweenByName( String name, int first, int max );
int getUserGroupCount();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java 2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java 2013-02-12 06:55:14 +0000
@@ -27,10 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
-import java.util.Collection;
-
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.i18n.I18nService;
@@ -38,6 +34,12 @@
import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
/**
* @author Lars Helge Overland
* @version $Id$
@@ -96,19 +98,19 @@
dataDictionaryStore.delete( dataDictionary );
}
- public DataDictionary getDataDictionaryByName( String name )
- {
- return i18n( i18nService, dataDictionaryStore.getByName( name ) );
- }
-
- public Collection<DataDictionary> getAllDataDictionaries()
- {
- return i18n( i18nService, dataDictionaryStore.getAll() );
- }
-
- public Collection<DataElement> getDataElementsByDictionaryId( int dictionaryId )
- {
- return i18n( i18nService, dataDictionaryStore.get( dictionaryId ).getDataElements() );
+ public List<DataDictionary> getDataDictionaryByName( String name )
+ {
+ return new ArrayList<DataDictionary>( i18n( i18nService, dataDictionaryStore.getAllEqName( name ) ) );
+ }
+
+ public List<DataDictionary> getAllDataDictionaries()
+ {
+ return new ArrayList<DataDictionary>( i18n( i18nService, dataDictionaryStore.getAll() ) );
+ }
+
+ public List<DataElement> getDataElementsByDictionaryId( int dictionaryId )
+ {
+ return new ArrayList<DataElement>( i18n( i18nService, dataDictionaryStore.get( dictionaryId ).getDataElements() ) );
}
public int getDataDictionaryCount()
@@ -121,13 +123,13 @@
return dataDictionaryStore.getCountLikeName( name );
}
- public Collection<DataDictionary> getDataDictionarysBetween( int first, int max )
+ public List<DataDictionary> getDataDictionarysBetween( int first, int max )
{
- return i18n( i18nService, dataDictionaryStore.getAllOrderedName( first, max ) );
+ return new ArrayList<DataDictionary>( i18n( i18nService, dataDictionaryStore.getAllOrderedName( first, max ) ) );
}
- public Collection<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max )
+ public List<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max )
{
- return i18n( i18nService, dataDictionaryStore.getAllLikeNameOrderedName( name, first, max ) );
+ return new ArrayList<DataDictionary>( i18n( i18nService, dataDictionaryStore.getAllLikeNameOrderedName( name, first, max ) ) );
}
}
=== 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-02-08 07:18:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-02-12 06:55:14 +0000
@@ -503,7 +503,6 @@
executeSql( "UPDATE userroleauthorities SET authority='F_USERGROUP_LIST' WHERE authority='F_USER_GRUP_LIST'" );
// update denominator of indicator which has indicatortype as 'number'
-
executeSql( "UPDATE indicator SET denominator = 1, denominatordescription = '' WHERE indicatortypeid IN (SELECT DISTINCT indicatortypeid FROM indicatortype WHERE indicatornumber = true) AND denominator IS NULL" );
// remove name/shortName uniqueness
@@ -518,6 +517,9 @@
executeSql( "ALTER TABLE dataset DROP CONSTRAINT dataset_shortname_key" );
executeSql( "ALTER TABLE document DROP CONSTRAINT document_name_key" );
executeSql( "ALTER TABLE reporttable DROP CONSTRAINT reporttable_name_key" );
+ executeSql( "ALTER TABLE report DROP CONSTRAINT report_name_key" );
+ executeSql( "ALTER TABLE usergroup DROP CONSTRAINT usergroup_name_key" );
+ executeSql( "ALTER TABLE datadictionary DROP CONSTRAINT datadictionary_name_key" );
log.info( "Tables updated" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java 2013-01-16 13:25:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java 2013-02-12 06:55:14 +0000
@@ -27,20 +27,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Collection;
+import java.util.List;
+
@Transactional
public class DefaultUserGroupService implements UserGroupService
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private GenericIdentifiableObjectStore<UserGroup> userGroupStore;
-
+
public void setUserGroupStore( GenericIdentifiableObjectStore<UserGroup> userGroupStore )
{
this.userGroupStore = userGroupStore;
@@ -68,7 +69,7 @@
userGroupStore.update( userGroup );
}
-
+
@Override
public Collection<UserGroup> getAllUserGroups()
{
@@ -88,9 +89,9 @@
}
@Override
- public UserGroup getUserGroupByName( String name )
+ public List<UserGroup> getUserGroupByName( String name )
{
- return userGroupStore.getByName( name );
+ return userGroupStore.getAllEqName( name );
}
@Override
@@ -106,13 +107,13 @@
}
@Override
- public Collection<UserGroup> getUserGroupsBetween( int first, int max )
+ public List<UserGroup> getUserGroupsBetween( int first, int max )
{
return userGroupStore.getAllOrderedName( first, max );
}
@Override
- public Collection<UserGroup> getUserGroupsBetweenByName( String name, int first, int max )
+ public List<UserGroup> getUserGroupsBetweenByName( String name, int first, int max )
{
return userGroupStore.getAllLikeNameOrderedName( name, first, max );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datadictionary/hibernate/DataDictionary.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datadictionary/hibernate/DataDictionary.hbm.xml 2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datadictionary/hibernate/DataDictionary.hbm.xml 2013-02-12 06:55:14 +0000
@@ -15,7 +15,7 @@
</id>
&identifiableProperties;
- <property name="name" column="name" not-null="true" unique="true" length="230" />
+ <property name="name" column="name" not-null="true" unique="false" length="230" />
<property name="description" type="text" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml 2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml 2013-02-12 06:55:14 +0000
@@ -13,7 +13,7 @@
</id>
&identifiableProperties;
- <property name="name" column="name" not-null="true" unique="true" length="230" />
+ <property name="name" column="name" not-null="true" unique="false" length="230" />
<set name="members" table="usergroupmembers">
<key column="usergroupid" foreign-key="fk_usergroupmembers_usergroupid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datadictionary/DataDictionaryServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datadictionary/DataDictionaryServiceTest.java 2012-11-20 17:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datadictionary/DataDictionaryServiceTest.java 2013-02-12 06:55:14 +0000
@@ -27,13 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
@@ -42,6 +35,11 @@
import org.hisp.dhis.indicator.IndicatorType;
import org.junit.Test;
+import java.util.Collection;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
/**
* @author Lars Helge Overland
* @version $Id$
@@ -50,18 +48,18 @@
extends DhisSpringTest
{
private DataDictionaryService dataDictionaryService;
-
+
private DataDictionary dataDictionaryA;
private DataDictionary dataDictionaryB;
-
+
private DataElement dataElementA;
private DataElement dataElementB;
private IndicatorType indicatorType;
-
+
private Indicator indicatorA;
private Indicator indicatorB;
-
+
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@@ -71,23 +69,23 @@
throws Exception
{
dataDictionaryService = (DataDictionaryService) getBean( DataDictionaryService.ID );
-
+
dataElementService = (DataElementService) getBean( DataElementService.ID );
indicatorService = (IndicatorService) getBean( IndicatorService.ID );
-
+
dataDictionaryA = createDataDictionary( 'A' );
dataDictionaryB = createDataDictionary( 'B' );
-
+
dataElementA = createDataElement( 'A' );
dataElementB = createDataElement( 'B' );
indicatorType = createIndicatorType( 'A' );
-
+
indicatorService.addIndicatorType( indicatorType );
-
+
indicatorA = createIndicator( 'A', indicatorType );
- indicatorB = createIndicator( 'B', indicatorType );
+ indicatorB = createIndicator( 'B', indicatorType );
}
// -------------------------------------------------------------------------
@@ -99,39 +97,39 @@
{
dataElementService.addDataElement( dataElementA );
dataElementService.addDataElement( dataElementB );
-
+
indicatorService.addIndicator( indicatorA );
indicatorService.addIndicator( indicatorB );
-
+
dataDictionaryA.getDataElements().add( dataElementA );
dataDictionaryA.getDataElements().add( dataElementB );
-
+
dataDictionaryA.getIndicators().add( indicatorA );
dataDictionaryA.getIndicators().add( indicatorB );
-
+
int id = dataDictionaryService.saveDataDictionary( dataDictionaryA );
-
+
dataDictionaryA = dataDictionaryService.getDataDictionary( id );
-
+
assertEquals( dataDictionaryA.getName(), "DataDictionaryA" );
assertEquals( dataDictionaryA.getDescription(), "DescriptionA" );
assertEquals( dataDictionaryA.getRegion(), "RegionA" );
assertEquals( dataDictionaryA.getDataElements().size(), 2 );
-
+
assertTrue( dataDictionaryA.getDataElements().contains( dataElementA ) );
assertTrue( dataDictionaryA.getDataElements().contains( dataElementB ) );
-
+
assertTrue( dataDictionaryA.getIndicators().contains( indicatorA ) );
assertTrue( dataDictionaryA.getIndicators().contains( indicatorB ) );
-
+
dataDictionaryA.setName( "DataDictionaryB" );
dataDictionaryA.setDescription( "DescriptionB" );
dataDictionaryA.setRegion( "RegionB" );
-
+
dataDictionaryService.saveDataDictionary( dataDictionaryA );
-
+
dataDictionaryA = dataDictionaryService.getDataDictionary( id );
-
+
assertEquals( dataDictionaryA.getName(), "DataDictionaryB" );
assertEquals( dataDictionaryA.getDescription(), "DescriptionB" );
assertEquals( dataDictionaryA.getRegion(), "RegionB" );
@@ -142,12 +140,13 @@
{
dataDictionaryService.saveDataDictionary( dataDictionaryA );
dataDictionaryService.saveDataDictionary( dataDictionaryB );
-
- dataDictionaryA = dataDictionaryService.getDataDictionaryByName( "DataDictionaryA" );
-
- assertNotNull( dataDictionaryA );
- assertEquals( dataDictionaryA.getName(), "DataDictionaryA" );
- assertEquals( dataDictionaryA.getDescription(), "DescriptionA" );
+
+ List<DataDictionary> dictionaryByName = dataDictionaryService.getDataDictionaryByName( "DataDictionaryA" );
+
+ assertFalse( dictionaryByName.isEmpty() );
+
+ assertEquals( dictionaryByName.get( 0 ).getName(), "DataDictionaryA" );
+ assertEquals( dictionaryByName.get( 0 ).getDescription(), "DescriptionA" );
}
@Test
@@ -155,10 +154,10 @@
{
int idA = dataDictionaryService.saveDataDictionary( dataDictionaryA );
int idB = dataDictionaryService.saveDataDictionary( dataDictionaryB );
-
+
assertNotNull( dataDictionaryService.getDataDictionary( idA ) );
assertNotNull( dataDictionaryService.getDataDictionary( idB ) );
-
+
dataDictionaryService.deleteDataDictionary( dataDictionaryA );
assertNull( dataDictionaryService.getDataDictionary( idA ) );
@@ -175,11 +174,11 @@
{
dataDictionaryService.saveDataDictionary( dataDictionaryA );
dataDictionaryService.saveDataDictionary( dataDictionaryB );
-
+
Collection<DataDictionary> dictionaries = dataDictionaryService.getAllDataDictionaries();
-
+
assertTrue( dictionaries.size() == 2 );
assertTrue( dictionaries.contains( dataDictionaryA ) );
- assertTrue( dictionaries.contains( dataDictionaryB ) );
+ assertTrue( dictionaries.contains( dataDictionaryB ) );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserGroupServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserGroupServiceTest.java 2012-11-20 17:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserGroupServiceTest.java 2013-02-12 06:55:14 +0000
@@ -27,18 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.DhisSpringTest;
-import org.junit.Test;
+import static org.junit.Assert.*;
/**
* @author Dang Duy Hieu
@@ -48,11 +45,11 @@
extends DhisSpringTest
{
private UserGroupService userGroupService;
-
+
private User user1;
- private User user2;
+ private User user2;
private User user3;
-
+
@Override
public void setUpTest()
throws Exception
@@ -63,7 +60,7 @@
user1 = createUser( 'A' );
user2 = createUser( 'B' );
user3 = createUser( 'C' );
-
+
userService.addUser( user1 );
userService.addUser( user2 );
userService.addUser( user3 );
@@ -112,7 +109,7 @@
userGroupService.addUserGroup( userGroup );
- userGroup = userGroupService.getUserGroupByName( "UserGroupA" );
+ userGroup = userGroupService.getUserGroupByName( "UserGroupA" ).get( 0 );
int id = userGroup.getId();
@@ -136,7 +133,7 @@
userGroupService.addUserGroup( userGroup );
- userGroup = userGroupService.getUserGroupByName( "UserGroupA" );
+ userGroup = userGroupService.getUserGroupByName( "UserGroupA" ).get( 0 );
int id = userGroup.getId();
@@ -163,7 +160,7 @@
public void testGetAllUserGroups()
{
List<UserGroup> userGroups = new ArrayList<UserGroup>();
-
+
Set<User> members = new HashSet<User>();
members.add( user1 );
@@ -171,22 +168,22 @@
UserGroup userGroupA = createUserGroup( 'A', members );
userGroups.add( userGroupA );
-
+
userGroupService.addUserGroup( userGroupA );
members = new HashSet<User>();
-
+
members.add( user1 );
members.add( user2 );
-
+
UserGroup userGroupB = createUserGroup( 'B', members );
userGroups.add( userGroupB );
-
+
userGroupService.addUserGroup( userGroupB );
-
+
assertEquals( userGroupService.getAllUserGroups(), userGroups );
}
-
+
@Test
public void testGetUserGroupById()
{
@@ -199,15 +196,15 @@
UserGroup userGroup = createUserGroup( 'A', members );
userGroupService.addUserGroup( userGroup );
-
- int id = userGroupService.getUserGroupByName( "UserGroupA" ).getId();
+
+ int id = userGroupService.getUserGroupByName( "UserGroupA" ).get( 0 ).getId();
userGroup = userGroupService.getUserGroup( id );
-
+
assertEq( 'A', userGroup );
assertNotNull( userGroup.getMembers() );
}
-
+
@Test
public void testGetUserGroupByName()
{
@@ -219,8 +216,8 @@
userGroupService.addUserGroup( userGroup );
- userGroup = userGroupService.getUserGroupByName( "UserGroupB" );
-
+ userGroup = userGroupService.getUserGroupByName( "UserGroupB" ).get( 0 );
+
assertEq( 'B', userGroup );
assertNotNull( userGroup.getMembers() );
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataDictionaryImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataDictionaryImporter.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataDictionaryImporter.java 2013-02-12 06:55:14 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.importexport.Importer;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
+import java.util.List;
+
/**
* @author Lars Helge Overland
* @version $Id$
@@ -47,25 +49,25 @@
public DataDictionaryImporter()
{
}
-
+
public DataDictionaryImporter( BatchHandler<DataDictionary> batchHandler, DataDictionaryService dataDictionaryService )
{
this.batchHandler = batchHandler;
this.dataDictionaryService = dataDictionaryService;
}
-
+
@Override
public void importObject( DataDictionary object, ImportParams params )
- {
+ {
NameMappingUtil.addDataDictionaryMapping( object.getId(), object.getName() );
-
- read( object, GroupMemberType.NONE, params );
+
+ read( object, GroupMemberType.NONE, params );
}
-
+
@Override
protected void importUnique( DataDictionary object )
{
- batchHandler.addObject( object );
+ batchHandler.addObject( object );
}
@Override
@@ -74,16 +76,15 @@
match.setName( object.getName() );
match.setDescription( object.getDescription() );
match.setRegion( object.getRegion() );
-
+
dataDictionaryService.saveDataDictionary( match );
}
@Override
protected DataDictionary getMatching( DataDictionary object )
{
- DataDictionary match = dataDictionaryService.getDataDictionaryByName( object.getName() );
-
- return match;
+ List<DataDictionary> dataDictionaryByName = dataDictionaryService.getDataDictionaryByName( object.getName() );
+ return dataDictionaryByName.isEmpty() ? null : dataDictionaryByName.get( 0 );
}
@Override
@@ -93,15 +94,15 @@
{
return false;
}
- if ( !isSimiliar( object.getDescription(), existing.getDescription() ) || ( isNotNull( object.getDescription(), existing.getDescription() ) && !object.getDescription().equals( existing.getDescription() ) ) )
- {
- return false;
- }
- if ( !isSimiliar( object.getRegion(), existing.getRegion() ) || ( isNotNull( object.getRegion(), existing.getRegion() ) && !object.getRegion().equals( existing.getRegion() ) ) )
- {
- return false;
- }
-
+ if ( !isSimiliar( object.getDescription(), existing.getDescription() ) || (isNotNull( object.getDescription(), existing.getDescription() ) && !object.getDescription().equals( existing.getDescription() )) )
+ {
+ return false;
+ }
+ if ( !isSimiliar( object.getRegion(), existing.getRegion() ) || (isNotNull( object.getRegion(), existing.getRegion() ) && !object.getRegion().equals( existing.getRegion() )) )
+ {
+ return false;
+ }
+
return true;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ReportImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ReportImporter.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ReportImporter.java 2013-02-12 06:55:14 +0000
@@ -33,6 +33,8 @@
import org.hisp.dhis.report.Report;
import org.hisp.dhis.report.ReportService;
+import java.util.List;
+
/**
* @author Lars Helge Overland
*/
@@ -40,16 +42,16 @@
extends AbstractImporter<Report> implements Importer<Report>
{
protected ReportService reportService;
-
+
public ReportImporter()
{
}
-
+
public ReportImporter( ReportService reportService )
{
this.reportService = reportService;
}
-
+
@Override
public void importObject( Report object, ImportParams params )
{
@@ -67,14 +69,15 @@
{
match.setName( match.getName() );
match.setDesignContent( object.getDesignContent() );
-
+
reportService.saveReport( match );
}
@Override
protected Report getMatching( Report object )
{
- return reportService.getReportByName( object.getName() );
+ List<Report> reportByName = reportService.getReportByName( object.getName() );
+ return reportByName.isEmpty() ? null : reportByName.get( 0 );
}
@Override
@@ -84,11 +87,11 @@
{
return false;
}
- if ( !isSimiliar( object.getDesignContent(), existing.getDesignContent() ) || ( isNotNull( object.getDesignContent(), existing.getDesignContent() ) && !object.getDesignContent().equals( existing.getDesignContent() ) ) )
+ if ( !isSimiliar( object.getDesignContent(), existing.getDesignContent() ) || (isNotNull( object.getDesignContent(), existing.getDesignContent() ) && !object.getDesignContent().equals( existing.getDesignContent() )) )
{
return false;
}
-
+
return true;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-02-12 06:55:14 +0000
@@ -35,6 +35,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.JasperCompileManager;
@@ -226,7 +227,7 @@
reportStore.delete( report );
}
- public Collection<Report> getAllReports()
+ public List<Report> getAllReports()
{
return reportStore.getAll();
}
@@ -254,20 +255,20 @@
}
@Override
- public Collection<Report> getReportsBetween( int first, int max )
+ public List<Report> getReportsBetween( int first, int max )
{
return reportStore.getAllOrderedName( first, max );
}
@Override
- public Collection<Report> getReportsBetweenByName( String name, int first, int max )
+ public List<Report> getReportsBetweenByName( String name, int first, int max )
{
return reportStore.getAllLikeNameOrderedName( name, first, max );
}
- public Report getReportByName( String name )
+ public List<Report> getReportByName( String name )
{
- return reportStore.getByName( name );
+ return reportStore.getAllEqName( name );
}
public Collection<Report> getReports( final Collection<Integer> identifiers )
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml 2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml 2013-02-12 06:55:14 +0000
@@ -15,7 +15,7 @@
</id>
&identifiableProperties;
- <property name="name" column="name" not-null="true" unique="true" length="230" />
+ <property name="name" column="name" not-null="true" unique="false" length="230" />
<property name="type" />
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/ValidateDataDictionaryAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/ValidateDataDictionaryAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/ValidateDataDictionaryAction.java 2013-02-12 06:55:14 +0000
@@ -27,12 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.i18n.I18n;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
* @version $Id$
@@ -96,7 +95,7 @@
if ( name != null )
{
- DataDictionary match = dataDictionaryService.getDataDictionaryByName( name );
+ DataDictionary match = dataDictionaryService.getDataDictionaryByName( name ).get( 0 );
if ( match != null && (id == null || match.getId() != id) )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataDictionaryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataDictionaryForm.js 2012-11-25 22:18:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataDictionaryForm.js 2013-02-12 06:55:14 +0000
@@ -28,5 +28,5 @@
'rules' : getValidationRules( "dataDictionary" )
} );
- checkValueIsExist( "name", "validateDataDictionary.action" );
+ // checkValueIsExist( "name", "validateDataDictionary.action" );
} );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataDictionaryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataDictionaryForm.vm 2012-10-17 11:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataDictionaryForm.vm 2013-02-12 06:55:14 +0000
@@ -43,7 +43,7 @@
}
});
- checkValueIsExist( "name", "validateDataDictionary.action", {id: $dataDictionary.id});
+ // checkValueIsExist( "name", "validateDataDictionary.action", {id: $dataDictionary.id});
});
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java 2013-02-12 06:55:14 +0000
@@ -27,12 +27,11 @@
* 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.user.UserGroup;
import org.hisp.dhis.user.UserGroupService;
-import com.opensymphony.xwork2.Action;
-
public class ValidateUserGroupAction
implements Action
{
@@ -89,7 +88,7 @@
if ( name != null )
{
- UserGroup match = userGroupService.getUserGroupByName( name );
+ UserGroup match = userGroupService.getUserGroupByName( name ).get( 0 );
if ( match != null && (id == null || match.getId() != id) )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserGroupForm.vm 2012-10-17 18:53:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserGroupForm.vm 2013-02-12 06:55:14 +0000
@@ -13,7 +13,7 @@
} );
/* remote validation */
- checkValueIsExist( "name", "validateUserGroup.action" );
+ // checkValueIsExist( "name", "validateUserGroup.action" );
jQuery("#availableUsersList").dhisAjaxSelect({
source: "../dhis-web-commons-ajax-json/getUsers.action",
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm 2012-10-17 18:53:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm 2013-02-12 06:55:14 +0000
@@ -26,9 +26,9 @@
});
/* remote validation */
- checkValueIsExist( "name", "validateUserGroup.action", {
+ /* checkValueIsExist( "name", "validateUserGroup.action", {
id : $group.id
- } );
+ } ); */
});
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java 2013-02-12 06:55:14 +0000
@@ -27,12 +27,11 @@
* 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.report.Report;
import org.hisp.dhis.report.ReportService;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
*/
@@ -109,14 +108,16 @@
return INPUT;
}
- Report match = reportService.getReportByName( name );
+ /*
+ Report match = reportService.getReportByName( name ).get( 0 );
- if ( match != null && ( id == null || match.getId() != id ) )
+ if ( match != null && (id == null || match.getId() != id) )
{
message = i18n.getString( "name_in_use" );
return INPUT;
}
+ */
}
message = i18n.getString( "ok" );