← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6965: Minor bugfixes to importer. Also made importing sections work.

 

------------------------------------------------------------
revno: 6965
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-16 20:08:43 +0200
message:
  Minor bugfixes to importer. Also made importing sections work.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  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/ExportOptions.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java
  dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2012-04-21 11:45:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2012-05-16 18:08:43 +0000
@@ -108,7 +108,6 @@
     /**
      * The Sections associated with the DataSet.
      */
-    @Scanned
     private Set<Section> sections = new HashSet<Section>();
 
     /**

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2012-04-18 20:24:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2012-05-16 18:08:43 +0000
@@ -192,7 +192,7 @@
     // -------------------------------------------------------------------------
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public DataSet getDataSet()

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-04-20 18:31:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-05-16 18:08:43 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.*;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
@@ -198,6 +199,11 @@
             metaData.setOrganisationUnitGroupSets( new ArrayList<OrganisationUnitGroupSet>( manager.getAll( OrganisationUnitGroupSet.class ) ) );
         }
 
+        if ( exportOptions.isSections() )
+        {
+            metaData.setSections( new ArrayList<Section>( manager.getAll( Section.class ) ) );
+        }
+
         if ( exportOptions.isDataSets() )
         {
             metaData.setDataSets( new ArrayList<DataSet>( manager.getAll( DataSet.class ) ) );

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-05-16 16:25:19 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-05-16 18:08:43 +0000
@@ -101,7 +101,6 @@
         doImport( metaData.getOrganisationUnitLevels(), importOptions, importSummary );
         doImport( metaData.getOrganisationUnitGroups(), importOptions, importSummary );
         doImport( metaData.getOrganisationUnitGroupSets(), importOptions, importSummary );
-
         doImport( metaData.getUsers(), importOptions, importSummary );
         doImport( metaData.getUserGroups(), importOptions, importSummary );
         doImport( metaData.getUserAuthorityGroups(), importOptions, importSummary );
@@ -126,6 +125,7 @@
         doImport( metaData.getIndicatorGroups(), importOptions, importSummary );
         doImport( metaData.getIndicatorGroupSets(), importOptions, importSummary );
 
+/*
         doImport( metaData.getMaps(), importOptions, importSummary );
         doImport( metaData.getMapLegends(), importOptions, importSummary );
         doImport( metaData.getMapLegendSets(), importOptions, importSummary );
@@ -140,8 +140,10 @@
         doImport( metaData.getReports(), importOptions, importSummary );
         doImport( metaData.getReportTables(), importOptions, importSummary );
         doImport( metaData.getCharts(), importOptions, importSummary );
+*/
 
         doImport( metaData.getDataSets(), importOptions, importSummary );
+        doImport( metaData.getSections(), importOptions, importSummary );
 
         if ( importOptions.isDryRun() )
         {

=== 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-05-16 09:54:13 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2012-05-16 18:08:43 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.*;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
@@ -153,6 +154,7 @@
         registeredTypes.add( ValidationRuleGroup.class );
 
         registeredTypes.add( DataSet.class );
+        registeredTypes.add( Section.class );
 
         registeredTypes.add( MapView.class );
         registeredTypes.add( MapLayer.class );

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportOptions.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportOptions.java	2012-04-25 13:46:05 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportOptions.java	2012-05-16 18:08:43 +0000
@@ -95,6 +95,8 @@
 
     private boolean dataSets = true;
 
+    private boolean sections = true;
+
     private boolean validationRules = true;
 
     private boolean validationRuleGroups = true;
@@ -355,6 +357,16 @@
         this.dataSets = dataSets;
     }
 
+    public boolean isSections()
+    {
+        return sections;
+    }
+
+    public void setSections( boolean sections )
+    {
+        this.sections = sections;
+    }
+
     public boolean isValidationRules()
     {
         return validationRules;

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	2012-04-20 18:31:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	2012-05-16 18:08:43 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.*;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
@@ -142,6 +143,8 @@
 
     private List<DataDictionary> dataDictionaries = new ArrayList<DataDictionary>();
 
+    private List<Section> sections = new ArrayList<Section>(  );
+
     private List<DataSet> dataSets = new ArrayList<DataSet>();
 
     public MetaData()
@@ -435,6 +438,19 @@
     }
 
     @JsonProperty
+    @JacksonXmlElementWrapper( localName = "sections", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "section", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Section> getSections()
+    {
+        return sections;
+    }
+
+    public void setSections( List<Section> sections )
+    {
+        this.sections = sections;
+    }
+
+    @JsonProperty
     @JacksonXmlElementWrapper( localName = "dataSets", namespace = Dxf2Namespace.NAMESPACE )
     @JacksonXmlProperty( localName = "dataSet", namespace = Dxf2Namespace.NAMESPACE )
     public List<DataSet> getDataSets()
@@ -642,6 +658,7 @@
             ", organisationUnitGroups=" + organisationUnitGroups.size() +
             ", organisationUnitGroupSets=" + organisationUnitGroupSets.size() +
             ", organisationUnitLevels=" + organisationUnitLevels.size() +
+            ", sections=" + sections.size() +
             ", dataSets=" + dataSets.size() +
             ", validationRules=" + validationRules.size() +
             ", validationRuleGroups=" + validationRuleGroups.size() +

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-05-16 16:25:19 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-05-16 18:08:43 +0000
@@ -487,13 +487,14 @@
                 // FIXME special case, possible forward reference.. so just skip it..
                 if ( !OrganisationUnitGroupSet.class.isInstance( idObject ) )
                 {
-                    log.warn( "Ignored reference " + idObject + " on object " + identifiableObject + "." );
-
-                    ImportConflict importConflict = new ImportConflict( getDisplayName( identifiableObject ),
-                        "Unknown reference to " + idObject + " on field " + field.getName() + ", reference has been discarded." );
-
-                    importConflicts.add( importConflict );
                 }
+
+                log.warn( "Ignored reference " + idObject + " (" + idObject.getClass() + ") " + " on object " + identifiableObject + "." );
+
+                ImportConflict importConflict = new ImportConflict( getDisplayName( identifiableObject ),
+                    "Unknown reference to " + idObject + " (" + idObject.getClass() + ") " + " on field " + field.getName() + ", reference has been discarded." );
+
+                importConflicts.add( importConflict );
             }
         }
 
@@ -562,10 +563,10 @@
                 }
                 else
                 {
-                    log.warn( "Ignored reference " + idObject + " on object " + identifiableObject + "." );
+                    log.warn( "Ignored reference " + idObject + " (" + idObject.getClass() + ") " + " on object " + identifiableObject + "." );
 
                     ImportConflict importConflict = new ImportConflict( getDisplayName( identifiableObject ),
-                        "Unknown reference to " + idObject + " on field " + field.getName() + ", reference has been discarded." );
+                        "Unknown reference to " + idObject + " (" + idObject.getClass() + ") " + " on field " + field.getName() + ", reference has been discarded." );
 
                     importConflicts.add( importConflict );
                 }

=== modified file 'dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml	2012-04-23 09:49:08 +0000
+++ dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml	2012-05-16 18:08:43 +0000
@@ -68,6 +68,10 @@
     <constructor-arg name="importerClass" type="java.lang.Class" value="org.hisp.dhis.constant.Constant" />
   </bean>
 
+  <bean id="sectionImporter" class="org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter">
+    <constructor-arg name="importerClass" type="java.lang.Class" value="org.hisp.dhis.dataset.Section" />
+  </bean>
+
   <bean id="dataSetImporter" class="org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter">
     <constructor-arg name="importerClass" type="java.lang.Class" value="org.hisp.dhis.dataset.DataSet" />
   </bean>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2012-01-22 11:35:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2012-05-16 18:08:43 +0000
@@ -1,28 +1,33 @@
 package org.hisp.dhis.dataset.hibernate;
 
 /*
- * Copyright (c) 2004-2012, University of Oslo All rights reserved.
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met: *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer. * Redistributions in binary
- * form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided
- * with the distribution. * Neither the name of the HISP project nor the names
- * of its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission. THIS SOFTWARE IS
- * PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+
 import org.hibernate.Criteria;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;