=== added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrder.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrder.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrder.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,120 @@ +package org.hisp.dhis.reportsheet; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.List; + +import org.hisp.dhis.dataelement.DataElementCategoryOption; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class CategoryOptionGroupOrder +{ + private int id; + + private String name; + + private List categoryOptions; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public CategoryOptionGroupOrder() + { + } + + public CategoryOptionGroupOrder( String name ) + { + this.name = name; + } + + // ------------------------------------------------------------------------- + // Getters and setters + // ------------------------------------------------------------------------- + + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public List getCategoryOptions() + { + return categoryOptions; + } + + public void setCategoryOptions( List categoryOptions ) + { + this.categoryOptions = categoryOptions; + } + + // ------------------------------------------------------------------------- + // hashCode and equals + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + id; + return result; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + CategoryOptionGroupOrder other = (CategoryOptionGroupOrder) obj; + if ( id != other.id ) + return false; + return true; + } +} === added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderService.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderService.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderService.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,50 @@ +package org.hisp.dhis.reportsheet; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public interface CategoryOptionGroupOrderService +{ + String ID = CategoryOptionGroupOrderService.class.getName(); + + // ------------------------------------------------------------------------- + // Category Option Group Order + // ------------------------------------------------------------------------- + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( Integer id ); + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( String name, String clazzName, Integer reportId ); + + public void updateCategoryOptionGroupOrder( CategoryOptionGroupOrder attributeValueGroupOrder ); + + public void deleteCategoryOptionGroupOrder( Integer id ); + +} \ No newline at end of file === added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderStore.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderStore.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/CategoryOptionGroupOrderStore.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,50 @@ +package org.hisp.dhis.reportsheet; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public interface CategoryOptionGroupOrderStore +{ + String ID = CategoryOptionGroupOrderStore.class.getName(); + + // ------------------------------------------------------------------------- + // Category Option Group Order + // ------------------------------------------------------------------------- + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( Integer id ); + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( String name, String clazzName, Integer reportId ); + + public void updateCategoryOptionGroupOrder( CategoryOptionGroupOrder attributeValueGroupOrder ); + + public void deleteCategoryOptionGroupOrder( Integer id ); + +} === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2012-04-26 18:25:07 +0000 @@ -87,25 +87,45 @@ return results; } - public abstract boolean isAttribute(); + public boolean isAttribute() + { + return this.getReportType().equalsIgnoreCase( TYPE.ATTRIBUTE ); + } + + public boolean isCategory() + { + return this.getReportType().equalsIgnoreCase( TYPE.CATEGORY ); + } + + public boolean isCategoryVertical() + { + return this.getReportType().equalsIgnoreCase( TYPE.CATEGORY_VERTICAL ); + } + + public boolean isNormal() + { + return this.getReportType().equalsIgnoreCase( TYPE.NORMAL ); + } + + public boolean isOrgUnitGroupListing() + { + return this.getReportType().equalsIgnoreCase( TYPE.ORGANIZATION_GROUP_LISTING ); + } + + public boolean isPeriodColumnListing() + { + return this.getReportType().equalsIgnoreCase( TYPE.PERIOD_COLUMN_LISTING ); + } + + // ------------------------------------------------------------------------- + // Abstract methods + // ------------------------------------------------------------------------- + + public abstract String getReportType(); - public abstract boolean isCategory(); - - public abstract boolean isOrgUnitGroupListing(); - - public abstract boolean isPeriodColumnListing(); - - public abstract boolean isNormal(); - public abstract List getItemTypes(); // ------------------------------------------------------------------------- - // Abstract methods - // ------------------------------------------------------------------------- - - public abstract String getReportType(); - - // ------------------------------------------------------------------------- // Internal classes // ------------------------------------------------------------------------- @@ -114,7 +134,9 @@ public static final String NORMAL = "NORMAL"; public static final String CATEGORY = "CATEGORY"; - + + public static final String CATEGORY_VERTICAL = "CATEGORY_VERTICAL"; + public static final String ATTRIBUTE = "ATTRIBUTE"; public static final String PERIOD_COLUMN_LISTING = "PERIOD_COLUMN_LISTING"; === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportCategory.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportCategory.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportCategory.java 2012-04-26 18:25:07 +0000 @@ -68,36 +68,6 @@ } @Override - public boolean isAttribute() - { - return false; - } - - @Override - public boolean isCategory() - { - return true; - } - - @Override - public boolean isNormal() - { - return false; - } - - @Override - public boolean isOrgUnitGroupListing() - { - return false; - } - - @Override - public boolean isPeriodColumnListing() - { - return false; - } - - @Override public List getItemTypes() { List types = new ArrayList(); === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportNormal.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportNormal.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportNormal.java 2012-04-26 18:25:07 +0000 @@ -52,40 +52,11 @@ } @Override - public boolean isAttribute() - { - return false; - } - - @Override - public boolean isCategory() - { - return false; - } - - @Override - public boolean isNormal() - { - return true; - } - - @Override - public boolean isOrgUnitGroupListing() - { - return false; - } - - @Override - public boolean isPeriodColumnListing() - { - return false; - } - - @Override public List getItemTypes() { List types = new ArrayList(); types.add( ExportItem.TYPE.DATAELEMENT ); + types.add( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ); types.add( ExportItem.TYPE.INDICATOR ); types.add( ExportItem.TYPE.FORMULA_EXCEL ); === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportOrganizationGroupListing.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportOrganizationGroupListing.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportOrganizationGroupListing.java 2012-04-26 18:25:07 +0000 @@ -85,36 +85,6 @@ } @Override - public boolean isAttribute() - { - return false; - } - - @Override - public boolean isCategory() - { - return false; - } - - @Override - public boolean isNormal() - { - return false; - } - - @Override - public boolean isOrgUnitGroupListing() - { - return true; - } - - @Override - public boolean isPeriodColumnListing() - { - return false; - } - - @Override public List getItemTypes() { List types = new ArrayList(); === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportPeriodColumnListing.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportPeriodColumnListing.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportPeriodColumnListing.java 2012-04-26 18:25:07 +0000 @@ -78,36 +78,6 @@ } @Override - public boolean isAttribute() - { - return false; - } - - @Override - public boolean isCategory() - { - return false; - } - - @Override - public boolean isNormal() - { - return false; - } - - @Override - public boolean isOrgUnitGroupListing() - { - return false; - } - - @Override - public boolean isPeriodColumnListing() - { - return true; - } - - @Override public List getItemTypes() { List types = new ArrayList(); === added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportVerticalCategory.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportVerticalCategory.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportVerticalCategory.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,82 @@ +package org.hisp.dhis.reportsheet; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import java.util.ArrayList; +import java.util.List; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class ExportReportVerticalCategory + extends ExportReport +{ + private List categoryOptionGroupOrders; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public ExportReportVerticalCategory() + { + super(); + } + + // ------------------------------------------------------------------------- + // Getters and setters + // ------------------------------------------------------------------------- + + public List getCategoryOptionGroupOrders() + { + return categoryOptionGroupOrders; + } + + public void setCategoryOptionGroupOrders( List categoryOptionGroupOrders ) + { + this.categoryOptionGroupOrders = categoryOptionGroupOrders; + } + + @Override + public String getReportType() + { + return ExportReport.TYPE.CATEGORY_VERTICAL; + } + + @Override + public List getItemTypes() + { + List types = new ArrayList(); + types.add( ExportItem.TYPE.DATAELEMENT ); + types.add( ExportItem.TYPE.DATAELEMENT_CODE ); + types.add( ExportItem.TYPE.DATAELEMENT_NAME ); + types.add( ExportItem.TYPE.FORMULA_EXCEL ); + types.add( ExportItem.TYPE.SERIAL ); + + return types; + } +} === added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateCategoryOptionGroupOrderStore.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateCategoryOptionGroupOrderStore.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateCategoryOptionGroupOrderStore.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,102 @@ +package org.hisp.dhis.reportsheet.hibernate; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hibernate.SQLQuery; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderStore; +import org.hisp.dhis.reportsheet.ExportReport; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +@Transactional +public class HibernateCategoryOptionGroupOrderStore + implements CategoryOptionGroupOrderStore +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private SessionFactory sessionFactory; + + public void setSessionFactory( SessionFactory sessionFactory ) + { + this.sessionFactory = sessionFactory; + } + + // ------------------------------------------------------------------------- + // Data Element Group Order + // ------------------------------------------------------------------------- + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( Integer id ) + { + Session session = sessionFactory.getCurrentSession(); + return (CategoryOptionGroupOrder) session.get( CategoryOptionGroupOrder.class, id ); + } + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( String name, String clazzName, Integer reportId ) + { + Session session = sessionFactory.getCurrentSession(); + + String sql = "SELECT * FROM reportexcel_categoryoptiongrouporders WHERE lower(name) = :name"; + + if ( clazzName.equals( ExportReport.class.getSimpleName() ) ) + { + sql += " AND reportexcelid = :reportId"; + } + else + { + sql += " AND excelitemgroupid = :reportId"; + } + + SQLQuery query = session.createSQLQuery( sql ); + + query.addEntity( CategoryOptionGroupOrder.class ); + query.setString( "name", name.toLowerCase() ).setInteger( "reportId", reportId ); + + return (CategoryOptionGroupOrder) query.uniqueResult(); + } + + public void updateCategoryOptionGroupOrder( CategoryOptionGroupOrder categoryOptionGroupOrder ) + { + Session session = sessionFactory.getCurrentSession(); + session.update( categoryOptionGroupOrder ); + } + + public void deleteCategoryOptionGroupOrder( Integer id ) + { + Session session = sessionFactory.getCurrentSession(); + session.delete( this.getCategoryOptionGroupOrder( id ) ); + } +} === added file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultCategoryOptionGroupOrderService.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultCategoryOptionGroupOrderService.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultCategoryOptionGroupOrderService.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,77 @@ +package org.hisp.dhis.reportsheet.impl; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderStore; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +@Transactional +public class DefaultCategoryOptionGroupOrderService + implements CategoryOptionGroupOrderService +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private CategoryOptionGroupOrderStore categoryOptionGroupOrderStore; + + public void setCategoryOptionGroupOrderStore( CategoryOptionGroupOrderStore categoryOptionGroupOrderStore ) + { + this.categoryOptionGroupOrderStore = categoryOptionGroupOrderStore; + } + + // ------------------------------------------------------------------------- + // Data Element Group Order + // ------------------------------------------------------------------------- + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( Integer id ) + { + return categoryOptionGroupOrderStore.getCategoryOptionGroupOrder( id ); + } + + public void updateCategoryOptionGroupOrder( CategoryOptionGroupOrder categoryOptionGroupOrder ) + { + categoryOptionGroupOrderStore.updateCategoryOptionGroupOrder( categoryOptionGroupOrder ); + } + + public void deleteCategoryOptionGroupOrder( Integer id ) + { + categoryOptionGroupOrderStore.deleteCategoryOptionGroupOrder( id ); + } + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder( String name, String clazzName, Integer reportId ) + { + return categoryOptionGroupOrderStore.getCategoryOptionGroupOrder( name, clazzName, reportId ); + } +} === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-04-26 18:25:07 +0000 @@ -72,6 +72,21 @@ ref="org.hisp.dhis.reportsheet.AttributeValueGroupOrderStore" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/DataElementGroupOrder.hbm.xml' --- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/DataElementGroupOrder.hbm.xml 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/DataElementGroupOrder.hbm.xml 2012-04-26 18:25:07 +0000 @@ -15,5 +15,5 @@ - + \ No newline at end of file === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml' --- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml 2012-04-25 09:59:24 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml 2012-04-26 18:25:07 +0000 @@ -31,38 +31,53 @@ - + + - + + - + - + + - - - + + + + + + + + + + + + + + - + + === added directory 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup' === added directory 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action' === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/DeleteCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/DeleteCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/DeleteCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,71 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class DeleteCategoryOptionGroupOrderAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + categoryOptionGroupOrderService.deleteCategoryOptionGroupOrder( id ); + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,104 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class GetCategoryOptionGroupOrderAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private Integer reportId; + + public Integer getReportId() + { + return reportId; + } + + public void setReportId( Integer reportId ) + { + this.reportId = reportId; + } + + private String clazzName; + + public void setClazzName( String clazzName ) + { + this.clazzName = clazzName; + } + + public String getClazzName() + { + return clazzName; + } + + private CategoryOptionGroupOrder categoryOptionGroupOrder; + + public CategoryOptionGroupOrder getCategoryOptionGroupOrder() + { + return categoryOptionGroupOrder; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + categoryOptionGroupOrder = categoryOptionGroupOrderService.getCategoryOptionGroupOrder( id ); + + return SUCCESS; + } + +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionsByCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionsByCategoryAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/GetCategoryOptionsByCategoryAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.reportsheet.cogroup.action; + +import java.util.ArrayList; +import java.util.Collection; + +import org.hisp.dhis.dataelement.DataElementCategory; +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class GetCategoryOptionsByCategoryAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private DataElementCategoryService categoryService; + + // ------------------------------------------------------------------------- + // Input && Output + // ------------------------------------------------------------------------- + + private Integer categoryId; + + public void setAttributeId( Integer categoryId ) + { + this.categoryId = categoryId; + } + + private Collection categoryOptions = new ArrayList(); + + public Collection getCategoryOptions() + { + return categoryOptions; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + DataElementCategory category = categoryService.getDataElementCategory( categoryId ); + + if ( category != null ) + { + categoryOptions = category.getCategoryOptions(); + } + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/SaveCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/SaveCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/SaveCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,156 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.ExportReport; +import org.hisp.dhis.reportsheet.ExportReportService; +import org.hisp.dhis.reportsheet.ExportReportVerticalCategory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +public class SaveCategoryOptionGroupOrderAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private DataElementCategoryService categoryService; + + @Autowired + private ExportReportService exportReportService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + private String name; + + private String clazzName; + + private List categoryOptionIds = new ArrayList(); + + // ------------------------------------------------------------------------- + // Getter & Setter + // ------------------------------------------------------------------------- + + public void setName( String name ) + { + this.name = name; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public Integer getId() + { + return id; + } + + public void setClazzName( String clazzName ) + { + this.clazzName = clazzName; + } + + public void setCategoryOptionIds( List categoryOptionIds ) + { + this.categoryOptionIds = categoryOptionIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @SuppressWarnings( "unchecked" ) + public String execute() + throws Exception + { + CategoryOptionGroupOrder categoryOptionGroupOrder = new CategoryOptionGroupOrder( name ); + + List finalList = new ArrayList(); + List categoryOptions = new ArrayList(); + + removeDuplicatedItems( categoryOptionIds, finalList ); + + for ( String id : this.categoryOptionIds ) + { + DataElementCategoryOption categoryOption = categoryService.getDataElementCategoryOption( Integer + .parseInt( id ) ); + categoryOptions.add( categoryOption ); + } + + categoryOptionGroupOrder.setCategoryOptions( categoryOptions ); + + if ( clazzName.equals( ExportReport.class.getSimpleName() ) ) + { + ExportReportVerticalCategory exportReportVerticalCategory = (ExportReportVerticalCategory) exportReportService + .getExportReport( id ); + + List categoryOptionGroupOrders = exportReportVerticalCategory + .getCategoryOptionGroupOrders(); + + categoryOptionGroupOrders.add( categoryOptionGroupOrder ); + + exportReportVerticalCategory.setCategoryOptionGroupOrders( categoryOptionGroupOrders ); + + exportReportService.updateExportReport( exportReportVerticalCategory ); + } + + categoryOptions = null; + + return SUCCESS; + } + + private static void removeDuplicatedItems( List a, List b ) + { + for ( String s1 : a ) + { + if ( !b.contains( s1 ) ) + { + b.add( s1 ); + } + } + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,140 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class UpdateCategoryOptionGroupOrderAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private DataElementCategoryService categoryService; + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + private Integer categoryOptionGroupOrderId; + + private String name; + + private List categoryOptionIds = new ArrayList(); + + // ------------------------------------------------------------------------- + // Getter & Setter + // ------------------------------------------------------------------------- + + public void setCategoryOptionGroupOrderId( Integer categoryOptionGroupOrderId ) + { + this.categoryOptionGroupOrderId = categoryOptionGroupOrderId; + } + + public void setName( String name ) + { + this.name = name; + } + + public Integer getId() + { + return id; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public void setCategoryOptionIds( List categoryOptionIds ) + { + this.categoryOptionIds = categoryOptionIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + CategoryOptionGroupOrder categoryOptionGroupOrder = categoryOptionGroupOrderService + .getCategoryOptionGroupOrder( categoryOptionGroupOrderId ); + + categoryOptionGroupOrder.setName( name ); + + List finalList = new ArrayList(); + List categoryOptions = new ArrayList(); + + removeDuplicatedItems( categoryOptionIds, finalList ); + + for ( String id : this.categoryOptionIds ) + { + DataElementCategoryOption categoryOption = categoryService.getDataElementCategoryOption( Integer + .parseInt( id ) ); + categoryOptions.add( categoryOption ); + } + + categoryOptionGroupOrder.setCategoryOptions( categoryOptions ); + + categoryOptionGroupOrderService.updateCategoryOptionGroupOrder( categoryOptionGroupOrder ); + + return SUCCESS; + } + + private static void removeDuplicatedItems( List a, List b ) + { + for ( String s1 : a ) + { + if ( !b.contains( s1 ) ) + { + b.add( s1 ); + } + } + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,142 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class UpdateSortedCategoryOptionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private DataElementCategoryService categoryService; + + // ------------------------------------------------------------------------- + // I18n + // ------------------------------------------------------------------------- + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer id; + + private Integer reportId; + + private List categoryOptionIds = new ArrayList(); + + public String message; + + public I18n i18n; + + // ------------------------------------------------------------------------- + // Getter & Setter + // ------------------------------------------------------------------------- + + public String getMessage() + { + return message; + } + + public void setReportId( Integer reportId ) + { + this.reportId = reportId; + } + + public Integer getReportId() + { + return reportId; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public Integer getId() + { + return id; + } + + public void setCategoryOptionIds( List categoryOptionIds ) + { + this.categoryOptionIds = categoryOptionIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + CategoryOptionGroupOrder categoryOptionGroupOrder = categoryOptionGroupOrderService + .getCategoryOptionGroupOrder( id ); + + List categoryOptions = new ArrayList(); + + for ( Integer id : this.categoryOptionIds ) + { + DataElementCategoryOption categoryOption = categoryService.getDataElementCategoryOption( id ); + categoryOptions.add( categoryOption ); + } + + categoryOptionGroupOrder.setCategoryOptions( categoryOptions ); + + message = i18n.getString( "update_sort_categoryoption_success" ); + + categoryOptionGroupOrderService.updateCategoryOptionGroupOrder( categoryOptionGroupOrder ); + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/UpdateSortedCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,120 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.hisp.dhis.reportsheet.ExportReport; +import org.hisp.dhis.reportsheet.ExportReportService; +import org.hisp.dhis.reportsheet.ExportReportVerticalCategory; +import org.hisp.dhis.reportsheet.action.ActionSupport; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class UpdateSortedCategoryOptionGroupOrderAction + extends ActionSupport +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + @Autowired + private ExportReportService exportReportService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer reportId; + + public Integer getReportId() + { + return reportId; + } + + public void setReportId( Integer reportId ) + { + this.reportId = reportId; + } + + private String clazzName; + + public void setClazzName( String clazzName ) + { + this.clazzName = clazzName; + } + + private List categoryOptionGroupOrderId = new ArrayList(); + + public void setCategoryOptionGroupOrderId( List categoryOptionGroupOrderId ) + { + this.categoryOptionGroupOrderId = categoryOptionGroupOrderId; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + List categoryOptionGroupOrders = new ArrayList(); + + for ( String id : this.categoryOptionGroupOrderId ) + { + CategoryOptionGroupOrder coGroupOrder = categoryOptionGroupOrderService + .getCategoryOptionGroupOrder( Integer.parseInt( id ) ); + + categoryOptionGroupOrders.add( coGroupOrder ); + } + + if ( clazzName.equals( ExportReport.class.getSimpleName() ) ) + { + ExportReportVerticalCategory exportReportVerticalCategory = (ExportReportVerticalCategory) exportReportService + .getExportReport( reportId ); + + exportReportVerticalCategory.setCategoryOptionGroupOrders( categoryOptionGroupOrders ); + + exportReportService.updateExportReport( exportReportVerticalCategory ); + } + + message = i18n.getString( "update_successful" ); + + return SUCCESS; + } + +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/ValidateCategoryOptionGroupOrderAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/ValidateCategoryOptionGroupOrderAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/cogroup/action/ValidateCategoryOptionGroupOrderAction.java 2012-04-26 18:25:07 +0000 @@ -0,0 +1,100 @@ +package org.hisp.dhis.reportsheet.cogroup.action; + +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; +import org.hisp.dhis.reportsheet.CategoryOptionGroupOrderService; +import org.hisp.dhis.reportsheet.action.ActionSupport; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class ValidateCategoryOptionGroupOrderAction + extends ActionSupport +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private CategoryOptionGroupOrderService categoryOptionGroupOrderService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private Integer reportId; + + public void setReportId( Integer reportId ) + { + this.reportId = reportId; + } + + private String clazzName; + + public void setClazzName( String clazzName ) + { + this.clazzName = clazzName; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + CategoryOptionGroupOrder match = categoryOptionGroupOrderService.getCategoryOptionGroupOrder( name, clazzName, + reportId ); + + if ( match != null && (id == null || match.getId() != id) ) + { + message = i18n.getString( "name_ready_exist" ); + + return ERROR; + } + + return SUCCESS; + } +} === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-04-19 03:58:49 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-04-26 18:25:07 +0000 @@ -258,6 +258,48 @@ + + + + + + + + + + + + + + + + + + === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-04-19 03:58:49 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-04-26 18:25:07 +0000 @@ -188,6 +188,108 @@ /dhis-web-commons/ajax/jsonResponseError.vm plainTextError + + + + + + + /main.vm + /dhis-web-spreadsheet-reporting/listCategoryOptionGroupOrder.vm + /dhis-web-spreadsheet-reporting/menu.vm + javascript/category.ajax.js,javascript/categoryOptionGroupOrder.js + style/basic.css,style/style.css + + + + /main.vm + /dhis-web-spreadsheet-reporting/listCategoryOptionGroupOrder.vm + /dhis-web-spreadsheet-reporting/menu.vm + javascript/category.ajax.js,javascript/categoryOptionGroupOrder.js + style/basic.css,style/style.css + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + /dhis-web-commons/ajax/jsonResponseError.vm + + + + + listCategoryOptionGroupOrderForExportReport.action?id=${id} + + + + + listCategoryOptionGroupOrderForImportReport.action?id=${id} + + + + + + listCategoryOptionGroupOrderForExportReport.action?id=${id} + + + + + listCategoryOptionGroupOrderForImportReport.action?id=${id} + + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + + + /dhis-web-spreadsheet-reporting/jsonCategoryOptionGroupOrder.vm + + + + /main.vm + /dhis-web-spreadsheet-reporting/sortCategoryOptions.vm + /dhis-web-spreadsheet-reporting/menu.vm + javascript/categoryOptionGroupOrder.js + style/basic.css + + + + + listCategoryOptionGroupOrderForExportReport.action?id=${reportId} + + + + + listCategoryOptionGroupOrderForImportReport.action?id=${reportId} + + + + + /dhis-web-spreadsheet-reporting/jsonCategoryOptions.vm + plainTextError + @@ -208,7 +310,7 @@ /dhis-web-spreadsheet-reporting/listDataElementGroupOrder.vm /dhis-web-spreadsheet-reporting/menu.vm javascript/dataElementGroupOrder.js - style/basic.css, style/style.css + style/basic.css,style/style.css listAttributeValueGroupOrderForImportReport.action?id=${reportId} - + === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attributeValueGroupOrder.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attributeValueGroupOrder.js 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attributeValueGroupOrder.js 2012-04-26 18:25:07 +0000 @@ -1,16 +1,5 @@ var selectedAttributeValueMap = new Array(); -function addOptionToListWithToolTip( list, optionValue, optionText ) -{ - var option = document.createElement( "option" ); - option.value = optionValue; - option.text = optionText; - option.onmousemove = function(e) { - showToolTip(e, optionText); - } - list.add( option, null ); -} - function showAttributeValueGroupOrderDetails( id ) { jQuery.post( 'getAttributeValueGroupOrder.action', { id: id }, function( json ) { @@ -152,37 +141,4 @@ moveAllById( 'availableList', 'selectedList' ); selectAllById( 'selectedList' ); document.forms[0].submit(); -} - -/* -* Tooltip -*/ -function showToolTip( e, value) -{ - var tooltipDiv = byId( 'tooltip' ); - tooltipDiv.style.display = 'block'; - - var posx = 0; - var posy = 0; - - if (!e) var e = window.event; - if (e.pageX || e.pageY) - { - posx = e.pageX; - posy = e.pageY; - } - else if (e.clientX || e.clientY) - { - posx = e.clientX; - posy = e.clientY; - } - - tooltipDiv.style.left= posx + 8 + 'px'; - tooltipDiv.style.top = posy + 8 + 'px'; - tooltipDiv.innerHTML = "     " + value; -} - -function hideToolTip() -{ - byId('tooltip').style.display = 'none'; } \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/category.ajax.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/category.ajax.js 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/category.ajax.js 2012-04-26 18:25:07 +0000 @@ -0,0 +1,133 @@ + +function CategoryLib() +{ + var categoryMap = new Array(); + var categoryOptionMap = new Array(); + + this.loadCategories = function( elementId, id ) + { + var target = jQuery( "#" + elementId ); + target.children().remove(); + + if ( categoryMap.length == 0 ) + { + jQuery.getJSON( '../dhis-web-commons-ajax-json/getDataElementCategories.action', function( json ) + { + categoryMap.push( new Category( -1, '[ ' + i18n_label + ' ]' ) ); + target.append( '' ); + + jQuery.each( json.dataElementCategories, function( i, item ) + { + if ( id && item.id == id ) { + target.append( '' ); + } + else { + target.append( '' ); + } + + categoryMap.push( new Category( item.id, item.name ) ); + } ); + } ); + } + else + { + jQuery.each( categoryMap, function( i, item ) + { + if ( id && item.id == id ) { + target.append( '' ); + } + else { + target.append( '' ); + } + } ); + } + }; + + this.loadCategoryOptionsByCategory = function( id, curItems, sourceList, destList, isFirstLoad ) + { + var source = jQuery( "#" + sourceList ); + var dest = jQuery( "#" + destList ); + + if ( source ) + { + source.empty(); + } + + if ( dest && !isFirstLoad ) + { + dest.empty(); + } + + var valueList = categoryOptionMap[ id ]; + + if ( valueList == null ) + { + valueList = new Array(); + + jQuery.getJSON( 'getCategoryOptionsByCategory.action', { + categoryId : id + }, function( json ) + { + jQuery.each( json.categoryOptions, function( i, item ) + { + valueList.push( new CategoryOption( item.id, item.name ) ); + source.append( '' ); + } ); + + categoryOptionMap[ id ] = valueList; + } ); + } + else + { + jQuery.each( valueList, function( i, item ) + { + source.append( '' ); + } ); + } + + if ( curItems ) + { + jQuery.each( curItems, function( i, item ) + { + dest.append( '' ); + } ); + } + + this.removeDuplicatedItem( sourceList, destList ); + }; + + this.removeDuplicatedItem = function( availableList, selectedList ) + { + var $list1 = jQuery('#' + availableList); + var $list2 = jQuery('#' + selectedList); + + if ( $list1 && $list2 ) + { + jQuery.each( $list2.children(), function( i, item ) + { + $list1.find( "option[value='" + item.value + "']" ).remove(); + } ); + } + }; + + this.resetParams = function() + { + this.categoryMap = new Array(); + this.categoryOptionMap = new Array(); + } +} + + +function Category( _id, _name ) +{ + this.id = _id; + this.name = _name; +} + +function CategoryOption( _id, _name ) +{ + this.id = _id; + this.name = _name; +} + +var categoryLib = new CategoryLib(); \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/categoryOptionGroupOrder.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/categoryOptionGroupOrder.js 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/categoryOptionGroupOrder.js 2012-04-26 18:25:07 +0000 @@ -0,0 +1,143 @@ +var selectedCategoryOptionMap = new Array(); + +function showCategoryOptionGroupOrderDetails( id ) +{ + jQuery.post( 'getCategoryOptionGroupOrder.action', { id: id }, function( json ) { + + setInnerHTML( 'nameField', json.categoryOptionGroupOrder.name ); + setInnerHTML( 'memberCountField', json.categoryOptionGroupOrder.memberCount ); + + showDetails(); + }); +} + +function resetForm() +{ + setFieldValue( "name", "" ); + setFieldValue( "categoryOptionGroupOrderId", "" ); + + var availableList = jQuery( '#availableCategoryOptions' ); + availableList.empty(); + var selectedList = jQuery( '#categoryOptions' ); + selectedList.empty(); +} + +/* +* Open Add Category Option Group Order +*/ +function openAddCategoryOptionGroupOrder() +{ + resetForm(); + validator.resetForm(); + + categoryLib.loadCategories( "categoryId" ); + + dialog.dialog("open"); + + jQuery( "#categoryOptionGroupsForm" ).attr( "action", "addCategoryOptionGroupOrderFor" + clazzName + ".action?clazzName=" + clazzName ); +} + +/* +* Open Update Category Option Order +*/ + +function openUpdateCategoryOptionGroupOrder( id ) +{ + validator.resetForm(); + setFieldValue("categoryOptionGroupOrderId", id ); + + jQuery.post( 'getCategoryOptionGroupOrder.action', { id: id }, function( json ) + { + var categoryOptions = json.categoryOptionGroupOrder.categoryOptions; + var categoryId = ( categoryOptions.length > 0 ? categoryOptions[ 0 ].categoryId : "" ); + var list = jQuery( "#categoryOptions" ); + list.empty(); + selectedCategoryOptionMap = []; + var items = []; + + setFieldValue( "name", json.categoryOptionGroupOrder.name ); + categoryLib.loadCategories( "categoryId", categoryId ); + categoryLib.loadCategoryOptionsByCategory( categoryId, items, "availableCategoryOptions", "categoryOptions", true ); + + for ( var i = 0 ; i < categoryOptions.length ; i++ ) + { + items.push( new CategoryOption( categoryOptions[ i ].id, categoryOptions[ i ].name ) ); + list.append( '' ); + } + + selectedCategoryOptionMap[ id + "-" + categoryId ] = items; + + categoryLib.removeDuplicatedItem( "availableCategoryOptions", "categoryOptions" ); + + jQuery( "#categoryOptionGroupsForm" ).attr( "action", "updateCategoryOptionGroupOrderFor" + clazzName + ".action" ); + dialog.dialog( "open" ); + } ); +} + +function validateCategoryOptionGroupOrder( _form ) +{ + var categoryId = getFieldValue( "categoryId" ); + + if ( categoryId && categoryId != -1 ) + { + jQuery.postUTF8( "validateCategoryOptionGroupOrder.action", { + name: getFieldValue( 'name' ), + id: getFieldValue( 'categoryOptionGroupOrderId' ), + reportId: reportId, + clazzName: clazzName + }, function( json ) + { + if ( json.response == "success" ) + { + if ( hasElements( 'categoryOptions' ) ) + { + selectAllById( 'categoryOptions' ); + _form.submit(); + } + else { markInvalid( "categoryOptions", i18n_selected_list_empty ); } + } + else { markInvalid( "name", json.message ); } + } ); + } else { markInvalid( "categoryId", i18n_verify_category ); } +} + +/* +* Delete Category Option Group Order +*/ +function deleteCategoryOptionGroupOrder( id, name ) +{ + removeItem( id, name, i18n_confirm_delete, 'deleteCategoryOptionGroupOrder.action', function(){ window.location.reload(); } ); +} + +/* +* Update Category Option Group Order +*/ +function updateSortCategoryOptionGroupOrder() +{ + var categoryOptionGroups = document.getElementsByName( 'categoryOptionGroupOrder' ); + var url = "updateSortCategoryOptionGroupOrder.action?reportId=" + reportId + "&clazzName=" + clazzName; + + for ( var i = 0 ; i < categoryOptionGroups.length ; i++ ) + { + url += "&categoryOptionGroupOrderId=" + categoryOptionGroups.item(i).value; + } + + jQuery.get( url, {}, function( json ) { + showSuccessMessage( json.message ); + }); +} + +function openSortCategoryOptionForGroupOrder( id ) +{ + window.location = "openSortCategoryOption.action?id="+id+"&reportId="+reportId+"&clazzName="+clazzName; +} + +/* +* Update Sorted Category Option +*/ +function updateSortedCategoryOption() +{ + moveAllById( 'availableList', 'selectedList' ); + selectAllById( 'selectedList' ); + document.forms[0].submit(); +} \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/dataElementGroupOrder.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/dataElementGroupOrder.js 2011-12-13 07:46:57 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/dataElementGroupOrder.js 2012-04-26 18:25:07 +0000 @@ -1,15 +1,3 @@ - -function addOptionToListWithToolTip( list, optionValue, optionText ) -{ - var option = document.createElement( "option" ); - option.value = optionValue; - option.text = optionText; - option.onmousemove = function(e) { - showToolTip(e, optionText); - } - list.add( option, null ); -} - function showDataElementGroupOrderDetails( id ) { jQuery.post( 'getDataElementGroupOrder.action', { id: id }, function( json ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-04-25 09:59:24 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-04-26 18:25:07 +0000 @@ -57,6 +57,8 @@ { if ( attribute ) { byId('expression-button' ).onclick = avExpressionBuilderForm; + } else if ( categoryVertical ) { + byId('expression-button' ).onclick = coExpressionBuilderForm; } else { byId('expression-button' ).onclick = deExpressionBuilderForm; } @@ -92,18 +94,22 @@ var expression = ''; if ( attribute ) { - expression = "[" + getFieldValue( "groupSelect" ) + "@" + getFieldValue( "elementSelect" ) + "]"; + expression = "[" + getFieldValue( "attributevalue [id=groupSelect]" ) + "@" + getFieldValue( "attributevalue [id=elementSelect]" ) + "]"; + setFieldValue( 'attributevalue [id=formula]', getFieldValue( 'attributevalue [id=formula]' ) + expression ); } else if ( category ) { - expression = "[*." + getFieldValue( "elementSelect" )+ "]"; + expression = "[*." + getFieldValue( "dataelement [id=elementSelect]" )+ "]"; + setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression ); + } + else if ( categoryVertical ) { + expression = "[*." + getFieldValue( "categoryoption [id=elementSelect]" )+ "]"; + setFieldValue( 'categoryoption [id=formula]', getFieldValue( 'categoryoption [id=formula]' ) + expression ); } else { - expression = getFieldValue( "elementSelect" ); - alert(expression); + expression = getFieldValue('dataelement [id=elementSelect]'); + setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression ); } - setFieldValue( 'formula', getFieldValue( 'formula' ) + expression ); - if ( !attribute ) { getExpression(); } } === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/grouporder.tooltip.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/grouporder.tooltip.js 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/grouporder.tooltip.js 2012-04-26 18:25:07 +0000 @@ -0,0 +1,44 @@ +/* +* Tooltip +*/ + +function addOptionToListWithToolTip( list, optionValue, optionText ) +{ + var option = document.createElement( "option" ); + option.value = optionValue; + option.text = optionText; + option.onmousemove = function(e) { + showToolTip(e, optionText); + } + list.add( option, null ); +} + +function showToolTip( e, value) +{ + var tooltipDiv = byId( 'tooltip' ); + tooltipDiv.style.display = 'block'; + + var posx = 0; + var posy = 0; + + if (!e) var e = window.event; + if (e.pageX || e.pageY) + { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) + { + posx = e.clientX; + posy = e.clientY; + } + + tooltipDiv.style.left= posx + 8 + 'px'; + tooltipDiv.style.top = posy + 8 + 'px'; + tooltipDiv.innerHTML = "     " + value; +} + +function hideToolTip() +{ + byId('tooltip').style.display = 'none'; +} \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptionGroupOrder.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptionGroupOrder.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptionGroupOrder.vm 2012-04-26 18:25:07 +0000 @@ -0,0 +1,18 @@ +{ "categoryOptionGroupOrder": + { + "name": "$!encoder.jsonEncode( ${categoryOptionGroupOrder.name} )", + + #set( $size = ${categoryOptionGroupOrder.categoryOptions.size()} ) + "memberCount": "${size}", + + "categoryOptions": [ + #foreach( $co in $!categoryOptionGroupOrder.categoryOptions ) + { + "id": "${co.id}", + "name": "$!encoder.jsonEncode( ${co.name} )", + "categoryId": "${co.category.id}" + }#if( $velocityCount < $size ),#end + #end + ] + } +} \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptions.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptions.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/jsonCategoryOptions.vm 2012-04-26 18:25:07 +0000 @@ -0,0 +1,12 @@ +#set( $size = $!categoryOptions.size() ) +{ + "categoryOptions": [ + #foreach( $co in $!categoryOptions ) + { + "id": "${co.id}", + "name": "$!encoder.jsonEncode( ${co.name} )", + "categoryId": "${co.category.id}" + }#if( $velocityCount < $size ),#end + #end + ] +} \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listCategoryOptionGroupOrder.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listCategoryOptionGroupOrder.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listCategoryOptionGroupOrder.vm 2012-04-26 18:25:07 +0000 @@ -0,0 +1,134 @@ + +

$i18n.getString( 'categoryoption_groups' )

+

$!encoder.htmlEncode( $!report.displayName )

+ + + + + + + + + +
+ + + + +
$i18n.getString('name')$i18n.getString('operations')
+ + + + + +
+ + + +
+ +
    +#foreach( $group in $!report.categoryOptionOrders ) +
  • + + + + + +
    $!encoder.htmlEncode( $group.name ) + $i18n.getString( 'remove' ) + $i18n.getString( 'edit' ) + + $i18n.getString( 'show_details' ) +
    +
  • +#end +
+ +
+
+ + + + + + + +
$i18n.getString('name')
+
+ + + + + + + + + + +
+ +
+ + +
+
+
+ +
+ +

+

+

+ +
+ +

+ + +

+
+
+ +
+ + \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2012-04-25 09:59:24 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2012-04-26 18:25:07 +0000 @@ -6,8 +6,9 @@ }); }); + var attribute = $!exportReport.isAttribute(); var category = $!exportReport.isCategory(); - var attribute = $!exportReport.isAttribute(); + var categoryVertical = $!exportReport.isCategoryVertical(); @@ -99,10 +100,24 @@ -#parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) \ No newline at end of file + +#if ( $!exportReport.isAttribute() ) + #parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isCategory() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isCategoryVertical() ) + #parse( "/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isPeriodColumnListing() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isNormal() || $!exportReport.isOrgUnitGroupListing() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) +#end === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm 2012-04-26 18:25:07 +0000 @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2012-04-25 09:59:24 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2012-04-26 18:25:07 +0000 @@ -6,8 +6,10 @@ }); }); + var attribute = $!exportReport.isAttribute(); var category = $!exportReport.isCategory(); - var attribute = $!exportReport.isAttribute(); + var categoryVertical = $!exportReport.isCategoryVertical(); +

$i18n.getString( 'update_export_item' )

@@ -100,10 +102,23 @@ -#parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) - -#parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) +#if ( $!exportReport.isAttribute() ) + #parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isCategory() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isCategoryVertical() ) + #parse( "/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isPeriodColumnListing() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) + +#elseif ( $!exportReport.isNormal() || $!exportReport.isOrgUnitGroupListing() ) + #parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" ) + #parse( "/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm" ) +#end \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortAttributeValues.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortAttributeValues.vm 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortAttributeValues.vm 2012-04-26 18:25:07 +0000 @@ -13,7 +13,7 @@ === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortCategoryOptions.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortCategoryOptions.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/sortCategoryOptions.vm 2012-04-26 18:25:07 +0000 @@ -0,0 +1,44 @@ +

$i18n.getString( "sort_categoryoption" )

+
+ + + + + + + + + + + + + + + +
$i18n.getString( "available_categoryoptions" )$i18n.getString( "selected_categoryoptions" )
+ + +
+
+
+ +
+ + +

+

+

+ +
+ +

+ + +

+ + \ No newline at end of file