use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class PeriodResourceTable method getCreateTempTableStatement.
@Override
public String getCreateTempTableStatement() {
String sql = "create table " + getTempTableName() + " (periodid bigint not null primary key, iso varchar(15) not null, daysno integer not null, startdate date not null, enddate date not null, year integer not null";
for (PeriodType periodType : PeriodType.PERIOD_TYPES) {
sql += ", " + quote(periodType.getName().toLowerCase()) + " varchar(15)";
}
sql += ")";
return sql;
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class DataOrgUnitSplitHandlerTest method setUpTest.
@Override
public void setUpTest() {
cocA = categoryService.getDefaultCategoryOptionCombo();
deA = createDataElement('A');
deB = createDataElement('B');
idObjectManager.save(deA);
idObjectManager.save(deB);
PeriodType monthly = periodService.getPeriodTypeByClass(MonthlyPeriodType.class);
peA = monthly.createPeriod("202101");
peB = monthly.createPeriod("202102");
periodService.addPeriod(peA);
periodService.addPeriod(peB);
ouA = createOrganisationUnit('A');
ouB = createOrganisationUnit('B');
ouC = createOrganisationUnit('C');
idObjectManager.save(ouA);
idObjectManager.save(ouB);
idObjectManager.save(ouC);
usA = createUser('A');
userService.addUser(usA);
dlA = new DataApprovalLevel("DataApprovalLevelA", 1);
idObjectManager.save(dlA);
dwA = new DataApprovalWorkflow("DataApprovalWorkflowA", monthly, Sets.newHashSet(dlA));
idObjectManager.save(dwA);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class DataElementResourceTable method getPopulateTempTableContent.
@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
List<Object[]> batchArgs = new ArrayList<>();
for (DataElement dataElement : objects) {
List<Object> values = new ArrayList<>();
final DataSet dataSet = dataElement.getApprovalDataSet();
final PeriodType periodType = dataElement.getPeriodType();
// -----------------------------------------------------------------
// Use highest approval level if data set does not require approval,
// or null if approval is required.
// -----------------------------------------------------------------
values.add(dataElement.getId());
values.add(dataElement.getUid());
values.add(dataElement.getName());
values.add(dataSet != null ? dataSet.getId() : null);
values.add(dataSet != null ? dataSet.getUid() : null);
values.add(dataSet != null ? dataSet.getName() : null);
values.add(dataSet != null && dataSet.isApproveData() ? null : APPROVAL_LEVEL_HIGHEST);
values.add(dataSet != null && dataSet.isApproveData() ? dataSet.getWorkflow().getId() : null);
values.add(periodType != null ? periodType.getId() : null);
values.add(periodType != null ? periodType.getName() : null);
batchArgs.add(values.toArray());
}
return Optional.of(batchArgs);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class DatePeriodResourceTable method getCreateTempTableStatement.
@Override
public String getCreateTempTableStatement() {
String sql = "create table " + getTempTableName() + " (dateperiod date not null primary key, year integer not null";
for (PeriodType periodType : PeriodType.PERIOD_TYPES) {
sql += ", " + quote(periodType.getName().toLowerCase()) + " varchar(15)";
}
sql += ")";
return sql;
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class JdbcValidationResultTableManager method getDimensionColumns.
private List<AnalyticsTableColumn> getDimensionColumns() {
List<AnalyticsTableColumn> columns = new ArrayList<>();
List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
List<Category> attributeCategories = categoryService.getAttributeDataDimensionCategoriesNoAcl();
for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "ougs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
}
for (OrganisationUnitLevel level : levels) {
String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
columns.add(new AnalyticsTableColumn(column, CHARACTER_11, "ous." + column).withCreated(level.getCreated()));
}
for (Category category : attributeCategories) {
columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
}
for (PeriodType periodType : PeriodType.getAvailablePeriodTypes()) {
String column = quote(periodType.getName().toLowerCase());
columns.add(new AnalyticsTableColumn(column, TEXT, "ps." + column));
}
columns.addAll(getFixedColumns());
return filterDimensionColumns(columns);
}
Aggregations