dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02313
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 776: Minor performance improvement related to datalocking in dataentry.
------------------------------------------------------------
revno: 776
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sun 2009-09-27 21:34:28 +0200
message:
Minor performance improvement related to datalocking in dataentry.
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/hibernate/HibernateDataSetLockStore.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/hibernate/HibernateDataSetLockStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/hibernate/HibernateDataSetLockStore.java 2009-09-15 12:37:50 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datalock/hibernate/HibernateDataSetLockStore.java 2009-09-27 19:34:28 +0000
@@ -80,27 +80,13 @@
return periodService.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
}
- private final Period reloadPeriodForceAdd( Period period )
- {
- Period storedPeriod = reloadPeriod( period );
-
- if ( storedPeriod == null )
- {
- periodService.addPeriod( period );
-
- return period;
- }
-
- return storedPeriod;
- }
-
// -------------------------------------------------------------------------
// DataSetLock
// -------------------------------------------------------------------------
public int addDataSetLock( DataSetLock dataSetLock )
{
- dataSetLock.setPeriod( reloadPeriodForceAdd( dataSetLock.getPeriod() ) );
+ dataSetLock.setPeriod( reloadPeriod( dataSetLock.getPeriod() ) );
Session session = sessionFactory.getCurrentSession();
@@ -109,7 +95,7 @@
public void updateDataSetLock( DataSetLock dataSetLock )
{
- dataSetLock.setPeriod( reloadPeriodForceAdd( dataSetLock.getPeriod() ) );
+ dataSetLock.setPeriod( reloadPeriod( dataSetLock.getPeriod() ) );
Session session = sessionFactory.getCurrentSession();
@@ -139,29 +125,24 @@
}
@SuppressWarnings("unchecked")
- public Collection<DataSetLock> getDataSetLockByDataSet( DataSet dataSet )
- {
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( DataSetLock.class );
+ public Collection<DataSetLock> getDataSetLockByDataSet( DataSet dataSet )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DataSetLock.class );
criteria.add( Restrictions.eq( "dataSet", dataSet ) );
+
return criteria.list();
}
@SuppressWarnings("unchecked")
- public Collection<DataSetLock> getDataSetLockByPeriod( Period period )
+ public Collection<DataSetLock> getDataSetLockByPeriod( Period period )
{
- Session session = sessionFactory.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
Period storedPeriod = reloadPeriod( period );
- if ( storedPeriod == null )
- {
- return null;
- }
-
- Criteria criteria = session.createCriteria( DataSetLock.class );
- //criteria.createAlias( "period", "ds" );
+ Criteria criteria = session.createCriteria( DataSetLock.class );
criteria.add( Restrictions.eq( "period", storedPeriod ) );
return criteria.list();
@@ -173,11 +154,6 @@
Period storedPeriod = reloadPeriod( period );
- if ( storedPeriod == null )
- {
- return null;
- }
-
Criteria criteria = session.createCriteria( DataSetLock.class );
criteria.add( Restrictions.eq( "dataSet", dataSet ) );
criteria.add( Restrictions.eq( "period", storedPeriod ) );
@@ -191,11 +167,6 @@
Period storedPeriod = reloadPeriod( period );
- if ( storedPeriod == null )
- {
- return null;
- }
-
Criteria criteria = session.createCriteria( DataSetLock.class );
criteria.add( Restrictions.eq( "dataSet", dataSet ) );
criteria.add( Restrictions.eq( "period", storedPeriod ) );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java 2009-09-10 13:17:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java 2009-09-27 19:34:28 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.dataelement.CalculatedDataElement;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.datalock.DataSetLock;
import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.DataEntryForm;
import org.hisp.dhis.dataset.DataEntryFormService;
@@ -305,11 +306,12 @@
customValues = (List<CustomValue>) customValueService.getCustomValuesByDataSet( dataSet );
Period period = selectedStateManager.getSelectedPeriod();
-
- if(dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period ) != null){
- if( dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period ).getSources().contains(organisationUnit) ) {
- disabled = "disabled";
- }
+
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
+
+ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
+ {
+ disabled = "disabled";
}
Collection<DataElement> dataElements = dataSet.getDataElements();
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java 2009-09-10 13:17:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java 2009-09-27 19:34:28 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.dataelement.DataElementDimensionColumnOrderService;
import org.hisp.dhis.dataelement.DataElementDimensionRowOrder;
import org.hisp.dhis.dataelement.DataElementDimensionRowOrderService;
+import org.hisp.dhis.datalock.DataSetLock;
import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.DataEntryForm;
import org.hisp.dhis.dataset.DataEntryFormService;
@@ -122,7 +123,8 @@
private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
- public void setDataElementCategoryOptionComboService( DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
+ public void setDataElementCategoryOptionComboService(
+ DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
{
this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
}
@@ -177,10 +179,10 @@
{
this.i18n = i18n;
}
-
+
private DataSetLockService dataSetLockService;
-
- public void setDataSetLockService( DataSetLockService dataSetLockService)
+
+ public void setDataSetLockService( DataSetLockService dataSetLockService )
{
this.dataSetLockService = dataSetLockService;
}
@@ -386,11 +388,12 @@
customValues = (List<CustomValue>) customValueService.getCustomValuesByDataSet( dataSet );
Period period = selectedStateManager.getSelectedPeriod();
+
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
- if(dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period ) != null){
- if( dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period ).getSources().contains(organisationUnit) ) {
- disabled = "disabled";
- }
+ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
+ {
+ disabled = "disabled";
}
Collection<DataElement> dataElements = dataSet.getDataElements();
@@ -432,7 +435,7 @@
numberOfTotalColumns = orderdCategoryOptionCombos.size();
for ( DataElementCategory category : categories ) // Get the order of
- // categories
+ // categories
{
DataElementDimensionRowOrder rowOrder = dataElementDimensionRowOrderService
.getDataElementDimensionRowOrder( decbo, category );
@@ -450,7 +453,7 @@
orderedCategories = categoryMap.values();
for ( DataElementCategory dec : orderedCategories ) // Get the order of
- // options
+ // options
{
Map<Integer, DataElementCategoryOption> optionsMap = new TreeMap<Integer, DataElementCategoryOption>();