← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2480: Fixed bug delete category combo. In process...

 

------------------------------------------------------------
revno: 2480
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-01-07 18:19:45 +0700
message:
  Fixed bug delete category combo. In process...
  Minor changed in Excel reporting.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryComboDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryCombo.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/AddReportExcelItemAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/reportItems.vm


--
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-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryComboDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryComboDeletionHandler.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryComboDeletionHandler.java	2011-01-07 11:19:45 +0000
@@ -60,9 +60,9 @@
     @Override
     public boolean allowDeleteDataElementCategory( DataElementCategory category )
     {
-        for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryService.getAllDataElementCategoryOptionCombos() )
+        for ( DataElementCategoryCombo categoryCombo : categoryService.getAllDataElementCategoryCombos() )
         {
-            if ( categoryOptionCombo.getCategoryCombo().getCategories().contains( category ) )
+            if ( categoryCombo.getCategories().contains( category ) )
             {
                 return false;
             }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java	2010-09-04 07:26:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java	2011-01-07 11:19:45 +0000
@@ -27,7 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.concept.Concept.DEFAULT_CONCEPT_NAME;
+
 import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.concept.ConceptService;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -50,6 +53,13 @@
         this.categoryService = categoryService;
     }
 
+    private ConceptService conceptService;
+
+    public void setConceptService( ConceptService conceptService )
+    {
+        this.conceptService = conceptService;
+    }
+
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
     // -------------------------------------------------------------------------
@@ -82,6 +92,8 @@
     @Override
     public void deleteConcept( Concept concept )
     {
+        Concept _default = conceptService.getConceptByName( DEFAULT_CONCEPT_NAME );
+
         for ( DataElementCategory category : categoryService.getAllDataElementCategories() )
         {
             Concept categoryConcept = category.getConcept();
@@ -90,7 +102,7 @@
             {
                 if ( categoryConcept.equals( concept ) )
                 {
-                    category.setConcept( null );
+                    category.setConcept( _default );
                     categoryService.updateDataElementCategory( category );
                 }
             }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java	2010-05-27 13:31:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java	2011-01-07 11:19:45 +0000
@@ -64,39 +64,43 @@
     {
         return DataElementCategoryOptionCombo.class.getSimpleName();
     }
-    
+
     @Override
     public boolean allowDeleteDataElementCategoryOption( DataElementCategoryOption categoryOption )
     {
-        for ( DataElementCategoryOptionCombo categoryOptionCombo : 
-            categoryService.getAllDataElementCategoryOptionCombos() )
+        for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryService
+            .getAllDataElementCategoryOptionCombos() )
         {
             if ( categoryOptionCombo.getCategoryOptions().contains( categoryOption ) )
             {
                 return false;
             }
         }
-        
+
         return true;
     }
-    
+
     @Override
     public boolean allowDeleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
     {
-        for(DataElementCategoryOptionCombo eachOptionCombo : categoryCombo.getOptionCombos())
+        for ( DataElementCategoryOptionCombo eachOptionCombo : categoryCombo.getOptionCombos() )
         {
             String sql = "SELECT COUNT(*) FROM datavalue where categoryoptioncomboid=" + eachOptionCombo.getId();
-            
-            if( jdbcTemplate.queryForInt( sql ) > 0) return false;
+
+            if ( jdbcTemplate.queryForInt( sql ) > 0 )
+            {
+                return false;
+            }
         }
-        
+
         return true;
     }
-    
+
     @Override
     public void deleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
     {
-        for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryService.getAllDataElementCategoryOptionCombos() )
+        for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryService
+            .getAllDataElementCategoryOptionCombos() )
         {
             if ( categoryOptionCombo.getCategoryCombo().equals( categoryCombo ) )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2010-08-24 01:48:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2011-01-07 11:19:45 +0000
@@ -67,6 +67,20 @@
     }
 
     @Override
+    public boolean allowDeleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
+    {
+        for ( DataElement dataElement : dataElementService.getAllDataElements() )
+        {
+            if ( dataElement.getCategoryCombo().equals( categoryCombo ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Override
     public void deleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
     {
         DataElementCategoryCombo default_ = categoryService

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2011-01-07 11:19:45 +0000
@@ -1387,6 +1387,8 @@
 		class="org.hisp.dhis.dataelement.DataElementCategoryDeletionHandler">
 		<property name="categoryService" 
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<property name="conceptService"
+			ref="org.hisp.dhis.concept.ConceptService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.dataelement.DataElementGroupSetDeletionHandler"

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2010-09-04 07:26:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2011-01-07 11:19:45 +0000
@@ -17,7 +17,7 @@
     <property name="name">
       <column name="name" not-null="true" unique="true" length="160"/>
     </property>
-		
+
 	<many-to-one name="concept" class="org.hisp.dhis.concept.Concept"
 		column="conceptid" foreign-key="fk_dataelementcategory_conceptid"/>
     

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryCombo.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryCombo.hbm.xml	2009-10-19 17:10:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryCombo.hbm.xml	2011-01-07 11:19:45 +0000
@@ -14,18 +14,18 @@
       <column name="name" not-null="true" unique="true" length="160"/>
     </property>
       
-    <list name="categories" table="categorycombos_categories" >  
+    <list name="categories" table="categorycombos_categories">  
       <key column="categorycomboid"/>
       <list-index column="sort_order" base="1"/>
       <many-to-many class="org.hisp.dhis.dataelement.DataElementCategory"
         column="categoryid" foreign-key="fk_categorycombo_categoryid"/> 
     </list>
 
-    <set name="optionCombos" table="categorycombos_optioncombos" inverse="true" cascade="all">
+    <set name="optionCombos" table="categorycombos_optioncombos" inverse="true">
       <key column="categorycomboid"/>
       <many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
         column="categoryoptioncomboid" foreign-key="fk_categorycombo_categoryoptioncomboid" unique="true"/>
-    </set>    
+    </set>
     
     </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml	2009-12-01 18:47:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml	2011-01-07 11:19:45 +0000
@@ -9,23 +9,23 @@
     <id name="id" column="categoryoptionid">
       <generator class="native"/>
     </id>
-        	
+
     <property name="uuid" length="40"/>
-    
+
     <property name="name">
       <column name="name" not-null="true" unique="true" length="160"/>
     </property>
-    
+
     <set name="categoryOptionCombos" table="categoryoptioncombos_categoryoptions" inverse="true">
 	  <key column="categoryoptionid"/>
 	  <many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
 		column="categoryoptioncomboid" foreign-key="fk_categoryoption_categoryoptioncomboid"/>
 	</set> 
-    
+
     <join table="categories_categoryoptions" inverse="true">
       <key column="categoryoptionid"/>
       <many-to-one column="categoryid" name="category"/>
     </join>
-    
+
   </class>
 </hibernate-mapping>

=== 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	2009-10-19 17:10:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml	2011-01-07 11:19:45 +0000
@@ -16,11 +16,11 @@
       <many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOption"
         column="categoryoptionid" foreign-key="fk_categoryoptioncombo_categoryoptionid"/> 
     </list>
-          
-    <join table="categorycombos_optioncombos">
+
+	<join table="categorycombos_optioncombos">
       <key column="categoryoptioncomboid"/>
       <many-to-one name="categoryCombo" column="categorycomboid"/>
-    </join>  
+    </join>
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/AddReportExcelItemAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/AddReportExcelItemAction.java	2010-08-31 08:12:53 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/AddReportExcelItemAction.java	2011-01-07 11:19:45 +0000
@@ -118,7 +118,6 @@
     public String execute()
         throws Exception
     {
-
         ReportExcelItem reportItem = new ReportExcelItem();
         reportItem.setName( name );
         reportItem.setItemType( itemType );

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm	2010-12-10 07:45:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm	2011-01-07 11:19:45 +0000
@@ -4,11 +4,11 @@
 	jQuery(document).ready(function(){	
 		deExpressionValidator = validation( 'dataelement-form', function(){ 
 			updateDeExpression();
-		});	
-		#if(!$reportExcel.isCategory()) 
-		remoteValidate( jQuery( "#dataelement textarea[id=formula]"), '../dhis-web-commons-ajax-json/getExpressionText.action' );	
+		});
+
+		#if( !$reportExcel.isCategory() )
+			remoteValidate( jQuery( "#dataelement textarea[id=formula]"), '../dhis-web-commons-ajax-json/getExpressionText.action' );	
 		#end
-	
 	});	
 	
 	

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/reportItems.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/reportItems.vm	2010-09-06 09:12:16 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/reportItems.vm	2011-01-07 11:19:45 +0000
@@ -73,7 +73,7 @@
 			<td>$reportItem.sheetNo </td>
 			<td align="center">				
 				<a href="updateReportExcelItemForm.action?reportExcelItemId=$reportItem.id&reportId=$reportExcel.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-				<a href="javascript:translate( 'ReportExcelItem', '$reportItem.id' )" title="$i18n.getString( "translation_translate" )"><img src="../images/i18n.png" alt="$i18n.getString( "translation_translate" )"></a>
+				<a href="javascript:translate( 'ReportExcelItem', '$reportItem.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"></a>
 				<a href="javascript:removeItem($reportItem.id, '$reportItem.name','$i18n.getString( 'confirm_delete' )', 'deleteReportExcelItem.action');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
 			</td>
 		</tr>