dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12908
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4038: Implemented GUI stuff for Constant
------------------------------------------------------------
revno: 4038
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-30 14:55:55 +0700
message:
Implemented GUI stuff for Constant
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator/
dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator/ConstantNameComparator.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/RemoveConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/ValidateConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addConstantForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/constant.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseConstant.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateConstantForm.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constant.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constant.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constant.java 2011-06-29 08:51:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constant.java 2011-06-30 07:55:55 +0000
@@ -49,7 +49,7 @@
// Variables
// -------------------------------------------------------------------------
- private Double value;
+ private double value;
// -------------------------------------------------------------------------
// Constructors
@@ -64,7 +64,7 @@
this.name = name;
}
- public Constant( String name, Double value )
+ public Constant( String name, double value )
{
this.name = name;
this.value = value;
@@ -113,12 +113,12 @@
// Getter & Setter
// -------------------------------------------------------------------------
- public Double getValue()
+ public double getValue()
{
return value;
}
- public void setValue( Double value )
+ public void setValue( double value )
{
this.value = value;
}
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator/ConstantNameComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator/ConstantNameComparator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/comparator/ConstantNameComparator.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,45 @@
+package org.hisp.dhis.constant.comparator;
+
+/*
+ * Copyright (c) 2004-2010, 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.Comparator;
+
+import org.hisp.dhis.constant.Constant;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ConstantNameComparator
+ implements Comparator<Constant>
+{
+ public int compare( Constant constant0, Constant constant1 )
+ {
+ return constant0.getName().compareToIgnoreCase( constant1.getName() );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-06-20 04:14:46 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-06-30 07:55:55 +0000
@@ -361,5 +361,14 @@
"description" : {
"rangelength" : [ 2, 160 ]
}
+ },
+ "constant" : {
+ "name" : {
+ "required" : true,
+ "rangelength" : [ 2, 230 ]
+ },
+ "value" : {
+ "required" : true
+ }
}
}
=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * 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.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class AddConstantAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String value;
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ Constant constant = new Constant( name, Double.parseDouble( value ) );
+
+ constantService.saveConstant( constant );
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * 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.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class GetConstantAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Constant constant;
+
+ public Constant getConstant()
+ {
+ return constant;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ constant = constantService.getConstant( id );
+System.out.println("\n\n constant : " + constant.getValue() );
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantListAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/GetConstantListAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,110 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * Copyright (c) 2004-2010, 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 static org.apache.commons.lang.StringUtils.isNotBlank;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.constant.comparator.ConstantNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class GetConstantListAction
+ extends ActionPagingSupport<Constant>
+{
+ /**
+ * Determines if a de-serialized file is compatible with this class.
+ */
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<Constant> constants;
+
+ public List<Constant> getConstants()
+ {
+ return constants;
+ }
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ if ( isNotBlank( key ) ) // Filter on key only if set
+ {
+ this.paging = createPaging( constantService.getConstantCountByName( key ) );
+
+ constants = new ArrayList<Constant>( constantService.getConstantsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( constantService.getConstantCount() );
+
+ constants = new ArrayList<Constant>( constantService.getConstantsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
+
+ Collections.sort( constants, new ConstantNameComparator() );
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/RemoveConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/RemoveConstantAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/RemoveConstantAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,109 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * Copyright (c) 2004-2010, 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.common.DeleteNotAllowedException;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class RemoveConstantAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ try
+ {
+ constantService.deleteConstant( constantService.getConstant( id ) );
+ }
+ catch ( DeleteNotAllowedException ex )
+ {
+ if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) )
+ {
+ message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getClassName();
+
+ return ERROR;
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * Copyright (c) 2004-2010, 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.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class UpdateConstantAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String value;
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ Constant constant = constantService.getConstant( id );
+
+ constant.setName( name );
+ constant.setValue( Double.parseDouble( value ) );
+
+ constantService.updateConstant( constant );
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/ValidateConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/ValidateConstantAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/ValidateConstantAction.java 2011-06-30 07:55:55 +0000
@@ -0,0 +1,141 @@
+package org.hisp.dhis.dataadmin.action.constant;
+
+/*
+ * Copyright (c) 2004-2010, 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.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ValidateConstantAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String value;
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ if ( name != null )
+ {
+ Constant match = constantService.getConstantByName( name );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "name_in_used" );
+
+ return ERROR;
+ }
+ }
+
+ if ( value != null )
+ {
+ try
+ {
+ double valueTemp = Double.parseDouble( value );
+
+ if ( Double.isNaN( valueTemp ) || Double.isInfinite( valueTemp ) )
+ {
+ message = i18n.getString( "value_must_be_double" );
+
+ return ERROR;
+ }
+ }
+ catch ( NumberFormatException nfe )
+ {
+ message = i18n.getString( "value_must_be_double" );
+
+ return ERROR;
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-06-30 07:55:55 +0000
@@ -246,5 +246,43 @@
scope="prototype">
<property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
</bean>
+
+ <!-- Constant Name -->
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.AddConstantAction"
+ class="org.hisp.dhis.dataadmin.action.constant.AddConstantAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.UpdateConstantAction"
+ class="org.hisp.dhis.dataadmin.action.constant.UpdateConstantAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.ValidateConstantAction"
+ class="org.hisp.dhis.dataadmin.action.constant.ValidateConstantAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.RemoveConstantAction"
+ class="org.hisp.dhis.dataadmin.action.constant.RemoveConstantAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.GetConstantAction"
+ class="org.hisp.dhis.dataadmin.action.constant.GetConstantAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.constant.GetConstantListAction"
+ class="org.hisp.dhis.dataadmin.action.constant.GetConstantListAction"
+ scope="prototype">
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ </bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2011-06-20 04:14:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2011-06-30 07:55:55 +0000
@@ -121,6 +121,7 @@
intro_zero_storage_management = Define which data elements for which zero values should be stored or ignored. Useful for reducing database size.
intro_duplicate_data_elimination = Eliminate data registered for duplicate data elements. Useful when data has been entered for identical data elements.
intro_sql_view = Create SQL database views. These views will typically use the resource tables to provide convenient views for third-party tools.
+intro_constant = Create the Constant which would be included in expression of indicator/validation rule.
expression_is_empty = Expression is empty
dataelement_id_not_numeric = Data element identifier must be a number
category_option_combo_id_not_numeric = Category option combo identifier must be a number
@@ -319,4 +320,10 @@
get_report_as_csv = Download as CSV
get_report_as_pdf = Download as PDF
data_element_structure = Data element structure
-organisation_not_selected = There is no organization unit selected
\ No newline at end of file
+organisation_not_selected = There is no organization unit selected
+constant = Constant
+constant_management = Constant Management
+create_new_constant = Add Constant
+edit_constant = Edit Constant
+value_must_be_double = The given value must be a double
+confirm_delete_constant = Do you want to delete this constant object ?
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties 2011-04-21 17:07:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties 2011-06-30 07:55:55 +0000
@@ -159,6 +159,7 @@
intro_data_browser = Tr\u00ecnh duy\u1ec7t d\u1eef li\u1ec7u v\u00e0 \u0111\u01b0a ra m\u1ed9t c\u00e1i nh\u00ecn t\u1ed5ng quan cho c\u00e1c t\u1eadp d\u1eef li\u1ec7u, c\u00e1c \u0111\u01a1n v\u1ecb, v\u00e0 c\u00e1c th\u1eddi k\u1ef3 c\u00f3 d\u1eef li\u1ec7u l\u01b0u tr\u1eef.
intro_data_archive = L\u01b0u tr\u1eef d\u1eef li\u1ec7u m\u00e0 hi\u1ec7n t\u1ea1i kh\u00f4ng li\u00ean quan \u0111\u1ebfn h\u1ec7 th\u1ed1ng nh\u1eb1m n\u00e2ng cao t\u00ednh th\u1ec3 hi\u1ec7n. D\u1eef li\u1ec7u c\u0169ng c\u00f3 th\u1ec3 kh\u00f4ng \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef.
intro_cache_statistics = Xem t\u00ecnh tr\u1ea1ng b\u1ed9 nh\u1edb cache trong c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u1ee7a h\u1ec7 th\u1ed1ng v\u00e0 x\u00f3a cache.
+intro_constant = Ch\u1ee9c n\u0103ng t\u1ea1o Bi\u1ec3u th\u1ee9c H\u1eb1ng. Bi\u1ec3u th\u1ee9c H\u1eb1ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong bi\u1ec3u th\u1ee9c c\u1ee7a Ch\u1ec9 s\u1ed1 v\u00e0/ho\u1eb7c Validation Rule.
indicators_without_groups = C\u00e1c ch\u1ec9 s\u1ed1 kh\u00f4ng c\u00f3 nh\u00f3m
indicators_with_identical_formulas = C\u00e1c ch\u1ec9 s\u1ed1 c\u00f9ng c\u00f4ng th\u1ee9c
indicators_with_blank_formulas = C\u00e1c ch\u1ec9 s\u1ed1 c\u00f3 c\u00f4ng th\u1ee9c ch\u1ee9a kho\u1ea3ng tr\u1eafng
@@ -296,4 +297,10 @@
lock = Kh\u00f3a
locked = \u0110\u00e3 kh\u00f3a
unlock = M\u1edf kh\u00f3a
-unlocked = \u0110\u00e3 m\u1edf kh\u00f3a
\ No newline at end of file
+unlocked = \u0110\u00e3 m\u1edf kh\u00f3a
+constant = Bi\u1ec3u th\u1ee9c H\u1eb1ng
+constant_management = Qu\u1ea3n l\u00fd Bi\u1ec3u th\u1ee9c H\u1eb1ng
+create_new_constant = Th\u00eam Bi\u1ec3u th\u1ee9c H\u1eb1ng
+edit_constant = Ch\u1ec9nh s\u1eeda Bi\u1ec3u th\u1ee9c H\u1eb1ng
+value_must_be_double = Gi\u00e1 tr\u1ecb nh\u1eadp v\u00e0o ph\u1ea3i l\u00e0 1 s\u1ed1 Double
+confirm_delete_constant = B\u1ea1n c\u00f3 mu\u1ed1n x\u00f3a Bi\u1ec3u th\u1ee9c H\u1eb1ng n\u00e0y kh\u00f4ng ?
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2011-06-30 07:55:55 +0000
@@ -385,5 +385,66 @@
<param name="requiredAuthorities">F_SQLVIEW_MANAGEMENT</param>
</action>
+ <!-- Constant Name -->
+
+ <action name="getConstant" class="org.hisp.dhis.dataadmin.action.constant.GetConstantAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-maintenance-dataadmin/responseConstant.vm</result>
+ </action>
+
+ <action name="constant" class="org.hisp.dhis.dataadmin.action.constant.GetConstantListAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+ <param name="page">
+ /dhis-web-maintenance-dataadmin/constant.vm</param>
+ <param name="requiredAuthorities">F_CONSTANT_MANAGEMENT</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
+ </action>
+
+ <action name="showAddConstantForm" class="org.hisp.dhis.dataadmin.action.NoAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+ <param name="page">
+ /dhis-web-maintenance-dataadmin/addConstantForm.vm</param>
+ <param name="requiredAuthorities">F_CONSTANT_ADD</param>
+ </action>
+
+ <action name="addConstant" class="org.hisp.dhis.dataadmin.action.constant.AddConstantAction">
+ <result name="success" type="redirect">constant.action</result>
+ <result name="error" type="redirect">index.action</result>
+ <param name="requiredAuthorities">F_CONSTANT_ADD</param>
+ </action>
+
+ <action name="showUpdateConstantForm" class="org.hisp.dhis.dataadmin.action.constant.GetConstantAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+ <param name="page">
+ /dhis-web-maintenance-dataadmin/updateConstantForm.vm</param>
+ <param name="requiredAuthorities">F_CONSTANT_UPDATE</param>
+ </action>
+
+ <action name="updateConstant" class="org.hisp.dhis.dataadmin.action.constant.UpdateConstantAction">
+ <result name="success" type="redirect">constant.action</result>
+ <result name="error" type="redirect">index.action</result>
+ <param name="requiredAuthorities">F_CONSTANT_UPDATE</param>
+ </action>
+
+ <action name="validateConstant" class="org.hisp.dhis.dataadmin.action.constant.ValidateConstantAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="removeConstant" class="org.hisp.dhis.dataadmin.action.constant.RemoveConstantAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ <param name="requiredAuthorities">F_CONSTANT_DELETE</param>
+ </action>
+
</package>
</struts>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addConstantForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addConstantForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addConstantForm.vm 2011-06-30 07:55:55 +0000
@@ -0,0 +1,37 @@
+<script type="text/javascript">
+ jQuery(document).ready( function(){
+ var rules = getValidationRules("constant");
+
+ validation2( 'addConstantForm', function( form ) { form.submit() }, {
+ 'rules': rules
+ });
+
+ checkValueIsExist( "name", "validateConstant.action" );
+ remoteValidateById( "value", "validateConstant.action" );
+ });
+</script>
+
+<h3>$i18n.getString( "create_new_constant" )</h3>
+
+<form id="addConstantForm" action="addConstant.action" method="post" >
+
+<table>
+ <tr>
+ <th colspan="2">$i18n.getString( "details" )</th>
+ </tr>
+ <tr>
+ <td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="name" name="name" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="name">$i18n.getString( "value" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="value" name="value" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='constant.action'" style="width:10em"/></td>
+ </tr>
+</table>
+
+</form>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/constant.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/constant.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/constant.vm 2011-06-30 07:55:55 +0000
@@ -0,0 +1,88 @@
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+ tableSorter( 'listTable' );
+ });
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_constant" ) , "'")';
+
+ // -----------------------------------------------------------------------------
+ // View details
+ // -----------------------------------------------------------------------------
+
+ function showConstantDetails( constantId )
+ {
+ jQuery.post( 'getConstant.action',
+ { 'id':constantId },
+ function( constantElement ) {
+ setInnerHTML( 'nameField', getElementValue( constantElement, 'name' ) );
+ setInnerHTML( 'valueField', getElementValue( constantElement, 'value' ) );
+ showDetails();
+ });
+ }
+
+ // -----------------------------------------------------------------------------
+ // Remove category constant
+ // -----------------------------------------------------------------------------
+
+ function removeConstant( constantId, constantName )
+ {
+ removeItem( constantId, constantName, i18n_confirm_delete, 'removeConstant.action' );
+ }
+</script>
+
+<h3>$i18n.getString( "constant_management" ) #openHelp( "constant" )</h3>
+
+<table class="mainPageTable">
+ <tr>
+ <td style="vertical-align:top">
+ <table width="100%">
+ <tr>
+ <td>#filterDiv( "constant" )</td>
+ <td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddConstantForm.action'" style="width:80px"/></td>
+ </tr>
+ </table>
+ <table class="listTable" id="listTable">
+ <col/>
+ <col width="96px"/>
+ <thead>
+ <tr>
+ <th>$i18n.getString( "name" )</th>
+ <th class="{sorter: false}">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #foreach( $constant in $constants )
+ <tr id="tr${constant.id}">
+ <td onclick="javascript:showConstantDetails( $constant.id )">$encoder.htmlEncode( $constant.name )</td>
+ <td style="text-align:right">
+ <a href="showUpdateConstantForm.action?id=$constant.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
+ <a href="javascript:removeConstant( $constant.id, '$encoder.jsEncode( $constant.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
+ <a href="javascript:showConstantDetails( $constant.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
+ </td>
+ </tr>
+ #end
+ </tbody>
+ </table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </td>
+
+ <td style="width:20em; padding-left:2em; vertical-align:top">
+
+ <div id="detailsArea" style="display:none">
+ <div style="float:right">
+ <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"/></a>
+ </div>
+ <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
+ <p><label>$i18n.getString( "value" ):</label><br/><span id="valueField"></span></p>
+ </div>
+
+ <div id="warningArea" style="position:fixed;right:10px;top:200px;display:none">
+ <div style="float:right">
+ <a href="javascript:hideWarning()" title="$i18n.getString( 'hide_warning' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_warning' )"/></a>
+ </div>
+ <p><span id="warningField"></span></p>
+ </div>
+ </td>
+ </tr>
+</table>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm 2011-05-31 12:24:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm 2011-06-30 07:55:55 +0000
@@ -23,4 +23,5 @@
#introListImgItem( "displayPruneOrganisationUnitForm.action" "organisation_unit_pruning" "organisationunitpruning" )
#introListImgItem( "getMinMaxValidationParams.action" "min_max_value_generation" "minmaxvaluegeneration" )
#introListImgItem( "showCache.action" "cache_statistics" "cachestatistics" )
+ #introListImgItem( "constant.action" "constant" "constant" )
</ul>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm 2011-03-17 14:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm 2011-06-30 07:55:55 +0000
@@ -16,6 +16,7 @@
<li><a href="zeroValueStorageManagement.action">$i18n.getString( "zero_storage_management" ) </a></li>
<li><a href="displayPruneOrganisationUnitForm.action">$i18n.getString( "organisation_unit_pruning" ) </a></li>
<li><a href="getMinMaxValidationParams.action">$i18n.getString( "min_max_value_generation") </a></li>
+ <li><a href="constant.action">$i18n.getString( "constant") </a></li>
</ul>
<h2>$i18n.getString( "system_administration" ) </h2>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseConstant.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseConstant.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseConstant.vm 2011-06-30 07:55:55 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<constant>
+ <id>$constant.id</id>
+ <name>$encoder.xmlEncode( $constant.name )</name>
+ <value>$constant.value</value>
+</constant>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateConstantForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateConstantForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateConstantForm.vm 2011-06-30 07:55:55 +0000
@@ -0,0 +1,38 @@
+<script type="text/javascript">
+ jQuery(document).ready( function(){
+ var rules = getValidationRules("constant");
+
+ validation2( 'updateConstantForm', function( form ) { form.submit() }, {
+ 'rules': rules
+ });
+
+ checkValueIsExist( "name", "validateConstant.action", {id: $constant.id});
+ remoteValidateById( "value", "validateConstant.action" );
+ });
+</script>
+
+<h3>$i18n.getString( "edit_constant" )</h3>
+
+<form id="updateConstantForm" action="updateConstant.action" method="post" >
+<input type="hidden" id="id" name="id" value="$!constant.id"/>
+
+<table>
+ <tr>
+ <th colspan="2">$i18n.getString( "details" )</th>
+ </tr>
+ <tr>
+ <td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $!constant.name )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="name">$i18n.getString( "value" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="value" name="value" value="$!constant.value" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><input type="submit" value="$i18n.getString( 'save' )" style="width:10em"/>
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='constant.action'" style="width:10em"/></td>
+ </tr>
+</table>
+
+</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2011-06-20 07:43:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2011-06-30 07:55:55 +0000
@@ -33,6 +33,10 @@
F_CONCEPT_DELETE = Delete Concept
F_CONCEPT_MANAGEMENT = Concept Management
F_CONCEPT_UPDATE = Update Concept
+F_CONSTANT_ADD = Add Constant
+F_CONSTANT_DELETE = Delete Constant
+F_CONSTANT_MANAGEMENT = Constant Management
+F_CONSTANT_UPDATE = Update Constant
F_DATAADMIN_LOCK = Data Admin Locking
F_DATAADMIN_UNLOCK = Data Admin UnLocking
F_DATAELEMENT_ADD = Add Data Element