use of org.hisp.dhis.program.ProgramTrackedEntityAttribute in project dhis2-core by dhis2.
the class DefaultTrackedEntityAttributeService method getOrAddProgramTrackedEntityAttribute.
// -------------------------------------------------------------------------
// ProgramTrackedEntityAttribute
// -------------------------------------------------------------------------
@Override
public ProgramTrackedEntityAttribute getOrAddProgramTrackedEntityAttribute(String programUid, String attributeUid) {
Program program = programService.getProgram(programUid);
TrackedEntityAttribute attribute = getTrackedEntityAttribute(attributeUid);
if (program == null || attribute == null) {
return null;
}
ProgramTrackedEntityAttribute programAttribute = programAttributeStore.get(program, attribute);
if (programAttribute == null) {
programAttribute = new ProgramTrackedEntityAttribute(program, attribute);
programAttributeStore.save(programAttribute);
}
return programAttribute;
}
use of org.hisp.dhis.program.ProgramTrackedEntityAttribute in project dhis2-core by dhis2.
the class DefaultTrackedEntityAttributeService method getProgramTrackedEntityAttribute.
@Override
public ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute(String programUid, String attributeUid) {
Program program = programService.getProgram(programUid);
TrackedEntityAttribute attribute = getTrackedEntityAttribute(attributeUid);
if (program == null || attribute == null) {
return null;
}
return new ProgramTrackedEntityAttribute(program, attribute);
}
use of org.hisp.dhis.program.ProgramTrackedEntityAttribute in project dhis2-core by dhis2.
the class DhisConvenienceTest method createProgram.
public static Program createProgram(char uniqueCharacter, Set<ProgramStage> programStages, Set<TrackedEntityAttribute> attributes, Set<OrganisationUnit> organisationUnits, DataElementCategoryCombo categoryCombo) {
Program program = new Program();
program.setAutoFields();
program.setName("Program" + uniqueCharacter);
program.setCode("ProgramCode" + uniqueCharacter);
program.setShortName("ProgramShort" + uniqueCharacter);
program.setDescription("Description" + uniqueCharacter);
program.setEnrollmentDateLabel("DateOfEnrollmentDescription");
program.setIncidentDateLabel("DateOfIncidentDescription");
program.setProgramType(ProgramType.WITH_REGISTRATION);
if (programStages != null) {
for (ProgramStage programStage : programStages) {
programStage.setProgram(program);
program.getProgramStages().add(programStage);
}
}
if (attributes != null) {
for (TrackedEntityAttribute attribute : attributes) {
ProgramTrackedEntityAttribute ptea = new ProgramTrackedEntityAttribute(program, attribute, false, false);
ptea.setAutoFields();
program.getProgramAttributes().add(ptea);
}
}
if (organisationUnits != null) {
program.getOrganisationUnits().addAll(organisationUnits);
}
if (categoryCombo != null) {
program.setCategoryCombo(categoryCombo);
} else if (categoryService != null) {
program.setCategoryCombo(categoryService.getDefaultDataElementCategoryCombo());
}
return program;
}
Aggregations