use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class CategoryOptionComboNameResourceTable method getPopulateTempTableContent.
@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
List<Object[]> batchArgs = new ArrayList<>();
for (CategoryCombo combo : objects) {
if (!combo.isValid()) {
log.warn("Ignoring category combo, not valid: " + combo);
continue;
}
for (CategoryOptionCombo coc : combo.getOptionCombos()) {
List<Object> values = new ArrayList<>();
values.add(coc.getId());
values.add(coc.getName());
values.add(coc.isIgnoreApproval() ? APPROVAL_LEVEL_HIGHEST : null);
values.add(coc.getLatestStartDate());
values.add(coc.getEarliestEndDate());
batchArgs.add(values.toArray());
}
}
return Optional.of(batchArgs);
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class DefaultCategoryService method getOperands.
@Override
@Transactional(readOnly = true)
public List<DataElementOperand> getOperands(DataSet dataSet, boolean includeTotals) {
List<DataElementOperand> operands = Lists.newArrayList();
for (DataSetElement element : dataSet.getDataSetElements()) {
CategoryCombo categoryCombo = element.getResolvedCategoryCombo();
if (includeTotals && !categoryCombo.isDefault()) {
operands.add(new DataElementOperand(element.getDataElement()));
}
operands.addAll(getOperands(element.getDataElement(), element.getResolvedCategoryCombo()));
}
return operands;
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class DataElementDeletionHandler method deleteCategoryCombo.
private void deleteCategoryCombo(CategoryCombo categoryCombo) {
CategoryCombo defaultCategoryCombo = categoryService.getCategoryComboByName(DEFAULT_CATEGORY_COMBO_NAME);
for (DataElement dataElement : idObjectManager.getAllNoAcl(DataElement.class)) {
if (dataElement != null && dataElement.getCategoryCombo().equals(categoryCombo)) {
dataElement.setCategoryCombo(defaultCategoryCombo);
idObjectManager.updateNoAcl(dataElement);
}
}
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class DefaultCsvImportService method dataElementsFromCsv.
// -------------------------------------------------------------------------
// Private methods
// -------------------------------------------------------------------------
private List<DataElement> dataElementsFromCsv(CsvReader reader) throws IOException {
CategoryCombo categoryCombo = categoryService.getDefaultCategoryCombo();
List<DataElement> list = new ArrayList<>();
while (reader.readRecord()) {
String[] values = reader.getValues();
if (values != null && values.length > 0) {
DataElement object = new DataElement();
setIdentifiableObject(object, values);
object.setShortName(getSafe(values, 3, object.getName(), 50));
object.setDescription(getSafe(values, 4));
object.setFormName(getSafe(values, 5, 230));
String domainType = getSafe(values, 6, DataElementDomain.AGGREGATE.getValue(), 16);
object.setDomainType(DataElementDomain.fromValue(domainType));
object.setValueType(ValueType.valueOf(getSafe(values, 7, ValueType.INTEGER.toString(), 50)));
object.setAggregationType(AggregationType.valueOf(getSafe(values, 8, AggregationType.SUM.toString(), 50)));
String categoryComboUid = getSafe(values, 9, 11);
object.setUrl(getSafe(values, 10, 255));
object.setZeroIsSignificant(Boolean.parseBoolean(getSafe(values, 11, "false", null)));
String optionSetUid = getSafe(values, 12, 11);
String commentOptionSetUid = getSafe(values, 13, 11);
object.setAutoFields();
CategoryCombo cc = new CategoryCombo();
cc.setUid(categoryComboUid);
cc.setAutoFields();
if (categoryComboUid == null) {
cc.setUid(categoryCombo.getUid());
}
object.setCategoryCombo(cc);
if (optionSetUid != null) {
OptionSet optionSet = new OptionSet();
optionSet.setUid(optionSetUid);
optionSet.setAutoFields();
object.setOptionSet(optionSet);
}
if (commentOptionSetUid != null) {
OptionSet optionSet = new OptionSet();
optionSet.setUid(commentOptionSetUid);
optionSet.setAutoFields();
object.setCommentOptionSet(optionSet);
}
list.add(object);
}
}
return list;
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class DefaultCsvImportService method categoryCombosFromCsv.
private List<CategoryCombo> categoryCombosFromCsv(CsvReader reader) throws IOException {
List<CategoryCombo> list = new ArrayList<>();
while (reader.readRecord()) {
String[] values = reader.getValues();
if (values != null && values.length > 0) {
CategoryCombo object = new CategoryCombo();
setIdentifiableObject(object, values);
object.setDataDimensionType(DataDimensionType.valueOf(getSafe(values, 3, DataDimensionType.DISAGGREGATION.toString(), 40)));
object.setSkipTotal(Boolean.parseBoolean(getSafe(values, 4, Boolean.FALSE.toString(), 40)));
list.add(object);
}
}
return list;
}
Aggregations