Exemple #1
0
  public ModelList getCategoryOptionCombos(org.hisp.dhis.dataelement.DataElement dataElement) {
    DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();

    // Client DataElement
    ModelList deCateOptCombo = new ModelList();
    List<Model> listCateOptCombo = new ArrayList<Model>();
    deCateOptCombo.setModels(listCateOptCombo);

    for (DataElementCategoryOptionCombo oneCatOptCombo : categoryCombo.getSortedOptionCombos()) {
      Model oneCateOptCombo = new Model();
      oneCateOptCombo.setId(oneCatOptCombo.getId());
      oneCateOptCombo.setName(oneCatOptCombo.getName());
      listCateOptCombo.add(oneCateOptCombo);
    }
    return deCateOptCombo;
  }
  @Override
  public DataApprovalLevel getLowestDataApprovalLevel(
      OrganisationUnit orgUnit, DataElementCategoryOptionCombo attributeOptionCombo) {
    Set<CategoryOptionGroupSet> cogSets = null;

    if (attributeOptionCombo != null
        && attributeOptionCombo != categoryService.getDefaultDataElementCategoryOptionCombo()) {
      cogSets = new HashSet<>();

      for (DataElementCategoryOption option : attributeOptionCombo.getCategoryOptions()) {
        if (option.getGroupSets() != null) {
          cogSets.addAll(option.getGroupSets());
        }
      }
    }

    int orgUnitLevel = orgUnit.getLevel();

    List<DataApprovalLevel> approvalLevels = getDataApprovalLevelsByOrgUnitLevel(orgUnitLevel);

    for (DataApprovalLevel level : Lists.reverse(approvalLevels)) {
      if (level.getCategoryOptionGroupSet() == null) {
        if (cogSets == null) {
          return level;
        }
      } else if (cogSets != null && cogSets.contains(level.getCategoryOptionGroupSet())) {
        return level;
      }
    }

    return null;
  }
  @Override
  public String execute() {
    if (dataElementGroupId > 0) {
      DataElementGroup group =
          dataElementService.getDataElementGroup(dataElementGroupId.intValue());

      dataElements = new ArrayList<>(group.getMembers());
    } else {
      dataElements = new ArrayList<>(dataElementService.getAllDataElements());
    }

    Collections.sort(dataElements, new IdentifiableObjectNameComparator());

    for (DataElement dataElement : dataElements) {
      DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();

      Set<DataElementCategoryOptionCombo> optionCombos = categoryCombo.getOptionCombos();

      if (optionCombos.size() > 1) {
        for (DataElementCategoryOptionCombo optionCombo : optionCombos) {
          DataElementOperand operand =
              new DataElementOperand(
                  dataElement.getUid(),
                  optionCombo.getUid(),
                  dataElement.getName() + optionCombo.getName());
          operands.add(operand);
        }
      } else {
        DataElementOperand operand =
            new DataElementOperand(
                dataElement.getUid(),
                optionCombos.iterator().next().getUid(),
                dataElement.getName());
        operands.add(operand);
      }
    }

    return SUCCESS;
  }
  @Override
  public Collection<ValidationResult> validate(
      DataSet dataSet,
      Period period,
      OrganisationUnit source,
      DataElementCategoryOptionCombo attributeCombo) {
    log.info(
        "Validate data set: "
            + dataSet.getName()
            + " period: "
            + period.getPeriodType().getName()
            + " "
            + period.getStartDate()
            + " "
            + period.getEndDate()
            + " source: "
            + source.getName()
            + " attribute combo: "
            + (attributeCombo == null ? "[none]" : attributeCombo.getName()));

    Collection<Period> periods = new ArrayList<>();
    periods.add(period);

    Collection<ValidationRule> rules =
        getValidationTypeRulesForDataElements(dataSet.getDataElements());

    log.debug("Using validation rules: " + rules.size());

    Collection<OrganisationUnit> sources = new HashSet<>();
    sources.add(source);

    return Validator.validate(
        sources,
        periods,
        rules,
        attributeCombo,
        null,
        constantService,
        expressionService,
        periodService,
        dataValueService,
        dataElementCategoryService,
        userService,
        currentUserService);
  }
  @Override
  public void setUpTest() {
    aggregationService = (AggregationService) getBean(AggregationService.ID);

    categoryService = (DataElementCategoryService) getBean(DataElementCategoryService.ID);

    dataElementService = (DataElementService) getBean(DataElementService.ID);

    indicatorService = (IndicatorService) getBean(IndicatorService.ID);

    dataSetService = (DataSetService) getBean(DataSetService.ID);

    periodService = (PeriodService) getBean(PeriodService.ID);

    organisationUnitService = (OrganisationUnitService) getBean(OrganisationUnitService.ID);

    dataValueService = (DataValueService) getBean(DataValueService.ID);

    expressionService = (ExpressionService) getBean(ExpressionService.ID);

    // ---------------------------------------------------------------------
    // Setup Dimensions
    // ---------------------------------------------------------------------

    categoryOptionA = new DataElementCategoryOption("Male");
    categoryOptionB = new DataElementCategoryOption("Female");

    categoryService.addDataElementCategoryOption(categoryOptionA);
    categoryService.addDataElementCategoryOption(categoryOptionB);

    category = new DataElementCategory("Gender");
    category.getCategoryOptions().add(categoryOptionA);
    category.getCategoryOptions().add(categoryOptionB);

    categoryService.addDataElementCategory(category);

    categoryCombo = new DataElementCategoryCombo("Gender");
    categoryCombo.getCategories().add(category);

    categoryService.addDataElementCategoryCombo(categoryCombo);

    categoryOptionComboA = createCategoryOptionCombo(categoryCombo, categoryOptionA);
    categoryOptionComboB = createCategoryOptionCombo(categoryCombo, categoryOptionB);

    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboA);
    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboB);

    // ---------------------------------------------------------------------
    // Setup DataElements
    // ---------------------------------------------------------------------

    dataElementA =
        createDataElement(
            'A', DataElement.VALUE_TYPE_INT, DataElement.AGGREGATION_OPERATOR_SUM, categoryCombo);
    dataElementB =
        createDataElement(
            'B', DataElement.VALUE_TYPE_BOOL, DataElement.AGGREGATION_OPERATOR_SUM, categoryCombo);
    dataElementC =
        createDataElement(
            'C', DataElement.VALUE_TYPE_INT, DataElement.AGGREGATION_OPERATOR_SUM, categoryCombo);

    dataElementService.addDataElement(dataElementA);
    dataElementService.addDataElement(dataElementB);
    dataElementService.addDataElement(dataElementC);

    // ---------------------------------------------------------------------
    // Setup Indicators
    // ---------------------------------------------------------------------

    indicatorType = createIndicatorType('A');
    indicatorType.setFactor(100);

    indicatorService.addIndicatorType(indicatorType);

    indicatorA = createIndicator('A', indicatorType);
    indicatorA.setNumerator(
        "#{" + dataElementA.getUid() + SEPARATOR + categoryOptionComboA.getUid() + "}+150");
    indicatorA.setDenominator(
        "#{" + dataElementB.getUid() + SEPARATOR + categoryOptionComboA.getUid() + "}");

    indicatorB = createIndicator('B', indicatorType);
    indicatorB.setNumerator("#{" + dataElementC.getUid() + "}");
    indicatorB.setDenominator("1");

    indicatorService.addIndicator(indicatorA);
    indicatorService.addIndicator(indicatorB);

    // ---------------------------------------------------------------------
    // Setup DataSets (to get correct PeriodType for DataElements)
    // ---------------------------------------------------------------------

    dataSet = createDataSet('A', new MonthlyPeriodType());
    dataSet.getDataElements().add(dataElementA);
    dataSet.getDataElements().add(dataElementB);
    dataSetService.addDataSet(dataSet);
    dataElementA.getDataSets().add(dataSet);
    dataElementB.getDataSets().add(dataSet);
    dataElementC.getDataSets().add(dataSet);
    dataElementService.updateDataElement(dataElementA);
    dataElementService.updateDataElement(dataElementB);
    dataElementService.updateDataElement(dataElementC);

    // ---------------------------------------------------------------------
    // Setup Periods
    // ---------------------------------------------------------------------

    PeriodType monthly = new MonthlyPeriodType();

    periodA = createPeriod(monthly, mar01, mar31);
    periodB = createPeriod(monthly, apr01, apr30);
    periodC = createPeriod(monthly, may01, may31);

    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    periodService.addPeriod(periodC);

    // ---------------------------------------------------------------------
    // Setup OrganisationUnits
    // ---------------------------------------------------------------------

    unitA = createOrganisationUnit('A');
    unitB = createOrganisationUnit('B', unitA);
    unitC = createOrganisationUnit('C', unitA);
    unitD = createOrganisationUnit('D', unitB);
    unitE = createOrganisationUnit('E', unitB);
    unitF = createOrganisationUnit('F', unitB);
    unitG = createOrganisationUnit('G', unitF);
    unitH = createOrganisationUnit('H', unitF);
    unitI = createOrganisationUnit('I');

    organisationUnitService.addOrganisationUnit(unitA);
    organisationUnitService.addOrganisationUnit(unitB);
    organisationUnitService.addOrganisationUnit(unitC);
    organisationUnitService.addOrganisationUnit(unitD);
    organisationUnitService.addOrganisationUnit(unitE);
    organisationUnitService.addOrganisationUnit(unitF);
    organisationUnitService.addOrganisationUnit(unitG);
    organisationUnitService.addOrganisationUnit(unitH);
    organisationUnitService.addOrganisationUnit(unitI);

    // ---------------------------------------------------------------------
    // Setup DataValues
    // ---------------------------------------------------------------------

    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitC, "90", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitD, "10", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitE, "35", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitF, "25", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitG, "20", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodA, unitH, "60", categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitC, "70", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitD, "40", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitE, "65", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitF, "55", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitG, "20", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodB, unitH, "15", categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitC, "95", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitD, "40", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitE, "45", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitF, "30", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitG, "50", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementA, periodC, unitH, "70", categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitC, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitD, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitE, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitF, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitG, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodA, unitH, T, categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitC, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitD, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitE, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitF, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitG, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodB, unitH, T, categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitC, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitD, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitE, F, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitF, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitG, T, categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementB, periodC, unitH, T, categoryOptionComboA));

    dataValueService.addDataValue(
        createDataValue(dataElementC, periodA, unitB, "30", categoryOptionComboA));
    dataValueService.addDataValue(
        createDataValue(dataElementC, periodA, unitB, "20", categoryOptionComboB));

    aggregationService.clearCache();
  }
  @Override
  public void setUpTest() {
    mockDataValueBatchHandler = new MockBatchHandler<>();
    mockBatchHandlerFactory = new MockBatchHandlerFactory();
    mockBatchHandlerFactory.registerBatchHandler(
        DataValueBatchHandler.class, mockDataValueBatchHandler);
    setDependency(dataValueSetService, "batchHandlerFactory", mockBatchHandlerFactory);

    categoryOptionA = createCategoryOption('A');
    categoryOptionB = createCategoryOption('B');
    categoryA = createDataElementCategory('A', categoryOptionA, categoryOptionB);
    categoryComboA = createCategoryCombo('A', categoryA);
    ocDef = categoryService.getDefaultDataElementCategoryOptionCombo();

    ocA = createCategoryOptionCombo(categoryComboA, categoryOptionA);
    ocB = createCategoryOptionCombo(categoryComboA, categoryOptionB);
    deA = createDataElement('A');
    deB = createDataElement('B');
    deC = createDataElement('C');
    deD = createDataElement('D');
    dsA = createDataSet('A', new MonthlyPeriodType());
    ouA = createOrganisationUnit('A');
    ouB = createOrganisationUnit('B');
    ouC = createOrganisationUnit('C');
    peA =
        createPeriod(
            PeriodType.getByNameIgnoreCase(MonthlyPeriodType.NAME),
            getDate(2012, 1, 1),
            getDate(2012, 1, 31));
    peB =
        createPeriod(
            PeriodType.getByNameIgnoreCase(MonthlyPeriodType.NAME),
            getDate(2012, 2, 1),
            getDate(2012, 2, 29));

    ocA.setUid("kjuiHgy67hg");
    ocB.setUid("Gad33qy67g5");
    deA.setUid("f7n9E0hX8qk");
    deB.setUid("Ix2HsbDMLea");
    deC.setUid("eY5ehpbEsB7");
    dsA.setUid("pBOMPrpg1QX");
    ouA.setUid("DiszpKrYNg8");
    ouB.setUid("BdfsJfj87js");
    ouC.setUid("j7Hg26FpoIa");

    ocA.setCode("OC_A");
    ocB.setCode("OC_B");
    deA.setCode("DE_A");
    deB.setCode("DE_B");
    deC.setCode("DE_C");
    deD.setCode("DE_D");
    dsA.setCode("DS_A");
    ouA.setCode("OU_A");
    ouB.setCode("OU_B");
    ouC.setCode("OU_C");

    categoryService.addDataElementCategoryOption(categoryOptionA);
    categoryService.addDataElementCategoryOption(categoryOptionB);
    categoryService.addDataElementCategory(categoryA);
    categoryService.addDataElementCategoryCombo(categoryComboA);
    categoryService.addDataElementCategoryOptionCombo(ocA);
    categoryService.addDataElementCategoryOptionCombo(ocB);

    dataElementService.addDataElement(deA);
    dataElementService.addDataElement(deB);
    dataElementService.addDataElement(deC);
    dataElementService.addDataElement(deD);
    dataSetService.addDataSet(dsA);
    organisationUnitService.addOrganisationUnit(ouA);
    organisationUnitService.addOrganisationUnit(ouB);
    organisationUnitService.addOrganisationUnit(ouC);
    periodService.addPeriod(peA);
    periodService.addPeriod(peB);

    user = createUser('A');
    user.setOrganisationUnits(Sets.newHashSet(ouA, ouB));
    CurrentUserService currentUserService = new MockCurrentUserService(user);
    setDependency(dataValueSetService, "currentUserService", currentUserService);
  }
  @Override
  public void setUpTest() {
    // ---------------------------------------------------------------------
    // Services
    // ---------------------------------------------------------------------

    importObjectService = (ImportObjectService) getBean(ImportObjectService.ID);

    batchHandlerFactory = (BatchHandlerFactory) getBean("batchHandlerFactory");

    dataElementService = (DataElementService) getBean(DataElementService.ID);

    categoryService = (DataElementCategoryService) getBean(DataElementCategoryService.ID);

    periodService = (PeriodService) getBean(PeriodService.ID);

    organisationUnitService = (OrganisationUnitService) getBean(OrganisationUnitService.ID);

    dataValueService = (DataValueService) getBean(DataValueService.ID);

    // ---------------------------------------------------------------------
    // CategoryOption
    // ---------------------------------------------------------------------

    categoryOptionA = new DataElementCategoryOption("CategoryOptionA");
    categoryOptionB = new DataElementCategoryOption("CategoryOptionB");
    categoryOptionC = new DataElementCategoryOption("CategoryOptionC");
    categoryOptionD = new DataElementCategoryOption("CategoryOptionD");

    categoryService.addDataElementCategoryOption(categoryOptionA);
    categoryService.addDataElementCategoryOption(categoryOptionB);
    categoryService.addDataElementCategoryOption(categoryOptionC);
    categoryService.addDataElementCategoryOption(categoryOptionD);

    categoryOptionADuplicate = new DataElementCategoryOption("CategoryOptionA");
    categoryOptionBDuplicate = new DataElementCategoryOption("CategoryOptionB");
    categoryOptionCDuplicate = new DataElementCategoryOption("CategoryOptionC");
    categoryOptionDDuplicate = new DataElementCategoryOption("CategoryOptionD");

    categoryOptionADuplicate.setId('A');
    categoryOptionBDuplicate.setId('B');
    categoryOptionCDuplicate.setId('C');
    categoryOptionDDuplicate.setId('D');

    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryOptionADuplicate, null);
    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryOptionBDuplicate, null);
    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryOptionCDuplicate, null);
    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryOptionDDuplicate, null);

    // ---------------------------------------------------------------------
    // Category
    // ---------------------------------------------------------------------

    categoryA = new DataElementCategory("CategoryA");
    categoryB = new DataElementCategory("CategoryB");

    categoryA.getCategoryOptions().add(categoryOptionA);
    categoryA.getCategoryOptions().add(categoryOptionB);
    categoryB.getCategoryOptions().add(categoryOptionC);
    categoryB.getCategoryOptions().add(categoryOptionD);

    categoryService.addDataElementCategory(categoryA);
    categoryService.addDataElementCategory(categoryB);

    categoryADuplicate = new DataElementCategory("CategoryA");
    categoryBDuplicate = new DataElementCategory("CategoryB");

    categoryADuplicate.setId('A');
    categoryBDuplicate.setId('B');

    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryADuplicate, null);
    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryBDuplicate, null);

    // ---------------------------------------------------------------------
    // Category - CategoryOption Association
    // ---------------------------------------------------------------------

    categoryCategoryOptionAssociationA = new GroupMemberAssociation('A', 'A', 1);
    categoryCategoryOptionAssociationB = new GroupMemberAssociation('A', 'B', 2);
    categoryCategoryOptionAssociationC = new GroupMemberAssociation('B', 'C', 1);
    categoryCategoryOptionAssociationD = new GroupMemberAssociation('B', 'D', 2);

    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORY_CATEGORYOPTION,
        categoryCategoryOptionAssociationA);
    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORY_CATEGORYOPTION,
        categoryCategoryOptionAssociationB);
    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORY_CATEGORYOPTION,
        categoryCategoryOptionAssociationC);
    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORY_CATEGORYOPTION,
        categoryCategoryOptionAssociationD);

    // ---------------------------------------------------------------------
    // CategoryCombo
    // ---------------------------------------------------------------------

    categoryComboA = new DataElementCategoryCombo("CategoryComboA");
    categoryComboB = new DataElementCategoryCombo("CategoryComboB");

    categoryComboA.getCategories().add(categoryA);
    categoryComboA.getCategories().add(categoryB);
    categoryComboB.getCategories().add(categoryA);

    categoryService.addDataElementCategoryCombo(categoryComboA);
    categoryService.addDataElementCategoryCombo(categoryComboB);

    categoryComboADuplicate = new DataElementCategoryCombo("CategoryComboA");
    categoryComboBDuplicate = new DataElementCategoryCombo("CategoryComboB");

    categoryComboADuplicate.setId('A');
    categoryComboBDuplicate.setId('B');

    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryComboADuplicate, null);
    importObjectService.addImportObject(ImportObjectStatus.MATCH, categoryComboBDuplicate, null);

    // ---------------------------------------------------------------------
    // CategoryCombo - Category Association
    // ---------------------------------------------------------------------

    categoryComboCategoryAssociationA = new GroupMemberAssociation('A', 'A', 1);
    categoryComboCategoryAssociationB = new GroupMemberAssociation('A', 'B', 2);
    categoryComboCategoryAssociationC = new GroupMemberAssociation('B', 'A', 1);

    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORYCOMBO_CATEGORY,
        categoryComboCategoryAssociationA);
    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORYCOMBO_CATEGORY,
        categoryComboCategoryAssociationB);
    importObjectService.addImportObject(
        ImportObjectStatus.NEW,
        GroupMemberType.CATEGORYCOMBO_CATEGORY,
        categoryComboCategoryAssociationC);

    // ---------------------------------------------------------------------
    // CategoryOptionCombo
    // ---------------------------------------------------------------------

    categoryOptionComboA = new DataElementCategoryOptionCombo();
    categoryOptionComboB = new DataElementCategoryOptionCombo();
    categoryOptionComboC = new DataElementCategoryOptionCombo();
    categoryOptionComboD = new DataElementCategoryOptionCombo();

    categoryOptionComboA.setCategoryCombo(categoryComboA);
    categoryOptionComboB.setCategoryCombo(categoryComboA);
    categoryOptionComboC.setCategoryCombo(categoryComboB);
    categoryOptionComboD.setCategoryCombo(categoryComboB);

    categoryOptionComboA.getCategoryOptions().add(categoryOptionA);
    categoryOptionComboA.getCategoryOptions().add(categoryOptionC);
    categoryOptionComboB.getCategoryOptions().add(categoryOptionB);
    categoryOptionComboB.getCategoryOptions().add(categoryOptionD);
    categoryOptionComboC.getCategoryOptions().add(categoryOptionA);
    categoryOptionComboD.getCategoryOptions().add(categoryOptionB);

    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboA);
    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboB);
    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboC);
    categoryService.addDataElementCategoryOptionCombo(categoryOptionComboD);

    categoryOptionComboADuplicate = new DataElementCategoryOptionCombo();
    categoryOptionComboBDuplicate = new DataElementCategoryOptionCombo();
    categoryOptionComboCDuplicate = new DataElementCategoryOptionCombo();
    categoryOptionComboDDuplicate = new DataElementCategoryOptionCombo();

    categoryOptionComboADuplicate.setId('A');
    categoryOptionComboBDuplicate.setId('B');
    categoryOptionComboCDuplicate.setId('C');
    categoryOptionComboDDuplicate.setId('D');

    categoryOptionComboADuplicate.setCategoryCombo(categoryComboADuplicate);
    categoryOptionComboBDuplicate.setCategoryCombo(categoryComboADuplicate);
    categoryOptionComboCDuplicate.setCategoryCombo(categoryComboBDuplicate);
    categoryOptionComboDDuplicate.setCategoryCombo(categoryComboBDuplicate);

    categoryOptionComboADuplicate.getCategoryOptions().add(categoryOptionADuplicate);
    categoryOptionComboADuplicate.getCategoryOptions().add(categoryOptionCDuplicate);
    categoryOptionComboBDuplicate.getCategoryOptions().add(categoryOptionBDuplicate);
    categoryOptionComboBDuplicate.getCategoryOptions().add(categoryOptionDDuplicate);
    categoryOptionComboCDuplicate.getCategoryOptions().add(categoryOptionADuplicate);
    categoryOptionComboDDuplicate.getCategoryOptions().add(categoryOptionBDuplicate);

    importObjectService.addImportObject(
        ImportObjectStatus.MATCH, categoryOptionComboADuplicate, null);
    importObjectService.addImportObject(
        ImportObjectStatus.MATCH, categoryOptionComboBDuplicate, null);
    importObjectService.addImportObject(
        ImportObjectStatus.MATCH, categoryOptionComboCDuplicate, null);
    importObjectService.addImportObject(
        ImportObjectStatus.MATCH, categoryOptionComboDDuplicate, null);

    // ---------------------------------------------------------------------
    // DataElement
    // ---------------------------------------------------------------------

    dataElementA = createDataElement('A', categoryComboA);
    dataElementB = createDataElement('B', categoryComboA);
    dataElementC = createDataElement('C', categoryComboA);
    dataElementD = createDataElement('D', categoryComboA);

    dataElementAModified = createDataElement('A', categoryComboADuplicate);
    dataElementBModified = createDataElement('B', categoryComboADuplicate);
    dataElementCModified = createDataElement('C', categoryComboADuplicate);
    dataElementDModified = createDataElement('D', categoryComboADuplicate);

    dataElementAModified.setId('A');
    dataElementBModified.setId('B');
    dataElementCModified.setId('C');
    dataElementDModified.setId('D');

    dataElementAModified.setShortName("ShortNameModifiedA");
    dataElementBModified.setShortName("ShortNameModifiedB");
    dataElementCModified.setShortName("ShortNameModifiedC");
    dataElementDModified.setShortName("ShortNameModifiedD");

    // ---------------------------------------------------------------------
    // DataElementGroup
    // ---------------------------------------------------------------------

    dataElementGroupA = createDataElementGroup('A');
    dataElementGroupB = createDataElementGroup('B');
    dataElementGroupC = createDataElementGroup('C');

    dataElementGroupADuplicate = createDataElementGroup('A');
    dataElementGroupBDuplicate = createDataElementGroup('B');
    dataElementGroupCDuplicate = createDataElementGroup('C');

    dataElementGroupADuplicate.setId('A');
    dataElementGroupBDuplicate.setId('B');
    dataElementGroupCDuplicate.setId('C');

    dataElementGroupAssociationA = new GroupMemberAssociation('A', 'A');
    dataElementGroupAssociationB = new GroupMemberAssociation('A', 'B');
    dataElementGroupAssociationC = new GroupMemberAssociation('A', 'C');
    dataElementGroupAssociationD = new GroupMemberAssociation('A', 'D');
    dataElementGroupAssociationE = new GroupMemberAssociation('B', 'A');
    dataElementGroupAssociationF = new GroupMemberAssociation('B', 'B');
    dataElementGroupAssociationG = new GroupMemberAssociation('B', 'C');
    dataElementGroupAssociationH = new GroupMemberAssociation('B', 'D');
    dataElementGroupAssociationI = new GroupMemberAssociation('C', 'A');
    dataElementGroupAssociationJ = new GroupMemberAssociation('C', 'B');
    dataElementGroupAssociationK = new GroupMemberAssociation('C', 'C');
    dataElementGroupAssociationL = new GroupMemberAssociation('C', 'D');

    // ---------------------------------------------------------------------
    // Period
    // ---------------------------------------------------------------------

    periodTypeA = periodService.getPeriodTypeByName(MonthlyPeriodType.NAME);

    periodA = createPeriod(periodTypeA, getDate(1, 0, 2000), getDate(31, 0, 2000));

    periodADuplicate = createPeriod(periodTypeA, getDate(1, 0, 2000), getDate(31, 0, 2000));

    periodADuplicate.setId('A');

    // ---------------------------------------------------------------------
    // OrganisationUnit
    // ---------------------------------------------------------------------

    organisationUnitA = createOrganisationUnit('A');
    organisationUnitB = createOrganisationUnit('B');
    organisationUnitC = createOrganisationUnit('C');

    organisationUnitAModified = createOrganisationUnit('A');
    organisationUnitBModified = createOrganisationUnit('B');
    organisationUnitCModified = createOrganisationUnit('C');

    organisationUnitAModified.setId('A');
    organisationUnitBModified.setId('B');
    organisationUnitCModified.setId('C');

    organisationUnitAModified.setShortName("ShortNameModifiedA");
    organisationUnitBModified.setShortName("ShortNameModifiedB");
    organisationUnitCModified.setShortName("ShortNameModifiedC");

    // ---------------------------------------------------------------------
    // RelationshipAssociation
    // ---------------------------------------------------------------------

    relationshipAssociationA = new GroupMemberAssociation('A', 'B');
    relationshipAssociationB = new GroupMemberAssociation('B', 'C');

    // ---------------------------------------------------------------------
    // DataValue
    // ---------------------------------------------------------------------

    dataValueA =
        createDataValue(dataElementA, periodA, organisationUnitA, "10", categoryOptionComboA);
    dataValueB =
        createDataValue(dataElementA, periodA, organisationUnitB, "10", categoryOptionComboA);
    dataValueC =
        createDataValue(dataElementA, periodA, organisationUnitC, "10", categoryOptionComboA);
    dataValueD =
        createDataValue(dataElementB, periodA, organisationUnitA, "10", categoryOptionComboA);
    dataValueE =
        createDataValue(dataElementB, periodA, organisationUnitB, "10", categoryOptionComboA);
    dataValueF =
        createDataValue(dataElementB, periodA, organisationUnitC, "10", categoryOptionComboA);
    dataValueG =
        createDataValue(dataElementC, periodA, organisationUnitA, "10", categoryOptionComboA);
    dataValueH =
        createDataValue(dataElementC, periodA, organisationUnitB, "10", categoryOptionComboA);
    dataValueI =
        createDataValue(dataElementC, periodA, organisationUnitC, "10", categoryOptionComboA);

    dataValueADuplicate =
        createDataValue(
            dataElementAModified,
            periodADuplicate,
            organisationUnitAModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueBDuplicate =
        createDataValue(
            dataElementAModified,
            periodADuplicate,
            organisationUnitBModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueCDuplicate =
        createDataValue(
            dataElementAModified,
            periodADuplicate,
            organisationUnitCModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueDDuplicate =
        createDataValue(
            dataElementBModified,
            periodADuplicate,
            organisationUnitAModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueEDuplicate =
        createDataValue(
            dataElementBModified,
            periodADuplicate,
            organisationUnitBModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueFDuplicate =
        createDataValue(
            dataElementBModified,
            periodADuplicate,
            organisationUnitCModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueGDuplicate =
        createDataValue(
            dataElementCModified,
            periodADuplicate,
            organisationUnitAModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueHDuplicate =
        createDataValue(
            dataElementCModified,
            periodADuplicate,
            organisationUnitBModified,
            "10",
            categoryOptionComboADuplicate);
    dataValueIDuplicate =
        createDataValue(
            dataElementCModified,
            periodADuplicate,
            organisationUnitCModified,
            "10",
            categoryOptionComboADuplicate);
  }