Examples of RDFResource


Examples of org.joggito.annotations.RDFResource

  /**
   * Resolves the full URI by concatenating namespace (from @RDFResource
   * annotation on the owner class) and the given local name.
   */
  private String resolveFromLocalName(String uriExp, Class<?> beanCls) {
    RDFResource annRsc = beanCls.getAnnotation(RDFResource.class);
    String ns = ResourceFactory.createResource(annRsc.uri())
        .getNameSpace();
    return ns.concat(uriExp.replace("#", ""));
  }
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

                continue;
            }
            writer.writeStartElement(triple.getPredicate().getIRI());
            RDFNode objectNode = triple.getObject();
            if (!objectNode.isLiteral()) {
                RDFResource objectRes = (RDFResource) objectNode;
                if (objectRes.isAnonymous()) {
                    // Special rendering for lists
                    if (isObjectList(objectRes)) {
                        writer.writeParseTypeAttribute();
                        List<RDFNode> list = new ArrayList<>();
                        toJavaList(objectRes, list);
                        for (RDFNode n : list) {
                            if (n.isAnonymous()) {
                                render((RDFResourceBlankNode) n);
                            } else {
                                if (n.isLiteral()) {
                                    RDFLiteral litNode = (RDFLiteral) n;
                                    writer.writeStartElement(RDFS_LITERAL
                                            .getIRI());
                                    if (!litNode.isPlainLiteral()) {
                                        writer.writeDatatypeAttribute(litNode
                                                .getDatatype());
                                    } else if (litNode.hasLang()) {
                                        writer.writeLangAttribute(litNode
                                                .getLang());
                                    }
                                    writer.writeTextContent(litNode
                                            .getLexicalValue());
                                    writer.writeEndElement();
                                } else {
                                    writer.writeStartElement(RDF_DESCRIPTION
                                            .getIRI());
                                    writer.writeAboutAttribute(n.getIRI());
                                    writer.writeEndElement();
                                }
                            }
                        }
                    } else {
                        render(objectRes);
                    }
                } else {
                    writer.writeResourceAttribute(objectRes.getIRI());
                }
            } else {
                RDFLiteral rdfLiteralNode = (RDFLiteral) objectNode;
                if (!rdfLiteralNode.isPlainLiteral()) {
                    writer.writeDatatypeAttribute(rdfLiteralNode.getDatatype());
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

     */
    @Nonnull
    public <E extends OWLEntity> E generateAndLogParseError(
            @Nonnull EntityType<E> entityType, @Nonnull IRI mainNode) {
        E entity = getErrorEntity(entityType);
        RDFResource mainNodeResource = getRDFResource(mainNode);
        Set<RDFTriple> mainNodeTriples = getTriplesForMainNode(mainNode);
        RDFResourceParseError error = new RDFResourceParseError(entity,
                mainNodeResource, mainNodeTriples);
        logError(error);
        return entity;
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

            triples = Collections.emptyList();
        } else {
            triples = graph.getTriplesForSubject(node, true);
        }
        pending.add(node);
        RDFResource lastSubject = null;
        RDFResourceIRI lastPredicate = null;
        boolean first = true;
        for (RDFTriple triple : triples) {
            RDFResource subj = triple.getSubject();
            RDFResourceIRI pred = triple.getPredicate();
            if (lastSubject != null
                    && (subj.equals(lastSubject) || subj.isAnonymous())) {
                if (lastPredicate != null && pred.equals(lastPredicate)) {
                    // Only the object differs from previous triple
                    // Just write the object
                    write(" ,");
                    writeNewLine();
                    write(triple.getObject());
                } else {
                    // The predicate, object differ from previous triple
                    // Just write the predicate and object
                    write(" ;");
                    popTab();
                    if (!subj.isAnonymous()) {
                        writeNewLine();
                    }
                    writeNewLine();
                    write(triple.getPredicate());
                    write(" ");
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

    }

    protected void renderOntologyHeader() throws IOException {
        graph = new RDFGraph();
        OWLOntologyID ontID = ontology.getOntologyID();
        RDFResource ontologyHeaderNode = createOntologyHeaderNode();
        addVersionIRIToOntologyHeader(ontologyHeaderNode);
        addImportsDeclarationsToOntologyHeader(ontologyHeaderNode);
        addAnnotationsToOntologyHeader(ontologyHeaderNode);
        if (!ontID.isAnonymous() || !graph.isEmpty()) {
            graph.addTriple(new RDFTriple(ontologyHeaderNode,
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

        }
    }


    private RDFResource getRDFResource(IRI iri) {
        return new RDFResource(iri, isAnonymousNode(iri));
    }
View Full Code Here

Examples of org.semanticweb.owlapi.io.RDFResource

        ontologyFormat.addError(error);
    }

    private <E extends OWLEntity> E generateAndLogParseError(EntityType<E> entityType, IRI mainNode) {
        E entity = getErrorEntity(entityType);
        RDFResource mainNodeResource = getRDFResource(mainNode);
        Set<RDFTriple> mainNodeTriples = getTriplesForMainNode(mainNode);
        RDFResourceParseError error = new RDFResourceParseError(entity, mainNodeResource, mainNodeTriples);
        logError(error);
        return entity;
    }
View Full Code Here

Examples of org.wikier.trioo.jtrioo.annotations.RdfResource

  }
     
  @SuppressWarnings("rawtypes")
  public static RDFMetaResource getRDFMetaResource(Class resourceClass) throws NotRegistrableRDFClassException {
    AnnotatedElement annotatedClass = (AnnotatedElement) resourceClass;
    RdfResource classResource = annotatedClass.getAnnotation(RdfResource.class);
    if (classResource == null) {
      throw new NotRegistrableRDFClassException(resourceClass.getCanonicalName());
    }
   
    RDFMetaResource resource = new RDFMetaResource(resourceClass);
   
    //URI
    try {
      MetaURI metauri = new MetaURI(resourceClass);
      resource.setMetaURI(metauri);
    } catch (IllegalArgumentException e) {
      logger.error("Invalid URI definition for " + resourceClass.getCanonicalName() + ", so resources of this class will be blank nodes: " + e);
    }
   
    //rdf:type
    resource.setRdfType(classResource.rdftype());
   
    //properties on fields
    for (Field field : resourceClass.getDeclaredFields()) {
      AnnotatedElement annotatedElement = (AnnotatedElement) field;
      RdfProperty propertyResource = annotatedElement.getAnnotation(RdfProperty.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.