Skip to content

Commit

Permalink
Merge pull request #12 from uonafya/viewprograms
Browse files Browse the repository at this point in the history
jphes program validation & fixes
  • Loading branch information
FelixOngati authored Jan 25, 2017
2 parents 630fb49 + b672e2f commit d31b278
Show file tree
Hide file tree
Showing 50 changed files with 1,277 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public class Program extends BaseIdentifiableObject {

private Boolean enabled;

//Constructor

public Program(){

}

//Logic DataElement

public void addDataElement( DataElement dataElement )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface ProgramService {
* @param name
* @return
*/
List<Program> getProgramByName(String name);
Program getProgramByName(String name);

/**
* retrieves all programs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.hisp.dhis.common.GenericIdentifiableObjectStore;

import java.util.List;

/**
* Created by xenial on 1/4/17.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public Program getProgramByCode(String code) {
* @return
*/
@Override
public List<Program> getProgramByName(String name) {
return programStore.getAllLikeName( name );
public Program getProgramByName(String name) {
return programStore.getByName(name);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
>
<hibernate-mapping>
<class name="org.hisp.dhis.jphes.program.Program" lazy="false" table="jphes_program">
<class name="org.hisp.dhis.jphes.program.Program" table="jphes_program">

<cache usage="read-write" />

<id name="id" column="programid">
Expand All @@ -15,30 +16,30 @@

<property name="name" column="name" not-null="true" unique="true" length="230" />

<property name="shortName" column="shortname" not-null="false" unique="true" length="50" />
<property name="shortName" column="shortname" not-null="false" length="50" />

<property name="enabled" column="enabled" type="boolean" />
<property name="enabled" column="enabled" type="boolean" />

<property name="description" type="text" />

<property name="displayName" column="displayname" not-null="false" length="230"/>

<many-to-one name="dataElementGroup" column="dataelementgroupid" class="org.hisp.dhis.dataelement.DataElementGroup"
foreign-key="fk_jphesprogramdataelementgroup" not-null="true" />

<many-to-one name="indicatorGroup" column="indicatorgroupid" class="org.hisp.dhis.indicator.IndicatorGroup"
foreign-key="fk_jphesprogramindicatorgroupid" not-null="true" />

<set name="dataElements" table="jphesprogramdataelements">
<set name="dataElements" table="jphes_programdataelements">
<cache usage="read-write" />
<key column="programid" />
<many-to-many class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"/>
<key column="programid" foreign-key="fk_programdataelements_programid" />
<many-to-many class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
foreign-key="fk_programdataelements_dataelementid"/>
</set>

<set name="indicators" table="jphesprogramindicators">
<set name="indicators" table="jphes_programindicators">
<cache usage="read-write" />
<key column="programid" />
<many-to-many class="org.hisp.dhis.indicator.Indicator" column="indicatorid"/>
<key column="programid" foreign-key="fk_programindicators_programid" />
<many-to-many class="org.hisp.dhis.indicator.Indicator" column="indicatorid"
foreign-key="fk_programindicators_indicatorid"/>
</set>

</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,21 @@ org.hisp.dhis.validation.ValidationRuleGroup.members
org.hisp.dhis.validation.ValidationRuleGroup.userGroupsToAlert
org.hisp.dhis.validation.ValidationRuleGroup.userGroupAccesses
org.hisp.dhis.version.Version
org.hisp.dhis.jphes.program.Program
org.hisp.dhis.jphes.program.Program.dataElements
org.hisp.dhis.jphes.program.Program.indicators
org.hisp.dhis.jphes.hierarchy.NationalUnit
org.hisp.dhis.jphes.hierarchy.NationalUnit.programs
org.hisp.dhis.jphes.hierarchy.NationalUnit.donorUnits
org.hisp.dhis.jphes.hierarchy.NationalUnit.userGroupAccesses
org.hisp.dhis.jphes.hierarchy.DonorUnit
org.hisp.dhis.jphes.hierarchy.DonorUnit.programs
org.hisp.dhis.jphes.hierarchy.DonorUnit.agencyUnits
org.hisp.dhis.jphes.hierarchy.DonorUnit.userGroupAccesses
org.hisp.dhis.jphes.hierarchy.AgencyUnit
org.hisp.dhis.jphes.hierarchy.AgencyUnit.programs
org.hisp.dhis.jphes.hierarchy.AgencyUnit.mechanismUnits
org.hisp.dhis.jphes.hierarchy.AgencyUnit.userGroupAccesses
org.hisp.dhis.jphes.hierarchy.MechanismUnit
org.hisp.dhis.jphes.hierarchy.MechanismUnit.programs
org.hisp.dhis.jphes.hierarchy.MechanismUnit.userGroupAccesses
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,22 @@ var validationRules = {
"required" : true,
"rangelength" : [ 2, 230]
}
},

"jphesProgram" : {
"name" : {
"required" : true,
"rangelength" : [ 2, 230 ]
},
"shortName" : {
"required" : true,
"rangelength" : [ 2, 50 ]
},
"code" : {
"rangelength" : [ 0, 50 ],
"alphanumericwithbasicpuncspaces" : true,
"notOnlyDigits" : false
}
}


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ F_MECHANISM_UNIT_CREATE=Add/Update Mechanism Unit
F_MECHANISM_UNIT_DELETE=Delete Mechanism Unit
F_MECHANISM_UNIT_LIST=List Mechanism Units

F_JPHES_PROGRAM_ADD=Add/Update JPHES Program
F_JPHES_PROGRAM_LIST=List JPHES Programs
F_JPHES_PROGRAM_DELETE=Delete JPHES Program

#-- User module ---------------------------------------------------------------#

user_management=User management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.hisp.dhis.paging.ActionPagingSupport;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collections;
import java.util.List;

import static org.apache.commons.lang.StringUtils.isNotBlank;
Expand Down Expand Up @@ -52,12 +53,16 @@ public String getKey()
this.paging = createPaging(agencyUnitService.getAgencyUnitCountByName(key));

agencyUnits = agencyUnitService.getAgencyUnitsBetweenByName(key, paging.getStartPos(), paging.getPageSize() );

Collections.sort( agencyUnits );
}
else
{
this.paging = createPaging( agencyUnitService.getAgencyUnitCount() );

agencyUnits = agencyUnitService.getAgencyUnitsBetween( paging.getStartPos(), paging.getPageSize() );

Collections.sort( agencyUnits );
}

return SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.hisp.dhis.jphes.hierarchy.action.agency;

import org.hisp.dhis.jphes.hierarchy.agency.AgencyUnit;
import org.hisp.dhis.jphes.hierarchy.agency.AgencyUnitService;
import org.hisp.dhis.jphes.program.Program;
import org.hisp.dhis.paging.ActionPagingSupport;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Created by afya on 25/01/17.
*/
public class viewAgencyProgramList extends ActionPagingSupport<Program>
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------

@Autowired
private AgencyUnitService agencyUnitService;

// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------

private Integer id;

public void setId(Integer id){
this.id = id;
}

// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------

private List<Program> programs;

public List<Program> getPrograms()
{
return programs;
}

private AgencyUnit unit;

public AgencyUnit getUnit(){ return unit; }

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------

@Override
public String execute()
throws Exception
{
unit = agencyUnitService.getAgencyUnit( id );

programs = new ArrayList<>( unit.getPrograms() );

Collections.sort( programs );

this.paging = createPaging( programs.size() );

programs = programs.subList( paging.getStartPos(), paging.getEndPos() );

return SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.hisp.dhis.jphes.hierarchy.donor.DonorUnitService;
import org.hisp.dhis.paging.ActionPagingSupport;

import java.util.Collections;
import java.util.List;

import static org.apache.commons.lang.StringUtils.isNotBlank;
Expand Down Expand Up @@ -54,12 +55,16 @@ public String getKey()
this.paging = createPaging(donorUnitService.getDonorUnitCountByName(key));

donorUnits = donorUnitService.getDonorUnitsBetweenByName(key, paging.getStartPos(), paging.getPageSize() );

Collections.sort( donorUnits );
}
else
{
this.paging = createPaging( donorUnitService.getDonorUnitCount() );

donorUnits = donorUnitService.getDonorUnitsBetween( paging.getStartPos(), paging.getPageSize() );

Collections.sort( donorUnits );
}

return SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.hisp.dhis.jphes.hierarchy.action.donor;

import org.hisp.dhis.jphes.hierarchy.donor.DonorUnit;
import org.hisp.dhis.jphes.hierarchy.donor.DonorUnitService;
import org.hisp.dhis.jphes.program.Program;
import org.hisp.dhis.paging.ActionPagingSupport;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Created by afya on 25/01/17.
*/
public class viewDonorProgramList extends ActionPagingSupport<Program>
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------

@Autowired
private DonorUnitService donorUnitService;

// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------

private Integer id;

public void setId(Integer id){
this.id = id;
}

// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------

private List<Program> programs;

public List<Program> getPrograms()
{
return programs;
}

private DonorUnit unit;

public DonorUnit getUnit(){ return unit; }

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------

@Override
public String execute()
throws Exception
{
unit = donorUnitService.getDonorUnit( id );

programs = new ArrayList<>( unit.getPrograms() );

Collections.sort( programs );

this.paging = createPaging( programs.size() );

programs = programs.subList( paging.getStartPos(), paging.getEndPos() );

return SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static org.apache.commons.lang.StringUtils.isNotBlank;
Expand Down Expand Up @@ -75,22 +77,30 @@ public String getKey()
this.paging = createPaging(mechanismUnitService.getMechanismUnitCountByName(key));

mechanismUnits = mechanismUnitService.getMechanismUnitsBetweenByName(key, paging.getStartPos(), paging.getPageSize() );

Collections.sort(mechanismUnits);
}

if ( (! isNotBlank( key )) && (! isNotBlank( agencyUnit )))
{
this.paging = createPaging( mechanismUnitService.getMechanismUnitCount() );

mechanismUnits = mechanismUnitService.getMechanismUnitsBetween( paging.getStartPos(), paging.getPageSize() );

Collections.sort(mechanismUnits);
}

if ( isNotBlank( agencyUnit ) )
{
AgencyUnit agency = agencyUnitService.getAgencyUnit( agencyUnit );

this.paging = createPaging(agency.getMechanismUnits().size());

mechanismUnits = new ArrayList<>( agency.getMechanismUnits() );

this.paging = createPaging(mechanismUnits.size());

mechanismUnits = mechanismUnits.subList(paging.getStartPos(), paging.getEndPos() );

Collections.sort(mechanismUnits);
}

return SUCCESS;
Expand Down
Loading

0 comments on commit d31b278

Please sign in to comment.