dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13823
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4541: Made update of organisation unit tree version more fine-grained
------------------------------------------------------------
revno: 4541
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-09-07 16:22:23 +0200
message:
Made update of organisation unit tree version more fine-grained
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/version/Version.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/DefaultVersionService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/hierarchy/MoveOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.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/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-09-02 12:06:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-09-07 14:22:23 +0000
@@ -307,4 +307,10 @@
void updateOrganisationUnits( Collection<OrganisationUnit> units );
Collection<OrganisationUnit> getOrganisationUnits( Boolean hasPatients );
+
+ // -------------------------------------------------------------------------
+ // Version
+ // -------------------------------------------------------------------------
+
+ void updateVersion();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/version/Version.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/version/Version.java 2011-08-11 11:31:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/version/Version.java 2011-09-07 14:22:23 +0000
@@ -38,6 +38,24 @@
private String value;
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public Version()
+ {
+ }
+
+ public Version( String key, String value )
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ // -------------------------------------------------------------------------
+ // hashCode and equals
+ // -------------------------------------------------------------------------
+
@Override
public int hashCode()
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-09-02 12:06:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-09-07 14:22:23 +0000
@@ -51,7 +51,6 @@
import org.hisp.dhis.system.util.UUIdUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import org.hisp.dhis.version.Version;
import org.hisp.dhis.version.VersionService;
import org.springframework.transaction.annotation.Transactional;
@@ -124,8 +123,6 @@
log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_EDIT,
OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
-
- updateVersion();
}
public void updateOrganisationUnit( OrganisationUnit organisationUnit, boolean updateHierarchy )
@@ -656,8 +653,6 @@
public void updateOrganisationUnits( Collection<OrganisationUnit> units )
{
organisationUnitStore.update( units );
-
- updateVersion();
}
@Override
@@ -666,24 +661,13 @@
return organisationUnitStore.get( hasPatients );
}
- private void updateVersion()
+ // -------------------------------------------------------------------------
+ // Version
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void updateVersion()
{
- String uuid = UUID.randomUUID().toString();
- Version orgUnitVersion = versionService.getVersionByKey( VersionService.ORGANISATIONUNIT_VERSION );
-
- if ( orgUnitVersion == null )
- {
- orgUnitVersion = new Version();
- orgUnitVersion.setKey( VersionService.ORGANISATIONUNIT_VERSION );
- orgUnitVersion.setValue( uuid );
-
- versionService.addVersion( orgUnitVersion );
- }
- else
- {
- orgUnitVersion.setValue( uuid );
- versionService.updateVersion( orgUnitVersion );
- }
+ versionService.updateVersion( VersionService.ORGANISATIONUNIT_VERSION, UUID.randomUUID().toString() );
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/DefaultVersionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/DefaultVersionService.java 2011-08-12 18:53:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/DefaultVersionService.java 2011-09-07 14:22:23 +0000
@@ -65,11 +65,16 @@
public void updateVersion( String key, String value )
{
Version version = getVersionByKey( key );
-
- if ( version != null )
+
+ if ( version == null )
+ {
+ version = new Version( key, value );
+ addVersion( version );
+ }
+ else
{
version.setValue( value );
- versionStore.update( version );
+ updateVersion( version );
}
}
@@ -96,5 +101,4 @@
{
return versionStore.getAll();
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/hierarchy/MoveOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/hierarchy/MoveOrganisationUnitAction.java 2011-06-13 12:50:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/hierarchy/MoveOrganisationUnitAction.java 2011-09-07 14:22:23 +0000
@@ -101,6 +101,8 @@
organisationUnitService.updateOrganisationUnit( unitToMove );
+ organisationUnitService.updateVersion();
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2011-05-30 14:56:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2011-09-07 14:22:23 +0000
@@ -251,8 +251,13 @@
// Update organisation unit
// ---------------------------------------------------------------------
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id.intValue() );
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id );
+ if ( !organisationUnit.getName().equals( name ) )
+ {
+ organisationUnitService.updateVersion();
+ }
+
organisationUnit.setName( name );
organisationUnit.setShortName( shortName );
organisationUnit.setCode( code );