Search in sources :

Example 41 with Tag

use of org.mozilla.jss.asn1.Tag in project GeoGig by boundlessgeo.

the class OSMUtils method buildTagsCollectionFromString.

public static Collection<Tag> buildTagsCollectionFromString(String tagsString) {
    Collection<Tag> tags = Lists.newArrayList();
    if (tagsString != null) {
        String[] tokens = tagsString.split("\\|");
        for (String token : tokens) {
            int idx = token.lastIndexOf(':');
            if (idx != -1) {
                Tag tag = new Tag(token.substring(0, idx), token.substring(idx + 1));
                tags.add(tag);
            } else {
                LOGGER.info("found tag token '{}' with no value in tagString '{}'", token, tagsString);
            }
        }
    }
    return tags;
}
Also used : Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 42 with Tag

use of org.mozilla.jss.asn1.Tag in project requery by requery.

the class JacksonTest method testOneToManySerialize.

@Test
public void testOneToManySerialize() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    event.setId(id);
    event.setName("test");
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    Tag t2 = new Tag();
    t2.setId(UUID.randomUUID());
    event.getTags().add(t1);
    event.getTags().add(t2);
    Place p = new Place();
    p.setId("SF");
    p.setName("San Francisco, CA");
    event.setPlace(p);
    data.insert(event);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, event);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Event read = mapper.readValue(value, Event.class);
        assertSame(event, read);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) Place(io.requery.test.model3.Place) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 43 with Tag

use of org.mozilla.jss.asn1.Tag in project requery by requery.

the class JacksonTest method testManyToManySerialize.

@Test
public void testManyToManySerialize() {
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    for (int i = 0; i < 3; i++) {
        Event event = new Event();
        UUID id = UUID.randomUUID();
        event.setId(id);
        event.setName("event" + i);
        t1.getEvents().add(event);
    }
    data.insert(t1);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, t1);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Tag tag = mapper.readValue(value, Tag.class);
        assertSame(t1, tag);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 44 with Tag

use of org.mozilla.jss.asn1.Tag in project requery by requery.

the class UpsertTest method testUpsertManyToMany.

@Test
public void testUpsertManyToMany() {
    Event event1 = new Event();
    event1.setId(UUID.randomUUID());
    Tag tag = new Tag();
    tag.setId(UUID.randomUUID());
    tag.getEvents().add(event1);
    data.upsert(tag);
    Event event2 = new Event();
    event2.setId(UUID.randomUUID());
    tag.getEvents().add(event2);
    data.upsert(event2);
    data.upsert(tag);
}
Also used : Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) Test(org.junit.Test)

Example 45 with Tag

use of org.mozilla.jss.asn1.Tag in project omegat by omegat-org.

the class Handler method translateButDontFlash.

/**
 * One of the main methods of the XML filter: it collects all the data,
 * adjusts it, and sends for translation.
 *
 * @see #translateAndFlush()
 */
private void translateButDontFlash() throws TranslationException {
    if (currEntry().isEmpty()) {
        return;
    }
    boolean isTranslated = true;
    List<ProtectedPart> shortcutDetails = new ArrayList<ProtectedPart>();
    boolean tagsAggregation = isTagsAggregationEnabled();
    String src = currEntry().sourceToShortcut(tagsAggregation, dialect, shortcutDetails);
    Element lead = currEntry().get(0);
    String translation = src;
    if ((lead instanceof Tag) && (isPreformattingTag(((Tag) lead).getTag(), ((Tag) lead).getAttributes()) || isSpacePreservingTag()) && isTranslatableTag() && !StringUtil.isEmpty(src)) {
        resetSpacePreservingTag();
        translation = translator.translate(src, shortcutDetails);
    } else {
        String compressed = src;
        if (Core.getFilterMaster().getConfig().isRemoveSpacesNonseg()) {
            compressed = StringUtil.compressSpaces(src);
        }
        if (isTranslatableTag()) {
            translation = translator.translate(compressed, shortcutDetails);
        }
        // untranslated is written out uncompressed
        if (compressed.equals(translation)) {
            translation = src;
            isTranslated = false;
        }
    }
    if (lead instanceof XMLTag) {
        dialect.handleXMLTag((XMLTag) lead, isTranslated);
    }
    currEntry().setTranslation(translation, dialect, new ArrayList<ProtectedPart>());
}
Also used : ProtectedPart(org.omegat.core.data.ProtectedPart) Element(org.omegat.filters3.Element) ArrayList(java.util.ArrayList) Tag(org.omegat.filters3.Tag)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)23 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Date (java.util.Date)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Tag (org.mozilla.jss.asn1.Tag)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)6 Osmformat (crosby.binary.Osmformat)5 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)5 Point (com.vividsolutions.jts.geom.Point)4