=== 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 2013-10-08 17:16:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2013-12-30 09:28:55 +0000 @@ -73,6 +73,8 @@ @Scanned private List members = new ArrayList(); + private boolean dataDimension = true; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -209,8 +211,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getDescription() { return description; @@ -254,6 +256,19 @@ this.members = members; } + @JsonProperty + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + public boolean isDataDimension() + { + return dataDimension; + } + + public void setDataDimension( boolean dataDimension ) + { + this.dataDimension = dataDimension; + } + @Override public void mergeWith( IdentifiableObject other ) { @@ -265,6 +280,7 @@ description = dataElementGroupSet.getDescription() == null ? description : dataElementGroupSet.getDescription(); compulsory = dataElementGroupSet.isCompulsory() == null ? compulsory : dataElementGroupSet.isCompulsory(); + dataDimension = dataElementGroupSet.isDataDimension(); removeAllDataElementGroups(); === 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 2013-10-08 17:16:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2013-12-30 09:28:55 +0000 @@ -75,6 +75,8 @@ @Scanned private Set organisationUnitGroups = new HashSet(); + private boolean dataDimension = true; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -247,6 +249,19 @@ this.organisationUnitGroups = organisationUnitGroups; } + @JsonProperty + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + public boolean isDataDimension() + { + return dataDimension; + } + + public void setDataDimension( boolean dataDimension ) + { + this.dataDimension = dataDimension; + } + @Override public void mergeWith( IdentifiableObject other ) { @@ -258,6 +273,7 @@ compulsory = organisationUnitGroupSet.isCompulsory(); description = organisationUnitGroupSet.getDescription() == null ? description : organisationUnitGroupSet.getDescription(); + dataDimension = organisationUnitGroupSet.isDataDimension(); removeAllOrganisationUnitGroups(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-12-29 15:05:36 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-12-30 09:28:55 +0000 @@ -80,7 +80,7 @@ public void execute() { int defaultCategoryComboId = getDefaultCategoryCombo(); - + // --------------------------------------------------------------------- // Drop outdated tables // --------------------------------------------------------------------- @@ -252,7 +252,7 @@ executeSql( "ALTER TABLE minmaxdataelement RENAME minvalue TO minimumvalue" ); executeSql( "ALTER TABLE minmaxdataelement RENAME maxvalue TO maximumvalue" ); - + // orgunit shortname uniqueness executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT organisationunit_shortname_key" ); @@ -452,7 +452,7 @@ executeSql( "update reporttable set digitgroupseparator = 'space' where digitgroupseparator is null" ); executeSql( "update reporttable set sortorder = 0 where sortorder is null" ); executeSql( "update reporttable set toplimit = 0 where toplimit is null" ); - executeSql( "update reporttable set showhierarchy = false where showhierarchy is null" ); + executeSql( "update reporttable set showhierarchy = false where showhierarchy is null" ); executeSql( "update chart set reportingmonth = false where reportingmonth is null" ); executeSql( "update chart set reportingbimonth = false where reportingbimonth is null" ); @@ -478,12 +478,12 @@ executeSql( "update chart set hidetitle = false where hidetitle is null" ); // Move chart filters to chart_filters table - + executeSql( "insert into chart_filters (chartid, sort_order, filter) select chartid, 0, filter from chart" ); executeSql( "alter table chart drop column filter" ); - + // Upgrade chart dimension identifiers - + executeSql( "update chart set series = 'dx' where series = 'data'" ); executeSql( "update chart set series = 'pe' where series = 'period'" ); executeSql( "update chart set series = 'ou' where series = 'organisationunit'" ); @@ -493,7 +493,7 @@ executeSql( "update chart_filters set filter = 'dx' where filter = 'data'" ); executeSql( "update chart_filters set filter = 'pe' where filter = 'period'" ); executeSql( "update chart_filters set filter = 'ou' where filter = 'organisationunit'" ); - + executeSql( "update users set selfregistered = false where selfregistered is null" ); executeSql( "update users set disabled = false where disabled is null" ); executeSql( "update dataentryform set format = 1 where format is null" ); @@ -633,8 +633,8 @@ executeSql( "ALTER TABLE dataelement ALTER COLUMN domaintype SET NOT NULL" ); executeSql( "update dataelementcategory set datadimension = false where datadimension is null" ); - - executeSql( "UPDATE dataset SET dataelementdecoration=false WHERE dataelementdecoration is null" ); + + executeSql( "UPDATE dataset SET dataelementdecoration=false WHERE dataelementdecoration is null" ); executeSql( "alter table validationrulegroup rename column validationgroupid to validationrulegroupid" ); executeSql( "alter table sqlview rename column viewid to sqlviewid" ); @@ -642,13 +642,13 @@ executeSql( "UPDATE dashboard SET publicaccess='--------' WHERE publicaccess is null" ); executeSql( "UPDATE optionset SET version=1 WHERE version IS NULL" ); - + executeSql( "ALTER TABLE datavalue ALTER COLUMN lastupdated TYPE timestamp" ); executeSql( "ALTER TABLE completedatasetregistration ALTER COLUMN date TYPE timestamp" ); executeSql( "ALTER TABLE message ALTER COLUMN userid DROP NOT NULL" ); executeSql( "ALTER TABLE message ALTER COLUMN messagetext TYPE text" ); executeSql( "drop index crosstab" ); - + executeSql( "delete from usersetting where name = 'dashboardConfig' or name = 'dashboardConfiguration'" ); executeSql( "update usersetting set name = 'keyUiLocale' where name = 'currentLocale'" ); executeSql( "update usersetting set name = 'keyDbLocale' where name = 'keyLocaleUserSetting'" ); @@ -656,13 +656,19 @@ executeSql( "UPDATE interpretation SET publicaccess='r-------' WHERE publicaccess IS NULL;" ); executeSql( "ALTER TABLE dataset DROP COLUMN symbol" ); - executeSql( "ALTER TABLE users ALTER COLUMN password DROP NOT NULL" ); - - executeSql( "update categorycombo set dimensiontype = '" + DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION + "' where dimensiontype is null" ); + executeSql( "ALTER TABLE users ALTER COLUMN password DROP NOT NULL" ); + + executeSql( "update categorycombo set dimensiontype = '" + DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION + "' where dimensiontype is null" ); executeSql( "update dataelementcategory set dimensiontype = '" + DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION + "' where dimensiontype is null" ); - executeSql( "update dataset set categorycomboid = " + defaultCategoryComboId + " where categorycomboid is null" ); - - upgradeDataValuesWithAttributeOptionCombo(); + executeSql( "update dataset set categorycomboid = " + defaultCategoryComboId + " where categorycomboid is null" ); + + // set default dataDimension on orgUnitGroupSet and deGroupSet + executeSql( "UPDATE dataelementgroupset SET datadimension=true WHERE datadimension IS NULL" ); + executeSql( "ALTER TABLE dataelementgroupset ALTER COLUMN datadimension SET NOT NULL" ); + executeSql( "UPDATE orgunitgroupset SET datadimension=true WHERE datadimension IS NULL" ); + executeSql( "ALTER TABLE orgunitgroupset ALTER COLUMN datadimension SET NOT NULL" ); + + upgradeDataValuesWithAttributeOptionCombo(); upgradeMapViewsToAnalyticalObject(); log.info( "Tables updated" ); @@ -674,9 +680,9 @@ { return; } - + int optionComboId = getDefaultOptionCombo(); - + executeSql( "alter table datavalue_audit drop constraint fk_datavalueaudit_datavalue;" ); executeSql( "alter table datavalue drop constraint datavalue_pkey;" ); @@ -686,13 +692,13 @@ executeSql( "alter table datavalue alter column attributeoptioncomboid set not null;" ); executeSql( "alter table datavalue add constraint fk_datavalue_attributeoptioncomboid foreign key (attributeoptioncomboid) references categoryoptioncombo (categoryoptioncomboid) match simple;" ); executeSql( "alter table datavalue add constraint datavalue_pkey primary key(dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid);" ); - - executeSql( "alter table datavalue_audit add constraint fk_datavalueaudit_datavalue foreign key (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) " + + + executeSql( "alter table datavalue_audit add constraint fk_datavalueaudit_datavalue foreign key (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) " + "references datavalue (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) match simple;" ); - + log.info( "Data value table upgraded with attributeoptioncomboid column" ); } - + private void upgradeMapViewsToAnalyticalObject() { executeSql( "insert into mapview_dataelements ( mapviewid, sort_order, dataelementid ) select mapviewid, 0, dataelementid from mapview where dataelementid is not null" ); @@ -710,18 +716,18 @@ executeSql( "insert into mapview_periods ( mapviewid, sort_order, periodid ) select mapviewid, 0, periodid from mapview where periodid is not null" ); executeSql( "alter table mapview drop column periodid" ); - executeSql( "insert into mapview_orgunitlevels ( mapviewid, sort_order, orgunitlevel ) select m.mapviewid, 0, o.level " + - "from mapview m join orgunitlevel o on (m.organisationunitlevelid=o.orgunitlevelid) where m.organisationunitlevelid is not null" ); + executeSql( "insert into mapview_orgunitlevels ( mapviewid, sort_order, orgunitlevel ) select m.mapviewid, 0, o.level " + + "from mapview m join orgunitlevel o on (m.organisationunitlevelid=o.orgunitlevelid) where m.organisationunitlevelid is not null" ); executeSql( "alter table mapview drop column organisationunitlevelid" ); - - executeSql( "alter table mapview drop column dataelementgroupid" ); + + executeSql( "alter table mapview drop column dataelementgroupid" ); executeSql( "alter table mapview drop column indicatorgroupid" ); - + executeSql( "update mapview set userorganisationunit = false where userorganisationunit is null" ); executeSql( "update mapview set userorganisationunitchildren = false where userorganisationunitchildren is null" ); executeSql( "update mapview set userorganisationunitgrandchildren = false where userorganisationunitgrandchildren is null" ); } - + private void upgradeChartRelativePeriods() { BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( RelativePeriodsBatchHandler.class ).init(); @@ -929,7 +935,7 @@ executeSql( "alter table reporttable drop column doperiods" ); executeSql( "alter table reporttable drop column dounits" ); executeSql( "alter table reporttable drop column categorycomboid" ); - + executeSql( "delete from configuration where configurationid not in (select configurationid from configuration limit 1)" ); } catch ( Exception ex ) @@ -1035,7 +1041,7 @@ try { //TODO use jdbcTemplate - + return statementManager.getHolder().executeUpdate( sql ); } catch ( Exception ex ) @@ -1051,7 +1057,7 @@ try { ResultSetMetaData metaData = statementManager.getHolder().getStatement().executeQuery( "select * from datavalue limit 1" ).getMetaData(); - + for ( int i = 1; i <= metaData.getColumnCount(); i++ ) { if ( column.equalsIgnoreCase( metaData.getColumnName( i ) ) ) @@ -1065,28 +1071,28 @@ log.error( "Column detection failed: " + ex.getMessage() ); log.error( ex ); } - + return false; } - + private int getDefaultOptionCombo() { - String sql = + String sql = "select coc.categoryoptioncomboid from categoryoptioncombo coc " + - "inner join categorycombos_optioncombos cco on coc.categoryoptioncomboid=cco.categoryoptioncomboid " + - "inner join categorycombo cc on cco.categorycomboid=cc.categorycomboid " + - "where cc.name='default';"; - + "inner join categorycombos_optioncombos cco on coc.categoryoptioncomboid=cco.categoryoptioncomboid " + + "inner join categorycombo cc on cco.categorycomboid=cc.categorycomboid " + + "where cc.name='default';"; + return statementManager.getHolder().queryForInteger( sql ); } - + private int getDefaultCategoryCombo() { String sql = "select categorycomboid from categorycombo where name = 'default'"; - + return statementManager.getHolder().queryForInteger( sql ); } - + private boolean updateDataSetAssociation() { StatementHolder holder = statementManager.getHolder(); === 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 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml 2013-12-30 09:28:55 +0000 @@ -21,6 +21,8 @@ + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml 2013-02-07 12:38:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml 2013-12-30 09:28:55 +0000 @@ -18,8 +18,11 @@ + + +