Search in sources :

Example 1 with CategoryOptionGroup

use of org.hisp.dhis.dataelement.CategoryOptionGroup in project dhis2-core by dhis2.

the class DhisConvenienceTest method createCategoryOptionGroup.

/**
     * @param uniqueIdentifier A unique character to identify the
     *                         category option group.
     * @param categoryOptions  the category options.
     * @return CategoryOptionGroup
     */
public static CategoryOptionGroup createCategoryOptionGroup(char uniqueIdentifier, DataElementCategoryOption... categoryOptions) {
    CategoryOptionGroup categoryOptionGroup = new CategoryOptionGroup("CategoryOptionGroup" + uniqueIdentifier);
    categoryOptionGroup.setShortName("ShortName" + uniqueIdentifier);
    categoryOptionGroup.setAutoFields();
    categoryOptionGroup.setMembers(new HashSet<>());
    for (DataElementCategoryOption categoryOption : categoryOptions) {
        categoryOptionGroup.addCategoryOption(categoryOption);
    }
    return categoryOptionGroup;
}
Also used : CategoryOptionGroup(org.hisp.dhis.dataelement.CategoryOptionGroup) DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption)

Example 2 with CategoryOptionGroup

use of org.hisp.dhis.dataelement.CategoryOptionGroup in project dhis2-core by dhis2.

the class AnalyticalObjectEmbeddedDimensionUpgrader method executeInTransaction.

@Override
public void executeInTransaction() {
    BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> dataElementGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
        DataElementGroupSetDimension dimension = new DataElementGroupSetDimension();
        dimension.setDimension((DataElementGroupSet) embeddedDimension.getDimension());
        dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
        analyticalObject.addDataElementGroupSetDimension(dimension);
    };
    BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> orgUnitGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
        OrganisationUnitGroupSetDimension dimension = new OrganisationUnitGroupSetDimension();
        dimension.setDimension((OrganisationUnitGroupSet) embeddedDimension.getDimension());
        dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
        analyticalObject.addOrganisationUnitGroupSetDimension(dimension);
    };
    BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> categoryOptionGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
        CategoryOptionGroupSetDimension dimension = new CategoryOptionGroupSetDimension();
        dimension.setDimension((CategoryOptionGroupSet) embeddedDimension.getDimension());
        dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
        analyticalObject.addCategoryOptionGroupSetDimension(dimension);
    };
    try {
        upgradeGrupSetDimensions("reporttable", "orgunitgroupset", "orgunitgroup", ReportTable.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
        upgradeGrupSetDimensions("reporttable", "dataelementgroupset", "dataelementgroup", ReportTable.class, DataElementGroupSet.class, DataElementGroup.class, dataElementGroupSetConsumer);
        upgradeGrupSetDimensions("reporttable", "categoryoptiongroupset", "categoryoptiongroup", ReportTable.class, CategoryOptionGroupSet.class, CategoryOptionGroup.class, categoryOptionGroupSetConsumer);
        upgradeGrupSetDimensions("chart", "orgunitgroupset", "orgunitgroup", Chart.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
        upgradeGrupSetDimensions("chart", "dataelementgroupset", "dataelementgroup", Chart.class, DataElementGroupSet.class, DataElementGroup.class, dataElementGroupSetConsumer);
        upgradeGrupSetDimensions("chart", "categoryoptiongroupset", "categoryoptiongroup", Chart.class, CategoryOptionGroupSet.class, CategoryOptionGroup.class, categoryOptionGroupSetConsumer);
        upgradeGrupSetDimensions("eventreport", "orgunitgroupset", "orgunitgroup", EventReport.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
        upgradeGrupSetDimensions("eventchart", "orgunitgroupset", "orgunitgroup", EventChart.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
    } catch (Exception ex) {
        log.debug("Error during group set dimensions upgrade of favorite, probably because upgrade was already done", ex);
        return;
    }
}
Also used : AnalyticalObject(org.hisp.dhis.common.AnalyticalObject) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) OrganisationUnitGroupSetDimension(org.hisp.dhis.organisationunit.OrganisationUnitGroupSetDimension) Autowired(org.springframework.beans.factory.annotation.Autowired) EventReport(org.hisp.dhis.eventreport.EventReport) ArrayList(java.util.ArrayList) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) EventChart(org.hisp.dhis.eventchart.EventChart) ReportTable(org.hisp.dhis.reporttable.ReportTable) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) BiConsumer(java.util.function.BiConsumer) SqlRowSet(org.springframework.jdbc.support.rowset.SqlRowSet) DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) DimensionalObjectUtils(org.hisp.dhis.common.DimensionalObjectUtils) Chart(org.hisp.dhis.chart.Chart) OrganisationUnitGroup(org.hisp.dhis.organisationunit.OrganisationUnitGroup) CategoryOptionGroup(org.hisp.dhis.dataelement.CategoryOptionGroup) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) TransactionContextStartupRoutine(org.hisp.dhis.system.startup.TransactionContextStartupRoutine) DataElementGroupSetDimension(org.hisp.dhis.dataelement.DataElementGroupSetDimension) List(java.util.List) DimensionalObject(org.hisp.dhis.common.DimensionalObject) CategoryOptionGroupSetDimension(org.hisp.dhis.dataelement.CategoryOptionGroupSetDimension) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) TextUtils(org.hisp.dhis.commons.util.TextUtils) Assert(org.springframework.util.Assert) DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) DataElementGroupSetDimension(org.hisp.dhis.dataelement.DataElementGroupSetDimension) OrganisationUnitGroupSetDimension(org.hisp.dhis.organisationunit.OrganisationUnitGroupSetDimension) CategoryOptionGroupSetDimension(org.hisp.dhis.dataelement.CategoryOptionGroupSetDimension) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) AnalyticalObject(org.hisp.dhis.common.AnalyticalObject)

Aggregations

CategoryOptionGroup (org.hisp.dhis.dataelement.CategoryOptionGroup)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BiConsumer (java.util.function.BiConsumer)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Chart (org.hisp.dhis.chart.Chart)1 AnalyticalObject (org.hisp.dhis.common.AnalyticalObject)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 DimensionalObject (org.hisp.dhis.common.DimensionalObject)1 DimensionalObjectUtils (org.hisp.dhis.common.DimensionalObjectUtils)1 IdentifiableObjectManager (org.hisp.dhis.common.IdentifiableObjectManager)1 TextUtils (org.hisp.dhis.commons.util.TextUtils)1 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)1 CategoryOptionGroupSetDimension (org.hisp.dhis.dataelement.CategoryOptionGroupSetDimension)1 DataElementCategoryOption (org.hisp.dhis.dataelement.DataElementCategoryOption)1 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)1 DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)1 DataElementGroupSetDimension (org.hisp.dhis.dataelement.DataElementGroupSetDimension)1 EventChart (org.hisp.dhis.eventchart.EventChart)1