Package com.serotonin

Examples of com.serotonin.ShouldNeverHappenException


      case DataTypes.BINARY:
        boolean bool  = b.getBoolean();
        dataValue = new BinaryValue(bool);
        break;
      case DataTypes.IMAGE:
        throw new ShouldNeverHappenException("Images are not supported");
      case DataTypes.MULTISTATE:
        int i  = b.getInt();
        dataValue = new MultistateValue(i);
        break;
      case DataTypes.NUMERIC:
        double d  = b.getDouble();
        dataValue = new NumericValue(d);
        break;
      default:
        throw new ShouldNeverHappenException("Data type of " + dataType + " is not supported");
    }
   
    //Get the annotation
    String annotation = b.getString();
   
 
    if(annotation != null){
      try{
        return new AnnotatedPointValueTime(dataValue, ts, TranslatableMessage.deserialize(annotation));
      }catch(Exception e){
        throw new ShouldNeverHappenException(e);
      }
    }else{
      return new PointValueTime(dataValue, ts);
    }
  }
View Full Code Here


        break;
      case DataTypes.BINARY:
        b.putBoolean(value.getBooleanValue());
        break;
      case DataTypes.IMAGE:
        throw new ShouldNeverHappenException("Images are not supported");
      case DataTypes.MULTISTATE:
        b.putInt(value.getIntegerValue());
        break;
      case DataTypes.NUMERIC:
        b.putDouble(value.getDoubleValue());
        break;
      default:
        throw new ShouldNeverHappenException("Data type of " + value.getValue().getDataType() + " is not supported");

    }
   
    //Put in annotation
    if(value.isAnnotated()){
View Full Code Here

        try {
            template = Common.freemarkerConfiguration.getTemplate(reportInstance.getTemplateFile());
        }
        catch (IOException e) {
            // Couldn't load the template?
            throw new ShouldNeverHappenException(e);
        }

        // Create the content from the template.
        StringWriter writer = new StringWriter();
        try {
            template.process(model, writer);
        }
        catch (Exception e) {
            // Couldn't process the template?
            throw new ShouldNeverHappenException(e);
        }

        // Save the content
        html = writer.toString();
        subject = subjectDirective.getSubject();
View Full Code Here

                    return new CronTimerTrigger(vo.getActiveCron());
                return new CronTimerTrigger(vo.getInactiveCron());
            }
            catch (ParseException e) {
                // Should never happen, so wrap and rethrow
                throw new ShouldNeverHappenException(e);
            }
        }

        if (vo.getScheduleType() == MaintenanceEventVO.TYPE_ONCE) {
            DateTime dt;
            if (activeTrigger)
                dt = new DateTime(vo.getActiveYear(), vo.getActiveMonth(), vo.getActiveDay(), vo.getActiveHour(),
                        vo.getActiveMinute(), vo.getActiveSecond(), 0);
            else
                dt = new DateTime(vo.getInactiveYear(), vo.getInactiveMonth(), vo.getInactiveDay(),
                        vo.getInactiveHour(), vo.getInactiveMinute(), vo.getInactiveSecond(), 0);
            return new OneTimeTrigger(new Date(dt.getMillis()));
        }

        int month = vo.getActiveMonth();
        int day = vo.getActiveDay();
        int hour = vo.getActiveHour();
        int minute = vo.getActiveMinute();
        int second = vo.getActiveSecond();
        if (!activeTrigger) {
            month = vo.getInactiveMonth();
            day = vo.getInactiveDay();
            hour = vo.getInactiveHour();
            minute = vo.getInactiveMinute();
            second = vo.getInactiveSecond();
        }

        StringBuilder expression = new StringBuilder();
        expression.append(second).append(' ');
        expression.append(minute).append(' ');
        if (vo.getScheduleType() == MaintenanceEventVO.TYPE_HOURLY)
            expression.append("* * * ?");
        else {
            expression.append(hour).append(' ');
            if (vo.getScheduleType() == MaintenanceEventVO.TYPE_DAILY)
                expression.append("* * ?");
            else if (vo.getScheduleType() == MaintenanceEventVO.TYPE_WEEKLY)
                expression.append("? * ").append(weekdays[day]);
            else {
                if (day > 0)
                    expression.append(day);
                else if (day == -1)
                    expression.append('L');
                else
                    expression.append(-day).append('L');

                if (vo.getScheduleType() == MaintenanceEventVO.TYPE_MONTHLY)
                    expression.append(" * ?");
                else
                    expression.append(' ').append(month).append(" ?");
            }
        }

        CronTimerTrigger cronTrigger;
        try {
            cronTrigger = new CronTimerTrigger(expression.toString());
        }
        catch (ParseException e) {
            // Should never happen, so wrap and rethrow
            throw new ShouldNeverHappenException(e);
        }
        return cronTrigger;
    }
View Full Code Here

                    month(true), activeTime(), monthday(false), month(false), inactiveTime());
        else if (scheduleType == TYPE_CRON)
            message = new TranslatableMessage("maintenanceEvents.schedule.cronUntil", dataSourceName, activeCron,
                    inactiveCron);
        else
            throw new ShouldNeverHappenException("Unknown schedule type: " + scheduleType);

        return message;
    }
View Full Code Here

TOP

Related Classes of com.serotonin.ShouldNeverHappenException

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.