@Ignore @Test public void testImportAllWithNewOnly() { importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementAModified, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementBModified, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementCModified, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementGroupADuplicate, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementGroupBDuplicate, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementGroupCDuplicate, null); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationA); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationB); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationC); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationE); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationF); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationG); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationI); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationJ); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationK); dbmsManager.clearSession(); importObjectService.importAll(); Collection<DataElement> dataElements = dataElementService.getAllDataElements(); assertEquals(dataElements.size(), 3); assertTrue(dataElements.contains(dataElementA)); assertTrue(dataElements.contains(dataElementB)); assertTrue(dataElements.contains(dataElementC)); Collection<DataElementGroup> dataElementGroups = dataElementService.getAllDataElementGroups(); assertEquals(dataElementGroups.size(), 3); assertTrue(dataElementGroups.contains(dataElementGroupA)); assertTrue(dataElementGroups.contains(dataElementGroupB)); assertTrue(dataElementGroups.contains(dataElementGroupC)); for (DataElementGroup dataElementGroup : dataElementGroups) { assertEquals(dataElementGroup.getMembers().size(), 3); assertTrue(dataElementGroup.getMembers().containsAll(dataElements)); } assertEquals(importObjectService.getImportObjects(DataElement.class).size(), 0); assertEquals(importObjectService.getImportObjects(DataElementGroup.class).size(), 0); assertEquals(importObjectService.getImportObjects(GroupMemberAssociation.class).size(), 0); }
public String execute() { // --------------------------------------------------------------------- // Get group members // --------------------------------------------------------------------- if (id != null) { DataElementGroup group = dataElementService.getDataElementGroup(id); groupMembers = new ArrayList<DataElement>(group.getMembers()); Collections.sort(groupMembers, new IdentifiableObjectNameComparator()); } return SUCCESS; }
@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 void setUpTest() { organisationUnit = createOrganisationUnit('A'); organisationUnitLevel = new OrganisationUnitLevel(1, "Level"); organisationUnitService.addOrganisationUnit(organisationUnit); organisationUnitService.addOrganisationUnitLevel(organisationUnitLevel); indicatorGroup = createIndicatorGroup('A'); indicatorService.addIndicatorGroup(indicatorGroup); indicatorType = createIndicatorType('A'); indicatorService.addIndicatorType(indicatorType); indicator = createIndicator('A', indicatorType); indicatorService.addIndicator(indicator); dataElement = createDataElement('A'); dataElementService.addDataElement(dataElement); dataElementGroup = createDataElementGroup('A'); dataElementGroup.getMembers().add(dataElement); dataElementService.addDataElementGroup(dataElementGroup); periodType = periodService.getPeriodTypeByName(MonthlyPeriodType.NAME); period = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 2, 1)); periodService.addPeriod(period); mapLegendSet = createLegendSet('A'); legendService.addLegendSet(mapLegendSet); internalMapLayer = new InternalMapLayer(); internalMapLayer.setRadiusLow(15); internalMapLayer.setRadiusHigh(35); internalMapLayer.setColorLow(Color.YELLOW); internalMapLayer.setColorHigh(Color.RED); internalMapLayer.setOpacity(0.5f); }
@Override public void setUpTest() { // --------------------------------------------------------------------- // Services // --------------------------------------------------------------------- dataIntegrityService = (DataIntegrityService) getBean(DataIntegrityService.ID); dataElementService = (DataElementService) getBean(DataElementService.ID); indicatorService = (IndicatorService) getBean(IndicatorService.ID); dataSetService = (DataSetService) getBean(DataSetService.ID); organisationUnitService = (OrganisationUnitService) getBean(OrganisationUnitService.ID); organisationUnitGroupService = (OrganisationUnitGroupService) getBean(OrganisationUnitGroupService.ID); // --------------------------------------------------------------------- // Objects // --------------------------------------------------------------------- elementA = createDataElement('A'); elementB = createDataElement('B'); elementC = createDataElement('C'); dataElementService.addDataElement(elementA); dataElementService.addDataElement(elementB); dataElementService.addDataElement(elementC); indicatorTypeA = createIndicatorType('A'); indicatorService.addIndicatorType(indicatorTypeA); indicatorA = createIndicator('A', indicatorTypeA); indicatorB = createIndicator('B', indicatorTypeA); indicatorC = createIndicator('C', indicatorTypeA); indicatorA.setNumerator(" "); indicatorB.setNumerator("Numerator"); indicatorB.setDenominator("Denominator"); indicatorC.setNumerator("Numerator"); indicatorC.setDenominator("Denominator"); indicatorService.addIndicator(indicatorA); indicatorService.addIndicator(indicatorB); indicatorService.addIndicator(indicatorC); unitA = createOrganisationUnit('A'); unitB = createOrganisationUnit('B', unitA); unitC = createOrganisationUnit('C', unitB); unitD = createOrganisationUnit('D', unitC); unitE = createOrganisationUnit('E', unitD); unitF = createOrganisationUnit('F'); organisationUnitService.addOrganisationUnit(unitA); organisationUnitService.addOrganisationUnit(unitB); organisationUnitService.addOrganisationUnit(unitC); organisationUnitService.addOrganisationUnit(unitD); organisationUnitService.addOrganisationUnit(unitE); organisationUnitService.addOrganisationUnit(unitF); unitA.setParent(unitC); organisationUnitService.updateOrganisationUnit(unitA); dataSetA = createDataSet('A', new MonthlyPeriodType()); dataSetB = createDataSet('B', new QuarterlyPeriodType()); dataSetA.getDataElements().add(elementA); dataSetA.getDataElements().add(elementB); elementA.getDataSets().add(dataSetA); elementB.getDataSets().add(dataSetA); dataSetA.getSources().add(unitA); unitA.getDataSets().add(dataSetA); dataSetB.getDataElements().add(elementA); elementA.getDataSets().add(dataSetB); dataSetService.addDataSet(dataSetA); dataSetService.addDataSet(dataSetB); // --------------------------------------------------------------------- // Groups // --------------------------------------------------------------------- elementGroupA = createDataElementGroup('A'); elementGroupA.getMembers().add(elementA); elementA.getGroups().add(elementGroupA); dataElementService.addDataElementGroup(elementGroupA); indicatorGroupA = createIndicatorGroup('A'); indicatorGroupA.getMembers().add(indicatorA); indicatorA.getGroups().add(indicatorGroupA); indicatorService.addIndicatorGroup(indicatorGroupA); unitGroupA = createOrganisationUnitGroup('A'); unitGroupB = createOrganisationUnitGroup('B'); unitGroupC = createOrganisationUnitGroup('C'); unitGroupD = createOrganisationUnitGroup('D'); unitGroupA.getMembers().add(unitA); unitGroupA.getMembers().add(unitB); unitGroupA.getMembers().add(unitC); unitA.getGroups().add(unitGroupA); unitB.getGroups().add(unitGroupA); unitC.getGroups().add(unitGroupA); unitGroupB.getMembers().add(unitA); unitGroupB.getMembers().add(unitB); unitGroupB.getMembers().add(unitF); unitA.getGroups().add(unitGroupB); unitB.getGroups().add(unitGroupB); unitF.getGroups().add(unitGroupB); unitGroupC.getMembers().add(unitA); unitA.getGroups().add(unitGroupC); organisationUnitGroupService.addOrganisationUnitGroup(unitGroupA); organisationUnitGroupService.addOrganisationUnitGroup(unitGroupB); organisationUnitGroupService.addOrganisationUnitGroup(unitGroupC); organisationUnitGroupService.addOrganisationUnitGroup(unitGroupD); // --------------------------------------------------------------------- // Group sets // --------------------------------------------------------------------- unitGroupSetA = createOrganisationUnitGroupSet('A'); unitGroupSetB = createOrganisationUnitGroupSet('B'); unitGroupSetA.setCompulsory(true); unitGroupSetB.setCompulsory(false); unitGroupSetA.getOrganisationUnitGroups().add(unitGroupA); unitGroupA.setGroupSet(unitGroupSetA); unitGroupSetB.getOrganisationUnitGroups().add(unitGroupB); unitGroupSetB.getOrganisationUnitGroups().add(unitGroupC); unitGroupB.setGroupSet(unitGroupSetB); unitGroupC.setGroupSet(unitGroupSetB); organisationUnitGroupService.addOrganisationUnitGroupSet(unitGroupSetA); organisationUnitGroupService.addOrganisationUnitGroupSet(unitGroupSetB); }
@Ignore @Test public void testDeleteAndImportAll() { dataElementService.addDataElement(dataElementA); dataElementGroupA.getMembers().add(dataElementA); dataElementService.addDataElementGroup(dataElementGroupA); int importObjectIdA = importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementBModified, null); int importObjectIdB = importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementCModified, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementDModified, null); int importObjectIdC = importObjectService.addImportObject( ImportObjectStatus.NEW, dataElementGroupBDuplicate, null); importObjectService.addImportObject(ImportObjectStatus.NEW, dataElementGroupCDuplicate, null); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationF); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationG); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationH); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationJ); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationK); importObjectService.addImportObject( ImportObjectStatus.NEW, GroupMemberType.DATAELEMENTGROUP, dataElementGroupAssociationL); dbmsManager.clearSession(); importObjectService.cascadeDeleteImportObject(importObjectIdA); importObjectService.cascadeDeleteImportObject(importObjectIdB); importObjectService.cascadeDeleteImportObject(importObjectIdC); importObjectService.importAll(); Collection<DataElement> dataElements = dataElementService.getAllDataElements(); assertEquals(dataElements.size(), 2); assertTrue(dataElements.contains(dataElementA)); assertTrue(dataElements.contains(dataElementDModified)); Collection<DataElementGroup> dataElementGroups = dataElementService.getAllDataElementGroups(); assertEquals(dataElementGroups.size(), 2); assertTrue(dataElementGroups.contains(dataElementGroupA)); assertTrue(dataElementGroups.contains(dataElementGroupCDuplicate)); for (DataElementGroup dataElementGroup : dataElementGroups) { assertEquals(dataElementGroup.getMembers().size(), 1); } assertEquals(importObjectService.getImportObjects(DataElement.class).size(), 0); assertEquals(importObjectService.getImportObjects(DataElementGroup.class).size(), 0); assertEquals(importObjectService.getImportObjects(GroupMemberAssociation.class).size(), 0); }