示例#1
0
  @MethodFilter
  public DwrResponseI18n saveSimpleCompoundComponent(
      String viewComponentId,
      String name,
      String backgroundColour,
      List<KeyValuePair> childPointIds) {
    DwrResponseI18n response = new DwrResponseI18n();

    validateCompoundComponent(response, name);

    String leadPointId = null;
    for (KeyValuePair kvp : childPointIds) {
      if (SimpleCompoundComponent.LEAD_POINT.equals(kvp.getKey())) {
        leadPointId = kvp.getValue();
        break;
      }
    }

    if (StringUtils.parseInt(leadPointId, 0) <= 0)
      response.addContextualMessage(
          "compoundPointSelect" + SimpleCompoundComponent.LEAD_POINT, "dsEdit.validate.required");

    if (!response.getHasMessages()) {
      SimpleCompoundComponent c = (SimpleCompoundComponent) getViewComponent(viewComponentId);
      c.setName(name);
      c.setBackgroundColour(backgroundColour);
      saveCompoundPoints(c, childPointIds);
    }

    return response;
  }
示例#2
0
  private void saveCompoundPoints(CompoundComponent c, List<KeyValuePair> childPointIds) {
    User user = Common.getUser();

    for (KeyValuePair kvp : childPointIds) {
      int dataPointId = -1;
      try {
        dataPointId = Integer.parseInt(kvp.getValue());
      } catch (NumberFormatException e) {
        // no op
      }

      DataPointVO dp = new DataPointDao().getDataPoint(dataPointId);

      if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
        c.setDataPoint(kvp.getKey(), null);
      else c.setDataPoint(kvp.getKey(), dp);
      c.getChildComponent(kvp.getKey()).validateDataPoint(user, false);
    }
  }