Exemplo n.º 1
0
  //
  //
  // Data points
  //
  public void saveDataPoint(DataPointVO point) {
    stopDataPoint(point.getId());

    // Since the point's data type may have changed, we must ensure that the other attrtibutes are
    // still ok with
    // it.
    int dataType = point.getPointLocator().getDataTypeId();

    // Chart renderer
    if (point.getChartRenderer() != null && !point.getChartRenderer().getDef().supports(dataType))
      // Return to a default renderer
      point.setChartRenderer(null);

    // Text renderer
    if (point.getTextRenderer() != null && !point.getTextRenderer().getDef().supports(dataType))
      // Return to a default renderer
      point.defaultTextRenderer();

    // Event detectors
    Iterator<PointEventDetectorVO> peds = point.getEventDetectors().iterator();
    while (peds.hasNext()) {
      PointEventDetectorVO ped = peds.next();
      if (!ped.getDef().supports(dataType))
        // Remove the detector.
        peds.remove();
    }

    new DataPointDao().saveDataPoint(point);

    if (point.isEnabled()) startDataPoint(point);
  }
Exemplo n.º 2
0
  @Override
  protected void createStateImpl(
      RuntimeManager rtm, HttpServletRequest request, JspComponentState state) {
    String value;
    DataPointRT dataPointRT = rtm.getDataPoint(dataPointVO.getId());
    if (dataPointRT == null) value = disabledValue;
    else {
      PointValueTime pvt = dataPointRT.getPointValue();

      if (pvt != null && pvt.getValue() instanceof ImageValue) {
        // Text renderers don't help here. Create a thumbnail.
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("point", dataPointVO);
        model.put("pointValue", pvt);
        value = BaseDwr.generateContent(request, "imageValueThumbnail.jsp", model);
      } else {
        int hint = raw ? TextRenderer.HINT_RAW : TextRenderer.HINT_FULL;
        value = dataPointVO.getTextRenderer().getText(pvt, hint);
        if (pvt != null && time) state.setTime(pvt.getTime());
      }
    }
    state.setValue(value);
  }