=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java 2014-04-03 13:57:45 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java 2014-04-03 16:03:26 +0000 @@ -28,28 +28,32 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.Serializable; import java.util.Date; +import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.DxfNamespaces; +import org.hisp.dhis.common.view.DetailedView; +import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.dataelement.CategoryOptionGroupSet; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + /** * Records the approval of DataSet values for a given OrganisationUnit and * Period. * * @author Jim Grace */ +@JacksonXmlRootElement( localName = "dataApprovalLevel", namespace = DxfNamespaces.DXF_2_0 ) public class DataApprovalLevel - implements Serializable + extends BaseIdentifiableObject { private static final long serialVersionUID = -8424400562969386167L; /** - * Identifies the data approval level instance. - */ - private int id; - - /** * The data approval level, 1=highest level, max=lowest level. */ private int level; @@ -65,16 +69,6 @@ private CategoryOptionGroupSet categoryOptionGroupSet; /** - * The Date (including time) when the data approval level was created. - */ - private Date created; - - /** - * The Date (including time) when the data approval level was last updated. - */ - private Date updated; - - /** * The name of the organisation unit level (derived through the service.) */ private String orgUnitLevelName; @@ -87,22 +81,22 @@ { } - public DataApprovalLevel( int orgUnitLevel, - CategoryOptionGroupSet categoryOptionGroupSet ) + public DataApprovalLevel( String name, int orgUnitLevel, CategoryOptionGroupSet categoryOptionGroupSet ) { + this.name = name; this.orgUnitLevel = orgUnitLevel; this.categoryOptionGroupSet = categoryOptionGroupSet; } - public DataApprovalLevel( int level, int orgUnitLevel, - CategoryOptionGroupSet categoryOptionGroupSet, - Date created, Date updated ) + public DataApprovalLevel( String name, int level, int orgUnitLevel, CategoryOptionGroupSet categoryOptionGroupSet, + Date created, Date lastUpdated ) { + this.name = name; this.level = level; this.orgUnitLevel = orgUnitLevel; this.categoryOptionGroupSet = categoryOptionGroupSet; this.created = created; - this.updated = updated; + this.lastUpdated = lastUpdated; } // ------------------------------------------------------------------------- @@ -145,16 +139,9 @@ // Getters and Setters // ------------------------------------------------------------------------- - public int getId() - { - return id; - } - - public void setId( int id ) - { - this.id = id; - } - + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public int getLevel() { return level; @@ -165,6 +152,9 @@ this.level = level; } + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public int getOrgUnitLevel() { return orgUnitLevel; @@ -175,6 +165,9 @@ this.orgUnitLevel = orgUnitLevel; } + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public CategoryOptionGroupSet getCategoryOptionGroupSet() { return categoryOptionGroupSet; @@ -185,26 +178,6 @@ this.categoryOptionGroupSet = categoryOptionGroupSet; } - public Date getCreated() - { - return created; - } - - public void setCreated( Date created ) - { - this.created = created; - } - - public Date getUpdated() - { - return updated; - } - - public void setUpdated( Date updated ) - { - this.updated = updated; - } - public String getOrgUnitLevelName() { return orgUnitLevelName; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java 2014-04-03 13:49:39 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java 2014-04-03 16:03:26 +0000 @@ -135,4 +135,12 @@ * @return level number of the lowest level the user can view. */ int getLowestUserDataApprovalLevel(); + + /** + * Gets the data approval level with the given name. + * + * @param name the name. + * @return a data approval level. + */ + DataApprovalLevel getDataApprovalLevelByName( String name ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java 2014-04-03 12:01:11 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java 2014-04-03 16:03:26 +0000 @@ -30,7 +30,7 @@ import java.util.List; -import org.hisp.dhis.common.GenericStore; +import org.hisp.dhis.common.GenericIdentifiableObjectStore; /** * Defines the functionality for persisting DataApproval objects. @@ -38,7 +38,7 @@ * @author Jim Grace */ public interface DataApprovalLevelStore - extends GenericStore + extends GenericIdentifiableObjectStore { String ID = DataApprovalLevelStore.class.getName(); === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 2014-04-03 16:03:26 +0000 @@ -0,0 +1,54 @@ +package org.hisp.dhis.schema.descriptors; + +/* + * Copyright (c) 2004-2014, 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.dataapproval.DataApprovalLevel; +import org.hisp.dhis.schema.Authority; +import org.hisp.dhis.schema.AuthorityType; +import org.hisp.dhis.schema.Schema; +import org.hisp.dhis.schema.SchemaDescriptor; +import org.springframework.stereotype.Component; + +import com.google.common.collect.Lists; + +@Component +public class DataApprovalLevelSchemaDescriptor implements SchemaDescriptor +{ + @Override + public Schema getSchema() + { + Schema schema = new Schema( DataApprovalLevel.class, "dataApprovalLevel", "dataApprovalLevels" ); + + schema.setShareable( false ); + + schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) ); + + return schema; + } +} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-03 13:49:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-03 16:03:26 +0000 @@ -271,6 +271,11 @@ return 0; } + + public DataApprovalLevel getDataApprovalLevelByName( String name ) + { + return dataApprovalLevelStore.getByName( name ); + } // ------------------------------------------------------------------------- // Supportive methods === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java 2014-04-03 12:01:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java 2014-04-03 16:03:26 +0000 @@ -32,15 +32,15 @@ import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.dataapproval.DataApprovalLevel; import org.hisp.dhis.dataapproval.DataApprovalLevelStore; -import org.hisp.dhis.hibernate.HibernateGenericStore; /** * @author Jim Grace */ public class HibernateDataApprovalLevelStore - extends HibernateGenericStore + extends HibernateIdentifiableObjectStore implements DataApprovalLevelStore { // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml 2014-03-30 04:37:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml 2014-04-03 16:03:26 +0000 @@ -10,6 +10,9 @@ + &identifiableProperties; + + @@ -18,9 +21,5 @@ - - - - === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-03-31 10:24:23 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-04-03 16:03:26 +0000 @@ -113,29 +113,29 @@ categoryService.saveCategoryOptionGroupSet( setC ); categoryService.saveCategoryOptionGroupSet( setD ); - level1 = new DataApprovalLevel( 1, null ); - level1A = new DataApprovalLevel( 1, setA ); - level1B = new DataApprovalLevel( 1, setB ); - level1C = new DataApprovalLevel( 1, setC ); - level1D = new DataApprovalLevel( 1, setD ); - - level2 = new DataApprovalLevel( 2, null ); - level2A = new DataApprovalLevel( 2, setA ); - level2B = new DataApprovalLevel( 2, setB ); - level2C = new DataApprovalLevel( 2, setC ); - level2D = new DataApprovalLevel( 2, setD ); - - level3 = new DataApprovalLevel( 3, null ); - level3A = new DataApprovalLevel( 3, setA ); - level3B = new DataApprovalLevel( 3, setB ); - level3C = new DataApprovalLevel( 3, setC ); - level3D = new DataApprovalLevel( 3, setD ); - - level4 = new DataApprovalLevel( 4, null ); - level4A = new DataApprovalLevel( 4, setA ); - level4B = new DataApprovalLevel( 4, setB ); - level4C = new DataApprovalLevel( 4, setC ); - level4D = new DataApprovalLevel( 4, setD ); + level1 = new DataApprovalLevel( "1", 1, null ); + level1A = new DataApprovalLevel( "1A", 1, setA ); + level1B = new DataApprovalLevel( "1B", 1, setB ); + level1C = new DataApprovalLevel( "1C", 1, setC ); + level1D = new DataApprovalLevel( "1D", 1, setD ); + + level2 = new DataApprovalLevel( "2", 2, null ); + level2A = new DataApprovalLevel( "2A", 2, setA ); + level2B = new DataApprovalLevel( "2B", 2, setB ); + level2C = new DataApprovalLevel( "2C", 2, setC ); + level2D = new DataApprovalLevel( "2D", 2, setD ); + + level3 = new DataApprovalLevel( "3", 3, null ); + level3A = new DataApprovalLevel( "3A", 3, setA ); + level3B = new DataApprovalLevel( "3B", 3, setB ); + level3C = new DataApprovalLevel( "3C", 3, setC ); + level3D = new DataApprovalLevel( "3D", 3, setD ); + + level4 = new DataApprovalLevel( "4", 4, null ); + level4A = new DataApprovalLevel( "4A", 4, setA ); + level4B = new DataApprovalLevel( "4B", 4, setB ); + level4C = new DataApprovalLevel( "4C", 4, setC ); + level4D = new DataApprovalLevel( "4D", 4, setD ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2014-04-01 19:50:22 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2014-04-03 16:03:26 +0000 @@ -284,10 +284,10 @@ organisationUnitService.addOrganisationUnit( organisationUnitE ); organisationUnitService.addOrganisationUnit( organisationUnitF ); - dataApprovalLevel1 = new DataApprovalLevel( 1, null ); - dataApprovalLevel2 = new DataApprovalLevel( 2, null ); - dataApprovalLevel3 = new DataApprovalLevel( 3, null ); - dataApprovalLevel4 = new DataApprovalLevel( 4, null ); + dataApprovalLevel1 = new DataApprovalLevel( "1", 1, null ); + dataApprovalLevel2 = new DataApprovalLevel( "2", 2, null ); + dataApprovalLevel3 = new DataApprovalLevel( "3", 3, null ); + dataApprovalLevel4 = new DataApprovalLevel( "4", 4, null ); userA = createUser( 'A' ); userB = createUser( 'B' ); @@ -387,14 +387,14 @@ groupSetB.addCategoryOptionGroup( groupC ); groupSetB.addCategoryOptionGroup( groupD ); - dataApprovalLevel1A = new DataApprovalLevel( 1, groupSetA ); - dataApprovalLevel1B = new DataApprovalLevel( 1, groupSetB ); - dataApprovalLevel2A = new DataApprovalLevel( 2, groupSetA ); - dataApprovalLevel2B = new DataApprovalLevel( 2, groupSetB ); - dataApprovalLevel3A = new DataApprovalLevel( 3, groupSetA ); - dataApprovalLevel3B = new DataApprovalLevel( 3, groupSetB ); - dataApprovalLevel4A = new DataApprovalLevel( 4, groupSetA ); - dataApprovalLevel4B = new DataApprovalLevel( 4, groupSetB ); + dataApprovalLevel1A = new DataApprovalLevel( "1A", 1, groupSetA ); + dataApprovalLevel1B = new DataApprovalLevel( "1B",1, groupSetB ); + dataApprovalLevel2A = new DataApprovalLevel( "2A", 2, groupSetA ); + dataApprovalLevel2B = new DataApprovalLevel( "2B", 2, groupSetB ); + dataApprovalLevel3A = new DataApprovalLevel( "3A", 3, groupSetA ); + dataApprovalLevel3B = new DataApprovalLevel( "3B", 3, groupSetB ); + dataApprovalLevel4A = new DataApprovalLevel( "4A", 4, groupSetA ); + dataApprovalLevel4B = new DataApprovalLevel( "4B", 4, groupSetB ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java 2014-03-27 15:10:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java 2014-04-03 16:03:26 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.concept.Concept; import org.hisp.dhis.constant.Constant; import org.hisp.dhis.dashboard.Dashboard; +import org.hisp.dhis.dataapproval.DataApprovalLevel; import org.hisp.dhis.datadictionary.DataDictionary; import org.hisp.dhis.dataelement.CategoryOptionGroup; import org.hisp.dhis.dataelement.CategoryOptionGroupSet; @@ -156,6 +157,8 @@ allExportClasses.put( Report.class, "reports" ); allExportClasses.put( Chart.class, "charts" ); allExportClasses.put( EventReport.class, "eventReports" ); + + allExportClasses.put( DataApprovalLevel.class, "dataApprovalLevels" ); allExportClasses.put( Dashboard.class, "dashboards" ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java 2014-03-27 15:10:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java 2014-04-03 16:03:26 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.concept.Concept; import org.hisp.dhis.constant.Constant; import org.hisp.dhis.dashboard.Dashboard; +import org.hisp.dhis.dataapproval.DataApprovalLevel; import org.hisp.dhis.datadictionary.DataDictionary; import org.hisp.dhis.dataelement.CategoryOptionGroup; import org.hisp.dhis.dataelement.CategoryOptionGroupSet; @@ -104,9 +105,11 @@ private Date created; private List schemas = Lists.newArrayList(); - + private List attributes = new ArrayList(); + private List dataApprovalLevels = new ArrayList(); + private List documents = new ArrayList(); private List constants = new ArrayList(); @@ -256,6 +259,19 @@ } @JsonProperty + @JacksonXmlElementWrapper( localName = "dataApprovalLevels", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "dataApprovalLevel", namespace = DxfNamespaces.DXF_2_0 ) + public List getDataApprovalLevels() + { + return dataApprovalLevels; + } + + public void setDataApprovalLevels( List dataApprovalLevels ) + { + this.dataApprovalLevels = dataApprovalLevels; + } + + @JsonProperty @JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "user", namespace = DxfNamespaces.DXF_2_0 ) public List getUsers() === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2014-03-22 15:30:31 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2014-04-03 16:03:26 +0000 @@ -42,6 +42,7 @@ { public static final TextUtils INSTANCE = new TextUtils(); public static final String EMPTY = ""; + public static final String SPACE = ""; public static final String LN = System.getProperty( "line.separator" ); private static final Pattern LINK_PATTERN = Pattern.compile( "((http://|https://|www\\.).+?)($|\\n|\\r|\\r\\n| )" ); === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalLevelController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalLevelController.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalLevelController.java 2014-04-03 16:03:26 +0000 @@ -0,0 +1,41 @@ +package org.hisp.dhis.api.controller; + +/* + * Copyright (c) 2004-2014, 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.dataapproval.DataApprovalLevel; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping( value = DataApprovalLevelController.RESOURCE_PATH ) +public class DataApprovalLevelController + extends AbstractCrudController +{ + public static final String RESOURCE_PATH = "/dataApprovalLevels"; +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/AddApprovalLevelAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/AddApprovalLevelAction.java 2014-03-31 11:43:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/AddApprovalLevelAction.java 2014-04-03 16:03:26 +0000 @@ -32,9 +32,14 @@ import org.hisp.dhis.dataapproval.DataApprovalLevelService; import org.hisp.dhis.dataelement.CategoryOptionGroupSet; import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; +import static org.hisp.dhis.system.util.TextUtils.*; + /** * @author Jim Grace */ @@ -45,20 +50,15 @@ // Dependencies // ------------------------------------------------------------------------- + @Autowired private DataApprovalLevelService dataApprovalLevelService; - public void setDataApprovalLevelService( DataApprovalLevelService dataApprovalLevelService ) - { - this.dataApprovalLevelService = dataApprovalLevelService; - } - + @Autowired private DataElementCategoryService categoryService; - public void setCategoryService( DataElementCategoryService categoryService ) - { - this.categoryService = categoryService; - } - + @Autowired + private OrganisationUnitService organisationUnitService; + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -83,14 +83,18 @@ public String execute() { - CategoryOptionGroupSet catOptGroupSet = null; + CategoryOptionGroupSet groupSet = null; if ( categoryOptionGroupSet != 0 ) { - catOptGroupSet = categoryService.getCategoryOptionGroupSet( categoryOptionGroupSet ); + groupSet = categoryService.getCategoryOptionGroupSet( categoryOptionGroupSet ); } + + OrganisationUnitLevel ouLevel = organisationUnitService.getOrganisationUnitLevelByLevel( organisationUnitLevel ); + + String name = ouLevel.getName() + ( groupSet != null ? SPACE + groupSet.getName() : EMPTY ); - DataApprovalLevel dataApprovalLevel = new DataApprovalLevel( organisationUnitLevel, catOptGroupSet ); + DataApprovalLevel dataApprovalLevel = new DataApprovalLevel( name, organisationUnitLevel, groupSet ); dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/ValidateApprovalLevelAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/ValidateApprovalLevelAction.java 2014-03-31 11:43:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/ValidateApprovalLevelAction.java 2014-04-03 16:03:26 +0000 @@ -64,7 +64,7 @@ { CategoryOptionGroupSet catOptGroupSet = categoryService.getCategoryOptionGroupSet( categoryOptionGroupSet ); - DataApprovalLevel level = new DataApprovalLevel( organisationUnitLevel, catOptGroupSet ); + DataApprovalLevel level = new DataApprovalLevel( null, organisationUnitLevel, catOptGroupSet ); boolean exists = dataApprovalLevelService.dataApprovalLevelExists( level ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2014-03-31 11:43:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2014-04-03 16:03:26 +0000 @@ -76,8 +76,6 @@ - -