=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java 2010-05-12 02:15:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java 1970-01-01 00:00:00 +0000 @@ -1,141 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.program; - -import java.io.Serializable; - - -/** - * @author Chau Thu Tran - * @version ProgramStageValidation.java May 6, 2010 9:34:10 AM - */ -public class ProgramStageDataElementValidation implements Serializable -{ - public static final int OPERATOR_LESS_THAN = -1; - - public static final int OPERATOR_EQUAL_TO = 0; - - public static final int OPERATOR_GREATER_THAN = 1; - - // ------------------------------------------------------------------------- - // Fields - // ------------------------------------------------------------------------- - - private int id; - - private String description; - - private ProgramStageDataElement leftProgramStageDataElement; - - private int operator; - - private ProgramStageDataElement rightProgramStageDataElement; - - // ------------------------------------------------------------------------- - // equals && hashCode - // ------------------------------------------------------------------------- - - @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; - ProgramStageDataElementValidation other = (ProgramStageDataElementValidation) obj; - if ( id != other.id ) - return false; - return true; - } - - // ------------------------------------------------------------------------- - // getters && Setters - // ------------------------------------------------------------------------- - - public int getId() - { - return id; - } - - public void setId( int id ) - { - this.id = id; - } - - public String getDescription() - { - return description; - } - - public void setDescription( String description ) - { - this.description = description; - } - - public int getOperator() - { - return operator; - } - - public void setOperator( int operator ) - { - this.operator = operator; - } - - public ProgramStageDataElement getLeftProgramStageDataElement() - { - return leftProgramStageDataElement; - } - - public void setLeftProgramStageDataElement( ProgramStageDataElement leftProgramStageDataElement ) - { - this.leftProgramStageDataElement = leftProgramStageDataElement; - } - - public ProgramStageDataElement getRightProgramStageDataElement() - { - return rightProgramStageDataElement; - } - - public void setRightProgramStageDataElement( ProgramStageDataElement rightProgramStageDataElement ) - { - this.rightProgramStageDataElement = rightProgramStageDataElement; - } - -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java 2010-10-22 06:43:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java 1970-01-01 00:00:00 +0000 @@ -1,60 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.program; - -import java.util.Collection; - -/** - * @author Chau Thu Tran - * @version ProgramStageDataElementValidationService.java May 6, 2010 10:08:04 - * AM - */ -public interface ProgramStageDataElementValidationService -{ - String ID = ProgramStageDataElementValidationService.class.getName(); - - // ------------------------------------------------------------------------- - // ProgramStage - DataElement validation - // ------------------------------------------------------------------------- - - int saveProgramStageDataElementValidation( ProgramStageDataElementValidation validation ); - - void deleteProgramStageDataElementValidation( ProgramStageDataElementValidation validation ); - - void updateProgramStageDataElementValidation( ProgramStageDataElementValidation validation ); - - ProgramStageDataElementValidation getProgramStageDataElementValidation( int id ); - - Collection getProgramStageDataElementValidations( Program program ); - - Collection getProgramStageDataElementValidations( ProgramStageDataElement element ); - - Collection getAllProgramStageDataElementValidations(); - - Collection getProgramStageDataElementValidations( ProgramStage programStage ); -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java 2010-10-22 06:43:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java 1970-01-01 00:00:00 +0000 @@ -1,52 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.program; - -import java.util.Collection; - -import org.hisp.dhis.common.GenericStore; - -/** - * @author Chau Thu Tran - * @version ProgramStageDataElementValidationStore.java May 7, 2010 10:08:04 AM - */ -public interface ProgramStageDataElementValidationStore - extends GenericStore -{ - String ID = ProgramStageDataElementValidationStore.class.getName(); - - // ------------------------------------------------------------------------- - // ProgramStage - DataElement validation - // ------------------------------------------------------------------------- - - Collection getProgramStageDataElementValidations( Program program ); - - Collection getProgramStageDataElementValidations( ProgramStageDataElement element ); - - Collection getProgramStageDataElementValidations( ProgramStage programStage ); -} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,180 @@ +/* + * 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. + */ + +package org.hisp.dhis.program; + +import java.io.Serializable; + + +/** + * @author Chau Thu Tran + * @version $ ProgramValidation.java Apr 28, 2011 10:27:29 AM $ + */ +public class ProgramValidation +implements Serializable +{ + public static final String SEPARATOR_ID = "\\."; + + public static final String SEPARATOR_OBJECT = ":"; + + public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE"; + + // ------------------------------------------------------------------------- + // Fields + // ------------------------------------------------------------------------- + + private int id; + + private String description; + + private String leftSide; + + private String rightSide; + + private Program program; + + // ------------------------------------------------------------------------- + // Constructor + // ------------------------------------------------------------------------- + + public ProgramValidation() + { + + } + + public ProgramValidation( String description, String leftSide, String rightSide, Program program ) + { + this.description = description; + this.leftSide = leftSide; + this.rightSide = rightSide; + this.program = program; + } + + // ------------------------------------------------------------------------- + // hashCode() and equals() + // ------------------------------------------------------------------------- + + public int getId() + { + return id; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((leftSide == null) ? 0 : leftSide.hashCode()); + result = prime * result + ((program == null) ? 0 : program.hashCode()); + result = prime * result + ((rightSide == null) ? 0 : rightSide.hashCode()); + return result; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + ProgramValidation other = (ProgramValidation) obj; + if ( leftSide == null ) + { + if ( other.leftSide != null ) + return false; + } + else if ( !leftSide.equals( other.leftSide ) ) + return false; + if ( program == null ) + { + if ( other.program != null ) + return false; + } + else if ( !program.equals( other.program ) ) + return false; + if ( rightSide == null ) + { + if ( other.rightSide != null ) + return false; + } + else if ( !rightSide.equals( other.rightSide ) ) + return false; + return true; + } + + // ------------------------------------------------------------------------- + // Getters && Setters + // ------------------------------------------------------------------------- + + public void setId( int id ) + { + this.id = id; + } + + public String getDescription() + { + return description; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public String getLeftSide() + { + return leftSide; + } + + public void setLeftSide( String leftSide ) + { + this.leftSide = leftSide; + } + + public String getRightSide() + { + return rightSide; + } + + public void setRightSide( String rightSide ) + { + this.rightSide = rightSide; + } + + public Program getProgram() + { + return program; + } + + public void setProgram( Program program ) + { + this.program = program; + } + +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,53 @@ +/* + * 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. + */ + +package org.hisp.dhis.program; + +import java.util.Collection; + +/** + * @author Chau Thu Tran + * @version $ ProgramValidationService.java Apr 28, 2011 10:32:20 AM $ + */ +public interface ProgramValidationService +{ + String ID = ProgramValidationService.class.getName(); + + int addProgramValidation( ProgramValidation programValidation ); + + void deleteProgramValidation( ProgramValidation programValidation ); + + void updateProgramValidation( ProgramValidation programValidation ); + + ProgramValidation getProgramValidation( int id ); + + Collection getAllProgramValidation(); + + Collection getProgramValidation( Program program ); + + boolean runValidation( ProgramValidation validation, ProgramInstance programInstance ); +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,43 @@ +/* + * 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. + */ + +package org.hisp.dhis.program; + +import java.util.Collection; +import org.hisp.dhis.common.GenericStore; + +/** + * @author Chau Thu Tran + * @version $ ProgramValidationStore.java Apr 28, 2011 10:33:44 AM $ + */ +public interface ProgramValidationStore + extends GenericStore +{ + String ID = ProgramValidation.class.getName(); + + Collection get( Program program ); +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2011-04-22 08:01:29 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2011-04-29 07:41:04 +0000 @@ -34,6 +34,8 @@ import org.amplecode.quick.StatementManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.system.startup.AbstractStartupRoutine; import org.springframework.transaction.annotation.Transactional; @@ -59,6 +61,13 @@ this.statementManager = statementManager; } + private DataElementCategoryService categoryService; + + public void setCategoryService( DataElementCategoryService categoryService ) + { + this.categoryService = categoryService; + } + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- @@ -69,16 +78,16 @@ { updatePatientOrgunitAssociation(); - updateDOBType(); + executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true" ); + + executeSql( "ALTER TABLE patient drop column birthdateestimated" ); + + executeSql( "DELETE FROM validationcriteria where property='birthdateestimated'" ); executeSql( "UPDATE patientattribute SET mandatory = false WHERE mandatory is NULL" ); - + executeSql( "UPDATE program SET version = 1 WHERE version is NULL" ); - updateDataSetMobileAttribute(); - - updateDataSetVersionAttribute(); - executeSql( "UPDATE patientidentifiertype SET type='" + PatientIdentifierType.VALUE_TYPE_TEXT + "' WHERE type IS NULL" ); @@ -89,6 +98,13 @@ executeSql( "UPDATE patient SET isdead=false WHERE isdead IS NULL" ); executeSql( "UPDATE patient SET hasPatients=false WHERE hasPatients IS NULL" ); + + executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" ); + + executeSql( "UPDATE dataset SET version = 1 WHERE version is null" ); + + updateSingleProgramValidation(); + } // ------------------------------------------------------------------------- @@ -130,53 +146,53 @@ } } - private void updateDOBType() - { - StatementHolder holder = statementManager.getHolder(); - - try - { - executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true" ); - - executeSql( "ALTER TABLE patient drop column birthdateestimated" ); - - executeSql( "DELETE FROM validationcriteria where property='birthdateestimated'" ); - } - catch ( Exception ex ) - { - log.error( ex ); - } - finally - { - holder.close(); - } - } - - private void updateDataSetMobileAttribute() - { - StatementHolder holder = statementManager.getHolder(); - - try - { - executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" ); - } - catch ( Exception ex ) - { - log.error( ex ); - } - finally - { - holder.close(); - } - } - - private void updateDataSetVersionAttribute() - { - StatementHolder holder = statementManager.getHolder(); - - try - { - executeSql( "UPDATE dataset SET version = 1 WHERE version is null" ); + private void updateSingleProgramValidation() + { + StatementHolder holder = statementManager.getHolder(); + + int optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo().getId(); + + try + { + Statement statement = holder.getStatement(); + + ResultSet isUpdated = statement + .executeQuery( "SELECT * FROM INFORMATION_SCHEMA.COLUMNS " + + "WHERE TABLE_NAME = 'programstage_dataelement_validation'" ); + + if ( isUpdated.next() ) + { + ResultSet rsCount = statement.executeQuery( "SELECT max(programvalidationid) FROM programvalidation" ); + rsCount.next(); + + int max = rsCount.getInt( 1 ) + 1; + + ResultSet resultSet = statement + .executeQuery( "SELECT pdv.description, pdv.leftprogramstageid, pdv.leftdataelementid, "+ + "pdv.rightprogramstageid, pdv.rightdataelementid, " + + "pdv.operator, ps.programid "+ + "FROM programstage_dataelement_validation pdv "+ + "INNER JOIN programstage_dataelements pd "+ + "ON (pdv.leftprogramstageid=pd.dataelementid AND "+ + "pdv.leftdataelementid=pd.programstageid) "+ + "INNER JOIN programstage ps "+ + "ON pd.programstageid=ps.programstageid" ); + + while ( resultSet.next() ) + { + max++; + String leftSide = "[" + resultSet.getString( 2 ) + "." + resultSet.getString( 3 ) + "." + optionCombo + "]"; + String rightSide = "[" + resultSet.getString( 4 ) + "." + resultSet.getString( 5 ) + "." + optionCombo + "]"; + String operator = resultSet.getInt( 6 ) > 0 ? ">" : ( resultSet.getInt( 6 ) < 0 ) ? "<" : "=="; + + String fomular = leftSide + operator + rightSide; + + executeSql( "INSERT INTO programvalidation (programvalidationid, description,leftSide, rightSide, programid )" + + "VALUES ( " + max + ",'" + resultSet.getString( 1 ) + "', '" + fomular + "', '1==1', " + resultSet.getInt( 7 ) + ")" ); + } + + executeSql( "DROP TABLE programstage_dataelement_validation" ); + } } catch ( Exception ex ) { === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2004-2009, 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.program; + +import java.util.Collection; + +import org.hisp.dhis.dataelement.DataElement; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Viet Nguyen + * + * @version $Id$ + */ +@Transactional +public class DefaultProgramStageDataElementService + implements ProgramStageDataElementService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageDataElementStore programStageDataElementStore; + + public void setProgramStageDataElementStore( ProgramStageDataElementStore programStageDataElementStore ) + { + this.programStageDataElementStore = programStageDataElementStore; + } + + // ------------------------------------------------------------------------- + // Implementation methods + // ------------------------------------------------------------------------- + + public void addProgramStageDataElement( ProgramStageDataElement programStageDataElement ) + { + programStageDataElementStore.saveOrUpdate( programStageDataElement ); + } + + public void deleteProgramStageDataElement( ProgramStageDataElement programStageDataElement ) + { + programStageDataElementStore.delete( programStageDataElement ); + } + + public Collection getAllProgramStageDataElements() + { + return programStageDataElementStore.getAll(); + } + + public Collection get( ProgramStage programStage ) + { + return programStageDataElementStore.get( programStage ); + } + + public ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement ) + { + return programStageDataElementStore.get( programStage, dataElement ); + } + + public void updateProgramStageDataElement( ProgramStageDataElement programStageDataElement ) + { + programStageDataElementStore.update( programStageDataElement ); + } + + public Collection getListDataElement( ProgramStage programStage ) + { + return programStageDataElementStore.getListDataElement( programStage ); + } + +} === removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java 1970-01-01 00:00:00 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004-2009, 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.program; - -import java.util.Collection; - -import org.hisp.dhis.dataelement.DataElement; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Viet Nguyen - * - * @version $Id$ - */ -@Transactional -public class DefaultProgramStageDataElementService - implements ProgramStageDataElementService -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ProgramStageDataElementStore programStageDataElementStore; - - public void setProgramStageDataElementStore( ProgramStageDataElementStore programStageDataElementStore ) - { - this.programStageDataElementStore = programStageDataElementStore; - } - - // ------------------------------------------------------------------------- - // Implementation methods - // ------------------------------------------------------------------------- - - public void addProgramStageDataElement( ProgramStageDataElement programStageDataElement ) - { - programStageDataElementStore.saveOrUpdate( programStageDataElement ); - } - - public void deleteProgramStageDataElement( ProgramStageDataElement programStageDataElement ) - { - programStageDataElementStore.delete( programStageDataElement ); - } - - public Collection getAllProgramStageDataElements() - { - return programStageDataElementStore.getAll(); - } - - public Collection get( ProgramStage programStage ) - { - return programStageDataElementStore.get( programStage ); - } - - public ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement ) - { - return programStageDataElementStore.get( programStage, dataElement ); - } - - public void updateProgramStageDataElement( ProgramStageDataElement programStageDataElement ) - { - programStageDataElementStore.update( programStageDataElement ); - } - - public Collection getListDataElement( ProgramStage programStage ) - { - return programStageDataElementStore.getListDataElement( programStage ); - } - -} === removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java 1970-01-01 00:00:00 +0000 @@ -1,101 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.program; - -import java.util.Collection; - -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Chau Thu Tran - * @version DefaultProgramStageDataElementValidationService.java May 6, 2010 - * 10:18:00 AM - */ - -@Transactional -public class DefaultProgramStageDataElementValidationService - implements ProgramStageDataElementValidationService -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ProgramStageDataElementValidationStore validationStore; - - public void setValidationStore( ProgramStageDataElementValidationStore validationStore ) - { - this.validationStore = validationStore; - } - - // ------------------------------------------------------------------------- - // Implementation methods - // ------------------------------------------------------------------------- - - public int saveProgramStageDataElementValidation( ProgramStageDataElementValidation validation ) - { - return validationStore.save( validation ); - } - - public void updateProgramStageDataElementValidation( ProgramStageDataElementValidation validation ) - { - validationStore.update( validation ); - } - - public void deleteProgramStageDataElementValidation( ProgramStageDataElementValidation validation ) - { - validationStore.delete( validation ); - } - - public Collection getAllProgramStageDataElementValidations() - { - return validationStore.getAll(); - } - - public ProgramStageDataElementValidation getProgramStageDataElementValidation( int id ) - { - return validationStore.get( id ); - } - - public Collection getProgramStageDataElementValidations( Program program ) - { - return validationStore.getProgramStageDataElementValidations( program ); - } - - public Collection getProgramStageDataElementValidations( - ProgramStageDataElement element ) - { - return validationStore.getProgramStageDataElementValidations( element ); - } - - public Collection getProgramStageDataElementValidations( - ProgramStage programStage ) - { - return validationStore.getProgramStageDataElementValidations( programStage ); - } - -} === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,197 @@ +/* + * 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. + */ + +package org.hisp.dhis.program; + +import static org.hisp.dhis.program.ProgramValidation.OBJECT_PROGRAM_STAGE_DATAELEMENT; +import static org.hisp.dhis.program.ProgramValidation.SEPARATOR_ID; +import static org.hisp.dhis.program.ProgramValidation.SEPARATOR_OBJECT; + +import java.util.Collection; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.patientdatavalue.PatientDataValue; +import org.hisp.dhis.patientdatavalue.PatientDataValueService; +import org.nfunk.jep.JEP; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Chau Thu Tran + * @version $ DefaultProgramValidationService.java Apr 28, 2011 10:36:50 AM $ + */ +@Transactional +public class DefaultProgramValidationService +implements ProgramValidationService +{ + private ProgramValidationStore validationStore; + + private ProgramStageService programStageService; + + private DataElementService dataElementService; + + private ProgramStageInstanceService stageInstanceService; + + private PatientDataValueService valueService; + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + public void setValidationStore( ProgramValidationStore validationStore ) + { + this.validationStore = validationStore; + } + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + public void setStageInstanceService( ProgramStageInstanceService stageInstanceService ) + { + this.stageInstanceService = stageInstanceService; + } + + public void setValueService( PatientDataValueService valueService ) + { + this.valueService = valueService; + } + + // ------------------------------------------------------------------------- + // Implementation methods + // ------------------------------------------------------------------------- + @Override + public int addProgramValidation( ProgramValidation programValidation ) + { + return validationStore.save( programValidation ); + } + + @Override + public void updateProgramValidation( ProgramValidation programValidation ) + { + validationStore.update( programValidation ); + } + + @Override + public void deleteProgramValidation( ProgramValidation programValidation ) + { + validationStore.delete( programValidation ); + } + + @Override + public Collection getAllProgramValidation() + { + return validationStore.getAll(); + } + + @Override + public ProgramValidation getProgramValidation( int id ) + { + return validationStore.get( id ); + } + + @Override + public boolean runValidation( ProgramValidation validation, ProgramInstance programInstance ) + { + // --------------------------------------------------------------------- + // parse left-expressions + // --------------------------------------------------------------------- + + boolean resultLeft = runExpression( validation.getLeftSide(), programInstance ); + + // --------------------------------------------------------------------- + // parse right-expressions + // --------------------------------------------------------------------- + + boolean resultRight = runExpression( validation.getRightSide(), programInstance ); + + return (resultLeft == resultRight); + + } + + public Collection getProgramValidation( Program program ) + { + return validationStore.get( program ); + } + + private boolean runExpression( String expression, ProgramInstance programInstance ) + { + final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + + SEPARATOR_ID + "[0-9]*]*)" + "\\]"; + + StringBuffer description = new StringBuffer(); + + Pattern pattern = Pattern.compile( regExp ); + + Matcher matcher = pattern.matcher( expression ); + + while ( matcher.find() ) + { + String match = matcher.group(); + match = match.replaceAll( "[\\[\\]]", "" ); + + String[] info = match.split( SEPARATOR_OBJECT ); + String[] ids = info[1].split( SEPARATOR_ID ); + + int programStageId = Integer.parseInt( ids[0] ); + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + int dataElementId = Integer.parseInt( ids[1] ); + DataElement dataElement = dataElementService.getDataElement( dataElementId ); + + ProgramStageInstance stageInstance = stageInstanceService.getProgramStageInstance( programInstance, + programStage ); + + PatientDataValue dataValue = valueService.getPatientDataValue( stageInstance, dataElement, programInstance + .getPatient().getOrganisationUnit() ); + + if ( dataValue == null ) + { + return true; + } + + matcher.appendReplacement( description, dataValue.getValue() ); + } + + matcher.appendTail( description ); + + final JEP parser = new JEP(); + + parser.parseExpression( description.toString() ); + + return ( parser.getValue() == 1.0 ); + } + +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2011-04-29 07:41:04 +0000 @@ -51,14 +51,6 @@ this.programStageDEService = programStageDEService; } - ProgramStageDataElementValidationService programStageDEValidationService; - - public void setProgramStageDEValidationService( - ProgramStageDataElementValidationService programStageDEValidationService ) - { - this.programStageDEValidationService = programStageDEValidationService; - } - // ------------------------------------------------------------------------- // Implementation methods // ------------------------------------------------------------------------- @@ -73,18 +65,6 @@ public void deleteProgram( Program program ) { // --------------------------------------------------------------------- - // Delete Program Stage data element validations - // --------------------------------------------------------------------- - - Collection validations = programStageDEValidationService - .getProgramStageDataElementValidations( program ); - - for ( ProgramStageDataElementValidation validation : validations ) - { - programStageDEValidationService.deleteProgramStageDataElementValidation( validation ); - } - - // --------------------------------------------------------------------- // Delete Program Stage data elements // --------------------------------------------------------------------- @@ -108,18 +88,6 @@ public void deleteProgramStage( ProgramStage programStage ) { // --------------------------------------------------------------------- - // Delete Program Stage data element validations - // --------------------------------------------------------------------- - - Collection validations = programStageDEValidationService - .getProgramStageDataElementValidations( programStage ); - - for ( ProgramStageDataElementValidation validation : validations ) - { - programStageDEValidationService.deleteProgramStageDataElementValidation( validation ); - } - - // --------------------------------------------------------------------- // Delete Program Stage data elements // --------------------------------------------------------------------- === removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java 1970-01-01 00:00:00 +0000 @@ -1,95 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.program.hibernate; - -import java.util.Collection; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hisp.dhis.hibernate.HibernateGenericStore; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElement; -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationStore; - -/** - * @author Chau Thu Tran - * @version HibernateProgramStageDataElementValidationStore.java May 10, 2010 - * 11:06:20 AM - */ -public class HibernateProgramStageDataElementValidationStore - extends HibernateGenericStore - implements ProgramStageDataElementValidationStore -{ - @SuppressWarnings( "unchecked" ) - public Collection getProgramStageDataElementValidations( Program program ) - { - Session session = sessionFactory.getCurrentSession(); - - Query query = session - .createQuery( "from ProgramStageDataElementValidation c where c.leftProgramStageDataElement.programStage.program.id = :program" ); - - query.setInteger( "program", program.getId() ); - - return query.list(); - } - - @SuppressWarnings( "unchecked" ) - public Collection getProgramStageDataElementValidations( - ProgramStageDataElement element ) - { - Session session = sessionFactory.getCurrentSession(); - - Query query = session - .createQuery( "from ProgramStageDataElementValidation c where " - + "( c.leftProgramStageDataElement.programStage.id = :programStageId and c.leftProgramStageDataElement.dataElement.id = :dataElementId ) or " - + "( c.rightProgramStageDataElement.programStage.id = :programStageId and c.rightProgramStageDataElement.dataElement.id = :dataElementId )" ); - - query.setInteger( "programStageId", element.getProgramStage().getId() ); - query.setInteger( "dataElementId", element.getDataElement().getId() ); - - return query.list(); - } - - @SuppressWarnings( "unchecked" ) - public Collection getProgramStageDataElementValidations( - ProgramStage programStage ) - { - Session session = sessionFactory.getCurrentSession(); - - Query query = session - .createQuery( "from ProgramStageDataElementValidation c where " - + "c.leftProgramStageDataElement.programStage.id = :programStageId or " - + "c.rightProgramStageDataElement.programStage.id = :programStageId" ); - - query.setInteger( "programStageId", programStage.getId() ); - - return query.list(); - } -} === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,52 @@ +/* + * 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. + */ + +package org.hisp.dhis.program.hibernate; + +import java.util.Collection; + +import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.hibernate.HibernateGenericStore; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationStore; + +/** + * @author Chau Thu Tran + * @version $ HibernateProgramValidationStore.java Apr 28, 2011 10:43:09 AM $ + */ +public class HibernateProgramValidationStore + extends HibernateGenericStore + implements ProgramValidationStore +{ + @SuppressWarnings( "unchecked" ) + public Collection get( Program program ) + { + return getCriteria( Restrictions.eq( "program", program ) ).list(); + } + +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-01-20 04:05:32 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-04-29 07:41:04 +0000 @@ -48,6 +48,12 @@ + + + + + @@ -103,12 +109,6 @@ - - - - - @@ -156,12 +156,6 @@ - - - - + + + + + + + + @@ -253,10 +261,10 @@ ref="org.hisp.dhis.patient.PatientAttributeGroupStore" /> - - + + @@ -301,7 +309,6 @@ class="org.hisp.dhis.program.ProgramInstanceDeletionHandler"> - @@ -336,7 +343,6 @@ - @@ -346,6 +352,7 @@ + === removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml 2011-04-12 13:44:50 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml 1970-01-01 00:00:00 +0000 @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml 2011-04-29 07:41:04 +0000 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,284 @@ +/* + * 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. + */ + +package org.hisp.dhis.caseentry.action.caseentry; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hisp.dhis.caseentry.state.SelectedStateManager; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patientdatavalue.PatientDataValue; +import org.hisp.dhis.patientdatavalue.PatientDataValueService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ ValidateProgramInstanceAction.java Apr 28, 2011 10:56:10 AM $ + */ +public class ValidateProgramInstanceAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectedStateManager selectedStateManager; + + private ProgramInstanceService programInstanceService; + + private ProgramStageInstanceService programStageInstanceService; + + private PatientDataValueService patientDataValueService; + + private ProgramValidationService programValidationService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private I18nFormat format; + + private I18n i18n; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Map resultDEMultiStages; + + private List programValidations; + + // ------------------------------------------------------------------------- + // Getters && Setters + // ------------------------------------------------------------------------- + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + public List getProgramValidations() + { + return programValidations; + } + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + public void setProgramInstanceService( ProgramInstanceService programInstanceService ) + { + this.programInstanceService = programInstanceService; + } + + public void setPatientDataValueService( PatientDataValueService patientDataValueService ) + { + this.patientDataValueService = patientDataValueService; + } + + public Map getResultDEMultiStages() + { + return resultDEMultiStages; + } + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + public SelectedStateManager getSelectedStateManager() + { + return selectedStateManager; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + resultDEMultiStages = new HashMap(); + + programValidations = new ArrayList(); + + // --------------------------------------------------------------------- + // Get selected objects + // --------------------------------------------------------------------- + + OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); + + Patient patient = selectedStateManager.getSelectedPatient(); + + Program program = selectedStateManager.getSelectedProgram(); + + ProgramStage programStage = selectedStateManager.getSelectedProgramStage(); + + Collection progamInstances = programInstanceService.getProgramInstances( patient, program, + false ); + + ProgramInstance programInstance = progamInstances.iterator().next(); + + ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( + programInstance, programStage ); + + // --------------------------------------------------------------------- + // Get selected objects + // --------------------------------------------------------------------- + Set dataElements = programStage.getProgramStageDataElements(); + + for ( ProgramStageDataElement psDataElement : dataElements ) + { + DataElement dataElement = psDataElement.getDataElement(); + + // resultDEMultiStages + checkDataElementInMultiStage( programStageInstance, organisationUnit, dataElement ); + + } + // end Check validation for dataElement into the Stage + + // --------------------------------------------------------------------- + // Check validations for dataelement into multi-stages + // --------------------------------------------------------------------- + + runProgramValidation( programValidationService.getProgramValidation( programInstance.getProgram() ), programInstance ); + + return SUCCESS; + } + + // ------------------------------------------------------------------------- + // Support method + // ------------------------------------------------------------------------- + + /** + * ------------------------------------------------------------------------ + * // Check value of the dataElment into previous . // If the value exists, + * allow users to enter data of // the dataElement into the + * programStageInstance // Else, disable Input-field of the dataElement + * ------------------------------------------------------------------------ + **/ + + private void checkDataElementInMultiStage( ProgramStageInstance programStageInstance, + OrganisationUnit organisationUnit, DataElement dataElement ) + { + ProgramInstance programInstance = programStageInstance.getProgramInstance(); + List stages = new ArrayList( programInstance.getProgram().getProgramStages() ); + + int index = stages.indexOf( programStageInstance.getProgramStage() ); + + if ( index != -1 && index != 0 ) + { + ProgramStage prevStage = stages.get( index - 1 ); + ProgramStageInstance prevStageInstance = programStageInstanceService.getProgramStageInstance( + programInstance, prevStage ); + PatientDataValue prevValue = patientDataValueService.getPatientDataValue( prevStageInstance, dataElement, + organisationUnit ); + + if ( prevValue == null ) + { + String message = i18n.getString( "selected" ) + " " + i18n.getString( "program_stage" ) + " " + + i18n.getString( "should" ) + " " + i18n.getString( "data_value" ) + " " + + i18n.getString( "is_null" ); + + resultDEMultiStages.put( dataElement, message ); + } + } + + } + + private void runProgramValidation( Collection validations, ProgramInstance programInstance ) + throws Exception + { + if ( validations != null ) + { + + for ( ProgramValidation validation : validations ) + { + boolean valid = programValidationService.runValidation( validation, programInstance ); + + if ( !valid ) + { + programValidations.add( validation ); + } + } + } + + } + + private Object getObject( String type, String value ) + throws Exception + { + if ( type.equals( DataElement.VALUE_TYPE_INT ) ) + { + return Integer.valueOf( value ); + } + else if ( type.equals( DataElement.VALUE_TYPE_BOOL ) ) + { + return Boolean.valueOf( value ); + } + else if ( type.equals( DataElement.VALUE_TYPE_DATE ) ) + { + return format.parseDate( value.trim() ); + } + + return value; + + } + +} === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java 2011-04-06 03:19:11 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java 1970-01-01 00:00:00 +0000 @@ -1,328 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.caseentry.action.caseentry; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.hisp.dhis.caseentry.state.SelectedStateManager; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.patientdatavalue.PatientDataValue; -import org.hisp.dhis.patientdatavalue.PatientDataValueService; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramInstance; -import org.hisp.dhis.program.ProgramInstanceService; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElement; -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; -import org.hisp.dhis.program.ProgramStageInstance; -import org.hisp.dhis.program.ProgramStageInstanceService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version ValidateValueAction.java May 11, 2010 2:13:52 PM - */ -public class ValidateValueAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private SelectedStateManager selectedStateManager; - - private DataElementService dataElementService; - - private ProgramInstanceService programInstanceService; - - private ProgramStageInstanceService programStageInstanceService; - - private ProgramStageDataElementValidationService validationService; - - private PatientDataValueService patientDataValueService; - - private PatientService patientService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private boolean providedByAnotherFacility; - - private String value; - - private int dataElementId; - - private int statusCode; - - private I18nFormat format; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private List resultValidation; - - // ------------------------------------------------------------------------- - // Getters && Setters - // ------------------------------------------------------------------------- - - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) - { - this.selectedStateManager = selectedStateManager; - } - - public void setValidationService( ProgramStageDataElementValidationService validationService ) - { - this.validationService = validationService; - } - - public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) - { - this.programStageInstanceService = programStageInstanceService; - } - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - public void setProgramInstanceService( ProgramInstanceService programInstanceService ) - { - this.programInstanceService = programInstanceService; - } - - public void setPatientDataValueService( PatientDataValueService patientDataValueService ) - { - this.patientDataValueService = patientDataValueService; - } - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - public int getDataElementId() - { - return dataElementId; - } - - public int getStatusCode() - { - return statusCode; - } - - public void setStatusCode( int statusCode ) - { - this.statusCode = statusCode; - } - - public void setValue( String value ) - { - this.value = value; - } - - public void setProvidedByAnotherFacility( boolean providedByAnotherFacility ) - { - this.providedByAnotherFacility = providedByAnotherFacility; - } - - public void setDataElementId( int dataElementId ) - { - this.dataElementId = dataElementId; - } - - public SelectedStateManager getSelectedStateManager() - { - return selectedStateManager; - } - - public ProgramStageDataElementValidationService getValidationService() - { - return validationService; - } - - public boolean isProvidedByAnotherFacility() - { - return providedByAnotherFacility; - } - - public String getValue() - { - return value; - } - - public List getResultValidation() - { - return resultValidation; - } - - public void setResultValidation( List resultValidation ) - { - this.resultValidation = resultValidation; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); - - Patient patient = selectedStateManager.getSelectedPatient(); - - Program program = selectedStateManager.getSelectedProgram(); - - ProgramStage programStage = selectedStateManager.getSelectedProgramStage(); - - Collection progamInstances = programInstanceService.getProgramInstances( patient, program, - false ); - - ProgramInstance programInstance = progamInstances.iterator().next(); - - DataElement dataElement = dataElementService.getDataElement( dataElementId ); - - // Check validation for dataElement into the Stage - - ProgramStageDataElement element = new ProgramStageDataElement( programStage, dataElement, false ); - - Collection validations = validationService - .getProgramStageDataElementValidations( element ); - - resultValidation = validation( validations, organisationUnit, programInstance, value, programStage, dataElement ); - - if ( resultValidation.size() > 0 ) - { - statusCode = 1; - - return INPUT; - } - - return SUCCESS; - } - - // ------------------------------------------------------------------------- - // Support methods - // ------------------------------------------------------------------------- - - @SuppressWarnings( "unchecked" ) - private List validation( - Collection validations, OrganisationUnit organisationUnit, - ProgramInstance programInstance, String value, ProgramStage programStage, DataElement dataElement ) - throws Exception - { - List result = new ArrayList(); - - if ( validations != null ) - { - - for ( ProgramStageDataElementValidation validation : validations ) - { - // Get left-side - ProgramStageDataElement leftSide = validation.getLeftProgramStageDataElement(); - // Get right-side - ProgramStageDataElement rightSide = validation.getRightProgramStageDataElement(); - - // Get stageInstance to compare - ProgramStageInstance comparerogramStageInstance = null; - - int i = 2; - if ( leftSide.getProgramStage().equals( programStage ) - && leftSide.getDataElement().equals( dataElement ) ) - { - // get left-side value - Object objectValue = patientService.getObjectValue( leftSide.getDataElement().getType(), value, format ); - - // get program-stage of right-side - comparerogramStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, - rightSide.getProgramStage() ); - - // Get value into right-right to compare; - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( - comparerogramStageInstance, rightSide.getDataElement(), organisationUnit ); - - if ( patientDataValue != null ) - { - String dbValue = patientDataValue.getValue(); - Object compareValue = patientService.getObjectValue( rightSide.getDataElement().getType(), - dbValue, format ); - - i = ((Comparable) objectValue).compareTo( (Comparable) compareValue ); - } - - } - else - { - // get right-side value - Object objectValue = patientService.getObjectValue( rightSide.getDataElement().getType(), value, format ); - - comparerogramStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, - leftSide.getProgramStage() ); - - // Get value to compare; - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( - comparerogramStageInstance, leftSide.getDataElement(), organisationUnit ); - if ( patientDataValue != null ) - { - String dbValue = patientDataValue.getValue(); - Object compareValue = patientService.getObjectValue( leftSide.getDataElement().getType(), - dbValue, format ); - - i = ((Comparable) compareValue).compareTo( (Comparable) objectValue ); - } - } - - if ( i != validation.getOperator() && i != 2 ) - { - result.add( validation ); - } - - } - } - - return result; - } - -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-04-01 03:00:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-04-29 07:41:04 +0000 @@ -190,22 +190,6 @@ - - - - - - - - - - + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-04-06 07:55:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-04-29 07:41:04 +0000 @@ -296,3 +296,14 @@ program_stage_lack_data_elements = The program stage lack data elements multiple_dataentry = Multiple Data Entry intro_multiple_dataentry = Enter data for beneficiaries by selecting a program. +in = In +is_null = is null +data_value = datavalue +successful_validation = The data entry screen successfully passed validation +unsuccessful_validation = The data entry screen has validation errors, please correct these before proceeding +the_following_values_violates_rules = The following values violates validation rules +the_following_dataelements_are_in_multi_stages = The following dataelements are in multi-program stages +validation_result = Validation Result +should = should +validation = Validation +program_validation_description = Program Validation Description \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-03-24 03:34:53 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-04-29 07:41:04 +0000 @@ -90,19 +90,15 @@ - - saveValueChain - /dhis-web-caseentry/status.vm - plainTextError - - + status.vm /dhis-web-caseentry/responseInput.vm plainTextError + saveDateValueChain /dhis-web-caseentry/status.vm @@ -258,5 +254,10 @@ /dhis-web-commons/ajax/jsonPeriods.vm + + /popup.vm + /dhis-web-caseentry/validationResult.vm + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm 2011-04-05 04:29:09 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm 2011-04-29 07:41:04 +0000 @@ -82,7 +82,12 @@ #end - + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2011-04-05 04:29:09 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2011-04-29 07:41:04 +0000 @@ -1172,9 +1172,11 @@ jQuery("#startMsg").hide(); jQuery("#entryFormContainer").show(); jQuery("#completeBtn").removeAttr('disabled'); + jQuery("#validationBtn").removeAttr('disabled'); }else { jQuery("#entryFormContainer").hide(); jQuery("#completeBtn").attr('disabled', 'disabled'); + jQuery("#validationBtn").attr('disabled', 'disabled'); jQuery("#startMsg").show(); } } === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java 2011-03-31 01:42:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java 1970-01-01 00:00:00 +0000 @@ -1,121 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.patient.action.program; - -import java.util.Collection; - -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version ShowValidationDEAssociationsFormAction.java May 5, 2010 9:35:09 AM - */ -public class ShowValidationDEAssociationsFormAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ProgramService programService; - - private ProgramStageDataElementValidationService programStageDEValidationService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Program program; - - private Collection stages; - - private Collection validations; - - // ------------------------------------------------------------------------- - // Getters && Setters - // ------------------------------------------------------------------------- - - public Program getProgram() - { - return program; - } - - public Collection getValidations() - { - return validations; - } - - public void setProgramStageDEValidationService( ProgramStageDataElementValidationService programStageDEValidationService ) - { - this.programStageDEValidationService = programStageDEValidationService; - } - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - public Collection getStages() - { - return stages; - } - - public void setId( Integer id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - program = programService.getProgram( id ); - - stages = program.getProgramStages(); - - validations = programStageDEValidationService.getProgramStageDataElementValidations( program ); - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java 2011-04-26 09:00:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java 1970-01-01 00:00:00 +0000 @@ -1,201 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.patient.action.validation; - -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElement; -import org.hisp.dhis.program.ProgramStageDataElementService; -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; -import org.hisp.dhis.program.ProgramStageService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM - */ -public class AddProgramStageDEValidationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ProgramStageDataElementValidationService validationService; - - private ProgramStageService programStageService; - - private DataElementService dataElementService; - - private ProgramStageDataElementService programStageDataElementService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String description; - - private Integer leftProgramStageId; - - private Integer leftDataElementId; - - private int operator; - - private Integer rightProgramStageId; - - private Integer rightDataElementId; - - private ProgramStageDataElementValidation validation; - - // ------------------------------------------------------------------------- - // Setters - // ------------------------------------------------------------------------- - - public void setValidationService( ProgramStageDataElementValidationService validationService ) - { - this.validationService = validationService; - } - - public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService ) - { - this.programStageDataElementService = programStageDataElementService; - } - - public void setProgramStageService( ProgramStageService programStageService ) - { - this.programStageService = programStageService; - } - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - public void setDescription( String description ) - { - this.description = description; - } - - public void setLeftProgramStageId( Integer leftProgramStageId ) - { - this.leftProgramStageId = leftProgramStageId; - } - - public void setLeftDataElementId( Integer leftDataElementId ) - { - this.leftDataElementId = leftDataElementId; - } - - public void setRightProgramStageId( Integer rightProgramStageId ) - { - this.rightProgramStageId = rightProgramStageId; - } - - public void setRightDataElementId( Integer rightDataElementId ) - { - this.rightDataElementId = rightDataElementId; - } - - public void setOperator( int operator ) - { - this.operator = operator; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - public ProgramStageDataElementValidation getValidation() - { - return validation; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - validation = new ProgramStageDataElementValidation(); - - validation.setDescription( description ); - - // --------------------------------------------------------------------- - // leftProgramStageDataElement - // --------------------------------------------------------------------- - - ProgramStage programStage = programStageService.getProgramStage( leftProgramStageId ); - - DataElement dataElement = dataElementService.getDataElement( leftDataElementId ); - - ProgramStageDataElement leftProgramStageDataElement = programStageDataElementService.get( programStage, - dataElement ); - - if ( leftProgramStageDataElement == null ) - { - leftProgramStageDataElement = new ProgramStageDataElement( programStage, dataElement, false ); - } - - validation.setLeftProgramStageDataElement( leftProgramStageDataElement ); - - // --------------------------------------------------------------------- - // rightProgramStageDataElement - // --------------------------------------------------------------------- - - programStage = programStageService.getProgramStage( rightProgramStageId ); - - dataElement = dataElementService.getDataElement( rightDataElementId ); - - ProgramStageDataElement rightProgramStageDataElement = programStageDataElementService.get( programStage, - dataElement ); - - if ( rightProgramStageDataElement == null ) - { - rightProgramStageDataElement = new ProgramStageDataElement( programStage, dataElement, false ); - } - - validation.setRightProgramStageDataElement( rightProgramStageDataElement ); - - // --------------------------------------------------------------------- - // Operator - // --------------------------------------------------------------------- - - validation.setOperator( operator ); - - int id = validationService.saveProgramStageDataElementValidation( validation ); - - validation = validationService.getProgramStageDataElementValidation( id ); - - return SUCCESS; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,125 @@ +/* + * 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. + */ + +package org.hisp.dhis.patient.action.validation; + +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ AddProgramValidationAction.java Apr 28, 2011 11:15:06 AM $ + */ +public class AddProgramValidationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramValidationService programValidationService; + + private ProgramService programService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String description; + + private String leftSide; + + private String rightSide; + + private Integer programId; + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public void setLeftSide( String leftSide ) + { + this.leftSide = leftSide; + } + + public void setRightSide( String rightSide ) + { + this.rightSide = rightSide; + } + + public Integer getProgramId() + { + return programId; + } + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramValidation validation = new ProgramValidation(); + + validation.setDescription( description ); + validation.setLeftSide( leftSide ); + validation.setRightSide( rightSide ); + + Program program = programService.getProgram( programId ); + validation.setProgram( program ); + + programValidationService.addProgramValidation( validation ); + + return SUCCESS; + } + +} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java 2010-05-12 02:15:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java 1970-01-01 00:00:00 +0000 @@ -1,87 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.patient.action.validation; - -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM - */ -public class GetProgramStageDEValidationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependency - // ------------------------------------------------------------------------- - - private ProgramStageDataElementValidationService validationService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private int id; - - private ProgramStageDataElementValidation validation; - - // ------------------------------------------------------------------------- - // Setters - // ------------------------------------------------------------------------- - - public void setValidationService( ProgramStageDataElementValidationService validationService ) - { - this.validationService = validationService; - } - - public ProgramStageDataElementValidation getValidation() - { - return validation; - } - - public void setId( int id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - validation = validationService.getProgramStageDataElementValidation( id ); - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java 2011-03-31 01:42:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java 1970-01-01 00:00:00 +0000 @@ -1,83 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.patient.action.validation; - -import java.util.Collection; - -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version GetProgramStageDEValidationListAction.java May 6, 2010 1:28:06 PM - */ -public class GetProgramStageDEValidationListAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependency - // ------------------------------------------------------------------------- - - private ProgramStageDataElementValidationService programStageDataElementValidationService; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Collection validations; - - // ------------------------------------------------------------------------- - // Getter && Setter - // ------------------------------------------------------------------------- - - public void setProgramStageDataElementValidationService( - ProgramStageDataElementValidationService programStageDataElementValidationService ) - { - this.programStageDataElementValidationService = programStageDataElementValidationService; - } - - public Collection getValidations() - { - return validations; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - validations = programStageDataElementValidationService.getAllProgramStageDataElementValidations(); - - return SUCCESS; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,88 @@ +/* + * 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. + */ + +package org.hisp.dhis.patient.action.validation; + +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ GetProgramValidationAction.java Apr 28, 2011 11:17:58 AM $ + */ +public class GetProgramValidationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramValidationService programValidationService; + + // ------------------------------------------------------------------------- + // Input && Output + // ------------------------------------------------------------------------- + + private Integer validationId; + + private ProgramValidation validation; + + // ------------------------------------------------------------------------- + // Getter && Setter + // ------------------------------------------------------------------------- + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public void setValidationId( Integer validationId ) + { + this.validationId = validationId; + } + + public ProgramValidation getValidation() + { + return validation; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + validation = programValidationService.getProgramValidation( validationId ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,107 @@ +/* + * 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. + */ + +package org.hisp.dhis.patient.action.validation; + +import java.util.Collection; + +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ GetProgramValidationListAction.java Apr 28, 2011 11:19:56 AM $ + */ +public class GetProgramValidationListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramValidationService programValidationService; + + private ProgramService programService; + + // ------------------------------------------------------------------------- + // Input && Output + // ------------------------------------------------------------------------- + + private Integer programId; + + private Collection validations; + + // ------------------------------------------------------------------------- + // Getter && Setter + // ------------------------------------------------------------------------- + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + public Collection getValidations() + { + return validations; + } + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public Integer getProgramId() + { + return programId; + } + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + + @Override + public String execute() + throws Exception + { + Program program = programService.getProgram( programId ); + + validations = programValidationService.getProgramValidation( program ); + + return SUCCESS; + } + +} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java 2010-05-12 02:15:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java 1970-01-01 00:00:00 +0000 @@ -1,82 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.patient.action.validation; - -import org.hisp.dhis.program.ProgramStageDataElementValidation; -import org.hisp.dhis.program.ProgramStageDataElementValidationService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM - */ -public class RemoveProgramStageDEValidationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependency - // ------------------------------------------------------------------------- - - private ProgramStageDataElementValidationService validationService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private int id; - - // ------------------------------------------------------------------------- - // Setters - // ------------------------------------------------------------------------- - - public void setValidationService( ProgramStageDataElementValidationService validationService ) - { - this.validationService = validationService; - } - - public void setId( int id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - ProgramStageDataElementValidation validation = validationService.getProgramStageDataElementValidation( id ); - - validationService.deleteProgramStageDataElementValidation( validation ); - - return SUCCESS; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,83 @@ +/* + * 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. + */ + +package org.hisp.dhis.patient.action.validation; + +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ RemoveProgramValidationAction.java Apr 28, 2011 11:22:14 AM $ + */ +public class RemoveProgramValidationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramValidationService programValidationService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramValidation validation = programValidationService.getProgramValidation( id ); + + programValidationService.deleteProgramValidation( validation ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java 2011-04-29 07:41:04 +0000 @@ -0,0 +1,116 @@ +/* + * 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. + */ + +package org.hisp.dhis.patient.action.validation; + +import org.hisp.dhis.program.ProgramValidation; +import org.hisp.dhis.program.ProgramValidationService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ UpdateProgramValidationAction.java Apr 28, 2011 11:24:43 AM $ + */ +public class UpdateProgramValidationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramValidationService programValidationService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + private String description; + + private String leftSide; + + private String rightSide; + + private Integer programId; + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + public void setProgramValidationService( ProgramValidationService programValidationService ) + { + this.programValidationService = programValidationService; + } + + public Integer getProgramId() + { + return programId; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public void setLeftSide( String leftSide ) + { + this.leftSide = leftSide; + } + + public void setRightSide( String rightSide ) + { + this.rightSide = rightSide; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramValidation validation = programValidationService.getProgramValidation( id ); + + programId = validation.getProgram().getId(); + + validation.setDescription( description ); + validation.setLeftSide( leftSide ); + validation.setRightSide( rightSide ); + programValidationService.updateProgramValidation( validation ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-04-26 02:06:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-04-29 07:41:04 +0000 @@ -720,18 +720,7 @@ ref="org.hisp.dhis.oust.manager.SelectionTreeManager" /> - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + program.action F_PROGRAM_UPDATE - - - - - /main.vm - /dhis-web-maintenance-patient/validationDEAssociations.vm - - javascript/program.js - ,javascript/programStageDEValidation.js - - F_PROGRAM_UPDATE - @@ -1166,27 +1153,59 @@ validationCriteria.action F_PROGRAM_UPDATE - - - - - /main.vm - /dhis-web-maintenance-patient/programStageDataElementValidation.vm - /dhis-web-maintenance-patient/patientAndProgramMenu.vm - javascript/programStageDEValidation.js - - - - - /dhis-web-maintenance-patient/loadValidationDEAssociation.vm - - - - - /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + + + /main.vm + /dhis-web-maintenance-patient/programValidationList.vm + /dhis-web-maintenance-patient/patientAndProgramMenu.vm + javascript/programValidation.js + F_PROGRAM_VALIDATION + + + + /main.vm + /dhis-web-maintenance-patient/addProgramValidationForm.vm + /dhis-web-maintenance-patient/patientAndProgramMenu.vm + javascript/programValidation.js + F_PROGRAM_VALIDATION + + + + programValidation.action?programId=${programId} + F_PROGRAM_VALIDATION + + + + /main.vm + /dhis-web-maintenance-patient/updateProgramValidationForm.vm + /dhis-web-maintenance-patient/patientAndProgramMenu.vm + javascript/programValidation.js + F_PROGRAM_VALIDATION + + + + programValidation.action?programId=${programId} + F_PROGRAM_VALIDATION + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + F_PROGRAM_VALIDATION + + + + + /dhis-web-maintenance-patient/responseProgramValidation.vm + plainTextError === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.vm 2011-04-29 07:41:04 +0000 @@ -0,0 +1,85 @@ +

$i18n.getString( "add_program_validation" )

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "program_validation_details" )
+ +
+ +
+ + +
+ +
+ +
+ + +
+
+ + + +
+ +
+ +
+ + +
+ +
+ +
+ + +
+ + === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js 2011-04-26 09:00:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js 1970-01-01 00:00:00 +0000 @@ -1,61 +0,0 @@ -//----------------------------------------------------------------------------- -// Add Programstage - DataElement Validation -//----------------------------------------------------------------------------- - -function validateProgramStageDEValidation() -{ - var description = byId( 'description' ).value; - var leftProgramStageId = getFieldValue( 'leftProgramStageId' ); - var leftDataElementId = getFieldValue( 'leftDataElementId' ); - var operator = getFieldValue( 'operator' ); - var rightProgramStageId = getFieldValue( 'rightProgramStageId' ); - var rightDataElementId = getFieldValue( 'rightDataElementId' ); - - if( isEmpty(description) || isEmpty(leftProgramStageId) || - isEmpty(leftDataElementId) ||isEmpty(operator) || - isEmpty(rightProgramStageId) ||isEmpty(rightDataElementId) ) - { - setMessage(i18n_fill_fields_in_programstage_dataelement_validation); - return; - } - addProgramStageDEValidation(); -} - -function isEmpty(value){ - return (value == '') ? true: false; -} - -//----------------------------------------------------------------------------- -// Add Programstage - DataElement Validation -//----------------------------------------------------------------------------- - -function addProgramStageDEValidation() -{ - jQuery.post( "addProgramStageDEValidation.action", - { - 'programId': getFieldValue( 'programId' ), - 'description': getFieldValue( 'description' ), - 'leftProgramStageId': getFieldValue( 'leftProgramStageId' ), - 'leftDataElementId': getFieldValue( 'leftDataElementId' ), - 'operator': getFieldValue( 'operator' ), - 'rightProgramStageId': getFieldValue( 'rightProgramStageId' ), - 'rightDataElementId': getFieldValue( 'rightDataElementId' ) - }, - function(data){ - jQuery( "table.listTable tbody#list tr:last" ).after( data ); - jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" ); - jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" ); - jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" ); - jQuery( "table.listTable tbody" ).trigger("update"); - } - ); -} - -// ----------------------------------------------------------------------------- -// Remove Criteria -// ----------------------------------------------------------------------------- - -function removeProgramStageDEValidation( id, name ) -{ - removeItem( id, name, i18n_confirm_delete, 'removeProgramStageDEValidation.action' ); -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js 2011-04-29 07:41:04 +0000 @@ -0,0 +1,165 @@ + +jQuery(document).ready( function(){ + validation( 'programValidationForm', function( form ){ + form.submit(); + }); + + var isSingle = eval(jQuery.getUrlVars('value')['single']); + + if( isSingle || getFieldValue('rightSide') == '1==1') + { + hideById('rightSideDiv'); + setFieldValue('rightSide','1==1'); + } +}); + +// ----------------------------------------------------------------------------- +// View details +// ----------------------------------------------------------------------------- + +function showProgramValidationDetails ( programValidationId ) +{ + var request = new Request(); + request.setResponseTypeXML( 'programValdiation' ); + request.setCallbackSuccess( programValdiationReceived ); + request.send( 'getProgramValidation.action?validationId=' + programValidationId ); +} + +function programValdiationReceived( programValidationElement ) +{ + setInnerHTML( 'idField', getElementValue( programValidationElement, 'id' ) ); + setInnerHTML( 'descriptionField', getElementValue( programValidationElement, 'description' ) ); + setInnerHTML( 'leftSideField', getElementValue( programValidationElement, 'leftSide' ) ); + setInnerHTML( 'rightSideField', getElementValue( programValidationElement, 'rightSide' ) ); + setInnerHTML( 'programField', getElementValue( programValidationElement, 'program' ) ); + + showDetails(); +} + +// ----------------------------------------------------------------------------- +// Remove ProgramValidation +// ----------------------------------------------------------------------------- + +function removeProgramValidation( programValidationId, name ) +{ + removeItem( programValidationId, name, i18n_confirm_delete, 'removeProgramValidation.action' ); +} + +//----------------------------------------------------------------- +// Insert items data-element +//----------------------------------------------------------------- + +function insertDataElement( element, target ) +{ + byId(target).value += " " + element.options[element.selectedIndex].value + " "; +} + + +//------------------------------------------------------------------------------ +// Get DataElements of Program-Stage into left-side +//------------------------------------------------------------------------------ + +function getLeftPrgramStageDataElements() +{ + var programStage = document.getElementById( 'leftStage' ); + var psId = programStage.options[ programStage.selectedIndex ].value; + if( psId == '') + { + return; + } + + var requestString = 'getPSDataElements.action?psId=' + psId; + + var request = new Request(); + request.setResponseTypeXML( 'leftSideDE' ); + request.setCallbackSuccess( getLeftPrgramStageDataElementsCompleted ); + + request.send( requestString ); +} + +function getLeftPrgramStageDataElementsCompleted( dataelementElement ) +{ + var programstageDE = document.getElementById( 'leftSideDE' ); + + clearList( programstageDE ); + + var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' ); + + for ( var i = 0; i < programstageDEList.length; i++ ) + { + var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue; + var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue; + var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue; + + var option = document.createElement("option"); + option.value = id; + option.text = name; + option.title = name; + jQuery(option).attr({data:"{type:'"+type+"'}"}); + programstageDE.add(option, null); + } +} + +//------------------------------------------------------------------------------ +// Get DataElements of Program-Stage into right-side +//------------------------------------------------------------------------------ + +function getRightPrgramStageDataElements() +{ + var programStage = document.getElementById( 'rightStage' ); + var psId = programStage.options[ programStage.selectedIndex ].value; + if( psId == '') + { + return; + } + + var requestString = 'getPSDataElements.action?psId=' + psId; + + var request = new Request(); + request.setResponseTypeXML( 'rightSideDE' ); + request.setCallbackSuccess( getRightPrgramStageDataElementsCompleted ); + + request.send( requestString ); +} + +function getRightPrgramStageDataElementsCompleted( dataelementElement ) +{ + var programstageDE = document.getElementById( 'rightSideDE' ); + + clearList( programstageDE ); + + var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' ); + + for ( var i = 0; i < programstageDEList.length; i++ ) + { + var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue; + var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue; + var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue; + + var option = document.createElement("option"); + option.value = id; + option.text = name; + option.title = name; + jQuery(option).attr({data:"{type:'"+type+"'}"}); + programstageDE.add(option, null); + } +} + + +$.extend({ + getUrlVars: function(){ + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; + }, + getUrlVar: function(name){ + return $.getUrlVars()[name]; + } +}); + === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm 2011-04-26 09:00:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm 1970-01-01 00:00:00 +0000 @@ -1,12 +0,0 @@ - - $validation.description - [$validation.leftProgramStageDataElement.programStage.name.$validation.leftProgramStageDataElement.dataElement.name] - #if($validation.operator == '-1') < - #elseif($validation.operator == '0') = - #else > - #end - [$validation.rightProgramStageDataElement.programStage.name.$validation.rightProgramStageDataElement.dataElement.name] - - $i18n.getString( 'remove' ) - - \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm 2011-04-28 09:19:06 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm 2011-04-29 07:41:04 +0000 @@ -5,10 +5,10 @@
  • $i18n.getString( "patient_attribute_group" )
  • $i18n.getString( "patient_identifier_type" )
  • $i18n.getString( "relationship_type" )
  • -
  • $i18n.getString( "patient_orgunit_registration" )
  • +
  • $i18n.getString( "patient_registration" )
  • $i18n.getString( "program" )
  • $i18n.getString( "program_attribute" )
  • -
  • $i18n.getString( "beneficiary_aggregation_query_builder" )
  • +
  • $i18n.getString( "beneficiary_aggregation" )
  • $i18n.getString( "validation_criteria" )
  • $i18n.getString( "patient_mobile_setting" )
  • === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2011-03-30 05:11:31 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2011-04-29 07:41:04 +0000 @@ -24,7 +24,7 @@ $i18n.getString( - $i18n.getString( + $i18n.getString( $i18n.getString( $i18n.getString( $i18n.getString( === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm 2011-01-20 15:25:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm 1970-01-01 00:00:00 +0000 @@ -1,43 +0,0 @@ -

    $i18n.getString( "programstage_dataelement_validation" )

    - - - - - - -
    - $i18n.getString( "filter_by_name" ): - - -
    - - - - - - - - - - - #foreach($validation in $validations) - - - - - - #end - -
    $i18n.getString('description')$i18n.getString('validation')$i18n.getString('operator')
    $validation.description$validation.leftProgramStageDataElement.dataElement.name - #if($validation.operator == '-1') < - #elseif($criteria.operator == '0') = - #else > - #end - $validation.$validation.leftProgramStageDataElement.dataElement.name - $i18n.getString( - $i18n.getString( -
    - - === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm 2011-04-29 07:41:04 +0000 @@ -0,0 +1,71 @@ +

    $i18n.getString( "define_program_validation" )

    + + + + + + +
    + + + + + + + + + + + + + + #foreach( $validation in $validations ) + + + + + + + #end + + + +
    + + + +
    $i18n.getString( "description" )$i18n.getString( "operations" )
    $validation.description + $i18n.getString( + $i18n.getString( + $i18n.getString( +
    +
    + + + +
    + + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.vm 2011-04-29 07:41:04 +0000 @@ -0,0 +1,8 @@ + + + $validation.id + $encoder.htmlEncode($validation.description) + $encoder.htmlEncode($validation.leftSide) + $encoder.htmlEncode($validation.rightSide) + $encoder.htmlEncode($validation.rightSide.name) + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramValidationForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramValidationForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramValidationForm.vm 2011-04-29 07:41:04 +0000 @@ -0,0 +1,77 @@ +

    $i18n.getString( "update_program_validation" )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    $i18n.getString( "program_validation_details" )
    + +
    + +
    + + +
    + +
    + +
    + + +
    +
    + + +
    + +
    + +
    + + +
    +
    + + +
    + + \ No newline at end of file