use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class JsonEmportScriptUtility method doImportGetStatus.
public List<ProcessMessage> doImportGetStatus(String json) throws Exception {
if (admin) {
JsonTypeReader reader = new JsonTypeReader(json);
JsonValue value = reader.read();
JsonObject jo = value.toJsonObject();
if (importExclusions != null)
doExclusions(jo);
ScriptImportTask sit = new ScriptImportTask(jo);
sit.run(Common.timer.currentTimeMillis());
return sit.getMessages();
}
return null;
}
use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class JsonEmportScriptUtility method doImport.
public void doImport(String json) throws Exception {
if (admin) {
JsonTypeReader reader = new JsonTypeReader(json);
JsonValue value = reader.read();
JsonObject jo = value.toJsonObject();
if (importExclusions != null)
doExclusions(jo);
ScriptImportTask sit = new ScriptImportTask(jo);
sit.run(Common.timer.currentTimeMillis());
}
}
use of com.serotonin.json.type.JsonValue in project ma-modules-public by infiniteautomation.
the class GraphicalView method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
if (isNew()) {
String username = jsonObject.getString("user");
if (StringUtils.isBlank(username))
throw new TranslatableJsonException("emport.error.missingValue", "user");
User user = UserDao.instance.getUser(username);
if (user == null)
throw new TranslatableJsonException("emport.error.missingUser", username);
userId = user.getId();
}
JsonArray components = jsonObject.getJsonArray("viewComponents");
if (components != null) {
viewComponents.clear();
for (JsonValue jv : components) addViewComponent(reader.read(ViewComponent.class, jv));
}
String text = jsonObject.getString("anonymousAccess");
if (text != null) {
anonymousAccess = ShareUser.ACCESS_CODES.getId(text);
if (anonymousAccess == -1)
throw new TranslatableJsonException("emport.error.invalid", "anonymousAccess", text, ShareUser.ACCESS_CODES.getCodeList());
}
}
use of com.serotonin.json.type.JsonValue in project ma-modules-public by infiniteautomation.
the class CompoundComponent method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
super.jsonRead(reader, jsonObject);
JsonObject jsonChildren = jsonObject.getJsonObject("children");
if (jsonChildren != null) {
for (Map.Entry<String, JsonValue> jsonChild : jsonChildren.entrySet()) {
CompoundChild child = getChild(jsonChild.getKey());
if (child == null || !child.getViewComponent().isPointComponent())
throw new TranslatableJsonException("emport.error.compound.invalidChildId", jsonChild.getKey(), definition().getId(), getPointComponentChildIds());
jsonReadDataPoint(jsonChild.getValue(), (PointComponent) child.getViewComponent());
}
}
}
use of com.serotonin.json.type.JsonValue in project ma-modules-public by infiniteautomation.
the class MultistateGraphicComponent method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
super.jsonRead(reader, jsonObject);
JsonArray jsonStateList = jsonObject.getJsonArray("stateImageMappings");
if (jsonStateList != null) {
stateImageMap.clear();
for (JsonValue jv : jsonStateList) {
JsonObject jsonMapping = jv.toJsonObject();
Integer state = jsonMapping.getInt("state");
if (state == null)
throw new TranslatableJsonException("emport.error.missingValue", "state");
Integer index = jsonMapping.getInt("imageIndex");
if (index == null)
throw new TranslatableJsonException("emport.error.missingValue", "index");
stateImageMap.put(state, index);
}
}
}
Aggregations