@Override
  public List<DataElementOperand> validateRequiredComments(
      DataSet dataSet,
      Period period,
      OrganisationUnit organisationUnit,
      DataElementCategoryOptionCombo attributeOptionCombo) {
    List<DataElementOperand> violations = new ArrayList<>();

    if (dataSet.isNoValueRequiresComment()) {
      for (DataElement de : dataSet.getDataElements()) {
        for (DataElementCategoryOptionCombo co : de.getCategoryCombo().getOptionCombos()) {
          DataValue dv =
              dataValueService.getDataValue(de, period, organisationUnit, co, attributeOptionCombo);

          boolean missingValue = dv == null || StringUtils.trimToNull(dv.getValue()) == null;
          boolean missingComment = dv == null || StringUtils.trimToNull(dv.getComment()) == null;

          if (missingValue && missingComment) {
            violations.add(new DataElementOperand(de, co));
          }
        }
      }
    }

    return violations;
  }
Beispiel #2
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 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;
  }