dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16390
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6226: (DV) Orgunit group set support enhanced. Work in progress.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6226 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-09 03:48:02 +0100
message:
(DV) Orgunit group set support enhanced. Work in progress.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java
dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js
--
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/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2012-02-28 10:53:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2012-03-09 02:29:32 +0000
@@ -53,6 +53,7 @@
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.RelativePeriods;
import org.hisp.dhis.user.User;
@@ -129,6 +130,8 @@
private boolean userOrganisationUnit;
private User user;
+
+ private OrganisationUnitGroupSet organisationUnitGroupSet;
// -------------------------------------------------------------------------
// Transient properties
@@ -605,4 +608,18 @@
{
this.user = user;
}
+
+ @XmlElement
+ @JsonProperty
+ public OrganisationUnitGroupSet getOrganisationUnitGroupSet()
+ {
+ return organisationUnitGroupSet;
+ }
+
+ public void setOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet )
+ {
+ this.organisationUnitGroupSet = organisationUnitGroupSet;
+ }
+
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2012-02-28 10:53:00 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2012-03-09 02:29:32 +0000
@@ -72,6 +72,8 @@
<many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit"
foreign-key="fk_chart_organisationunits_organisationunitid" />
</list>
+
+ <many-to-one name="organisationUnitGroupSet" class="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet" column="organisationunitgroupsetid" foreign-key="fk_chart_organisationunitgroupsetid" />
<component name="relatives">
<property name="reportingMonth" />
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java 2012-02-28 10:53:00 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java 2012-03-09 02:29:32 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.RelativePeriods;
import org.hisp.dhis.user.CurrentUserService;
@@ -86,6 +87,13 @@
this.organisationUnitService = organisationUnitService;
}
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
private CurrentUserService currentUserService;
public void setCurrentUserService( CurrentUserService currentUserService )
@@ -152,9 +160,9 @@
{
this.dataElementIds = dataElementIds;
}
-
+
private List<Integer> dataSetIds = new ArrayList<Integer>();
-
+
public void setDataSetIds( List<Integer> dataSetIds )
{
this.dataSetIds = dataSetIds;
@@ -208,7 +216,7 @@
{
this.thisYear = thisYear;
}
-
+
private boolean lastYear;
public void setLastYear( boolean lastYear )
@@ -230,6 +238,13 @@
this.organisationUnitIds = organisationUnitIds;
}
+ private Integer organisationUnitGroupSetId;
+
+ public void setOrganisationUnitGroupSetId( Integer organisationUnitGroupSetId )
+ {
+ this.organisationUnitGroupSetId = organisationUnitGroupSetId;
+ }
+
private Boolean system;
public void setSystem( Boolean system )
@@ -292,14 +307,14 @@
{
this.targetLineLabel = targetLineLabel;
}
-
+
private Double baseLineValue;
public void setBaseLineValue( Double baseLineValue )
{
this.baseLineValue = baseLineValue;
}
-
+
private String baseLineLabel;
public void setBaseLineLabel( String baseLineLabel )
@@ -313,7 +328,7 @@
public String execute()
throws Exception
- {
+ {
Chart chart = null;
if ( uid != null )
@@ -353,35 +368,35 @@
if ( indicatorIds != null )
{
chart.getIndicators().clear();
-
+
for ( Integer id : indicatorIds )
{
chart.getIndicators().add( indicatorService.getIndicator( id ) );
}
}
-
+
if ( dataElementIds != null )
{
chart.getDataElements().clear();
-
+
for ( Integer id : dataElementIds )
{
chart.getDataElements().add( dataElementService.getDataElement( id ) );
}
}
-
+
if ( dataSetIds != null )
{
chart.getDataSets().clear();
-
+
for ( Integer id : dataSetIds )
{
chart.getDataSets().add( dataSetService.getDataSet( id ) );
}
}
- if ( lastMonth || last12Months || lastQuarter || last4Quarters || lastSixMonth ||
- last2SixMonths || thisYear || lastYear || last5Years )
+ if ( lastMonth || last12Months || lastQuarter || last4Quarters || lastSixMonth || last2SixMonths || thisYear
+ || lastYear || last5Years )
{
RelativePeriods rp = new RelativePeriods();
rp.setReportingMonth( lastMonth );
@@ -400,13 +415,19 @@
if ( organisationUnitIds != null )
{
chart.getOrganisationUnits().clear();
-
+
for ( Integer id : organisationUnitIds )
{
chart.getOrganisationUnits().add( organisationUnitService.getOrganisationUnit( id ) );
}
}
+ if ( organisationUnitGroupSetId != null )
+ {
+ chart.setOrganisationUnitGroupSet( organisationUnitGroupService
+ .getOrganisationUnitGroupSet( organisationUnitGroupSetId ) );
+ }
+
if ( system == null )
{
chart.setUser( currentUserService.getCurrentUser() );
@@ -451,7 +472,7 @@
chart.setBaseLineValue( baseLineValue );
chart.setBaseLineLabel( baseLineLabel );
-
+
chartService.saveOrUpdate( chart );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml 2012-02-29 15:58:54 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml 2012-03-09 02:29:32 +0000
@@ -63,6 +63,7 @@
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js 2012-03-08 11:12:46 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js 2012-03-09 02:44:12 +0000
@@ -131,7 +131,10 @@
warning: {
filter: DV.i18n.wm_multiple_filter_orgunit
}
- }
+ },
+ organisationunitgroup: {
+ value: 'organisationunitgroup'
+ }
},
chart: {
series: 'series',
@@ -404,13 +407,13 @@
addToStorage: function(s, records) {
s.each( function(r) {
if (!s.storage[r.data.id]) {
- s.storage[r.data.id] = {id: r.data.id, name: r.data.name, parent: s.parent};
+ s.storage[r.data.id] = {id: r.data.id, name: DV.util.string.getEncodedString(r.data.name), parent: s.parent};
}
});
if (records) {
Ext.Array.each(records, function(r) {
if (!s.storage[r.data.id]) {
- s.storage[r.data.id] = {id: r.data.id, name: r.data.name, parent: s.parent};
+ s.storage[r.data.id] = {id: r.data.id, name: DV.util.string.getEncodedString(r.data.name), parent: s.parent};
}
});
}
@@ -664,6 +667,17 @@
getGroupSetId: function() {
var value = DV.cmp.fieldset.organisationunit.groupsets.getValue();
return !value || value === DV.i18n.none || value === DV.conf.finals.cmd.none ? null : value;
+ },
+ getGroupNameByGroupId: function(id) {
+ var gs = DV.init.system.organisationunitgroupsets;
+ for (var k in gs) {
+ for (var i = 0; i < gs[k].length; i++) {
+ if (gs[k][i].id == id) {
+ return gs[k][i].name;
+ }
+ }
+ }
+ return null;
}
}
},
@@ -1144,6 +1158,11 @@
return this.allValuesAreIntegers(DV.value.values) ? '0' : '0.0';
}
},
+ variable: {
+ hasValue: function(str) {
+ return (str & str !== 0 && str !== '0' && str !== '');
+ }
+ },
/*FIXME:This is probably not going to work as intended with UNICODE?*/
string: {
getEncodedString: function(text) {
@@ -1158,10 +1177,13 @@
var t = r[i][1];
values.push({
value: r[i][0],
- type: t === 'in' ? DV.conf.finals.dimension.indicator.value : t === 'de' ? DV.conf.finals.dimension.dataelement.value : t === 'ds' ? DV.conf.finals.dimension.dataset.value : t,
+ type: r[i][1] === 'in' ? DV.conf.finals.dimension.indicator.value :
+ r[i][1] === 'de' ? DV.conf.finals.dimension.dataelement.value :
+ r[i][1] === 'ds' ? DV.conf.finals.dimension.dataset.value : t,
dataid: r[i][2],
periodid: r[i][3],
- organisationunitid: r[i][4]
+ organisationunitid: r[i][4],
+ organisationunitgroupid: r[i][5]
});
}
return values;
@@ -1310,10 +1332,10 @@
}
},
storage: {},
- isLoaded: false,
+ isloaded: false,
listeners: {
load: function(s) {
- this.isLoaded = true;
+ this.isloaded = true;
DV.util.store.addToStorage(s);
DV.util.multiselect.filterAvailable(DV.cmp.dimension.dataset.available, DV.cmp.dimension.dataset.selected);
}
@@ -1378,7 +1400,7 @@
root: 'charts'
}
},
- isLoaded: false,
+ isloaded: false,
sorting: {
field: 'name',
direction: 'ASC'
@@ -1388,7 +1410,7 @@
},
listeners: {
load: function(s) {
- s.isLoaded = !s.isLoaded ? true : false;
+ s.isloaded = !s.isloaded ? true : false;
s.sortStore();
s.each(function(r) {
@@ -1398,13 +1420,32 @@
});
}
}
- })
+ }),
+ groupset: Ext.create('Ext.data.Store', {
+ fields: ['id', 'name', 'index'],
+ proxy: {
+ type: 'ajax',
+ url: DV.conf.finals.ajax.path_commons + DV.conf.finals.ajax.organisationunitgroupset_get,
+ reader: {
+ type: 'json',
+ root: 'organisationUnitGroupSets'
+ }
+ },
+ isloaded: false,
+ listeners: {
+ load: function() {
+ this.isloaded = true;
+ this.add({id: DV.conf.finals.cmd.none, name: DV.i18n.none, index: -1});
+ this.sort('index', 'ASC');
+ }
+ }
+ })
};
DV.state = {
setChart: function(exe, id) {
DV.chart.reset();
-
+
if (id) {
Ext.Ajax.request({
url: DV.conf.finals.ajax.path_api + DV.conf.finals.ajax.favorite_get + id + '.json?links=false',
@@ -1415,7 +1456,7 @@
}
var f = Ext.JSON.decode(r.responseText);
-
+
if (!this.validation.favorite(f)) {
return;
}
@@ -1450,7 +1491,7 @@
for (var i = 0; i < f.organisationUnits.length; i++) {
DV.c.organisationunit.objects.push({id: f.organisationUnits[i].internalId, name: DV.util.string.getEncodedString(f.organisationUnits[i].shortName)});
}
- DV.c.organisationunit.groupsetid = f.organisationUnitGroupSetId;
+ DV.c.organisationunit.groupsetid = f.organisationUnitGroupSet ? f.organisationUnitGroupSet.internalId : null;
DV.c.hidesubtitle = f.hideSubtitle;
DV.c.hidelegend = f.hideLegend;
@@ -1593,7 +1634,9 @@
p.dataSetIds = DV.c.dataset.ids;
p = Ext.Object.merge(p, DV.c.period.rp);
p.organisationUnitIds = DV.c.organisationunit.ids;
- p.organisationUnitGroupSetId = DV.c.organisationunit.groupsetid;
+ if (DV.c.organisationunit.groupsetid) {
+ p.organisationUnitGroupSetId = DV.c.organisationunit.groupsetid;
+ }
return p;
},
setUI: function() {
@@ -1641,6 +1684,22 @@
DV.util.checkbox.setRelativePeriods(DV.c.period.rp);
DV.cmp.dimension.organisationunit.treepanel.addToStorage(DV.c.organisationunit.objects);
+
+ if (DV.c.organisationunit.groupsetid) {
+ if (DV.store.groupset.isloaded) {
+ DV.cmp.fieldset.organisationunit.groupsets.setValue(DV.c.organisationunit.groupsetid);
+ }
+ else {
+ DV.store.groupset.load({
+ callback: function() {
+ DV.cmp.fieldset.organisationunit.groupsets.setValue(DV.c.organisationunit.groupsetid);
+ }
+ });
+ }
+ }
+ else {
+ DV.cmp.fieldset.organisationunit.groupsets.setValue(DV.store.isloaded ? DV.conf.finals.cmd.none : DV.i18n.none);
+ }
},
validation: {
dimensions: function() {
@@ -1815,7 +1874,9 @@
Ext.Array.each(DV.value.values, function(item) {
item[DV.conf.finals.dimension.data.value] = DV.util.string.getEncodedString(DV.store[item.type].available.storage[item.dataid].name);
item[DV.conf.finals.dimension.period.value] = DV.util.string.getEncodedString(DV.util.dimension.period.getNameById(item.periodid));
- item[DV.conf.finals.dimension.organisationunit.value] = DV.util.string.getEncodedString(DV.cmp.dimension.organisationunit.treepanel.findNameById(item.organisationunitid));
+ item[DV.conf.finals.dimension.organisationunit.value] = DV.util.variable.hasValue(item.organisationunitgroupid) ?
+ DV.util.dimension.organisationunit.getGroupNameByGroupId(item.organisationunitgroupid) : DV.cmp.dimension.organisationunit.treepanel.findNameById(item.organisationunitid);
+ item[DV.conf.finals.dimension.organisationunitgroup.value] = DV.util.variable.hasValue(item.organisationunitgroupid) ? DV.util.dimension.organisationunit.getGroupNameByGroupId(item.organisationunitgroupid) : null;
item.value = parseFloat(item.value);
});
@@ -1852,32 +1913,30 @@
isrendered: false
},
reset: function() {
- this.chart = {
- type: DV.conf.finals.chart.column,
- dimension: {},
- series: null,
- category: null,
- filter: null,
- indicator: {},
- dataelement: {},
- dataset: {},
- period: {},
- organisationunit: {},
- hidesubtitle: false,
- hidelegend: false,
- trendline: false,
- userorganisationunit: false,
- domainaxislabel: null,
- rangeaxislabel: null,
- targetlinevalue: null,
- targetlinelabel: null,
- baselinevalue: null,
- baselinelabel: null
- };
+ this.chart.type = DV.conf.finals.chart.column;
+ this.chart.dimension = {};
+ this.chart.series = null;
+ this.chart.category = null;
+ this.chart.filter = null;
+ this.chart.indicator = {};
+ this.chart.dataelement = {};
+ this.chart.dataset = {};
+ this.chart.period = {};
+ this.chart.organisationunit = {};
+ this.chart.hidesubtitle = false;
+ this.chart.hidelegend = false;
+ this.chart.trendline = false;
+ this.chart.userorganisationunit = false;
+ this.chart.domainaxislabel = null;
+ this.chart.rangeaxislabel = null;
+ this.chart.targetlinevalue = null;
+ this.chart.targetlinelabel = null;
+ this.chart.baselinevalue = null;
+ this.chart.baselinelabel = null;
},
data: [],
getData: function(exe) {
- this.data = [];
+ this.data = [];
Ext.Array.each(DV.c.category.names, function(item) {
var obj = {};
@@ -2834,7 +2893,7 @@
DV.cmp.fieldset.dataset = this;
},
expand: function() {
- if (!DV.store.dataset.available.isLoaded) {
+ if (!DV.store.dataset.available.isloaded) {
DV.store.dataset.available.load();
}
DV.util.fieldset.collapseFieldsets([DV.cmp.fieldset.indicator, DV.cmp.fieldset.dataelement, DV.cmp.fieldset.period, DV.cmp.fieldset.organisationunit]);
@@ -3031,23 +3090,7 @@
editable: false,
queryMode: 'remote',
value: DV.i18n.none,
- store: Ext.create('Ext.data.Store', {
- fields: ['id', 'name', 'index'],
- proxy: {
- type: 'ajax',
- url: DV.conf.finals.ajax.path_commons + DV.conf.finals.ajax.organisationunitgroupset_get,
- reader: {
- type: 'json',
- root: 'organisationUnitGroupSets'
- }
- },
- listeners: {
- load: function() {
- this.add({id: DV.conf.finals.cmd.none, name: DV.i18n.none, index: -1});
- this.sort('index', 'ASC');
- }
- }
- }),
+ store: DV.store.groupset,
listeners: {
added: function() {
this.up('fieldset').groupsets = this;
@@ -3965,7 +4008,7 @@
],
listeners: {
show: function() {
- if (!DV.store.favorite.isLoaded) {
+ if (!DV.store.favorite.isloaded) {
DV.store.favorite.load({scope: this, callback: function() {
this.down('grid').setHeightInMenu(DV.store.favorite);
}});