use of com.serotonin.m2m2.Constants in project ma-core-public by infiniteautomation.
the class M2M2ContextListener method constantsInitialize.
//
//
// Constants
//
private void constantsInitialize(ServletContext ctx) {
ctx.setAttribute("constants.Common.NEW_ID", Common.NEW_ID);
ctx.setAttribute("constants.DataTypes.BINARY", DataTypes.BINARY);
ctx.setAttribute("constants.DataTypes.MULTISTATE", DataTypes.MULTISTATE);
ctx.setAttribute("constants.DataTypes.NUMERIC", DataTypes.NUMERIC);
ctx.setAttribute("constants.DataTypes.ALPHANUMERIC", DataTypes.ALPHANUMERIC);
ctx.setAttribute("constants.DataTypes.IMAGE", DataTypes.IMAGE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.NONE", Permissions.DataPointAccessTypes.NONE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.READ", Permissions.DataPointAccessTypes.READ);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.SET", Permissions.DataPointAccessTypes.SET);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.DATA_SOURCE", Permissions.DataPointAccessTypes.DATA_SOURCE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.ADMIN", Permissions.DataPointAccessTypes.ADMIN);
ctx.setAttribute("constants.EventType.EventTypeNames.DATA_POINT", EventType.EventTypeNames.DATA_POINT);
ctx.setAttribute("constants.EventType.EventTypeNames.DATA_SOURCE", EventType.EventTypeNames.DATA_SOURCE);
ctx.setAttribute("constants.EventType.EventTypeNames.SYSTEM", EventType.EventTypeNames.SYSTEM);
ctx.setAttribute("constants.EventType.EventTypeNames.PUBLISHER", EventType.EventTypeNames.PUBLISHER);
ctx.setAttribute("constants.EventType.EventTypeNames.AUDIT", EventType.EventTypeNames.AUDIT);
ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_STARTUP", SystemEventType.TYPE_SYSTEM_STARTUP);
ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_SHUTDOWN", SystemEventType.TYPE_SYSTEM_SHUTDOWN);
ctx.setAttribute("constants.SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED", SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED);
ctx.setAttribute("constants.SystemEventType.TYPE_USER_LOGIN", SystemEventType.TYPE_USER_LOGIN);
ctx.setAttribute("constants.SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE", SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_EMAIL_SEND_FAILURE", SystemEventType.TYPE_EMAIL_SEND_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_PROCESS_FAILURE", SystemEventType.TYPE_PROCESS_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_LICENSE_CHECK", SystemEventType.TYPE_LICENSE_CHECK);
ctx.setAttribute("constants.SystemEventType.TYPE_UPGRADE_CHECK", SystemEventType.TYPE_UPGRADE_CHECK);
ctx.setAttribute("constants.AuditEventType.TYPE_DATA_SOURCE", AuditEventType.TYPE_DATA_SOURCE);
ctx.setAttribute("constants.AuditEventType.TYPE_DATA_POINT", AuditEventType.TYPE_DATA_POINT);
ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_DETECTOR", AuditEventType.TYPE_EVENT_DETECTOR);
ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_HANDLER", AuditEventType.TYPE_EVENT_HANDLER);
ctx.setAttribute("constants.UserComment.TYPE_EVENT", UserCommentVO.TYPE_EVENT);
ctx.setAttribute("constants.UserComment.TYPE_POINT", UserCommentVO.TYPE_POINT);
String[] codes = { "common.access.read", "common.access.set", "common.alarmLevel.none", "common.alarmLevel.info", "common.alarmLevel.important", "common.alarmLevel.warning", "common.alarmLevel.urgent", "common.alarmLevel.critical", "common.alarmLevel.lifeSafety", "common.alarmLevel.doNotLog", "common.alarmLevel.ignore", "common.disabled", "common.administrator", "common.user", "common.disabledToggle", "common.enabledToggle", "common.maximize", "common.minimize", "common.loading", "js.help.error", "js.help.related", "js.help.lastUpdated", "common.sendTestEmail", "js.email.noRecipients", "js.email.addMailingList", "js.email.addUser", "js.email.addAddress", "js.email.noRecipForEmail", "js.email.testSent", "events.silence", "events.unsilence", "header.mute", "header.unmute" };
Map<String, TranslatableMessage> messages = new HashMap<>();
for (String code : codes) messages.put(code, new TranslatableMessage(code));
ctx.setAttribute("clientSideMessages", messages);
SessionCookieConfig sessionCookieConfig = ctx.getSessionCookieConfig();
sessionCookieConfig.setHttpOnly(true);
sessionCookieConfig.setName(Common.getCookieName());
}
use of com.serotonin.m2m2.Constants in project atlasmap by atlasmap.
the class AtlasTestData method generateAtlasMapping.
public static AtlasMapping generateAtlasMapping() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("generated.mapping." + UUID.randomUUID().toString().replace('-', '.'));
mapping.getProperties().getProperty().addAll(generateAtlasProperties());
mapping.setConstants(new Constants());
return mapping;
}
use of com.serotonin.m2m2.Constants in project ma-core-public by infiniteautomation.
the class MangoJavaScriptService method compile.
/**
* Compile a script to be run and add global bindings
*/
public CompiledScript compile(String script, boolean wrapInFunction) throws ScriptError {
try {
final ScriptEngine engine = newEngine();
// Add constants to the context
Bindings globalBindings = new SimpleBindings();
// left here for legacy compatibility
globalBindings.put("SECOND", Common.TimePeriods.SECONDS);
globalBindings.put("MINUTE", Common.TimePeriods.MINUTES);
globalBindings.put("HOUR", Common.TimePeriods.HOURS);
globalBindings.put("DAY", Common.TimePeriods.DAYS);
globalBindings.put("WEEK", Common.TimePeriods.WEEKS);
globalBindings.put("MONTH", Common.TimePeriods.MONTHS);
globalBindings.put("YEAR", Common.TimePeriods.YEARS);
for (IntStringPair isp : Common.TIME_PERIOD_CODES.getIdKeys()) globalBindings.put(Common.TIME_PERIOD_CODES.getCode(isp.getKey()), isp.getKey());
for (IntStringPair isp : Common.ROLLUP_CODES.getIdKeys(Common.Rollups.NONE)) globalBindings.put(Common.ROLLUP_CODES.getCode(isp.getKey()), isp.getKey());
// Add in Additional Utilities with Global Scope
globalBindings.put(DateTimeUtility.CONTEXT_KEY, new DateTimeUtility());
globalBindings.put(UnitUtility.CONTEXT_KEY, new UnitUtility());
engine.setBindings(globalBindings, ScriptContext.GLOBAL_SCOPE);
String toCompile;
if (wrapInFunction) {
toCompile = SCRIPT_PREFIX + script + SCRIPT_SUFFIX;
} else {
toCompile = script;
}
return ((Compilable) engine).compile(toCompile);
} catch (ScriptException e) {
throw ScriptError.create(e, wrapInFunction);
}
}
Aggregations