use of org.n52.iceland.exception.JSONException in project arctic-sea by 52North.
the class I18NJsonEncoder method decodeI18NMetadata.
public AbstractI18NMetadata decodeI18NMetadata(JsonNode s) throws JSONException {
String type = s.path(TYPE).asText();
String id = s.path(ID).asText();
final AbstractI18NMetadata i18n;
if (type.equals(TYPE_FEATURE)) {
i18n = new I18NFeatureMetadata(id);
} else if (type.equals(TYPE_OBSERVABLE_PROPERTY)) {
i18n = new I18NObservablePropertyMetadata(id);
} else if (type.equals(TYPE_OFFERING)) {
i18n = new I18NOfferingMetadata(id);
} else if (type.equals(TYPE_PROCEDURE)) {
I18NProcedureMetadata pi18n = new I18NProcedureMetadata(id);
decodeMultilingualString(s.path(LONG_NAME), pi18n.getLongName());
decodeMultilingualString(s.path(SHORT_NAME), pi18n.getShortName());
i18n = pi18n;
} else {
throw new JSONException("Unknown type: " + type);
}
decodeMultilingualString(s.path(NAME), i18n.getName());
decodeMultilingualString(s.path(DESCRIPTION), i18n.getDescription());
return i18n;
}
use of org.n52.iceland.exception.JSONException in project arctic-sea by 52North.
the class I18NJsonEncoder method encode.
public ObjectNode encode(Iterable<? extends AbstractI18NMetadata> i18ns) throws JSONException {
ObjectNode node = nodeFactory.objectNode();
ArrayNode array = node.putArray(I18N);
for (AbstractI18NMetadata i18n : i18ns) {
array.add(encode(i18n));
}
return node;
}
Aggregations