use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class JdbcEventAnalyticsTableManager method getTables.
@Override
@Transactional
public List<AnalyticsTable> getTables(Date earliest) {
log.info(String.format("Get tables using earliest: %s, spatial support: %b", earliest, databaseInfo.isSpatialSupport()));
List<AnalyticsTable> tables = new UniqueArrayList<>();
Calendar calendar = PeriodType.getCalendar();
String baseName = getTableName();
List<Program> programs = idObjectManager.getAllNoAcl(Program.class);
for (Program program : programs) {
List<Integer> dataYears = getDataYears(program, earliest);
Collections.sort(dataYears);
for (Integer year : dataYears) {
Period period = PartitionUtils.getPeriod(calendar, year);
AnalyticsTable table = new AnalyticsTable(baseName, null, period, program);
List<AnalyticsTableColumn> dimensionColumns = getDimensionColumns(table);
table.setDimensionColumns(dimensionColumns);
tables.add(table);
}
}
return tables;
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class AnalyticsUtilsTest method testGetByDataDimensionType.
@Test
public void testGetByDataDimensionType() {
Program prA = createProgram('A');
DataElement deA = createDataElement('A', new DataElementCategoryCombo());
DataElement deB = createDataElement('B', new DataElementCategoryCombo());
ProgramDataElementDimensionItem pdeA = new ProgramDataElementDimensionItem(prA, deA);
ProgramDataElementDimensionItem pdeB = new ProgramDataElementDimensionItem(prA, deB);
ProgramIndicator piA = createProgramIndicator('A', prA, null, null);
List<DimensionalItemObject> list = Lists.newArrayList(deA, deB, pdeA, pdeB, piA);
assertEquals(Lists.newArrayList(deA, deB), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.DATA_ELEMENT, list));
assertEquals(Lists.newArrayList(pdeA, pdeB), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_DATA_ELEMENT, list));
assertEquals(Lists.newArrayList(piA), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_INDICATOR, list));
assertEquals(Lists.newArrayList(), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_ATTRIBUTE, list));
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class DefaultTrackedEntityAttributeService method getTrackedEntityAttributesWithoutProgram.
@Override
public List<TrackedEntityAttribute> getTrackedEntityAttributesWithoutProgram() {
List<TrackedEntityAttribute> result = new ArrayList<>(attributeStore.getAll());
List<Program> programs = programService.getAllPrograms();
for (Program program : programs) {
result.removeAll(program.getProgramAttributes());
}
return result;
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class DefaultTrackedEntityInstanceService method getFromUrl.
@Override
public TrackedEntityInstanceQueryParams getFromUrl(String query, Set<String> attribute, Set<String> filter, Set<String> ou, OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus, Boolean followUp, Date lastUpdatedStartDate, Date lastUpdatedEndDate, Date programEnrollmentStartDate, Date programEnrollmentEndDate, Date programIncidentStartDate, Date programIncidentEndDate, String trackedEntity, EventStatus eventStatus, Date eventStartDate, Date eventEndDate, boolean skipMeta, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging, boolean includeDeleted, List<String> orders) {
TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
QueryFilter queryFilter = getQueryFilter(query);
if (attribute != null) {
for (String attr : attribute) {
QueryItem it = getQueryItem(attr);
params.getAttributes().add(it);
}
}
if (filter != null) {
for (String filt : filter) {
QueryItem it = getQueryItem(filt);
params.getFilters().add(it);
}
}
if (ou != null) {
for (String orgUnit : ou) {
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(orgUnit);
if (organisationUnit == null) {
throw new IllegalQueryException("Organisation unit does not exist: " + orgUnit);
}
params.getOrganisationUnits().add(organisationUnit);
}
}
Program pr = program != null ? programService.getProgram(program) : null;
if (program != null && pr == null) {
throw new IllegalQueryException("Program does not exist: " + program);
}
TrackedEntity te = trackedEntity != null ? trackedEntityService.getTrackedEntity(trackedEntity) : null;
if (trackedEntity != null && te == null) {
throw new IllegalQueryException("Tracked entity does not exist: " + program);
}
params.setQuery(queryFilter).setProgram(pr).setProgramStatus(programStatus).setFollowUp(followUp).setLastUpdatedStartDate(lastUpdatedStartDate).setLastUpdatedEndDate(lastUpdatedEndDate).setProgramEnrollmentStartDate(programEnrollmentStartDate).setProgramEnrollmentEndDate(programEnrollmentEndDate).setProgramIncidentStartDate(programIncidentStartDate).setProgramIncidentEndDate(programIncidentEndDate).setTrackedEntity(te).setOrganisationUnitMode(ouMode).setEventStatus(eventStatus).setEventStartDate(eventStartDate).setEventEndDate(eventEndDate).setSkipMeta(skipMeta).setPage(page).setPageSize(pageSize).setTotalPages(totalPages).setSkipPaging(skipPaging).setIncludeDeleted(includeDeleted).setOrders(orders);
return params;
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class CreateSMSCommandForm method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
SMSCommand command = new SMSCommand();
command.setName(name);
command.setParserType(parserType);
if (parserType.equals(ParserType.KEY_VALUE_PARSER) || parserType.equals(ParserType.J2ME_PARSER)) {
DataSet dataset = dataSetService.getDataSet(selectedDataSetID);
command.setDataset(dataset);
} else if (parserType.equals(ParserType.ALERT_PARSER) || parserType.equals(ParserType.UNREGISTERED_PARSER)) {
UserGroup userGroup = new UserGroup();
userGroup = userGroupService.getUserGroup(userGroupID);
command.setUserGroup(userGroup);
} else if (parserType.equals(ParserType.TRACKED_ENTITY_REGISTRATION_PARSER)) {
Program program = programService.getProgram(selectedProgramId);
command.setProgram(program);
} else if (parserType.equals(ParserType.EVENT_REGISTRATION_PARSER)) {
Program program = programService.getProgram(selectedProgramIdWithoutRegistration);
command.setProgram(program);
command.setProgramStage(program.getProgramStages().iterator().next());
}
smsCommandService.save(command);
return SUCCESS;
}
Aggregations