dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21058
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9871: Removed name/shortName matching in dxf2-importer. Minor change to PatientAttribute so that Jackso...
------------------------------------------------------------
revno: 9871
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-22 12:43:28 +0700
message:
Removed name/shortName matching in dxf2-importer. Minor change to PatientAttribute so that Jackson can read it in.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.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/patient/PatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-02-22 05:43:28 +0000
@@ -150,11 +150,6 @@
return inherit;
}
- public Boolean isGroupBy()
- {
- return groupBy;
- }
-
public void setGroupBy( Boolean groupBy )
{
this.groupBy = groupBy;
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2012-12-06 09:21:56 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2013-02-22 05:43:28 +0000
@@ -31,13 +31,17 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.common.NameableObject;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.period.PeriodType;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -63,8 +67,6 @@
private static final List<Class<?>> registeredTypes = new ArrayList<Class<?>>();
- private static final List<Class<?>> shortNameNotUnique = new ArrayList<Class<?>>();
-
private Map<Class<?>, Collection<?>> masterMap;
private Map<String, PeriodType> periodTypeMap;
@@ -73,10 +75,6 @@
private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> codeMap;
- private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> nameMap;
-
- private Map<Class<? extends NameableObject>, Map<String, NameableObject>> shortNameMap;
-
private boolean writeEnabled = true;
//-------------------------------------------------------------------------------------------------------
@@ -91,8 +89,6 @@
{
registeredTypes.add( clazz );
}
-
- shortNameNotUnique.add( OrganisationUnit.class );
}
@Override
@@ -104,8 +100,6 @@
periodTypeMap = new HashMap<String, PeriodType>();
uidMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
codeMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
- nameMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
- shortNameMap = new HashMap<Class<? extends NameableObject>, Map<String, NameableObject>>();
for ( Class<?> type : registeredTypes )
{
@@ -113,8 +107,6 @@
populateIdentifiableObjectMap( type );
populateIdentifiableObjectMap( type, IdentifiableObject.IdentifiableProperty.UID );
populateIdentifiableObjectMap( type, IdentifiableObject.IdentifiableProperty.CODE );
- populateIdentifiableObjectMap( type, IdentifiableObject.IdentifiableProperty.NAME );
- populateNameableObjectMap( type, NameableObject.NameableProperty.SHORT_NAME );
}
log.info( "Finished updating lookup maps at " + new Date() );
@@ -126,8 +118,6 @@
masterMap = null;
uidMap = null;
codeMap = null;
- nameMap = null;
- shortNameMap = null;
periodTypeMap = null;
writeEnabled = true;
@@ -137,7 +127,7 @@
// Populate Helpers
//-------------------------------------------------------------------------------------------------------
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private void populateIdentifiableObjectMap( Class<?> clazz )
{
Collection<IdentifiableObject> map = new ArrayList<IdentifiableObject>();
@@ -153,7 +143,7 @@
}
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private void populateIdentifiableObjectMap( Class<?> clazz, IdentifiableObject.IdentifiableProperty property )
{
Map<String, IdentifiableObject> map = new HashMap<String, IdentifiableObject>();
@@ -173,29 +163,6 @@
{
codeMap.put( (Class<? extends IdentifiableObject>) clazz, map );
}
- else if ( property == IdentifiableObject.IdentifiableProperty.NAME )
- {
- nameMap.put( (Class<? extends IdentifiableObject>) clazz, map );
- }
- }
- }
-
- @SuppressWarnings( "unchecked" )
- private void populateNameableObjectMap( Class<?> clazz, NameableObject.NameableProperty property )
- {
- Map<String, NameableObject> map = null;
-
- if ( NameableObject.class.isAssignableFrom( clazz ) )
- {
- map = (Map<String, NameableObject>) manager.getIdMap( (Class<? extends NameableObject>) clazz, property );
- }
-
- if ( map != null )
- {
- if ( property == NameableObject.NameableProperty.SHORT_NAME )
- {
- shortNameMap.put( (Class<? extends NameableObject>) clazz, map );
- }
}
}
@@ -296,7 +263,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public <T> Collection<T> getAllObjects( Class<T> clazz )
{
return (Collection<T>) masterMap.get( clazz );
@@ -328,7 +295,7 @@
// Internal Methods
//-------------------------------------------------------------------------------------------------------
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private <T> Collection<T> _findMatches( T object )
{
Collection<T> objects = new HashSet<T>();
@@ -367,31 +334,6 @@
objects.add( (T) match );
}
}
-
- if ( identifiableObject.getName() != null )
- {
- IdentifiableObject match = getNameMatch( identifiableObject );
-
- if ( match != null )
- {
- objects.add( (T) match );
- }
- }
- }
-
- if ( NameableObject.class.isInstance( object ) )
- {
- NameableObject nameableObject = (NameableObject) object;
-
- if ( _shortNameUnique( object ) && nameableObject.getShortName() != null )
- {
- IdentifiableObject match = getShortNameMatch( nameableObject );
-
- if ( match != null )
- {
- objects.add( (T) match );
- }
- }
}
return objects;
@@ -428,37 +370,6 @@
map.put( identifiableObject.getCode(), identifiableObject );
}
-
- if ( identifiableObject.getName() != null )
- {
- Map<String, IdentifiableObject> map = nameMap.get( identifiableObject.getClass() );
-
- if ( map == null )
- {
- // might be dynamically sub-classed by javassist or cglib, fetch superclass and try again
- map = nameMap.get( identifiableObject.getClass().getSuperclass() );
- }
-
- map.put( identifiableObject.getName(), identifiableObject );
- }
- }
-
- if ( NameableObject.class.isInstance( object ) )
- {
- NameableObject nameableObject = (NameableObject) object;
-
- if ( _shortNameUnique( object ) && nameableObject.getShortName() != null )
- {
- Map<String, NameableObject> map = shortNameMap.get( nameableObject.getClass() );
-
- if ( map == null )
- {
- // might be dynamically sub-classed by javassist or cglib, fetch superclass and try again
- map = shortNameMap.get( nameableObject.getClass().getSuperclass() );
- }
-
- map.put( nameableObject.getShortName(), nameableObject );
- }
}
}
@@ -486,30 +397,6 @@
return null;
}
- private IdentifiableObject getNameMatch( IdentifiableObject identifiableObject )
- {
- Map<String, IdentifiableObject> map = nameMap.get( identifiableObject.getClass() );
-
- if ( map != null )
- {
- return map.get( identifiableObject.getName() );
- }
-
- return null;
- }
-
- private NameableObject getShortNameMatch( NameableObject nameableObject )
- {
- Map<String, NameableObject> map = shortNameMap.get( nameableObject.getClass() );
-
- if ( map != null )
- {
- return map.get( nameableObject.getShortName() );
- }
-
- return null;
- }
-
private boolean _typeSupported( Class<?> clazz )
{
for ( Class<?> c : registeredTypes )
@@ -522,17 +409,4 @@
return false;
}
-
- private <T> boolean _shortNameUnique( T object )
- {
- for ( Class<?> clazz : shortNameNotUnique )
- {
- if ( clazz.isAssignableFrom( object.getClass() ) )
- {
- return false;
- }
- }
-
- return true;
- }
}