Search in sources :

Example 1 with AbstractI18NMetadata

use of org.n52.iceland.i18n.metadata.AbstractI18NMetadata 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;
}
Also used : AbstractI18NMetadata(org.n52.iceland.i18n.metadata.AbstractI18NMetadata) I18NFeatureMetadata(org.n52.iceland.i18n.metadata.I18NFeatureMetadata) I18NOfferingMetadata(org.n52.iceland.i18n.metadata.I18NOfferingMetadata) JSONException(org.n52.iceland.exception.JSONException) MultilingualString(org.n52.janmayen.i18n.MultilingualString) LocalizedString(org.n52.janmayen.i18n.LocalizedString) I18NObservablePropertyMetadata(org.n52.iceland.i18n.metadata.I18NObservablePropertyMetadata) I18NProcedureMetadata(org.n52.iceland.i18n.metadata.I18NProcedureMetadata)

Example 2 with AbstractI18NMetadata

use of org.n52.iceland.i18n.metadata.AbstractI18NMetadata 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;
}
Also used : AbstractI18NMetadata(org.n52.iceland.i18n.metadata.AbstractI18NMetadata) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

AbstractI18NMetadata (org.n52.iceland.i18n.metadata.AbstractI18NMetadata)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 JSONException (org.n52.iceland.exception.JSONException)1 I18NFeatureMetadata (org.n52.iceland.i18n.metadata.I18NFeatureMetadata)1 I18NObservablePropertyMetadata (org.n52.iceland.i18n.metadata.I18NObservablePropertyMetadata)1 I18NOfferingMetadata (org.n52.iceland.i18n.metadata.I18NOfferingMetadata)1 I18NProcedureMetadata (org.n52.iceland.i18n.metadata.I18NProcedureMetadata)1 LocalizedString (org.n52.janmayen.i18n.LocalizedString)1 MultilingualString (org.n52.janmayen.i18n.MultilingualString)1