Search in sources :

Example 16 with Annotation

use of org.exquery.xquery3.Annotation in project exist by eXist-db.

the class RegistryFunctions method serializeAnnotations.

private static void serializeAnnotations(final MemTreeBuilder builder, final ResourceFunction resourceFn) {
    final List<Annotation> annotations = new ArrayList<>();
    annotations.addAll(resourceFn.getHttpMethodAnnotations());
    annotations.addAll(resourceFn.getConsumesAnnotations());
    annotations.addAll(resourceFn.getProducesAnnotations());
    for (final Annotation annotation : annotations) {
        builder.startElement(QName.fromJavaQName(annotation.getName()), null);
        final Literal[] literals = annotation.getLiterals();
        if (literals != null) {
            for (final Literal literal : literals) {
                if (annotation instanceof ConsumesAnnotation || annotation instanceof ProducesAnnotation) {
                    builder.startElement(INTERNET_MEDIA_TYPE, null);
                    builder.characters(literal.getValue());
                    builder.endElement();
                }
            }
        }
        builder.endElement();
    }
    // path annotation
    if (resourceFn.getPathAnnotation() != null) {
        final PathAnnotation pathAnnotation = resourceFn.getPathAnnotation();
        final AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute(null, SPECIFICITY_METRIC, "", "string", Long.toString(pathAnnotation.getPathSpecificityMetric()));
        builder.startElement(QName.fromJavaQName(pathAnnotation.getName()), attrs);
        final String[] segments = pathAnnotation.getLiterals()[0].getValue().split("/");
        for (final String segment : segments) {
            if (!segment.isEmpty()) {
                builder.startElement(SEGMENT, null);
                builder.characters(segment);
                builder.endElement();
            }
        }
        builder.endElement();
    }
    // parameter annotations
    for (final ParameterAnnotation parameterAnnotation : resourceFn.getParameterAnnotations()) {
        final Literal[] literals = parameterAnnotation.getLiterals();
        final AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute(null, NAME, "", "string", literals[0].getValue());
        attrs.addAttribute(null, ARGUMENT, "", "string", literals[1].getValue());
        if (literals.length == 3) {
            attrs.addAttribute(null, DEFAULT_VALUE, "", "string", literals[2].getValue());
        }
        builder.startElement(QName.fromJavaQName(parameterAnnotation.getName()), attrs);
        builder.endElement();
    }
    // serialization annotations
    for (final SerializationAnnotation serializationAnnotation : resourceFn.getSerializationAnnotations()) {
        serializeSerializationAnnotation(builder, serializationAnnotation);
    }
}
Also used : ArrayList(java.util.ArrayList) SerializationAnnotation(org.exquery.serialization.annotation.SerializationAnnotation) Annotation(org.exquery.xquery3.Annotation) AbstractYesNoSerializationAnnotation(org.exquery.serialization.annotation.AbstractYesNoSerializationAnnotation) MethodAnnotation(org.exquery.serialization.annotation.MethodAnnotation) SerializationAnnotation(org.exquery.serialization.annotation.SerializationAnnotation) AbstractYesNoSerializationAnnotation(org.exquery.serialization.annotation.AbstractYesNoSerializationAnnotation) AttributesImpl(org.xml.sax.helpers.AttributesImpl) Literal(org.exquery.xquery.Literal)

Example 17 with Annotation

use of org.exquery.xquery3.Annotation in project libSBOLj by SynBioDex.

the class AnnotationTest method test_toString.

@Test
public void test_toString() throws SBOLValidationException {
    Annotation CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), true);
    // System.out.println(CD_annot.toString());
    assertTrue(CD_annot.toString().contains("value=" + true));
}
Also used : QName(javax.xml.namespace.QName) Annotation(org.sbolstandard.core2.Annotation) Test(org.junit.Test)

Example 18 with Annotation

use of org.exquery.xquery3.Annotation in project libSBOLj by SynBioDex.

the class AnnotationOutput method main.

public static void main(String[] args) throws Exception {
    String prURI = "http://partsregistry.org/";
    String prPrefix = "pr";
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(prURI);
    document.setTypesInURIs(true);
    document.addNamespace(URI.create(prURI), prPrefix);
    ComponentDefinition promoter = document.createComponentDefinition("BBa_J23119", "", new HashSet<URI>(Arrays.asList(URI.create("http://www.biopax.org/release/biopax-level3.owl#DnaRegion"))));
    promoter.addRole(SequenceOntology.PROMOTER);
    promoter.setName("J23119");
    promoter.setDescription("Constitutive promoter");
    promoter.createAnnotation(new QName(prURI, "group", prPrefix), "iGEM2006_Berkeley");
    promoter.createAnnotation(new QName(prURI, "experience", prPrefix), URI.create("http://parts.igem.org/cgi/partsdb/part_info.cgi?part_name=BBa_J23119"));
    Annotation sigmaFactor = new Annotation(QName(prURI, "sigmafactor", prPrefix), "//rnap/prokaryote/ecoli/sigma70");
    Annotation regulation = new Annotation(QName(prURI, "regulation", prPrefix), "//regulation/constitutive");
    promoter.createAnnotation(new QName(prURI, "information", prPrefix), new QName(prURI, "Information", prPrefix), "information", new ArrayList<Annotation>(Arrays.asList(sigmaFactor, regulation)));
    SBOLWriter.write(document, (System.out));
}
Also used : QName(javax.xml.namespace.QName) SBOLDocument(org.sbolstandard.core2.SBOLDocument) URI(java.net.URI) Annotation(org.sbolstandard.core2.Annotation) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Aggregations

Annotation (zipkin2.Annotation)14 Map (java.util.Map)8 Test (org.junit.Test)5 Endpoint (zipkin2.Endpoint)5 ArrayList (java.util.ArrayList)4 Span (zipkin2.Span)4 LinkedHashMap (java.util.LinkedHashMap)3 TreeMap (java.util.TreeMap)3 QName (javax.xml.namespace.QName)3 Annotation (org.sbolstandard.core2.Annotation)3 JsonToken (com.fasterxml.jackson.core.JsonToken)2 JaegerSpan (io.jaegertracing.internal.JaegerSpan)2 IOException (java.io.IOException)2 URI (java.net.URI)2 List (java.util.List)2 Tracing (brave.Tracing)1 Platform (brave.internal.Platform)1 TraceContext (brave.propagation.TraceContext)1 TimeEvents (com.google.devtools.cloudtrace.v2.Span.TimeEvents)1 Timestamp (com.google.protobuf.Timestamp)1