dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17054
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6665: all domain objects now have proper mergeWith according to hibernate owner-side rules
------------------------------------------------------------
revno: 6665
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-20 21:31:48 +0300
message:
all domain objects now have proper mergeWith according to hibernate owner-side rules
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionary.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.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/ImportOptions.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-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml
--
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/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2012-04-11 04:56:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2012-04-20 18:31:48 +0000
@@ -193,16 +193,6 @@
userAttribute = attribute.isUserAttribute();
mandatory = attribute.isMandatory();
sortOrder = attribute.getSortOrder() == null ? sortOrder : attribute.getSortOrder();
-
- for ( AttributeValue attributeValue : attribute.getAttributeValues() )
- {
- attributeValues.add( attributeValue );
-
- if ( attributeValue.getAttribute() == null )
- {
- attributeValue.setAttribute( this );
- }
- }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2012-04-19 13:58:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2012-04-20 18:31:48 +0000
@@ -130,7 +130,7 @@
private boolean userOrganisationUnit;
private boolean userOrganisationUnitChildren;
-
+
private boolean showData;
private User user;
@@ -279,6 +279,26 @@
// Logic
// -------------------------------------------------------------------------
+ public void removeAllOrganisationUnits()
+ {
+ organisationUnits.clear();
+ }
+
+ public void removeAllDataSets()
+ {
+ dataSets.clear();
+ }
+
+ public void removeAllDataElements()
+ {
+ dataElements.clear();
+ }
+
+ public void removeAllIndicators()
+ {
+ indicators.clear();
+ }
+
/**
* Sets all dimensions for this chart.
*
@@ -617,7 +637,7 @@
{
this.showData = showData;
}
-
+
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@@ -711,16 +731,16 @@
user = chart.getUser() == null ? user : chart.getUser();
organisationUnitGroupSet = chart.getOrganisationUnitGroupSet() == null ? organisationUnitGroupSet : chart.getOrganisationUnitGroupSet();
- indicators.clear();
+ removeAllIndicators();
indicators.addAll( chart.getIndicators() );
- dataElements.clear();
+ removeAllDataElements();
dataElements.addAll( chart.getDataElements() );
- dataSets.clear();
+ removeAllDataSets();
dataSets.addAll( chart.getDataSets() );
- organisationUnits.clear();
+ removeAllOrganisationUnits();
organisationUnits.addAll( chart.getOrganisationUnits() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionary.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionary.java 2012-03-20 09:04:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionary.java 2012-04-20 18:31:48 +0000
@@ -27,9 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.HashSet;
-import java.util.Set;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -38,11 +35,16 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.indicator.Indicator;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* @author Lars Helge Overland
*/
@@ -56,11 +58,13 @@
private static final long serialVersionUID = -2221681462723457717L;
private String description;
-
+
private String region;
-
+
+ @Scanned
private Set<DataElement> dataElements = new HashSet<DataElement>();
-
+
+ @Scanned
private Set<Indicator> indicators = new HashSet<Indicator>();
// -------------------------------------------------------------------------
@@ -68,9 +72,9 @@
// -------------------------------------------------------------------------
public DataDictionary()
- {
+ {
}
-
+
public DataDictionary( String name, String description, String region )
{
this.name = name;
@@ -112,6 +116,20 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void removeAllIndicators()
+ {
+ indicators.clear();
+ }
+
+ public void removeAllDataElements()
+ {
+ dataElements.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Set and get methods
// -------------------------------------------------------------------------
@@ -127,7 +145,7 @@
{
this.description = description;
}
-
+
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty
@@ -170,4 +188,24 @@
{
this.indicators = indicators;
}
+
+ @Override
+ public void mergeWith( IdentifiableObject other )
+ {
+ super.mergeWith( other );
+
+ if ( other.getClass().isInstance( this ) )
+ {
+ DataDictionary dataDictionary = (DataDictionary) other;
+
+ description = dataDictionary.getDescription() == null ? description : dataDictionary.getDescription();
+ region = dataDictionary.getRegion() == null ? region : dataDictionary.getRegion();
+
+ removeAllDataElements();
+ dataElements.addAll( dataDictionary.getDataElements() );
+
+ removeAllIndicators();
+ indicators.addAll( dataDictionary.getIndicators() );
+ }
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2012-04-20 18:31:48 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataset.DataSet;
@@ -235,6 +236,16 @@
// Logic
// -------------------------------------------------------------------------
+ public void removeAllAttributeValues()
+ {
+ attributeValues.clear();
+ }
+
+ public void removeAllCategoryLevels()
+ {
+ aggregationLevels.clear();
+ }
+
public void addDataElementGroup( DataElementGroup group )
{
groups.add( group );
@@ -620,18 +631,11 @@
url = dataElement.getUrl() == null ? url : dataElement.getUrl();
optionSet = dataElement.getOptionSet() == null ? optionSet : dataElement.getOptionSet();
+ removeAllCategoryLevels();
aggregationLevels.addAll( dataElement.getAggregationLevels() );
+
+ removeAllAttributeValues();
attributeValues.addAll( dataElement.getAttributeValues() );
-
- for ( DataElementGroup dataElementGroup : dataElement.getGroups() )
- {
- addDataElementGroup( dataElementGroup );
- }
-
- for ( DataSet dataSet : dataElement.getDataSets() )
- {
- addDataSet( dataSet );
- }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2012-04-11 07:45:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.concept.Concept;
@@ -64,6 +65,7 @@
private Concept concept;
+ @Scanned
private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
// -------------------------------------------------------------------------
@@ -96,6 +98,25 @@
// Logic
// -------------------------------------------------------------------------
+ public void addDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption )
+ {
+ categoryOptions.add( dataElementCategoryOption );
+ dataElementCategoryOption.setCategory( this );
+ }
+
+ public void removeAllCategoryOptions()
+ {
+ for ( DataElementCategoryOption dataElementCategoryOption : categoryOptions )
+ {
+ if ( dataElementCategoryOption.getCategory() == this )
+ {
+ dataElementCategoryOption.setCategory( null );
+ }
+ }
+
+ categoryOptions.clear();
+ }
+
public DataElementCategoryOption getCategoryOption( DataElementCategoryOptionCombo categoryOptionCombo )
{
for ( DataElementCategoryOption categoryOption : categoryOptions )
@@ -192,14 +213,11 @@
concept = dataElementCategory.getConcept() == null ? concept : dataElementCategory.getConcept();
+ removeAllCategoryOptions();
+
for ( DataElementCategoryOption dataElementCategoryOption : dataElementCategory.getCategoryOptions() )
{
- categoryOptions.add( dataElementCategoryOption );
-
- if ( dataElementCategoryOption.getCategory() == null )
- {
- dataElementCategoryOption.setCategory( this );
- }
+ addDataElementCategoryOption( dataElementCategoryOption );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2012-04-11 07:45:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2012-04-20 18:31:48 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.common.CombinationGenerator;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -59,6 +60,7 @@
/**
* A set with categories.
*/
+ @Scanned
private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
/**
@@ -212,6 +214,25 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void addDataElementCategory( DataElementCategory dataElementCategory )
+ {
+ categories.add( dataElementCategory );
+ }
+
+ public void removeDataElementCategory( DataElementCategory dataElementCategory )
+ {
+ categories.remove( dataElementCategory );
+ }
+
+ public void removeAllDataElementCategories()
+ {
+ categories.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -254,16 +275,11 @@
{
DataElementCategoryCombo dataElementCategoryCombo = (DataElementCategoryCombo) other;
- categories.addAll( dataElementCategoryCombo.getCategories() );
+ removeAllDataElementCategories();
- for ( DataElementCategoryOptionCombo dataElementCategoryOptionCombo : dataElementCategoryCombo.getOptionCombos() )
+ for ( DataElementCategory dataElementCategory : dataElementCategoryCombo.getCategories() )
{
- optionCombos.add( dataElementCategoryOptionCombo );
-
- if ( dataElementCategoryOptionCombo.getCategoryCombo() == null )
- {
- dataElementCategoryOptionCombo.setCategoryCombo( this );
- }
+ addDataElementCategory( dataElementCategory );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2012-04-11 07:45:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2012-04-20 18:31:48 +0000
@@ -201,12 +201,6 @@
DataElementCategoryOption dataElementCategoryOption = (DataElementCategoryOption) other;
concept = dataElementCategoryOption.getConcept() == null ? concept : dataElementCategoryOption.getConcept();
- category = category != null ? category : dataElementCategoryOption.getCategory();
-
- for ( DataElementCategoryOptionCombo dataElementCategoryOptionCombo : dataElementCategoryOption.getCategoryOptionCombos() )
- {
- addCategoryOptionCombo( dataElementCategoryOptionCombo );
- }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2012-04-11 07:45:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2012-04-20 18:31:48 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -67,6 +68,7 @@
/**
* The category options.
*/
+ @Scanned
private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
// -------------------------------------------------------------------------
@@ -166,6 +168,23 @@
// Logic
// -------------------------------------------------------------------------
+ public void addDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption )
+ {
+ categoryOptions.add( dataElementCategoryOption );
+ dataElementCategoryOption.getCategoryOptionCombos().add( this );
+ }
+
+ public void removeDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption )
+ {
+ categoryOptions.remove( dataElementCategoryOption );
+ dataElementCategoryOption.getCategoryOptionCombos().remove( this );
+ }
+
+ public void removeAllCategoryOptions()
+ {
+ categoryOptions.clear();
+ }
+
/**
* Tests whether two objects compare on a name basis. The default equals
* method becomes unusable in the case of detached objects in conjunction
@@ -336,8 +355,14 @@
{
DataElementCategoryOptionCombo dataElementCategoryOptionCombo = (DataElementCategoryOptionCombo) other;
- categoryCombo = categoryCombo != null ? categoryCombo : dataElementCategoryOptionCombo.getCategoryCombo();
- categoryOptions.addAll( dataElementCategoryOptionCombo.getCategoryOptions() );
+ categoryCombo = dataElementCategoryOptionCombo.getCategoryCombo() == null ? categoryCombo : dataElementCategoryOptionCombo.getCategoryCombo();
+
+ removeAllCategoryOptions();
+
+ for ( DataElementCategoryOption dataElementCategoryOption : dataElementCategoryOptionCombo.getCategoryOptions() )
+ {
+ addDataElementCategoryOption( dataElementCategoryOption );
+ }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -54,6 +55,7 @@
*/
private static final long serialVersionUID = 6101685842665568056L;
+ @Scanned
private Set<DataElement> members = new HashSet<DataElement>();
private DataElementGroupSet groupSet;
@@ -87,6 +89,16 @@
dataElement.getGroups().remove( this );
}
+ public void removeAllDataElements()
+ {
+ for ( DataElement dataElement : members )
+ {
+ dataElement.getGroups().remove( this );
+ }
+
+ members.clear();
+ }
+
public void updateDataElements( Set<DataElement> updates )
{
for ( DataElement dataElement : new HashSet<DataElement>( members ) )
@@ -184,8 +196,12 @@
{
DataElementGroup dataElementGroup = (DataElementGroup) other;
- members.addAll( dataElementGroup.getMembers() );
- groupSet = groupSet != null ? groupSet : dataElementGroup.getGroupSet();
+ removeAllDataElements();
+
+ for ( DataElement dataElement : dataElementGroup.getMembers() )
+ {
+ addDataElement( dataElement );
+ }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -65,6 +66,7 @@
private Boolean compulsory = false;
+ @Scanned
private List<DataElementGroup> members = new ArrayList<DataElementGroup>();
// -------------------------------------------------------------------------
@@ -104,6 +106,19 @@
dataElementGroup.setGroupSet( this );
}
+ public void removeAllDataElementGroups()
+ {
+ for ( DataElementGroup dataElementGroup : members )
+ {
+ if ( dataElementGroup.getGroupSet() == this )
+ {
+ dataElementGroup.setGroupSet( null );
+ }
+ }
+
+ members.clear();
+ }
+
public Collection<DataElement> getDataElements()
{
List<DataElement> dataElements = new ArrayList<DataElement>();
@@ -257,14 +272,11 @@
description = dataElementGroupSet.getDescription() == null ? description : dataElementGroupSet.getDescription();
compulsory = dataElementGroupSet.isCompulsory() == null ? compulsory : dataElementGroupSet.isCompulsory();
+ removeAllDataElementGroups();
+
for ( DataElementGroup dataElementGroup : dataElementGroupSet.getMembers() )
{
- members.add( dataElementGroup );
-
- if ( dataElementGroup.getGroupSet() == null )
- {
- dataElementGroup.setGroupSet( this );
- }
+ addDataElementGroup( dataElementGroup );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2012-04-20 18:31:48 +0000
@@ -170,6 +170,15 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void removeAllAttributeValues()
+ {
+ attributeValues.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -363,18 +372,8 @@
explodedDenominator = indicator.getExplodedDenominator() == null ? explodedDenominator : indicator.getExplodedDenominator();
indicatorType = indicator.getIndicatorType() == null ? indicatorType : indicator.getIndicatorType();
+ removeAllAttributeValues();
attributeValues.addAll( indicator.getAttributeValues() );
-
- for ( DataSet dataSet : indicator.getDataSets() )
- {
- addDataSet( dataSet );
- }
-
- for ( IndicatorGroup indicatorGroup : indicator.getGroups() )
- {
- addIndicatorGroup( indicatorGroup );
- }
-
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java 2012-04-10 21:41:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -54,6 +55,7 @@
*/
private static final long serialVersionUID = 1447947029536960810L;
+ @Scanned
private Set<Indicator> members = new HashSet<Indicator>();
private IndicatorGroupSet groupSet;
@@ -143,6 +145,15 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void removeAllIndicators()
+ {
+ members.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -184,7 +195,7 @@
{
IndicatorGroup indicatorGroup = (IndicatorGroup) other;
- groupSet = groupSet != null ? groupSet : indicatorGroup.getGroupSet();
+ removeAllIndicators();
for ( Indicator indicator : indicatorGroup.getMembers() )
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2012-04-11 04:56:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -65,6 +66,7 @@
private Boolean compulsory = false;
+ @Scanned
private List<IndicatorGroup> members = new ArrayList<IndicatorGroup>();
// -------------------------------------------------------------------------
@@ -193,6 +195,11 @@
// Logic
// -------------------------------------------------------------------------
+ public void removeAllIndicatorGroups()
+ {
+ members.clear();
+ }
+
public void addIndicatorGroup( IndicatorGroup indicatorGroup )
{
if ( !members.contains( indicatorGroup ) )
@@ -265,17 +272,11 @@
compulsory = indicatorGroupSet.isCompulsory() == null ? compulsory : indicatorGroupSet.isCompulsory();
description = indicatorGroupSet.getDescription() == null ? description : indicatorGroupSet.getDescription();
+ removeAllIndicatorGroups();
+
for ( IndicatorGroup indicatorGroup : indicatorGroupSet.getMembers() )
{
- if ( !members.contains( indicatorGroup ) )
- {
- members.add( indicatorGroup );
- }
-
- if ( indicatorGroup.getGroupSet() == null )
- {
- indicatorGroup.setGroupSet( this );
- }
+ addIndicatorGroup( indicatorGroup );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataelement.DataElement;
@@ -55,10 +56,13 @@
private String symbolizer;
+ @Scanned
private Set<MapLegend> mapLegends = new HashSet<MapLegend>();
+ @Scanned
private Set<Indicator> indicators = new HashSet<Indicator>();
+ @Scanned
private Set<DataElement> dataElements = new HashSet<DataElement>();
public MapLegendSet()
@@ -110,6 +114,25 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void removeAllDataElements()
+ {
+ dataElements.clear();
+ }
+
+ public void removeAllIndicators()
+ {
+ indicators.clear();
+ }
+
+ public void removeAllMapLegends()
+ {
+ mapLegends.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -196,8 +219,13 @@
type = mapLegendSet.getType() == null ? type : mapLegendSet.getType();
symbolizer = mapLegendSet.getSymbolizer() == null ? symbolizer : mapLegendSet.getSymbolizer();
+ removeAllMapLegends();
mapLegends.addAll( mapLegendSet.getMapLegends() );
+
+ removeAllIndicators();
indicators.addAll( mapLegendSet.getIndicators() );
+
+ removeAllDataElements();
dataElements.addAll( mapLegendSet.getDataElements() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.user.User;
@@ -55,14 +56,16 @@
private String subject;
+ private User lastSender;
+
+ private Date lastMessage;
+
+ @Scanned
private Set<UserMessage> userMessages = new HashSet<UserMessage>();
+ @Scanned
private List<Message> messages = new ArrayList<Message>();
- private User lastSender;
-
- private Date lastMessage;
-
//-------------------------------------------------------------------------------------------------------
// Transient fields
//-------------------------------------------------------------------------------------------------------
@@ -234,6 +237,16 @@
return users;
}
+ public void removeAllMessages()
+ {
+ messages.clear();
+ }
+
+ public void removeAllUserMessages()
+ {
+ userMessages.clear();
+ }
+
//-------------------------------------------------------------------------------------------------------
// Persistent fields
//-------------------------------------------------------------------------------------------------------
@@ -258,6 +271,33 @@
}
@JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public User getLastSender()
+ {
+ return lastSender;
+ }
+
+ public void setLastSender( User lastSender )
+ {
+ this.lastSender = lastSender;
+ }
+
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public Date getLastMessage()
+ {
+ return lastMessage;
+ }
+
+ public void setLastMessage( Date lastMessage )
+ {
+ this.lastMessage = lastMessage;
+ }
+
+ @JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlElementWrapper( localName = "userMessages", namespace = Dxf2Namespace.NAMESPACE )
@JacksonXmlProperty( localName = "userMessage", namespace = Dxf2Namespace.NAMESPACE )
@@ -286,33 +326,6 @@
this.messages = messages;
}
- @JsonProperty
- @JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public User getLastSender()
- {
- return lastSender;
- }
-
- public void setLastSender( User lastSender )
- {
- this.lastSender = lastSender;
- }
-
- @JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public Date getLastMessage()
- {
- return lastMessage;
- }
-
- public void setLastMessage( Date lastMessage )
- {
- this.lastMessage = lastMessage;
- }
-
//-------------------------------------------------------------------------------------------------------
// Transient fields
//-------------------------------------------------------------------------------------------------------
@@ -375,7 +388,10 @@
lastSender = messageConversation.getLastSender() == null ? lastSender : messageConversation.getLastSender();
lastMessage = messageConversation.getLastMessage() == null ? lastMessage : messageConversation.getLastMessage();
+ removeAllUserMessages();
userMessages.addAll( messageConversation.getUserMessages() );
+
+ removeAllMessages();
messages.addAll( messageConversation.getMessages() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2012-04-17 08:36:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2012-04-20 18:31:48 +0000
@@ -93,6 +93,11 @@
return name.equals( other.getName() );
}
+ public void removeAllOptions()
+ {
+ options.clear();
+ }
+
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlElementWrapper( localName = "options", namespace = Dxf2Namespace.NAMESPACE )
@@ -127,7 +132,8 @@
{
OptionSet optionSet = (OptionSet) other;
- options.clear();
+ removeAllOptions();
+
options.addAll( optionSet.getOptions() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2012-04-18 20:24:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2012-04-20 18:31:48 +0000
@@ -257,12 +257,7 @@
for ( OrganisationUnitGroup organisationUnitGroup : organisationUnitGroupSet.getOrganisationUnitGroups() )
{
- organisationUnitGroups.add( organisationUnitGroup );
-
- if ( organisationUnitGroup.getGroupSet() == null )
- {
- organisationUnitGroup.setGroupSet( this );
- }
+ addOrganisationUnitGroup( organisationUnitGroup );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2012-04-18 20:24:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2012-04-20 18:31:48 +0000
@@ -746,6 +746,36 @@
return organisationUnitGroups != null && organisationUnitGroups.size() > 0;
}
+ public void removeAllDataElements()
+ {
+ dataElements.clear();
+ }
+
+ public void removeAllIndicators()
+ {
+ indicators.clear();
+ }
+
+ public void removeAllDataSets()
+ {
+ dataSets.clear();
+ }
+
+ public void removeAllPeriods()
+ {
+ periods.clear();
+ }
+
+ public void removeAllOrganisationUnits()
+ {
+ units.clear();
+ }
+
+ public void removeAllOrganisationUnitGroups()
+ {
+ organisationUnitGroups.clear();
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
@@ -1278,22 +1308,22 @@
sortOrder = reportTable.getSortOrder() == null ? sortOrder : reportTable.getSortOrder();
topLimit = reportTable.getTopLimit() == null ? topLimit : reportTable.getTopLimit();
- organisationUnitGroups.clear();
+ removeAllOrganisationUnitGroups();
organisationUnitGroups.addAll( reportTable.getOrganisationUnitGroups() );
- units.clear();
+ removeAllOrganisationUnits();
units.addAll( reportTable.getUnits() );
- periods.clear();
+ removeAllPeriods();
periods.addAll( reportTable.getPeriods() );
- dataSets.clear();
+ removeAllDataSets();
dataSets.addAll( reportTable.getDataSets() );
- indicators.clear();
+ removeAllIndicators();
indicators.addAll( reportTable.getIndicators() );
- dataElements.clear();
+ removeAllDataElements();
dataElements.addAll( reportTable.getDataElements() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-04-20 18:31:48 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectUtils;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -80,11 +81,13 @@
* <p/>
* TODO This should have been put in UserCredentials
*/
+ @Scanned
private Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
/**
* Set of the dynamic attributes values that belong to this User.
*/
+ @Scanned
private Set<AttributeValue> attributeValues = new HashSet<AttributeValue>();
// -------------------------------------------------------------------------
@@ -253,6 +256,16 @@
return userCredentials != null ? userCredentials.getUsername() : null;
}
+ public void removeAllOrganisationUnits()
+ {
+ organisationUnits.clear();
+ }
+
+ public void removeAllAttributeValues()
+ {
+ attributeValues.clear();
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -366,8 +379,11 @@
phoneNumber = user.getPhoneNumber() == null ? phoneNumber : user.getPhoneNumber();
userCredentials = user.getUserCredentials() == null ? userCredentials : user.getUserCredentials();
+ removeAllAttributeValues();
attributeValues.addAll( user.getAttributeValues() );
+ removeAllOrganisationUnits();
+
for ( OrganisationUnit organisationUnit : user.getOrganisationUnits() )
{
addOrganisationUnit( organisationUnit );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataset.DataSet;
@@ -61,6 +62,7 @@
private Set<UserCredentials> members = new HashSet<UserCredentials>();
+ @Scanned
private Set<DataSet> dataSets = new HashSet<DataSet>();
// -------------------------------------------------------------------------
@@ -179,13 +181,21 @@
description = userAuthorityGroup.getDescription() == null ? description : userAuthorityGroup.getDescription();
+ removeAllAuthorities();
authorities.addAll( authorities );
+
+ removeAllDataSets();
dataSets.addAll( userAuthorityGroup.getDataSets() );
-
- for ( UserCredentials userCredentials : userAuthorityGroup.getMembers() )
- {
- addUserCredentials( userCredentials );
- }
}
}
+
+ public void removeAllDataSets()
+ {
+ dataSets.clear();
+ }
+
+ private void removeAllAuthorities()
+ {
+ authorities.clear();
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2012-04-11 07:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -54,6 +55,7 @@
/**
* Set of related users
*/
+ @Scanned
private Set<User> members = new HashSet<User>();
// -------------------------------------------------------------------------
@@ -76,7 +78,6 @@
this.members = members;
}
-
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
@@ -107,6 +108,15 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void removeAllUsers()
+ {
+ members.clear();
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -134,6 +144,7 @@
{
UserGroup userGroup = (UserGroup) other;
+ removeAllUsers();
members.addAll( userGroup.getMembers() );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2012-04-11 04:56:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2012-04-20 18:31:48 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer;
import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.expression.Expression;
@@ -263,11 +264,6 @@
leftSide = validationRule.getLeftSide() == null ? leftSide : validationRule.getLeftSide();
rightSide = validationRule.getRightSide() == null ? rightSide : validationRule.getRightSide();
periodType = validationRule.getPeriodType() == null ? periodType : validationRule.getPeriodType();
-
- for ( ValidationRuleGroup validationRuleGroup : validationRule.getGroups() )
- {
- addValidationRuleGroup( validationRuleGroup );
- }
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java 2012-04-17 08:04:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java 2012-04-20 18:31:48 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
@@ -56,6 +57,7 @@
private String description;
+ @Scanned
private Set<ValidationRule> members = new HashSet<ValidationRule>();
// -------------------------------------------------------------------------
@@ -89,6 +91,11 @@
validationRule.getGroups().remove( this );
}
+ public void removeAllValidationRules()
+ {
+ members.clear();
+ }
+
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
@@ -166,7 +173,8 @@
ValidationRuleGroup validationRuleGroup = (ValidationRuleGroup) other;
description = validationRuleGroup.getDescription() == null ? description : validationRuleGroup.getDescription();
- members.clear();
+
+ removeAllValidationRules();
for ( ValidationRule validationRule : validationRuleGroup.getMembers() )
{
=== 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 08:34:30 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java 2012-04-20 18:31:48 +0000
@@ -36,7 +36,6 @@
import org.hisp.dhis.dataelement.*;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.document.Document;
-import org.hisp.dhis.dxf2.utils.OrganisationUnitUtils;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorGroupSet;
@@ -86,8 +85,6 @@
{
MetaData metaData = new MetaData();
- System.err.println("Starting export..");
-
if ( exportOptions.isAttributeTypes() )
{
metaData.setAttributeTypes( new ArrayList<Attribute>( manager.getAll( Attribute.class ) ) );
@@ -266,8 +263,6 @@
metaData.setDataDictionaries( new ArrayList<DataDictionary>( manager.getAll( DataDictionary.class ) ) );
}
- System.err.println("Ending export..");
-
return metaData;
}
}
=== 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-04-19 16:40:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2012-04-20 18:31:48 +0000
@@ -96,8 +96,9 @@
doImport( metaData.getMapLegends(), importOptions, importSummary );
doImport( metaData.getMapLegendSets(), importOptions, importSummary );
doImport( metaData.getMapLayers(), importOptions, importSummary );
- doImport( metaData.getMessageConversations(), importOptions, importSummary );
+ // doImport( metaData.getMessageConversations(), importOptions, importSummary );
doImport( metaData.getOrganisationUnits(), importOptions, importSummary );
+ // doImport( metaData.getOrganisationUnitLevels(), importOptions, importSummary );
doImport( metaData.getOrganisationUnitGroups(), importOptions, importSummary );
doImport( metaData.getOrganisationUnitGroupSets(), importOptions, importSummary );
doImport( metaData.getSqlViews(), importOptions, importSummary );
@@ -129,7 +130,7 @@
return null;
}
- private <T> Importer<T> findImporterClass( Class<?> clazz )
+ private <T> Importer findImporterClass( Class<?> clazz )
{
for ( Importer i : importerClasses )
{
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java 2012-04-11 16:18:25 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java 2012-04-20 18:31:48 +0000
@@ -43,7 +43,7 @@
private ImportStrategy importStrategy;
- private static ImportOptions DEFAULT_OPTIONS = new ImportOptions( IdentifiableProperty.UID, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES );
+ private static final ImportOptions DEFAULT_OPTIONS = new ImportOptions( IdentifiableProperty.UID, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES );
public static ImportOptions getDefaultImportOptions()
{
=== 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-13 01:16:51 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java 2012-04-20 18:31:48 +0000
@@ -74,6 +74,12 @@
{
private List<Attribute> attributeTypes = new ArrayList<Attribute>();
+ private List<Document> documents = new ArrayList<Document>();
+
+ private List<Constant> constants = new ArrayList<Constant>();
+
+ private List<Concept> concepts = new ArrayList<Concept>();
+
private List<User> users = new ArrayList<User>();
private List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>();
@@ -82,16 +88,8 @@
private List<MessageConversation> messageConversations = new ArrayList<MessageConversation>();
- private List<DataElement> dataElements = new ArrayList<DataElement>();
-
private List<OptionSet> optionSets = new ArrayList<OptionSet>();
- private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
-
- private List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>();
-
- private List<Concept> concepts = new ArrayList<Concept>();
-
private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
@@ -100,6 +98,12 @@
private List<DataElementCategoryOptionCombo> categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+ private List<DataElement> dataElements = new ArrayList<DataElement>();
+
+ private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
+
+ private List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>();
+
private List<Indicator> indicators = new ArrayList<Indicator>();
private List<IndicatorGroup> indicatorGroups = new ArrayList<IndicatorGroup>();
@@ -116,8 +120,6 @@
private List<OrganisationUnitLevel> organisationUnitLevels = new ArrayList<OrganisationUnitLevel>();
- private List<DataSet> dataSets = new ArrayList<DataSet>();
-
private List<ValidationRule> validationRules = new ArrayList<ValidationRule>();
private List<ValidationRuleGroup> validationRuleGroups = new ArrayList<ValidationRuleGroup>();
@@ -130,10 +132,6 @@
private List<ReportTable> reportTables = new ArrayList<ReportTable>();
- private List<Document> documents = new ArrayList<Document>();
-
- private List<Constant> constants = new ArrayList<Constant>();
-
private List<MapView> maps = new ArrayList<MapView>();
private List<MapLegend> mapLegends = new ArrayList<MapLegend>();
@@ -144,6 +142,8 @@
private List<DataDictionary> dataDictionaries = new ArrayList<DataDictionary>();
+ private List<DataSet> dataSets = new ArrayList<DataSet>();
+
public MetaData()
{
}
=== 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-04-20 08:34:30 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2012-04-20 18:31:48 +0000
@@ -180,6 +180,7 @@
//-------------------------------------------------------------------------------------------------------
@Override
+ @SuppressWarnings( "unchecked" )
public List<ImportConflict> importObjects( List<T> objects, ImportOptions options )
{
List<ImportConflict> conflicts = new ArrayList<ImportConflict>();
@@ -285,20 +286,11 @@
return object.getClass().getName();
}
- /**
- * Current object name, used to fill name part of a ImportConflict
- *
- * @return Name of object
- */
- protected String getClassName()
- {
- return importerClass.getSimpleName();
- }
-
//-------------------------------------------------------------------------------------------------------
// Helpers
//-------------------------------------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
private void reset()
{
imported = 0;
@@ -407,29 +399,29 @@
if ( ImportStrategy.NEW.equals( options.getImportStrategy() ) )
{
- conflict = validateForNewStrategy( object, options );
+ conflict = validateForNewStrategy( object );
}
else if ( ImportStrategy.UPDATES.equals( options.getImportStrategy() ) )
{
- conflict = validateForUpdatesStrategy( object, options );
+ conflict = validateForUpdatesStrategy( object );
}
else if ( ImportStrategy.NEW_AND_UPDATES.equals( options.getImportStrategy() ) )
{
// if we have a match on at least one of the objects, then assume update
if ( uidObject != null || codeObject != null || nameObject != null || shortNameObject != null )
{
- conflict = validateForUpdatesStrategy( object, options );
+ conflict = validateForUpdatesStrategy( object );
}
else
{
- conflict = validateForNewStrategy( object, options );
+ conflict = validateForNewStrategy( object );
}
}
return conflict;
}
- private ImportConflict validateForUpdatesStrategy( T object, ImportOptions options )
+ private ImportConflict validateForUpdatesStrategy( T object )
{
T uidObject = uidMap.get( object.getUid() );
T codeObject = codeMap.get( object.getCode() );
@@ -470,17 +462,17 @@
if ( nonNullObjects.isEmpty() )
{
- conflict = reportLookupConflict( object, options );
+ conflict = reportLookupConflict( object );
}
else if ( nonNullObjects.size() > 1 )
{
- conflict = reportMoreThanOneConflict( object, options );
+ conflict = reportMoreThanOneConflict( object );
}
return conflict;
}
- private ImportConflict validateForNewStrategy( T object, ImportOptions options )
+ private ImportConflict validateForNewStrategy( T object )
{
T uidObject = uidMap.get( object.getUid() );
T codeObject = codeMap.get( object.getCode() );
@@ -499,23 +491,23 @@
if ( uidObject != null || codeObject != null || nameObject != null || shortNameObject != null )
{
- conflict = reportConflict( object, options );
+ conflict = reportConflict( object );
}
return conflict;
}
- private ImportConflict reportLookupConflict( IdentifiableObject object, ImportOptions options )
+ private ImportConflict reportLookupConflict( IdentifiableObject object )
{
return new ImportConflict( getDisplayName( object ), "Object does not exist." );
}
- private ImportConflict reportMoreThanOneConflict( IdentifiableObject object, ImportOptions options )
+ private ImportConflict reportMoreThanOneConflict( IdentifiableObject object )
{
return new ImportConflict( getDisplayName( object ), "More than one object matches identifiers." );
}
- private ImportConflict reportConflict( IdentifiableObject object, ImportOptions options )
+ private ImportConflict reportConflict( IdentifiableObject object )
{
return new ImportConflict( getDisplayName( object ), "Object already exists." );
}
@@ -654,7 +646,7 @@
for ( Field field : identifiableObjectCollections.keySet() )
{
Collection<? extends IdentifiableObject> identifiableObjects = identifiableObjectCollections.get( field );
- Collection<IdentifiableObject> objects = null;
+ Collection<IdentifiableObject> objects;
if ( List.class.isAssignableFrom( field.getType() ) )
{
@@ -667,6 +659,7 @@
else
{
log.warn( "Unknown Collection type!" );
+ continue;
}
for ( IdentifiableObject idObject : identifiableObjects )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml 2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml 2012-04-20 18:31:48 +0000
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" table="categoryoptioncombo">
@@ -13,15 +13,17 @@
</id>
<property name="uid" column="uid" length="11" />
+
<property name="code" column="code" not-null="false" unique="true" length="50" />
- <property name="lastUpdated" type="timestamp"/>
-
+
+ <property name="lastUpdated" type="timestamp" />
+
<list name="categoryOptions" table="categoryoptioncombos_categoryoptions">
- <cache usage="read-write" />
+ <cache usage="read-write" />
<key column="categoryoptioncomboid" foreign-key="fk_categoryoptioncombos_categoryoptions_categoryoptioncomboid" />
<list-index column="sort_order" base="1" />
<many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOption" column="categoryoptionid"
- foreign-key="fk_categoryoptioncombo_categoryoptionid" />
+ foreign-key="fk_categoryoptioncombo_categoryoptionid" />
</list>
<join table="categorycombos_optioncombos">
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml 2011-11-03 01:02:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml 2012-04-20 18:31:48 +0000
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
- [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+ >
<hibernate-mapping>
<class name="org.hisp.dhis.dataelement.DataElementGroupSet" table="dataelementgroupset">
@@ -14,7 +14,7 @@
<generator class="native" />
</id>
&identifiableProperties;
-
+
<property name="description" />
<property name="compulsory" />
@@ -24,7 +24,7 @@
<key column="dataelementgroupsetid" foreign-key="fk_dataelementgroupsetmembers_dataelementgroupsetid" />
<list-index column="sort_order" base="1" />
<many-to-many class="org.hisp.dhis.dataelement.DataElementGroup" column="dataelementgroupid" unique="true"
- foreign-key="fk_dataelementgroupset_dataelementgroupid" />
+ foreign-key="fk_dataelementgroupset_dataelementgroupid" />
</list>
</class>