use of org.hisp.dhis.category.CategoryOptionCombo 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.CategoryOptionCombo in project dhis2-core by dhis2.
the class HibernateDataApprovalStore method getDataApprovals.
@Override
public List<DataApproval> getDataApprovals(Collection<DataApprovalLevel> dataApprovalLevels, Collection<DataApprovalWorkflow> workflows, Collection<Period> periods, Collection<OrganisationUnit> organisationUnits, Collection<CategoryOptionCombo> attributeOptionCombos) {
List<Period> storedPeriods = periods.stream().map(p -> periodService.reloadPeriod(p)).collect(Collectors.toList());
CriteriaBuilder builder = getCriteriaBuilder();
return getList(builder, newJpaParameters().addPredicate(root -> root.get("dataApprovalLevel").in(dataApprovalLevels)).addPredicate(root -> root.get("workflow").in(workflows)).addPredicate(root -> root.get("period").in(storedPeriods)).addPredicate(root -> root.get("organisationUnit").in(organisationUnits)).addPredicate(root -> root.get("attributeOptionCombo").in(attributeOptionCombos)));
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class HibernateCategoryOptionComboStore method updateNames.
@Override
public void updateNames() {
List<CategoryOptionCombo> categoryOptionCombos = getQuery("from CategoryOptionCombo co where co.name is null").list();
int counter = 0;
Session session = getSession();
for (CategoryOptionCombo coc : categoryOptionCombos) {
session.update(coc);
if ((counter % 400) == 0) {
dbmsManager.clearSession();
}
}
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class DefaultAdxDataService method convertAttributesToDxf.
private void convertAttributesToDxf(Map<String, String> attributes, String optionComboName, CategoryCombo catCombo, IdSchemes idSchemes) throws AdxException {
log.debug("ADX attributes: " + attributes);
if (catCombo.isDefault()) {
return;
}
Map<String, Category> categoryMap = getCodeCategoryMap(catCombo, idSchemes.getCategoryIdScheme());
Map<String, String> attributeOptions = new HashMap<>();
for (String category : categoryMap.keySet()) {
if (attributes.containsKey(category)) {
attributeOptions.put(category, attributes.get(category));
attributes.remove(category);
} else {
throw new AdxException("Category combo " + catCombo.getName() + " must have " + categoryMap.get(category).getName());
}
}
CategoryOptionCombo catOptCombo = getCatOptComboFromAttributes(attributeOptions, catCombo, idSchemes);
attributes.put(optionComboName, catOptCombo.getPropertyValue(idSchemes.getCategoryOptionComboIdScheme()));
log.debug("DXF attributes: " + attributes);
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class DefaultCompleteDataSetRegistrationExchangeService method initMetaDataProperties.
private MetadataProperties initMetaDataProperties(org.hisp.dhis.dxf2.dataset.CompleteDataSetRegistration cdsr, MetadataCallables callables, MetadataCaches cache) {
String ds = StringUtils.trimToNull(cdsr.getDataSet());
String pe = StringUtils.trimToNull(cdsr.getPeriod());
String ou = StringUtils.trimToNull(cdsr.getOrganisationUnit());
String aoc = StringUtils.trimToNull(cdsr.getAttributeOptionCombo());
if (aoc == null) {
CategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(cdsr.getCc(), cdsr.getCp(), false);
aoc = attributeOptionCombo != null ? attributeOptionCombo.getUid() : aoc;
}
return new MetadataProperties(cache.getDataSets().get(ds, callables.getDataSetCallable().setId(ds)), cache.getPeriods().get(pe, callables.getPeriodCallable().setId(pe)), cache.getOrgUnits().get(ou, callables.getOrgUnitCallable().setId(ou)), cache.getAttrOptionCombos().get(aoc, callables.getOptionComboCallable().setId(aoc)));
}
Aggregations