Package com.serotonin.m2m2.vo

Examples of com.serotonin.m2m2.vo.DataPointVO


        SerialDataSourceVO ds = (SerialDataSourceVO) Common.getUser().getEditDataSource();
        if(ds.getId() == -1) {
          pr.addContextualMessage("testString", "serial.test.needsSave");
          return pr;
        }
        DataPointDao dpd = new DataPointDao();
        List<DataPointVO> points = dpd.getDataPoints(ds.getId(), null);
        if(ds.getUseTerminator()) {
          if(msg.indexOf(ds.getMessageTerminator()) != -1) {
            msg = msg.substring(0, msg.indexOf(ds.getMessageTerminator())+1);
            Pattern p = Pattern.compile(ds.getMessageRegex());
            Matcher m = p.matcher(msg);
View Full Code Here


            int fromMonth, int fromDay, int fromHour, int fromMinute, boolean toNone, int toYear, int toMonth,
            int toDay, int toHour, int toMinute, boolean schedule, int schedulePeriod, int runDelayMinutes,
            String scheduleCron, boolean email, boolean includeData, boolean zipData,
            List<RecipientListEntryBean> recipients) {

        ProcessResult response = new ProcessResult();

        // Basic validation
        validateData(response, name, points, dateRangeType, relativeDateType, previousPeriodCount, pastPeriodCount);

        if (schedule) {
            if (schedulePeriod == ReportVO.SCHEDULE_CRON) {
                // Check the cron pattern.
                try {
                    new CronTimerTrigger(scheduleCron);
                }
                catch (Exception e) {
                    response.addContextualMessage("scheduleCron", "reports.validate.cron", e.getMessage());
                }
            }
            else {
                if (runDelayMinutes < 0)
                    response.addContextualMessage("runDelayMinutes", "reports.validate.lessThan0");
                else if (runDelayMinutes > 59)
                    response.addContextualMessage("runDelayMinutes", "reports.validate.greaterThan59");
            }
        }

        if (schedule && email && recipients.isEmpty())
            response.addContextualMessage("recipients", "reports.validate.needRecip");

        if (response.getHasMessages())
            return response;

        User user = Common.getUser();
        ReportDao reportDao = new ReportDao();
        ReportVO report;
        if (id == Common.NEW_ID) {
            report = new ReportVO();
            report.setUserId(user.getId());
        }
        else
            report = reportDao.getReport(id);
       
        ReportCommon.ensureReportPermission(user, report);

        // Update the new values.
        report.setXid(xid);
        report.setName(name);
        report.setPoints(points);
        report.setTemplate(template);
        report.setIncludeEvents(includeEvents);
        report.setIncludeUserComments(includeUserComments);
        report.setDateRangeType(dateRangeType);
        report.setRelativeDateType(relativeDateType);
        report.setPreviousPeriodCount(previousPeriodCount);
        report.setPreviousPeriodType(previousPeriodType);
        report.setPastPeriodCount(pastPeriodCount);
        report.setPastPeriodType(pastPeriodType);
        report.setFromNone(fromNone);
        report.setFromYear(fromYear);
        report.setFromMonth(fromMonth);
        report.setFromDay(fromDay);
        report.setFromHour(fromHour);
        report.setFromMinute(fromMinute);
        report.setToNone(toNone);
        report.setToYear(toYear);
        report.setToMonth(toMonth);
        report.setToDay(toDay);
        report.setToHour(toHour);
        report.setToMinute(toMinute);
        report.setSchedule(schedule);
        report.setSchedulePeriod(schedulePeriod);
        report.setRunDelayMinutes(runDelayMinutes);
        report.setScheduleCron(scheduleCron);
        report.setEmail(email);
        report.setIncludeData(includeData);
        report.setZipData(zipData);
        report.setRecipients(recipients);

        // Save the report
        reportDao.saveReport(report);

        // Conditionally schedule the report.
        ReportJob.scheduleReportJob(report);

        // Send back the report id in case this was new.
        response.addData("reportId", report.getId());
        response.addData("report", report);
        return response;
    }
View Full Code Here

            boolean includeUserComments, int dateRangeType, int relativeDateType, int previousPeriodCount,
            int previousPeriodType, int pastPeriodCount, int pastPeriodType, boolean fromNone, int fromYear,
            int fromMonth, int fromDay, int fromHour, int fromMinute, boolean toNone, int toYear, int toMonth,
            int toDay, int toHour, int toMinute, boolean email, boolean includeData, boolean zipData,
            List<RecipientListEntryBean> recipients) {
        ProcessResult response = new ProcessResult();

        // Basic validation
        //TODO Replace with vo.validate()
        validateData(response, name, points, dateRangeType, relativeDateType, previousPeriodCount, pastPeriodCount);

        if (!response.getHasMessages()) {
            ReportVO report = new ReportVO();
            report.setXid(xid);
            report.setName(name);
            report.setUserId(Common.getUser().getId());
            report.setPoints(points);
View Full Code Here

        return StringEscapeUtils.escapeJava(ds.getMessageTerminator());
      }
     
      @DwrPermission(user = true)
      public ProcessResult testString(String raw) {
        ProcessResult pr = new ProcessResult();
        String msg = StringEscapeUtils.unescapeJava(raw);
        SerialDataSourceVO ds = (SerialDataSourceVO) Common.getUser().getEditDataSource();
        if(ds.getId() == -1) {
          pr.addContextualMessage("testString", "serial.test.needsSave");
          return pr;
        }
        DataPointDao dpd = new DataPointDao();
        List<DataPointVO> points = dpd.getDataPoints(ds.getId(), null);
        if(ds.getUseTerminator()) {
          if(msg.indexOf(ds.getMessageTerminator()) != -1) {
            msg = msg.substring(0, msg.indexOf(ds.getMessageTerminator())+1);
            Pattern p = Pattern.compile(ds.getMessageRegex());
            Matcher m = p.matcher(msg);
            if(!m.matches()) {
              pr.addContextualMessage("testString", "serial.test.noMessageMatch");
              return pr;
            }
            String identifier = m.group(ds.getPointIdentifierIndex());
            for(DataPointVO pnt : points) {
              SerialPointLocatorVO plVo = (SerialPointLocatorVO) pnt.getPointLocator();
              if(identifier.equals(plVo.getPointIdentifier())) {
                Pattern v = Pattern.compile(plVo.getValueRegex());
                Matcher vm = v.matcher(msg);
                if(vm.find())
                  pr.addContextualMessage("testString", "serial.test.consumed", pnt.getName(), vm.group(0));
              }
               
            }
          }
          else {
            pr.addContextualMessage("testString", "serial.test.noTerminator");
            return pr;
          }
        }
        else {
          for(DataPointVO pnt : points) {
            SerialPointLocatorVO plVo = (SerialPointLocatorVO) pnt.getPointLocator();
            Pattern p = Pattern.compile(plVo.getValueRegex());
            Matcher m = p.matcher(msg);
            if(m.find())
              pr.addContextualMessage("testString", "serial.test.consumed", pnt.getName(), m.group(0));         
          }
        }
        return pr;
      }
View Full Code Here

        se.setInactiveHour(inactiveHour);
        se.setInactiveMinute(inactiveMinute);
        se.setInactiveSecond(inactiveSecond);
        se.setInactiveCron(inactiveCron);

        ProcessResult response = new ProcessResult();
        ScheduledEventDao scheduledEventDao = new ScheduledEventDao();

        if (StringUtils.isBlank(xid))
            response.addContextualMessage("xid", "validate.required");
        else if (!scheduledEventDao.isXidUnique(xid, id))
            response.addContextualMessage("xid", "validate.xidUsed");

        se.validate(response);

        // Save the scheduled event
        if (!response.getHasMessages())
            RTMDefinition.instance.saveScheduledEvent(se);

        response.addData("seId", se.getId());
        return response;
    }
View Full Code Here

        String text = jsonObject.getString("outputScale");
        if (text != null) {
            outputScale = OUTPUT_SCALE_CODES.getId(text);
            if (outputScale == -1)
                throw new TranslatableJsonException("emport.error.invalid", "outputScale", text,
                        OUTPUT_SCALE_CODES.getCodeList());
        }
    }
View Full Code Here

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("attributeId");
        if (text == null)
            throw new TranslatableJsonException("emport.error.missing", "attributeId", ATTRIBUTE_CODES.getCodeList());
        attributeId = ATTRIBUTE_CODES.getId(text);
        if (!ATTRIBUTE_CODES.isValidId(attributeId))
            throw new TranslatableJsonException("emport.error.invalid", "attributeId", text,
                    ATTRIBUTE_CODES.getCodeList());
    }
View Full Code Here

    if (value != null)
      dataTypeId = value;

    JsonObject ctjson = jsonObject.getJsonObject("changeType");
    if (ctjson == null)
      throw new TranslatableJsonException("emport.error.missingObject",
          "changeType");

    String text = ctjson.getString("type");
    if (text == null)
      throw new TranslatableJsonException("emport.error.missing", "type",
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    changeTypeId = ChangeTypeVO.CHANGE_TYPE_CODES.getId(text);
    if (changeTypeId == -1)
      throw new TranslatableJsonException("emport.error.invalid",
          "changeType", text,
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    reader.readInto(getChangeType(), ctjson);
  }
View Full Code Here

    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("alarmLevel");
        if (text != null) {
            alarmLevel = AlarmLevels.CODES.getId(text);
            if (!AlarmLevels.CODES.isValidId(alarmLevel))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "alarmLevel", text,
                        AlarmLevels.CODES.getCodeList());
        }

        text = jsonObject.getString("scheduleType");
        if (text != null) {
            scheduleType = TYPE_CODES.getId(text);
            if (!TYPE_CODES.isValidId(scheduleType))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "scheduleType", text,
                        TYPE_CODES.getCodeList());
        }
    }
View Full Code Here

* @author Matthew Lohbihler
*/
public class VMStatDataSourceVO extends DataSourceVO<VMStatDataSourceVO> {
    @Override
    protected void addEventTypes(List<EventTypeVO> ets) {
        ets.add(createEventType(VMStatDataSourceRT.DATA_SOURCE_EXCEPTION_EVENT, new TranslatableMessage(
                "event.ds.dataSource"), EventType.DuplicateHandling.IGNORE_SAME_MESSAGE, AlarmLevels.URGENT));
        ets.add(createEventType(VMStatDataSourceRT.PARSE_EXCEPTION_EVENT, new TranslatableMessage("event.ds.dataParse")));
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.vo.DataPointVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.