Beispiel #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;
  }
Beispiel #2
0
  @MethodFilter
  public DwrResponseI18n saveMultistateGraphicComponent(
      String viewComponentId,
      List<IntValuePair> imageStates,
      int defaultImage,
      boolean displayText,
      String imageSetId) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
      response.addContextualMessage(
          "graphicRendererMultistateImageSet", "viewEdit.graphic.missingImageSet");

    if (!response.getHasMessages()) {
      MultistateGraphicComponent c = (MultistateGraphicComponent) getViewComponent(viewComponentId);
      c.setImageStateList(imageStates);
      c.setDefaultImage(defaultImage);
      c.setDisplayText(displayText);
      c.tsetImageSet(imageSet);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #3
0
  @MethodFilter
  public DwrResponseI18n saveDynamicGraphicComponent(
      String viewComponentId, double min, double max, boolean displayText, String dynamicImageId) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    if (min >= max)
      response.addContextualMessage("graphicRendererDynamicMin", "viewEdit.graphic.invalidMinMax");

    DynamicImage dynamicImage = getDynamicImage(dynamicImageId);
    if (dynamicImage == null)
      response.addContextualMessage(
          "graphicRendererDynamicImage", "viewEdit.graphic.missingDynamicImage");

    if (!response.getHasMessages()) {
      DynamicGraphicComponent c = (DynamicGraphicComponent) getViewComponent(viewComponentId);
      c.setMin(min);
      c.setMax(max);
      c.setDisplayText(displayText);
      c.tsetDynamicImage(dynamicImage);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #4
0
  @MethodFilter
  public DwrResponseI18n saveBinaryGraphicComponent(
      String viewComponentId, int zeroImage, int oneImage, boolean displayText, String imageSetId) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
      response.addContextualMessage(
          "graphicRendererBinaryImageSet", "viewEdit.graphic.missingImageSet");
    else {
      if (zeroImage == -1)
        response.addContextualMessage(
            "graphicRendererBinaryImageSetZeroMsg", "viewEdit.graphic.missingZeroImage");
      if (oneImage == -1)
        response.addContextualMessage(
            "graphicRendererBinaryImageSetOneMsg", "viewEdit.graphic.missingOneImage");
    }

    if (!response.getHasMessages()) {
      BinaryGraphicComponent c = (BinaryGraphicComponent) getViewComponent(viewComponentId);
      c.tsetImageSet(imageSet);
      c.setZeroImage(zeroImage);
      c.setOneImage(oneImage);
      c.setDisplayText(displayText);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #5
0
  @MethodFilter
  public DwrResponseI18n saveAnalogGraphicComponent(
      String viewComponentId, double min, double max, boolean displayText, String imageSetId) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    if (min >= max)
      response.addContextualMessage("graphicRendererAnalogMin", "viewEdit.graphic.invalidMinMax");

    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
      response.addContextualMessage(
          "graphicRendererAnalogImageSet", "viewEdit.graphic.missingImageSet");

    if (!response.getHasMessages()) {
      AnalogGraphicComponent c = (AnalogGraphicComponent) getViewComponent(viewComponentId);
      c.setMin(min);
      c.setMax(max);
      c.setDisplayText(displayText);
      c.tsetImageSet(imageSet);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #6
0
  @MethodFilter
  public DwrResponseI18n setPointComponentSettings(
      String pointComponentId,
      int dataPointId,
      String name,
      boolean settable,
      String bkgdColorOverride,
      boolean displayControls) {
    DwrResponseI18n response = new DwrResponseI18n();
    PointComponent pc = (PointComponent) getViewComponent(pointComponentId);
    User user = Common.getUser();

    DataPointVO dp = new DataPointDao().getDataPoint(dataPointId);
    if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
      response.addContextualMessage("settingsPointList", "validate.required");
    else {
      pc.tsetDataPoint(dp);
      pc.setNameOverride(name);
      pc.setSettableOverride(settable && Permissions.hasDataPointSetPermission(user, dp));
      pc.setBkgdColorOverride(bkgdColorOverride);
      pc.setDisplayControls(displayControls);

      pc.validateDataPoint(user, false);
    }

    return response;
  }
Beispiel #7
0
  @MethodFilter
  public DwrResponseI18n saveCompoundComponent(
      String viewComponentId, String name, List<KeyValuePair> childPointIds) {
    DwrResponseI18n response = new DwrResponseI18n();

    validateCompoundComponent(response, name);

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

    return response;
  }
Beispiel #8
0
  @MethodFilter
  public DwrResponseI18n saveThumbnailComponent(String viewComponentId, int scalePercent) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    if (scalePercent < 1)
      response.addContextualMessage(
          "graphicRendererThumbnailScalePercent", "viewEdit.graphic.invalidScale");

    if (!response.getHasMessages()) {
      ThumbnailComponent c = (ThumbnailComponent) getViewComponent(viewComponentId);
      c.setScalePercent(scalePercent);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #9
0
  @MethodFilter
  public DwrResponseI18n saveScriptComponent(String viewComponentId, String script) {
    DwrResponseI18n response = new DwrResponseI18n();

    // Validate
    if (StringUtils.isEmpty(script))
      response.addContextualMessage(
          "graphicRendererScriptScript", "viewEdit.graphic.missingScript");

    if (!response.getHasMessages()) {
      ScriptComponent c = (ScriptComponent) getViewComponent(viewComponentId);
      c.setScript(script);
      resetPointComponent(c);
    }

    return response;
  }
Beispiel #10
0
  @MethodFilter
  public DwrResponseI18n saveImageChartComponent(
      String viewComponentId,
      String name,
      int width,
      int height,
      int durationType,
      int durationPeriods,
      List<KeyValuePair> childPointIds) {
    DwrResponseI18n response = new DwrResponseI18n();

    validateCompoundComponent(response, name);
    if (width < 1) response.addContextualMessage("imageChartWidth", "validate.greaterThanZero");
    if (height < 1) response.addContextualMessage("imageChartHeight", "validate.greaterThanZero");
    if (!Common.TIME_PERIOD_CODES.isValidId(durationType))
      response.addContextualMessage("imageChartDurationType", "validate.invalidValue");
    if (durationPeriods <= 0)
      response.addContextualMessage("imageChartDurationPeriods", "validate.greaterThanZero");

    if (!response.getHasMessages()) {
      ImageChartComponent c = (ImageChartComponent) getViewComponent(viewComponentId);
      c.setName(name);
      c.setWidth(width);
      c.setHeight(height);
      c.setDurationType(durationType);
      c.setDurationPeriods(durationPeriods);
      saveCompoundPoints(c, childPointIds);
    }

    return response;
  }
Beispiel #11
0
 private void validateCompoundComponent(DwrResponseI18n response, String name) {
   if (StringUtils.isEmpty(name))
     response.addContextualMessage("compoundName", "dsEdit.validate.required");
 }