コード例 #1
0
  @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);
  }
コード例 #2
0
  @Override
  public String execute() throws Exception {
    OptionSet optionSet = optionService.getOptionSet(optionSetId);

    valueType =
        optionSet != null && optionSet.getValueType() != null
            ? optionSet.getValueType()
            : valueType;

    TrackedEntityAttribute trackedEntityAttribute =
        trackedEntityAttributeService.getTrackedEntityAttribute(id);

    trackedEntityAttribute.setName(StringUtils.trimToNull(name));
    trackedEntityAttribute.setShortName(StringUtils.trimToNull(shortName));
    trackedEntityAttribute.setCode(StringUtils.trimToNull(code));
    trackedEntityAttribute.setDescription(StringUtils.trimToNull(description));
    trackedEntityAttribute.setValueType(valueType);
    trackedEntityAttribute.setAggregationType(AggregationType.fromValue(aggregationType));
    trackedEntityAttribute.setExpression(expression);
    trackedEntityAttribute.setDisplayOnVisitSchedule(false);
    trackedEntityAttribute.setOptionSet(optionSet);

    unique = unique != null;
    trackedEntityAttribute.setUnique(unique);

    inherit = inherit != null;
    trackedEntityAttribute.setInherit(inherit);

    confidential = confidential != null;
    trackedEntityAttribute.setConfidential(confidential);

    if (unique) {
      boolean orgunitScope = false;
      boolean programScope = false;

      if (Objects.equals(scope, SCOPE_ORGUNIT) || Objects.equals(scope, SCOPE_PROGRAM_IN_ORGUNIT)) {
        orgunitScope = true;
      }

      if (Objects.equals(scope, SCOPE_PROGRAM) || Objects.equals(scope, SCOPE_PROGRAM_IN_ORGUNIT)) {
        programScope = true;
      }

      trackedEntityAttribute.setOrgunitScope(orgunitScope);
      trackedEntityAttribute.setProgramScope(programScope);
    } else if (ValueType.TRACKER_ASSOCIATE == valueType) {
      trackedEntityAttribute.setTrackedEntity(
          trackedEntityService.getTrackedEntity(trackedEntityId));
    }

    if (legendSetId != null) {
      trackedEntityAttribute.setLegendSet(legendService.getLegendSet(legendSetId));
    }

    if (jsonAttributeValues != null) {
      AttributeUtils.updateAttributeValuesFromJson(
          trackedEntityAttribute.getAttributeValues(), jsonAttributeValues, attributeService);
    }

    trackedEntityAttributeService.updateTrackedEntityAttribute(trackedEntityAttribute);

    return SUCCESS;
  }