Examples of TranslatableMessage


Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        return EVENT_CODES;
    }

    @Override
    public TranslatableMessage getConfigDescription() {
        return new TranslatableMessage("common.noMessage");
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

                };
                postEmail = new Runnable[] { deleteTempFile };
            }

            try {
                TranslatableMessage lm = new TranslatableMessage("ftl.scheduledReport", reportConfig.getName());
                String subject = creator.getSubject();
                if (subject == null)
                    subject = lm.translate(translations);
                EmailWorkItem.queueEmail(toAddrs, subject, emailContent, postEmail);
            }
            catch (AddressException e) {
                LOG.error(e);
            }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        this.style = style;
    }

    public void validate(ProcessResult response) {
        if (x < 0)
            response.addMessage("x", new TranslatableMessage("validate.cannotBeNegative"));
        if (y < 0)
            response.addMessage("y", new TranslatableMessage("validate.cannotBeNegative"));
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        this.viewUsers = viewUsers;
    }

    public void validate(ProcessResult response) {
        if (StringUtils.isBlank(name))
            response.addMessage("name", new TranslatableMessage("validate.required"));
        else if (StringValidation.isLengthGreaterThan(name, 100))
            response.addMessage("name", new TranslatableMessage("validate.notLongerThan", 100));

        if (StringUtils.isBlank(xid))
            response.addMessage("xid", new TranslatableMessage("validate.required"));
        else if (StringValidation.isLengthGreaterThan(xid, 50))
            response.addMessage("xid", new TranslatableMessage("validate.notLongerThan", 50));
        else if (!new GraphicalViewDao().isXidUnique(xid, id))
            response.addMessage("xid", new TranslatableMessage("validate.xidUsed"));

        for (ViewComponent vc : viewComponents)
            vc.validate(response);
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

   
   
   
        this.file = new File( vo.getFilePath() );
    if ( !file.exists() ) {
      raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.fileNotFound",vo.getFilePath()));
      return false;
    }else if ( !file.canRead() ){
      raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.readFailed",vo.getFilePath()));
      return false;
        }else{
      this.fobs = new FileAlterationObserver(this.file);
      this.fobs.initialize();
      this.fobs.addListener(this);
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        LOG.debug("Error while initializing data source", e);
        String msg = e.getMessage();
        if(msg == null){
          msg = "Unknown";
        }
      raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.readFailed",msg));
     
      }
     
      if(connected){
        returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        if(this.file != null) {
      try {
        this.fobs.destroy();
      } catch (Exception e) {
        LOG.debug("Error destroying file observer");
        raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.obsDestroy", e.getMessage()));
      }
      this.file = null;
    }

    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

  }

  private void fileEvent() {
    //Should never happen
    if(this.file == null) {
      raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.readFailedFileNotSetup"));
      return;
    }
   
   
    //The file is modified or we've just started, so read it.
    try{
      BufferedReader reader = new BufferedReader(new FileReader(this.file));

      String msg;
            if(!this.dataPoints.isEmpty()) {
         
              //TODO optimize to be better than numLines*numPoints
              while( (msg = reader.readLine()) != null) {
          //Give all points the chance to find their data
          for(DataPointRT dp: this.dataPoints){
            AsciiFilePointLocatorRT pl = dp.getPointLocator();
            AsciiFilePointLocatorVO plVo = pl.getVo();
            Pattern pointValuePattern = Pattern.compile(plVo.getValueRegex());
            Matcher pointValueMatcher = pointValuePattern.matcher(msg); //Use the index from the above message
            if(pointValueMatcher.find()){
              if(plVo.getPointIdentifier().equals(pointValueMatcher.group(plVo.getPointIdentifierIndex()))) {
                String value = pointValueMatcher.group(plVo.getValueIndex());                 
                PointValueTime newValue;
                Date dt;
                if(plVo.getHasTimestamp() && !plVo.getTimestampFormat().equals(".")) {
                  SimpleDateFormat fmt = new SimpleDateFormat(plVo.getTimestampFormat());
                  dt = fmt.parse(pointValueMatcher.group(plVo.getTimestampIndex()));
                }
                else if(plVo.getHasTimestamp()) {
                  dt = new Date(Long.parseLong(pointValueMatcher.group(plVo.getTimestampIndex())));
                }
                else {
                  dt = new Date();
                }
               
                //Switch on the type
                switch(plVo.getDataTypeId()){
                case DataTypes.ALPHANUMERIC:
                  newValue = new PointValueTime(value, dt.getTime());
                  break;
                case DataTypes.NUMERIC:
                  newValue = new PointValueTime(Double.parseDouble(value), dt.getTime());
                  break;
                case DataTypes.MULTISTATE:
                  newValue = new PointValueTime(Integer.parseInt(value), dt.getTime());
                  break;
                case DataTypes.BINARY:
                  newValue = new PointValueTime(Boolean.parseBoolean(value), dt.getTime());
                  break;
                default:
                  throw new ShouldNeverHappenException("Uknown Data type for point");
                }
               
                if(!plVo.getHasTimestamp())
                  dp.updatePointValue(newValue);
                else
                  dp.savePointValueDirectToCache(newValue, null, true, true);
              }
            }
          }
              }
      }
            reader.close();
            returnToNormal(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis());
        }catch ( FileNotFoundException e ){
      raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.fileNotFound",e.getMessage()));
        } catch (IOException e) {
          raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.readFailed",e.getMessage()));
    } catch (NumberFormatException e) {
      raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.notNumber",e.getMessage()));
    } catch (ParseException e) {
      raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.dateParseFailed",e.getMessage()));
    }
   
  }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

            watchList.setName(translate("common.newName"));
        }
        else {
            watchList = new WatchListDao().getWatchList(getWatchList().getId());
            watchList.setId(Common.NEW_ID);
            watchList.setName(translate(new TranslatableMessage("common.copyPrefix", watchList.getName())));
            //Check to see if we are a Shared User (we can't share a watchlist with ourselves)
            List<ShareUser> watchListShared =  new ArrayList<ShareUser>();
            for(ShareUser shareUser : watchList.getWatchListUsers()){
              //Don't add yourself
              if(shareUser.getUserId() != user.getId())
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableMessage

        params.setStopBits(vo.getStopBits());
        params.setParity(vo.getParity());
        params.setRecieveTimeout(vo.getReadTimeout());
   
        if ( SerialUtils.portOwned(vo.getCommPortId()) ){
      raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.serial.portInUse",vo.getCommPortId()));
      return false;
        }else{
          try{
                this.port = SerialUtils.openSerialPort(params);
                this.port.addEventListener(this);
                return true;
             
            }catch(Exception e){
          raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.serial.portError",vo.getCommPortId(),e.getLocalizedMessage()));
          return false;
            }
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.