Search in sources :

Example 6 with MultilingualString

use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.

the class OwsServiceIdentificationFactory method setTitle.

@Setting(OwsServiceIdentificationFactorySettings.TITLE)
public void setTitle(Object title) throws ConfigurationError {
    Validation.notNull("Service Identification Title", title);
    if (title instanceof MultilingualString) {
        this.title = (MultilingualString) title;
    } else if (title instanceof String) {
        this.title = createFromString(title);
    } else {
        throw new ConfigurationError(String.format("%s is not supported as title!", title.getClass().getName()));
    }
    setRecreate();
}
Also used : ConfigurationError(org.n52.faroe.ConfigurationError) MultilingualString(org.n52.janmayen.i18n.MultilingualString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) Setting(org.n52.faroe.annotation.Setting)

Example 7 with MultilingualString

use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.

the class I18NSerializerTest method test.

private void test(MultilingualString string) {
    errors.checkThat(string, is(notNullValue()));
    String encoded = new I18NSerializer().encode(string);
    System.out.println(encoded);
    errors.checkThat(encoded.isEmpty(), is(string.isEmpty()));
    MultilingualString decoded = new I18NSerializer().decode(encoded);
    errors.checkThat(decoded, is(equalTo(string)));
}
Also used : MultilingualString(org.n52.janmayen.i18n.MultilingualString) MultilingualString(org.n52.janmayen.i18n.MultilingualString)

Example 8 with MultilingualString

use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parseServiceIdentification.

private OwsServiceIdentification parseServiceIdentification(ServiceIdentification serviceIdentification) {
    if (serviceIdentification == null) {
        return null;
    }
    OwsCode serviceType = parseCode(serviceIdentification.getServiceType());
    Set<String> serviceTypeVersion = Optional.ofNullable(serviceIdentification.getServiceTypeVersionArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
    Set<String> fees = Optional.ofNullable(serviceIdentification.getFees()).map(Collections::singleton).orElseGet(Collections::emptySet);
    Set<URI> profiles = Optional.ofNullable(serviceIdentification.getProfileArray()).map(Arrays::stream).orElseGet(Stream::empty).map(URI::create).collect(toSet());
    Set<String> accessConstraints = Optional.ofNullable(serviceIdentification.getAccessConstraintsArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
    MultilingualString title = new MultilingualString();
    MultilingualString abstrakt = new MultilingualString();
    Optional.ofNullable(serviceIdentification.getTitleArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(title::addLocalization);
    Optional.ofNullable(serviceIdentification.getAbstractArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(abstrakt::addLocalization);
    Set<OwsKeyword> keywords = Optional.ofNullable(serviceIdentification.getKeywordsArray()).map(Arrays::stream).orElseGet(Stream::empty).flatMap(this::parseKeyword).filter(Objects::nonNull).collect(toSet());
    return new OwsServiceIdentification(serviceType, serviceTypeVersion, profiles, fees, accessConstraints, title, abstrakt, keywords);
}
Also used : OwsCode(org.n52.shetland.ogc.ows.OwsCode) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) URI(java.net.URI) OwsKeyword(org.n52.shetland.ogc.ows.OwsKeyword) Stream(java.util.stream.Stream) MultilingualString(org.n52.janmayen.i18n.MultilingualString) Arrays(java.util.Arrays) Collections(java.util.Collections)

Example 9 with MultilingualString

use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.

the class I18NJsonEncoder method decodeMultilingualString.

public MultilingualString decodeMultilingualString(JsonNode json) {
    MultilingualString mls = new MultilingualString();
    decodeMultilingualString(json, mls);
    return mls;
}
Also used : MultilingualString(org.n52.janmayen.i18n.MultilingualString)

Example 10 with MultilingualString

use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.

the class I18NJsonEncoder method decodeMultilingualString.

private void decodeMultilingualString(JsonNode json, MultilingualString mls) {
    Iterator<Entry<String, JsonNode>> it = json.fields();
    while (it.hasNext()) {
        Entry<String, JsonNode> e = it.next();
        Locale locale = LocaleHelper.decode(e.getKey());
        mls.addLocalization(locale, e.getValue().asText());
    }
}
Also used : Locale(java.util.Locale) Entry(java.util.Map.Entry) JsonNode(com.fasterxml.jackson.databind.JsonNode) MultilingualString(org.n52.janmayen.i18n.MultilingualString) LocalizedString(org.n52.janmayen.i18n.LocalizedString)

Aggregations

MultilingualString (org.n52.janmayen.i18n.MultilingualString)10 LocalizedString (org.n52.janmayen.i18n.LocalizedString)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Locale (java.util.Locale)2 ConfigurationError (org.n52.faroe.ConfigurationError)2 Setting (org.n52.faroe.annotation.Setting)2 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Entry (java.util.Map.Entry)1 Stream (java.util.stream.Stream)1 Test (org.junit.Test)1 OwsCode (org.n52.shetland.ogc.ows.OwsCode)1 OwsKeyword (org.n52.shetland.ogc.ows.OwsKeyword)1 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)1 OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)1