use of com.serotonin.ShouldNeverHappenException in project ma-modules-public by infiniteautomation.
the class ChartRendererFactory method createModel.
/**
* @param vo
* @return
*/
public static BaseChartRendererModel<?> createModel(DataPointVO vo) {
ChartRenderer renderer = vo.getChartRenderer();
if (renderer == null)
return null;
if (renderer.getTypeName().equals(ImageChartRenderer.getDefinition().getName())) {
ImageChartRenderer r = (ImageChartRenderer) renderer;
TimePeriodModel tp = new TimePeriodModel(r.getNumberOfPeriods(), r.getTimePeriod());
ImageChartRendererModel model = new ImageChartRendererModel(tp);
return model;
} else if (renderer.getTypeName().equals(ImageFlipbookRenderer.getDefinition().getName())) {
ImageFlipbookRenderer r = (ImageFlipbookRenderer) renderer;
ImageFlipbookChartRendererModel model = new ImageFlipbookChartRendererModel(r.getLimit());
return model;
} else if (renderer.getTypeName().equals(StatisticsChartRenderer.getDefinition().getName())) {
StatisticsChartRenderer r = (StatisticsChartRenderer) renderer;
TimePeriodModel tp = new TimePeriodModel(r.getNumberOfPeriods(), r.getTimePeriod());
StatisticsChartRendererModel model = new StatisticsChartRendererModel(tp, r.isIncludeSum());
return model;
} else if (renderer.getTypeName().equals(TableChartRenderer.getDefinition().getName())) {
TableChartRenderer r = (TableChartRenderer) renderer;
TableChartRendererModel model = new TableChartRendererModel(r.getLimit());
return model;
} else {
throw new ShouldNeverHappenException("Unknown Chart Renderer: " + renderer.getDef().getName());
}
}
use of com.serotonin.ShouldNeverHappenException in project ma-modules-public by infiniteautomation.
the class AuditEventInstanceModel method getContext.
@JsonRawValue
public String getContext() {
// Since the JsonData table can contain JSON within the context, return raw JSON all the time here
StringWriter stringWriter = new StringWriter();
JsonWriter writer = new JsonWriter(Common.JSON_CONTEXT, stringWriter);
writer.setPrettyIndent(3);
writer.setPrettyOutput(true);
try {
writer.writeObject(this.data.getContext());
return stringWriter.toString();
} catch (JsonException e) {
throw new ShouldNeverHappenException(e);
} catch (IOException e) {
throw new ShouldNeverHappenException(e);
}
}
use of com.serotonin.ShouldNeverHappenException in project ma-modules-public by infiniteautomation.
the class ScheduledEventVO method getDescription.
public TranslatableMessage getDescription() {
TranslatableMessage message;
if (!StringUtils.isBlank(alias))
message = new TranslatableMessage("common.default", alias);
else if (scheduleType == TYPE_ONCE) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.onceUntil", Functions.getTime(new DateTime(activeYear, activeMonth, activeDay, activeHour, activeMinute, activeSecond, 0).getMillis()), Functions.getTime(new DateTime(inactiveYear, inactiveMonth, inactiveDay, inactiveHour, inactiveMinute, inactiveSecond, 0).getMillis()));
else
message = new TranslatableMessage("event.schedule.onceAt", Functions.getTime(new DateTime(activeYear, activeMonth, activeDay, activeHour, activeMinute, activeSecond, 0).getMillis()));
} else if (scheduleType == TYPE_HOURLY) {
String activeTime = StringUtils.leftPad(Integer.toString(activeMinute), 2, '0') + ":" + StringUtils.leftPad(Integer.toString(activeSecond), 2, '0');
if (returnToNormal)
message = new TranslatableMessage("event.schedule.hoursUntil", activeTime, StringUtils.leftPad(Integer.toString(inactiveMinute), 2, '0') + ":" + StringUtils.leftPad(Integer.toString(inactiveSecond), 2, '0'));
else
message = new TranslatableMessage("event.schedule.hoursAt", activeTime);
} else if (scheduleType == TYPE_DAILY) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.dailyUntil", activeTime(), inactiveTime());
else
message = new TranslatableMessage("event.schedule.dailyAt", activeTime());
} else if (scheduleType == TYPE_WEEKLY) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.weeklyUntil", weekday(true), activeTime(), weekday(false), inactiveTime());
else
message = new TranslatableMessage("event.schedule.weeklyAt", weekday(true), activeTime());
} else if (scheduleType == TYPE_MONTHLY) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.monthlyUntil", monthday(true), activeTime(), monthday(false), inactiveTime());
else
message = new TranslatableMessage("event.schedule.monthlyAt", monthday(true), activeTime());
} else if (scheduleType == TYPE_YEARLY) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.yearlyUntil", monthday(true), month(true), activeTime(), monthday(false), month(false), inactiveTime());
else
message = new TranslatableMessage("event.schedule.yearlyAt", monthday(true), month(true), activeTime());
} else if (scheduleType == TYPE_CRON) {
if (returnToNormal)
message = new TranslatableMessage("event.schedule.cronUntil", activeCron, inactiveCron);
else
message = new TranslatableMessage("event.schedule.cronAt", activeCron);
} else
throw new ShouldNeverHappenException("Unknown schedule type: " + scheduleType);
return message;
}
use of com.serotonin.ShouldNeverHappenException in project ma-modules-public by infiniteautomation.
the class M2MRecipientListEntryBean method createEmailRecipient.
public EmailRecipient createEmailRecipient() {
switch(recipientType) {
case EmailRecipient.TYPE_MAILING_LIST:
MailingList ml = new MailingList();
ml.setId(referenceId);
return ml;
case EmailRecipient.TYPE_USER:
UserEntry u = new UserEntry();
u.setUserId(referenceId);
return u;
case EmailRecipient.TYPE_ADDRESS:
AddressEntry a = new AddressEntry();
a.setAddress(referenceAddress);
return a;
}
throw new ShouldNeverHappenException("Unknown email recipient type: " + recipientType);
}
use of com.serotonin.ShouldNeverHappenException in project ma-modules-public by infiniteautomation.
the class M2MReportVO method convert.
/**
* @return
*/
public ReportVO convert(M2MReportDao legacyDao) {
ReportVO vo = new ReportVO();
List<ReportPointVO> newPoints = new ArrayList<ReportPointVO>();
for (M2MReportPointVO legacyPoint : this.points) newPoints.add(legacyPoint.convert(legacyDao));
vo.setPoints(newPoints);
// Find the user from M2M
String username = legacyDao.getUsername(userId);
User user = UserDao.instance.getUser(username);
if (user != null)
vo.setUserId(user.getId());
else
throw new ShouldNeverHappenException("Unable to find User " + username + " in Mango.");
// Use default vo.setTemplate(template);
vo.setIncludeEvents(includeEvents);
vo.setIncludeUserComments(includeUserComments);
vo.setDateRangeType(dateRangeType);
vo.setRelativeDateType(relativeDateType);
vo.setPreviousPeriodCount(previousPeriodCount);
vo.setPreviousPeriodType(previousPeriodType);
vo.setPastPeriodCount(pastPeriodCount);
vo.setPastPeriodType(pastPeriodType);
vo.setFromNone(fromNone);
vo.setFromYear(fromYear);
vo.setFromMonth(fromMonth);
vo.setFromDay(fromDay);
vo.setFromHour(fromHour);
vo.setFromMinute(fromMinute);
vo.setToNone(toNone);
vo.setToYear(toYear);
vo.setToMonth(toMonth);
vo.setToDay(toDay);
vo.setToHour(toHour);
vo.setToMinute(toMinute);
vo.setSchedule(schedule);
vo.setSchedulePeriod(schedulePeriod);
vo.setScheduleCron(scheduleCron);
vo.setRunDelayMinutes(runDelayMinutes);
vo.setEmail(email);
// Convert the Recipient list
List<RecipientListEntryBean> newRecipients = new ArrayList<RecipientListEntryBean>();
for (M2MRecipientListEntryBean legacyRecipient : this.recipients) newRecipients.add(legacyRecipient.convert(legacyDao));
vo.setIncludeData(includeData);
vo.setZipData(zipData);
return vo;
}
Aggregations