dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26742
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13217: minor fixes to object-bridge, allow deletion of sqlviews
------------------------------------------------------------
revno: 13217
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-13 10:58:21 +0100
message:
minor fixes to object-bridge, allow deletion of sqlviews
modified:
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/importers/DefaultIdentifiableObjectImporter.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.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/DefaultObjectBridge.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2013-12-12 16:34:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java 2013-12-13 09:58:21 +0000
@@ -278,7 +278,7 @@
manager.save( (IdentifiableObject) object );
}
- _updateInternalMaps( object );
+ _updateInternalMaps( object, false );
}
else
{
@@ -296,7 +296,7 @@
manager.update( (IdentifiableObject) object );
}
- _updateInternalMaps( object );
+ _updateInternalMaps( object, false );
}
else
{
@@ -315,7 +315,7 @@
manager.delete( (IdentifiableObject) object );
}
- // _updateInternalMaps( object );
+ _updateInternalMaps( object, true );
}
else
{
@@ -467,7 +467,7 @@
return objects;
}
- private <T> void _updateInternalMaps( T object )
+ private <T> void _updateInternalMaps( T object, boolean delete )
{
if ( IdentifiableObject.class.isInstance( object ) )
{
@@ -483,7 +483,20 @@
map = uidMap.get( identifiableObject.getClass().getSuperclass() );
}
- map.put( identifiableObject.getUid(), identifiableObject );
+ if ( !delete )
+ {
+ map.put( identifiableObject.getUid(), identifiableObject );
+ }
+ else
+ {
+ try
+ {
+ map.remove( identifiableObject.getUid() );
+ }
+ catch ( NullPointerException ignored )
+ {
+ }
+ }
}
if ( identifiableObject.getCode() != null )
@@ -496,7 +509,20 @@
map = codeMap.get( identifiableObject.getClass().getSuperclass() );
}
- map.put( identifiableObject.getCode(), identifiableObject );
+ if ( !delete )
+ {
+ map.put( identifiableObject.getCode(), identifiableObject );
+ }
+ else
+ {
+ try
+ {
+ map.remove( identifiableObject.getCode() );
+ }
+ catch ( NullPointerException ignored )
+ {
+ }
+ }
}
if ( (identifiableObject.haveUniqueNames() || identifiableObject.isAutoGenerated()) && identifiableObject.getName() != null )
@@ -509,7 +535,21 @@
map = nameMap.get( identifiableObject.getClass().getSuperclass() );
}
- map.put( identifiableObject.getName(), identifiableObject );
+ if ( !delete )
+ {
+ map.put( identifiableObject.getName(), identifiableObject );
+ }
+ else
+ {
+ try
+ {
+ map.remove( identifiableObject.getName() );
+ }
+ catch ( NullPointerException ignored )
+ {
+ }
+ }
+
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2013-12-12 16:34:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2013-12-13 09:58:21 +0000
@@ -38,7 +38,6 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.SharingUtils;
-import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataelement.DataElementOperandService;
import org.hisp.dhis.dataentryform.DataEntryForm;
@@ -55,10 +54,10 @@
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.system.util.CollectionUtils;
import org.hisp.dhis.system.util.ReflectionUtils;
import org.hisp.dhis.system.util.functional.Function1;
@@ -112,7 +111,7 @@
@Autowired
private SessionFactory sessionFactory;
- @Autowired(required = false)
+ @Autowired( required = false )
private List<ObjectHandler<T>> objectHandlers;
//-------------------------------------------------------------------------------------------------------
@@ -426,17 +425,6 @@
log.debug( "Trying to delete object => " + ImportUtils.getDisplayName( persistedObject ) + " (" + persistedObject.getClass().getSimpleName() + ")" );
- /*
- persistedObject.setUser( null );
- NonIdentifiableObjects nonIdentifiableObjects = new NonIdentifiableObjects();
- nonIdentifiableObjects.delete( persistedObject );
-
- Map<Field, Object> fields = detachFields( persistedObject );
- Map<Field, Collection<Object>> collectionFields = detachCollectionFields( persistedObject );
- */
-
- sessionFactory.getCurrentSession().flush();
-
try
{
objectBridge.deleteObject( persistedObject );
@@ -448,8 +436,6 @@
return false;
}
- sessionFactory.getCurrentSession().flush();
-
log.debug( "Delete successful." );
return true;
@@ -856,7 +842,7 @@
conflict = reportMoreThanOneConflict( object );
}
- if ( !OrganisationUnit.class.isAssignableFrom( object.getClass() ) )
+ if ( !SqlView.class.isAssignableFrom( object.getClass() ) )
{
conflict = new ImportConflict( "NoOrg", "no no no" );
}
=== 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 2013-10-08 17:16:47 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2013-12-13 09:58:21 +0000
@@ -88,6 +88,7 @@
import org.hisp.dhis.relationship.RelationshipType;
import org.hisp.dhis.report.Report;
import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.user.UserGroup;
@@ -125,21 +126,21 @@
public void deleteAttribute( Attribute attribute )
{
}
-
+
public String allowDeleteAttribute( Attribute attribute )
{
return null;
}
-
+
public void deleteAttributeValue( AttributeValue attributeValue )
{
}
-
+
public String allowDeleteAttributeValue( AttributeValue attributeValue )
{
return null;
}
-
+
public void deleteChart( Chart chart )
{
}
@@ -323,12 +324,12 @@
public void deleteRelativePeriods( RelativePeriods relativePeriods )
{
}
-
+
public String allowDeleteRelativePeriods( RelativePeriods relativePeriods )
{
return null;
}
-
+
public void deleteValidationRule( ValidationRule validationRule )
{
}
@@ -476,12 +477,12 @@
public void deleteMap( Map map )
{
}
-
+
public String allowDeleteMap( Map map )
{
return null;
}
-
+
public void deleteMapView( MapView mapView )
{
}
@@ -598,11 +599,11 @@
public void deleteProgramStage( ProgramStage programStage )
{
}
-
+
public void deleteProgramStageSection( ProgramStageSection programStageSection )
{
}
-
+
public String allowDeleteProgramStageSection( ProgramStageSection programStageSection )
{
return null;
@@ -661,7 +662,7 @@
public void deletePatientRegistrationForm( PatientRegistrationForm patientRegistrationForm )
{
}
-
+
public String allowDeleteConstant( Constant constant )
{
return null;
@@ -697,7 +698,7 @@
public void deleteLockException( LockException lockException )
{
}
-
+
public void deletePatientAudit( PatientAudit patientAudit )
{
}
@@ -706,22 +707,32 @@
{
return null;
}
-
+
public void deleteIntepretation( Interpretation interpretation )
{
}
-
+
public String allowDeleteInterpretation( Interpretation interpretation )
{
return null;
}
-
+
public void deleteI18nLocale( I18nLocale i18nLocale )
{
}
-
+
public String allowDeleteI18nLocale( I18nLocale i18nLocale )
- {
+ {
+ return null;
+ }
+
+ public void deleteSqlView( SqlView sqlView )
+ {
+
+ }
+
+ public String allowDeleteSqlView( SqlView sqlView )
+ {
return null;
}
}