@DwrPermission(user = true)
  public ProcessResult getHistoryTableData(int limit) {
    DataPointVO pointVO = Common.getUser().getEditPoint();
    PointValueFacade facade = new PointValueFacade(pointVO.getId());

    List<PointValueTime> rawData = facade.getLatestPointValues(limit);
    List<RenderedPointValueTime> renderedData =
        new ArrayList<RenderedPointValueTime>(rawData.size());

    for (PointValueTime pvt : rawData) {
      RenderedPointValueTime rpvt = new RenderedPointValueTime();
      rpvt.setValue(Functions.getHtmlText(pointVO, pvt));
      rpvt.setTime(Functions.getTime(pvt));
      if (pvt.isAnnotated()) {
        AnnotatedPointValueTime apvt = (AnnotatedPointValueTime) pvt;
        rpvt.setAnnotation(apvt.getAnnotation(getTranslations()));
      }
      renderedData.add(rpvt);
    }

    ProcessResult response = new ProcessResult();
    response.addData("history", renderedData);
    addAsof(response);
    return response;
  }
  @DwrPermission(user = true)
  public ProcessResult getFlipbookData(int limit) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    DataPointVO vo = Common.getUser(request).getEditPoint();
    PointValueFacade facade = new PointValueFacade(vo.getId());

    List<PointValueTime> values = facade.getLatestPointValues(limit);
    Collections.reverse(values);
    List<ImageValueBean> result = new ArrayList<ImageValueBean>();
    for (PointValueTime pvt : values) {
      ImageValue imageValue = (ImageValue) pvt.getValue();
      String uri =
          ImageValueServlet.servletPath
              + ImageValueServlet.historyPrefix
              + pvt.getTime()
              + "_"
              + vo.getId()
              + "."
              + imageValue.getTypeExtension();
      result.add(new ImageValueBean(Functions.getTime(pvt), uri));
    }

    ProcessResult response = new ProcessResult();
    response.addData("images", result);
    addAsof(response);
    return response;
  }
Exemplo n.º 3
0
    private boolean send(List<PublishQueueEntry<SquwkPointVO>> entries) {
      List reqs = new ArrayList();

      for (PublishQueueEntry entry : entries) {
        SquwkPointVO vo = (SquwkPointVO) entry.getVo();
        PointValueTime pvt = entry.getPvt();
        SampleAppendRequest req =
            new SampleAppendRequest(
                vo.getGuid(),
                pvt.getTime(),
                SquwkSenderRT.this.coerceDataValue(pvt.getValue(), vo.getDataType()));

        reqs.add(req);
      }

      SquwkSenderRT.ResultHandler resultHandler = new SquwkSenderRT.ResultHandler();
      try {
        SquwkSenderRT.this.squwkClient.sendBatch(reqs, resultHandler);

        Common.eventManager.returnToNormal(
            SquwkSenderRT.this.requestExceptionEventType, System.currentTimeMillis());

        if (resultHandler.getSquwkException() != null) {
          SquwkSenderRT.LOG.warn("Service exception", resultHandler.getSquwkException());
          Common.eventManager.raiseEvent(
              SquwkSenderRT.this.serviceExceptionEventType,
              System.currentTimeMillis(),
              false,
              2,
              SquwkSenderRT.this.toTranslatableMessage(resultHandler.getSquwkException()),
              SquwkSenderRT.this.createEventContext());
        }

      } catch (SquwkException e) {
        SquwkSenderRT.LOG.warn("Request exception", e);
        Common.eventManager.raiseEvent(
            SquwkSenderRT.this.requestExceptionEventType,
            System.currentTimeMillis(),
            true,
            2,
            SquwkSenderRT.this.toTranslatableMessage(e),
            SquwkSenderRT.this.createEventContext());

        return false;
      }

      return true;
    }
Exemplo n.º 4
0
 protected void createStateImpl(
     RuntimeManager rtm, HttpServletRequest request, JspComponentState state) {
   DataPointRT dataPointRT = rtm.getDataPoint(this.dataPointVO.getId());
   String value;
   if (dataPointRT == null) {
     value = this.disabledValue;
   } else {
     PointValueTime pvt = dataPointRT.getPointValue();
     if ((pvt != null) && ((pvt.getValue() instanceof ImageValue))) {
       Map model = new HashMap();
       model.put("point", this.dataPointVO);
       model.put("pointValue", pvt);
       value = BaseDwr.generateContent(request, "imageValueThumbnail.jsp", model);
     } else {
       int hint = this.raw ? 1 : 2;
       value = this.dataPointVO.getTextRenderer().getText(pvt, hint);
       if ((pvt != null) && (this.time)) state.setTime(Long.valueOf(pvt.getTime()));
     }
   }
   state.setValue(value);
 }
Exemplo n.º 5
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);
  }