Search in sources :

Example 56 with Tag

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

the class UpsertTest method testInsertOneToManyInsert.

@Test
public void testInsertOneToManyInsert() {
    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);
    data.insert(event);
    HashSet<Tag> set = new HashSet<>(event.getTags());
    assertEquals(2, set.size());
    assertTrue(set.containsAll(Arrays.asList(t1, t2)));
    assertSame(2, data.select(Tag.class).get().toList().size());
}
Also used : Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) UUID(java.util.UUID) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 57 with Tag

use of org.mozilla.jss.asn1.Tag in project bboxdb by jnidzwetzki.

the class OSMDataConverter method handleWay.

/**
 * Handle a way
 * @param entityContainer
 */
protected void handleWay(final Way way) {
    try {
        for (final Entry<OSMType, OSMTagEntityFilter> osm : filter.entrySet()) {
            final OSMType osmType = osm.getKey();
            final OSMTagEntityFilter entityFilter = osm.getValue();
            if (entityFilter.match(way.getTags())) {
                final GeoJsonPolygon geometricalStructure = new GeoJsonPolygon(way.getId());
                for (final Tag tag : way.getTags()) {
                    geometricalStructure.addProperty(tag.getKey(), tag.getValue());
                }
                // Perform search async
                for (final WayNode wayNode : way.getWayNodes()) {
                    final SerializableNode node = osmNodeStore.getNodeForId(wayNode.getNodeId());
                    // GeoJSON: [longitude, latitude]
                    geometricalStructure.addPoint(node.getLongitude(), node.getLatitude());
                }
                writePolygonToOutput(osmType, geometricalStructure);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : OSMTagEntityFilter(org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) GeoJsonPolygon(org.bboxdb.commons.math.GeoJsonPolygon) SerializableNode(org.bboxdb.tools.converter.osm.util.SerializableNode) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) ParseException(org.apache.commons.cli.ParseException) IOException(java.io.IOException)

Example 58 with Tag

use of org.mozilla.jss.asn1.Tag in project bboxdb by jnidzwetzki.

the class OSMDataConverter method handleNode.

/**
 * Handle a node
 * @param entityContainer
 */
protected void handleNode(final Node node) {
    try {
        for (final Entry<OSMType, OSMTagEntityFilter> osm : filter.entrySet()) {
            final OSMType osmType = osm.getKey();
            final OSMTagEntityFilter entityFilter = osm.getValue();
            if (entityFilter.match(node.getTags())) {
                final GeoJsonPolygon geometricalStructure = new GeoJsonPolygon(node.getId());
                // GeoJSON: [longitude, latitude]
                geometricalStructure.addPoint(node.getLongitude(), node.getLatitude());
                for (final Tag tag : node.getTags()) {
                    geometricalStructure.addProperty(tag.getKey(), tag.getValue());
                }
                writePolygonToOutput(osmType, geometricalStructure);
            }
        }
        osmNodeStore.storeNode(node);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : OSMTagEntityFilter(org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter) GeoJsonPolygon(org.bboxdb.commons.math.GeoJsonPolygon) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) ParseException(org.apache.commons.cli.ParseException) IOException(java.io.IOException)

Example 59 with Tag

use of org.mozilla.jss.asn1.Tag in project clinical_quality_language by cqframework.

the class CommentTests method testTags.

@Test
public void testTags() throws IOException {
    CqlTranslator translator = TestUtils.runSemanticTest("TestTags.cql", 0);
    CompiledLibrary library = translator.getTranslatedLibrary();
    assertThat(library.getLibrary().getAnnotation(), notNullValue());
    Annotation a = null;
    for (Object o : library.getLibrary().getAnnotation()) {
        if (o instanceof Annotation) {
            a = (Annotation) o;
        }
    }
    assertThat(a, notNullValue());
    assertThat(a.getT(), notNullValue());
    assertThat(a.getT().size(), equalTo(3));
    for (int i = 0; i < a.getT().size(); i++) {
        Tag t = a.getT().get(i);
        switch(i) {
            case 0:
                assertThat(t.getName(), equalTo("author"));
                assertThat(t.getValue(), equalTo("Frederic Chopin"));
                break;
            case 1:
                assertThat(t.getName(), equalTo("description"));
                assertThat(t.getValue(), equalTo("Test tags"));
                break;
            case 2:
                assertThat(t.getName(), equalTo("allowFluent"));
                assertThat(t.getValue(), equalTo("true"));
                break;
        }
    }
    ExpressionDef d = library.resolveExpressionRef("TestExpression");
    assertThat(d.getAnnotation(), notNullValue());
    for (Object o : d.getAnnotation()) {
        if (o instanceof Annotation) {
            a = (Annotation) o;
        }
    }
    assertThat(a, notNullValue());
    assertThat(a.getT(), notNullValue());
    assertThat(a.getT().size(), equalTo(2));
    for (int i = 0; i < a.getT().size(); i++) {
        Tag t = a.getT().get(i);
        switch(i) {
            case 0:
                assertThat(t.getName(), equalTo("author"));
                assertThat(t.getValue(), equalTo("Frederic Chopin"));
                break;
            case 1:
                assertThat(t.getName(), equalTo("description"));
                assertThat(t.getValue(), equalTo("Test tags"));
                break;
        }
    }
    for (ExpressionDef e : library.getLibrary().getStatements().getDef()) {
        if (e instanceof FunctionDef) {
            d = e;
            break;
        }
    }
    assertThat(d.getAnnotation(), notNullValue());
    for (Object o : d.getAnnotation()) {
        if (o instanceof Annotation) {
            a = (Annotation) o;
        }
    }
    assertThat(a, notNullValue());
    assertThat(a.getT(), notNullValue());
    assertThat(a.getT().size(), equalTo(2));
    for (int i = 0; i < a.getT().size(); i++) {
        Tag t = a.getT().get(i);
        switch(i) {
            case 0:
                assertThat(t.getName(), equalTo("author"));
                assertThat(t.getValue(), equalTo("Frederic Chopin"));
                break;
            case 1:
                assertThat(t.getName(), equalTo("description"));
                assertThat(t.getValue(), equalTo("Test tags"));
                break;
        }
    }
    d = library.resolveExpressionRef("TestMultiline");
    assertThat(d.getAnnotation(), notNullValue());
    for (Object o : d.getAnnotation()) {
        if (o instanceof Annotation) {
            a = (Annotation) o;
        }
    }
    assertThat(a, notNullValue());
    assertThat(a.getT(), notNullValue());
    assertThat(a.getT().size(), equalTo(3));
    for (int i = 0; i < a.getT().size(); i++) {
        Tag t = a.getT().get(i);
        switch(i) {
            case 0:
                assertThat(t.getName(), equalTo("author"));
                assertThat(t.getValue(), equalTo("Frederic Chopin"));
                break;
            case 1:
                assertThat(t.getName(), equalTo("description"));
                assertThat(t.getValue(), equalTo("This is a multi-line description that\n spans multiple lines."));
                break;
            case 2:
                assertThat(t.getName(), equalTo("following"));
                assertThat(t.getValue(), equalTo("true"));
                break;
        }
    }
}
Also used : CompiledLibrary(org.cqframework.cql.cql2elm.model.CompiledLibrary) ExpressionDef(org.hl7.elm.r1.ExpressionDef) FunctionDef(org.hl7.elm.r1.FunctionDef) Tag(org.hl7.cql_annotations.r1.Tag) Annotation(org.hl7.cql_annotations.r1.Annotation) Test(org.testng.annotations.Test)

Example 60 with Tag

use of org.mozilla.jss.asn1.Tag in project clinical_quality_language by cqframework.

the class Cql2ElmVisitor method processTags.

private void processTags(ParseTree tree, Object o) {
    if (libraryBuilder.isCompatibleWith("1.5")) {
        if (o instanceof Element) {
            Element element = (Element) o;
            if (!(tree instanceof cqlParser.LibraryContext)) {
                if (element instanceof UsingDef || element instanceof IncludeDef || element instanceof CodeSystemDef || element instanceof ValueSetDef || element instanceof CodeDef || element instanceof ConceptDef || element instanceof ParameterDef || element instanceof ContextDef || element instanceof ExpressionDef) {
                    List<Tag> tags = getTags(tree);
                    if (tags != null && tags.size() > 0) {
                        Annotation a = getAnnotation(element);
                        if (a == null) {
                            a = buildAnnotation();
                            element.getAnnotation().add(a);
                        }
                        // tags, and there is currently nothing that would add tags other than being processed from comments
                        if (a.getT().size() == 0) {
                            a.getT().addAll(tags);
                        }
                    }
                }
            } else {
                if (libraryInfo.getDefinition() != null && libraryInfo.getHeaderInterval() != null) {
                    List<Tag> tags = getTags(libraryInfo.getHeader());
                    if (tags != null && tags.size() > 0) {
                        Annotation a = getAnnotation(libraryBuilder.getLibrary());
                        if (a == null) {
                            a = buildAnnotation();
                            libraryBuilder.getLibrary().getAnnotation().add(a);
                        }
                        a.getT().addAll(tags);
                    }
                }
            }
        }
    }
}
Also used : Element(org.hl7.elm.r1.Element) Annotation(org.hl7.cql_annotations.r1.Annotation) Tag(org.hl7.cql_annotations.r1.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