dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30512
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15481: removed dependency of ExchangeClasses in DefaultObjectBridge
------------------------------------------------------------
revno: 15481
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-05-31 14:59:54 +0200
message:
removed dependency of ExchangeClasses in DefaultObjectBridge
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
dhis-2/dhis-services/dhis-service-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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2014-05-30 15:30:58 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2014-05-31 12:59:54 +0000
@@ -70,8 +70,8 @@
// Dependencies
//-------------------------------------------------------------------------------------------------------
- @Autowired(required = false)
- private Set<Importer> importerClasses = new HashSet<Importer>();
+ @Autowired( required = false )
+ private Set<Importer> importerClasses = new HashSet<>();
@Autowired
private ObjectBridge objectBridge;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2014-05-28 16:54:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2014-05-31 12:59:54 +0000
@@ -28,14 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,6 +38,7 @@
import org.hisp.dhis.dxf2.timer.Timer;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.schema.Schema;
import org.hisp.dhis.schema.SchemaService;
import org.hisp.dhis.system.deletion.DeletionManager;
import org.hisp.dhis.user.User;
@@ -52,6 +46,15 @@
import org.hisp.dhis.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -83,7 +86,7 @@
// Internal and Semi-Public maps
//-------------------------------------------------------------------------------------------------------
- private static final List<Class<?>> registeredTypes = new ArrayList<Class<?>>();
+ private List<Class<?>> registeredTypes = Lists.newArrayList();
private HashMap<Class<?>, Set<?>> masterMap;
@@ -105,14 +108,15 @@
// Build maps
//-------------------------------------------------------------------------------------------------------
- static
+ @PostConstruct
+ public void postConstruct()
{
registeredTypes.add( PeriodType.class );
registeredTypes.add( UserCredentials.class );
- for ( Class<?> clazz : ExchangeClasses.getImportClasses() )
+ for ( Schema schema : schemaService.getMetadataSchemas() )
{
- registeredTypes.add( clazz );
+ registeredTypes.add( schema.getKlass() );
}
}
@@ -165,11 +169,11 @@
@SuppressWarnings( "unchecked" )
private void populateIdentifiableObjectMap( Class<?> clazz )
{
- Set<IdentifiableObject> map = new HashSet<IdentifiableObject>();
+ Set<IdentifiableObject> map = new HashSet<>();
if ( preheatCache && IdentifiableObject.class.isAssignableFrom( clazz ) )
{
- map = new HashSet<IdentifiableObject>( manager.getAll( (Class<IdentifiableObject>) clazz ) );
+ map = new HashSet<>( manager.getAll( (Class<IdentifiableObject>) clazz ) );
}
masterMap.put( clazz, map );
@@ -178,7 +182,7 @@
@SuppressWarnings( "unchecked" )
private void populateIdentifiableObjectMap( Class<?> clazz, IdentifiableObject.IdentifiableProperty property )
{
- Map<String, IdentifiableObject> map = new HashMap<String, IdentifiableObject>();
+ Map<String, IdentifiableObject> map = new HashMap<>();
if ( preheatCache && IdentifiableObject.class.isAssignableFrom( clazz ) )
{
@@ -226,10 +230,7 @@
}
}
}
- catch ( InstantiationException ignored )
- {
- }
- catch ( IllegalAccessException ignored )
+ catch ( InstantiationException | IllegalAccessException ignored )
{
}
}
@@ -239,7 +240,7 @@
private void populatePeriodTypeMap( Class<?> clazz )
{
- Collection<Object> periodTypes = new ArrayList<Object>();
+ Collection<Object> periodTypes = new ArrayList<>();
if ( PeriodType.class.isAssignableFrom( clazz ) )
{
@@ -250,7 +251,7 @@
}
}
- masterMap.put( clazz, new HashSet<Object>( periodTypes ) );
+ masterMap.put( clazz, new HashSet<>( periodTypes ) );
}
private void populateUsernameMap( Class<?> clazz )
@@ -339,7 +340,7 @@
}
else
{
- String objectName = null;
+ String objectName;
try
{
@@ -409,7 +410,7 @@
@SuppressWarnings( "unchecked" )
private <T> Set<T> _findMatches( T object )
{
- Set<T> objects = new HashSet<T>();
+ Set<T> objects = new HashSet<>();
if ( PeriodType.class.isInstance( object ) )
{