Package com.serotonin.m2m2.db.dao

Examples of com.serotonin.m2m2.db.dao.DataPointDao


        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


        return null;
    }

    private int importCsv(FileItem item) throws IOException, TranslatableException {
        CSVReader csvReader = new CSVReader(new InputStreamReader(item.getInputStream()));
        DataPointDao dataPointDao = new DataPointDao();
        PointValueDao pointValueDao = Common.databaseProxy.newPointValueDao();
        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss");

        // Basic validation
        String[] nextLine = csvReader.readNext();
        if (nextLine == null)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noData"));
        if (nextLine.length < 2)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noPoints"));

        // Find the points by XID
        DataPointVO[] vos = new DataPointVO[nextLine.length - 1];

        for (int i = 1; i < nextLine.length; i++) {
            if (StringUtils.isBlank(nextLine[i]))
                throw new TranslatableException(new TranslatableMessage("dataImport.import.badXid", i));

            DataPointVO vo = dataPointDao.getDataPoint(nextLine[i]);
            if (vo == null)
                throw new TranslatableException(new TranslatableMessage("dataImport.import.xidNotFound", nextLine[i]));

            vos[i - 1] = vo;
        }
View Full Code Here

      Common.runtimeManager.saveDataSource(ds);
    else
      throw new RuntimeException("Invalid data!");
   
   
    DataPointDao dpDao = new DataPointDao();
    //Create Test Points
    for(int i=0; i<10; i++){
      VirtualPointLocatorVO pointLocator = ds.createPointLocator();
      //Create a Random Points
      pointLocator.setDataTypeId(DataTypes.NUMERIC);
      pointLocator.setChangeTypeId(ChangeTypeVO.Types.RANDOM_ANALOG);
      pointLocator.getRandomAnalogChange().setMin(0);
      pointLocator.getRandomAnalogChange().setMax(100);
      pointLocator.getRandomAnalogChange().setStartValue("1");
      pointLocator.setSettable(true);
     
     
      DataPointVO dp = new DataPointVO();
      dp.setXid(dpDao.generateUniqueXid());
      dp.setName("Virtual Random " + i);
            dp.setDataSourceId(ds.getId());
            dp.setDataSourceTypeName(ds.getDefinition().getDataSourceTypeName());
            dp.setDeviceName(ds.getName());
            dp.setEventDetectors(new ArrayList<PointEventDetectorVO>(0));
View Full Code Here

    public void setRunDelayMinutes(int runDelayMinutes) {
        this.runDelayMinutes = runDelayMinutes;
    }
   
    public Map<String, String> getXidMapping() {
      DataPointDao dpd = new DataPointDao();
      Map<String, String> ans = new HashMap<String, String>();
      for(ReportPointVO vo : points) {
        ans.put(dpd.get(vo.getPointId()).getXid(), vo.getPointKey());
      }
      return ans;
    }
View Full Code Here

       
        File t = new File(Common.MA_HOME + ModuleRegistry.getModule("reports").getDirectoryPath() + "/web/ftl/" + template);
        if(!t.isFile())
          response.addContextualMessage("template", "reports.validate.template");
       
        DataPointDao dataPointDao = new DataPointDao();
        for (ReportPointVO point : points) {
          DataPointVO vo  = dataPointDao.getDataPoint(point.getPointId());
          String pointXid = "unknown";
          if(vo != null){
            pointXid = vo.getXid();
              try{
                Permissions.ensureDataPointReadPermission(user, dataPointDao.getDataPoint(point.getPointId()));
              }catch(PermissionException e){
               
                response.addContextualMessage("points", "reports.vaildate.pointDNE");
              }
          }else{
View Full Code Here

        reportInstance.setRunStartTime(System.currentTimeMillis());
        reportDao.saveReportInstance(reportInstance);
        Translations translations = Common.getTranslations();

        // Create a list of DataPointVOs to which the user has permission.
        DataPointDao dataPointDao = new DataPointDao();
        List<ReportDao.PointInfo> points = new ArrayList<ReportDao.PointInfo>(reportConfig.getPoints().size());
        for (ReportPointVO reportPoint : reportConfig.getPoints()) {
            DataPointVO point = dataPointDao.getDataPoint(reportPoint.getPointId());
            if (point != null && Permissions.hasDataPointReadPermission(user, point)) {
                String colour = null;
                try {
                    if (!StringUtils.isBlank(reportPoint.getColour()))
                        colour = ColorUtils.toHexString(reportPoint.getColour()).substring(1);
View Full Code Here

        AuditEventType.maybeAddPropertyChangeMessage(list, "dsEdit.virtual.attractionPoint",
                from.getAttractionPointName(), getAttractionPointName());
    }

    private String getAttractionPointName() {
        DataPointVO dp = new DataPointDao().getDataPoint(attractionPointId);
        if (dp == null)
            return "";
        return dp.getName();
    }
View Full Code Here

    }

    @Override
    public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
        super.jsonWrite(writer);
        DataPointVO dp = new DataPointDao().getDataPoint(attractionPointId);
        if (dp == null)
            writer.writeEntry("attractionPointId", null);
        else
            writer.writeEntry("attractionPointId", dp.getXid());
    }
View Full Code Here

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        super.jsonRead(reader, jsonObject);
        String text = jsonObject.getString("attractionPointId");
        if (text != null) {
            DataPointVO dp = new DataPointDao().getDataPoint(text);
            if (dp == null)
                throw new TranslatableJsonException("virtual.error.attractor.missingPoint", "attractionPointId", text);
            attractionPointId = dp.getId();
        }
    }
View Full Code Here

            response.addContextualMessage("previousPeriodCount", "reports.validate.periodCountLessThan1");
        if (pastPeriodCount < 1)
            response.addContextualMessage("pastPeriodCount", "reports.validate.periodCountLessThan1");

        User user = Common.getUser();
        DataPointDao dataPointDao = new DataPointDao();
        for (ReportPointVO point : points) {
            Permissions.ensureDataPointReadPermission(user, dataPointDao.getDataPoint(point.getPointId()));

            try {
                if (!StringUtils.isBlank(point.getColour()))
                    ColorUtils.toColor(point.getColour());
            }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.db.dao.DataPointDao

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.