public String execute() throws Exception {
    if (id == null || id == ALL) {
      indicators = new ArrayList<Indicator>(indicatorService.getAllIndicators());
    } else {
      IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup(id);

      if (indicatorGroup != null) {
        indicators = new ArrayList<Indicator>(indicatorGroup.getMembers());
      } else {
        indicators = new ArrayList<Indicator>();
      }
    }

    // To Filter the indicators that are assigned to any survey
    /*
    if( surveyflag != null && surveyflag.equalsIgnoreCase( "yes" ) )
    {
        List<Indicator> surveyIndicators = new ArrayList<Indicator>( surveyService.getAllSurveyIndicators() );

        indicators.retainAll( surveyIndicators );
    }
    System.out.println( "id = "+id + " indicator size = "+ indicators.size() );
    */

    // filter all the indicators which have not any survey
    if (surveyExist != null && surveyExist.equalsIgnoreCase("yes")) {
      System.out.println("surveyExist" + surveyExist);
      Iterator<Indicator> allIndicatorIterator = indicators.iterator();
      while (allIndicatorIterator.hasNext()) {
        Indicator indicator = allIndicatorIterator.next();
        Collection<Survey> surveyList = surveyService.getSurveysByIndicator(indicator);
        // surveyList = surveyService.getSurveysByIndicator( indicator );

        if (surveyList == null || surveyList.size() <= 0) {
          allIndicatorIterator.remove();
        }
      }
    }

    System.out.println("id = " + id + " indicator final size = " + indicators.size());

    Collections.sort(indicators, indicatorComparator);

    // displayPropertyHandler.handle( indicators );

    return SUCCESS;
  }
Ejemplo n.º 2
0
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }

    if (o == null) {
      return false;
    }

    if (!(o instanceof IndicatorGroup)) {
      return false;
    }

    final IndicatorGroup other = (IndicatorGroup) o;

    return name.equals(other.getName());
  }
  @Override
  public String execute() {
    indicatorGroup = indicatorService.getIndicatorGroup(id);

    if (name != null && name.trim().length() > 0) {
      indicatorGroup.setName(name);
    }

    indicatorService.updateIndicatorGroup(indicatorGroup);

    return SUCCESS;
  }
Ejemplo n.º 4
0
  @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);
  }
Ejemplo n.º 5
0
 @Override
 protected boolean isIdentical(IndicatorGroup object, IndicatorGroup existing) {
   return object.getName().equals(existing.getName());
 }
Ejemplo n.º 6
0
 @Override
 protected IndicatorGroup getMatching(IndicatorGroup object) {
   List<IndicatorGroup> indicatorGroupByName =
       indicatorService.getIndicatorGroupByName(object.getName());
   return indicatorGroupByName.isEmpty() ? null : indicatorGroupByName.get(0);
 }
Ejemplo n.º 7
0
  @Override
  protected void importMatching(IndicatorGroup object, IndicatorGroup match) {
    match.setName(object.getName());

    indicatorService.updateIndicatorGroup(object);
  }
Ejemplo n.º 8
0
  @Override
  public void importObject(IndicatorGroup object, ImportParams params) {
    NameMappingUtil.addIndicatorGroupMapping(object.getId(), object.getName());

    read(object, GroupMemberType.NONE, params);
  }
  @Transactional
  public void matchObject(int importObjectId, int existingObjectId) {
    ImportObject importObject = importObjectStore.getImportObject(importObjectId);

    Object object = importObject.getObject();

    // ---------------------------------------------------------------------
    // Updates the name of the import object to the name of the existing
    // object.
    // ---------------------------------------------------------------------

    if (object.getClass().equals(DataElement.class)) {
      DataElement element = (DataElement) object;

      element.setName(dataElementService.getDataElement(existingObjectId).getName());
    } else if (object.getClass().equals(DataElementGroup.class)) {
      DataElementGroup group = (DataElementGroup) object;

      group.setName(dataElementService.getDataElementGroup(existingObjectId).getName());
    } else if (object.getClass().equals(DataElementGroupSet.class)) {
      DataElementGroupSet groupSet = (DataElementGroupSet) object;

      groupSet.setName(dataElementService.getDataElementGroupSet(existingObjectId).getName());
    } else if (object.getClass().equals(IndicatorType.class)) {
      IndicatorType type = (IndicatorType) object;

      type.setName(indicatorService.getIndicatorType(existingObjectId).getName());
    } else if (object.getClass().equals(Indicator.class)) {
      Indicator indicator = (Indicator) object;

      indicator.setName(indicatorService.getIndicator(existingObjectId).getName());
    } else if (object.getClass().equals(IndicatorGroup.class)) {
      IndicatorGroup group = (IndicatorGroup) object;

      group.setName(indicatorService.getIndicatorGroup(existingObjectId).getName());
    } else if (object.getClass().equals(IndicatorGroupSet.class)) {
      IndicatorGroupSet groupSet = (IndicatorGroupSet) object;

      groupSet.setName(indicatorService.getIndicatorGroupSet(existingObjectId).getName());
    } else if (object.getClass().equals(DataDictionary.class)) {
      DataDictionary dictionary = (DataDictionary) object;

      dictionary.setName(dataDictionaryService.getDataDictionary(existingObjectId).getName());
    } else if (object.getClass().equals(DataSet.class)) {
      DataSet dataSet = (DataSet) object;

      dataSet.setName(dataSetService.getDataSet(existingObjectId).getName());
    } else if (object.getClass().equals(OrganisationUnit.class)) {
      OrganisationUnit unit = (OrganisationUnit) object;

      unit.setName(organisationUnitService.getOrganisationUnit(existingObjectId).getName());
    } else if (object.getClass().equals(OrganisationUnitGroup.class)) {
      OrganisationUnitGroup group = (OrganisationUnitGroup) object;

      group.setName(
          organisationUnitGroupService.getOrganisationUnitGroup(existingObjectId).getName());
    } else if (object.getClass().equals(OrganisationUnitGroupSet.class)) {
      OrganisationUnitGroupSet groupSet = (OrganisationUnitGroupSet) object;

      groupSet.setName(
          organisationUnitGroupService.getOrganisationUnitGroupSet(existingObjectId).getName());
    } else if (object.getClass().equals(OrganisationUnitLevel.class)) {
      OrganisationUnitLevel level = (OrganisationUnitLevel) object;

      level.setName(organisationUnitService.getOrganisationUnitLevel(existingObjectId).getName());
    } else if (object.getClass().equals(ValidationRule.class)) {
      ValidationRule validationRule = (ValidationRule) object;

      validationRule.setName(validationRuleService.getValidationRule(existingObjectId).getName());
    } else if (object.getClass().equals(Report.class)) {
      Report report = (Report) object;

      report.setName(reportService.getReport(existingObjectId).getName());
    } else if (object.getClass().equals(ReportTable.class)) {
      ReportTable reportTable = (ReportTable) object;

      reportTable.setName(reportTableService.getReportTable(existingObjectId).getName());
    } else if (object.getClass().equals(Chart.class)) {
      Chart chart = (Chart) object;

      chart.setName(chartService.getChart(existingObjectId).getName());
    } else if (object.getClass().equals(DataValue.class)) {
      DataValue dataValue = (DataValue) object;

      dataValue =
          updateDataValue(
              dataValue,
              dataValueService.getDataValue(
                  dataValue.getSource(),
                  dataValue.getDataElement(),
                  dataValue.getPeriod(),
                  dataValue.getOptionCombo()));
    }

    // ---------------------------------------------------------------------
    // Sets the status of the import object to match, these objects will
    // later be ignored on import all but is needed for matching of
    // associations.
    // ---------------------------------------------------------------------

    importObject.setStatus(ImportObjectStatus.MATCH);

    importObjectStore.updateImportObject(importObject);
  }
  @Transactional
  public void cascadeDeleteImportObject(int importObjectId) {
    ImportObject importObject = importObjectStore.getImportObject(importObjectId);

    if (importObject != null) {
      if (importObject.getClassName().equals(DataElement.class.getName())) {
        DataElement element = (DataElement) importObject.getObject();

        deleteMemberAssociations(GroupMemberType.DATAELEMENTGROUP, element.getId());
        deleteMemberAssociations(GroupMemberType.DATASET, element.getId());
        deleteMemberAssociations(GroupMemberType.DATADICTIONARY_DATAELEMENT, element.getId());

        deleteIndicatorsContainingDataElement(element.getId());

        importDataValueService.deleteImportDataValuesByDataElement(element.getId());
      } else if (importObject.getClassName().equals(DataElementGroup.class.getName())) {
        DataElementGroup group = (DataElementGroup) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.DATAELEMENTGROUP, group.getId());
        deleteMemberAssociations(GroupMemberType.DATAELEMENTGROUPSET, group.getId());
      } else if (importObject.getClassName().equals(DataElementGroupSet.class.getName())) {
        DataElementGroupSet groupSet = (DataElementGroupSet) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.DATAELEMENTGROUPSET, groupSet.getId());
      } else if (importObject.getClassName().equals(IndicatorType.class.getName())) {
        IndicatorType type = (IndicatorType) importObject.getObject();

        deleteIndicatorsWithIndicatorType(type.getId());
      } else if (importObject.getClassName().equals(Indicator.class.getName())) {
        Indicator indicator = (Indicator) importObject.getObject();

        deleteMemberAssociations(GroupMemberType.INDICATORGROUP, indicator.getId());
        deleteMemberAssociations(GroupMemberType.DATADICTIONARY_INDICATOR, indicator.getId());
      } else if (importObject.getClassName().equals(IndicatorGroup.class.getName())) {
        IndicatorGroup group = (IndicatorGroup) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.INDICATORGROUP, group.getId());
        deleteMemberAssociations(GroupMemberType.INDICATORGROUPSET, group.getId());
      } else if (importObject.getClassName().equals(IndicatorGroupSet.class.getName())) {
        IndicatorGroupSet groupSet = (IndicatorGroupSet) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.INDICATORGROUPSET, groupSet.getId());
      } else if (importObject.getClassName().equals(DataDictionary.class.getName())) {
        DataDictionary dictionary = (DataDictionary) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.DATADICTIONARY_DATAELEMENT, dictionary.getId());
        deleteGroupAssociations(GroupMemberType.DATADICTIONARY_INDICATOR, dictionary.getId());
      } else if (importObject.getClassName().equals(DataSet.class.getName())) {
        DataSet dataSet = (DataSet) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.DATASET, dataSet.getId());
        deleteMemberAssociations(GroupMemberType.DATASET_SOURCE, dataSet.getId());

        deleteCompleteDataSetRegistrationsByDataSet(dataSet.getId());
      } else if (importObject.getClassName().equals(OrganisationUnit.class.getName())) {
        OrganisationUnit unit = (OrganisationUnit) importObject.getObject();

        deleteMemberAssociations(GroupMemberType.ORGANISATIONUNITGROUP, unit.getId());
        deleteGroupAssociations(GroupMemberType.ORGANISATIONUNITRELATIONSHIP, unit.getId());
        deleteMemberAssociations(GroupMemberType.DATASET_SOURCE, unit.getId());
        deleteMemberAssociations(GroupMemberType.ORGANISATIONUNITRELATIONSHIP, unit.getId());

        deleteCompleteDataSetRegistrationsBySource(unit.getId());

        importDataValueService.deleteImportDataValuesBySource(unit.getId());
      } else if (importObject.getClassName().equals(OrganisationUnitGroup.class.getName())) {
        OrganisationUnitGroup group = (OrganisationUnitGroup) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.ORGANISATIONUNITGROUP, group.getId());
        deleteMemberAssociations(GroupMemberType.ORGANISATIONUNITGROUPSET, group.getId());
      } else if (importObject.getClassName().equals(OrganisationUnitGroupSet.class.getName())) {
        OrganisationUnitGroupSet groupSet = (OrganisationUnitGroupSet) importObject.getObject();

        deleteGroupAssociations(GroupMemberType.ORGANISATIONUNITGROUPSET, groupSet.getId());
      }
    }

    deleteImportObject(importObjectId);
  }