use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EventType method getInt.
protected int getInt(JsonObject json, String name, ExportCodes codes) throws JsonException {
String text = json.getString(name);
if (text == null)
throw new TranslatableJsonException("emport.error.eventType.missing", name, codes.getCodeList());
int i = codes.getId(text);
if (i == -1)
throw new TranslatableJsonException("emport.error.eventType.invalid", name, text, codes.getCodeList());
return i;
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EventType method getDataPointId.
protected int getDataPointId(JsonObject json, String name) throws JsonException {
String xid = json.getString(name);
if (xid == null)
throw new TranslatableJsonException("emport.error.eventType.missing.reference", name);
Integer dpid = DataPointDao.instance.getIdByXid(xid);
if (dpid == null)
throw new TranslatableJsonException("emport.error.eventType.invalid.reference", name, xid);
return dpid;
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class ScriptContextVariable method jsonReadVarContext.
/**
* Read in context,
* @param json
* @param context
* @return if my XID is in the context, return the name it has to map into the VO otherwise return null
* @throws JsonException
*/
public static String jsonReadVarContext(JsonObject json, List<ScriptContextVariable> context, boolean isContextUpdate) throws JsonException {
JsonArray jsonContext = json.getJsonArray("context");
if (jsonContext != null) {
context.clear();
DataPointDao dataPointDao = DataPointDao.instance;
for (JsonValue jv : jsonContext) {
JsonObject jo = jv.toJsonObject();
String xid = jo.getString("dataPointXid");
if (xid == null)
throw new TranslatableJsonException("emport.error.context.missing", "dataPointXid");
Integer dpid = dataPointDao.getIdByXid(xid);
if (dpid == null) {
// This can also happen if the point is in its own context (Bug from legacy systems).
throw new TranslatableJsonException("emport.error.missingPoint", xid);
}
// For compatibility with varName and variableName json types
String var = jo.getString("varName");
if (var == null) {
var = jo.getString("variableName");
if (var == null)
throw new TranslatableJsonException("emport.error.context.missing", "varName");
}
// Default for legacy systems
if (jo.containsKey("updateContext"))
isContextUpdate = jo.getBoolean("updateContext");
context.add(new ScriptContextVariable(dpid, var, isContextUpdate));
}
}
return json.getString("variableName");
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class DeltamationCommon method parsePoint.
public static int parsePoint(JsonObject jsonObject, String name) throws TranslatableJsonException {
DataPointDao points = DataPointDao.instance;
String xid = jsonObject.getString(name);
Integer dpid = points.getIdByXid(xid);
if (dpid == null) {
throw new TranslatableJsonException("validate.pointMissing", name, xid);
}
return dpid;
}
Aggregations