use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class VirtualSerialPortConfigResolver method resolve.
@Override
public Type resolve(JsonValue jsonValue) throws JsonException {
if (jsonValue == null)
return null;
JsonObject json = jsonValue.toJsonObject();
String text = json.getString("type");
if (text == null)
throw new TranslatableJsonException("emport.error.virtual.comm.missing", "type", VirtualSerialPortConfig.PORT_TYPE_CODES);
return findClass(text);
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class CompoundDetectorEventType method getCompoundEventDetectorId.
protected int getCompoundEventDetectorId(JsonObject json, String name) throws JsonException {
String xid = json.getString(name);
if (xid == null)
throw new TranslatableJsonException("emport.error.eventType.missing.reference", name);
CompoundEventDetectorVO ced = new CompoundEventDetectorDao().getCompoundEventDetector(xid);
if (ced == null)
throw new TranslatableJsonException("emport.error.eventType.invalid.reference", name, xid);
return ced.getId();
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EventType method getPointEventDetectorId.
protected int getPointEventDetectorId(JsonObject json, int dpId, String pedName) throws JsonException {
String pedXid = json.getString(pedName);
if (pedXid == null)
throw new TranslatableJsonException("emport.error.eventType.missing.reference", pedName);
int id = EventDetectorDao.instance.getId(pedXid, dpId);
if (id == -1)
throw new TranslatableJsonException("emport.error.eventType.invalid.reference", pedName, pedXid);
return id;
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EventType method getDataSource.
protected DataSourceVO<?> getDataSource(JsonObject json, String name) throws JsonException {
String xid = json.getString(name);
if (xid == null)
throw new TranslatableJsonException("emport.error.eventType.missing.reference", name);
DataSourceVO<?> ds = DataSourceDao.instance.getDataSource(xid);
if (ds == null)
throw new TranslatableJsonException("emport.error.eventType.invalid.reference", name, xid);
return ds;
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EventTypeResolver method resolve.
@Override
public Type resolve(JsonValue jsonValue) throws JsonException {
if (jsonValue == null)
throw new TranslatableJsonException("emport.error.eventType.null");
JsonObject json = jsonValue.toJsonObject();
String text = json.getString("sourceType");
if (text == null)
throw new TranslatableJsonException("emport.error.eventType.missing", "sourceType", EventType.SOURCE_NAMES.getCodeList());
if (!EventType.SOURCE_NAMES.hasCode(text))
throw new TranslatableJsonException("emport.error.eventType.invalid", "sourceType", text, EventType.SOURCE_NAMES.getCodeList());
if (text.equalsIgnoreCase(EventTypeNames.DATA_POINT))
return DataPointEventType.class;
if (text.equalsIgnoreCase(EventTypeNames.DATA_SOURCE))
return DataSourceEventType.class;
if (text.equalsIgnoreCase(EventTypeNames.SYSTEM))
return SystemEventType.class;
if (text.equalsIgnoreCase(EventTypeNames.PUBLISHER))
return PublisherEventType.class;
if (text.equalsIgnoreCase(EventTypeNames.AUDIT))
return AuditEventType.class;
EventTypeDefinition def = ModuleRegistry.getEventTypeDefinition(text);
if (def != null)
return def.getEventTypeClass();
return null;
}
Aggregations