Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Node


      T tripleSet, Node source, Node target, C result)
      throws SourceNodeNotFoundException {
    boolean somethingChanged = false;
    for (Triple triple : tripleSet) {
      boolean tripleModified = false;
      Node subject = triple.getSubject();
      if (subject.equals(source)) {
        subject = target;
        tripleModified = true;
      }
      Node object = triple.getObject();
      if (object.equals(source)) {
        object = target;
        tripleModified = true;
      }
      if (tripleModified) {
        result
View Full Code Here


      throws SourceNodeNotFoundException {
    boolean somethingChanged = false;
    SimpleGraph result = new SimpleGraph();
    for (Triple triple : tripleSet) {
      boolean tripleModified = false;
      Node subject = triple.getSubject();
      if (sources.contains(subject)) {
        subject = target;
        tripleModified = true;
      }
      Node object = triple.getObject();
      if (sources.contains(object)) {
        object = target;
        tripleModified = true;
      }
      if (tripleModified) {
View Full Code Here

   * @param impl
   * @return
   */
  public static Triple replaceInTriple(Triple triple, Node origNode,
      Node replacementNode) {
    Node subject = triple.getSubject();
    Node object = triple.getObject();
    PropertyNode predicate = triple.getPredicate();
    if (subject.equals(origNode)) {
      subject = replacementNode;
    }
    if (object.equals(origNode)) {
      object = replacementNode;
    }
    return new TripleImpl(subject, predicate, object);
  }
View Full Code Here

      StmtIterator iter = jenaModel.listStatements();
      while (iter.hasNext()) {
        Statement current = iter.nextStatement();
       
        Resource jenaSubject = current.getSubject();
        Node subject = nodeFactory.getNonLiteralNode(jenaSubject);
        /*if (jenaSubject.isAnon()) {
          subject = new JenaReferenceNode(jenaSubject);
        } else {
          subject = new NamedNodeImpl(jenaSubject.getURI());
        }*/
        Property jenaProperty = current.getPredicate();
        PropertyNode predicate = nodeFactory.getPropertyNode(jenaProperty);
          //new PropertyNodeImpl(jenaProperty.getURI(), false, false);
        RDFNode jenaObject = current.getObject();
        Node object = nodeFactory.getNode(jenaObject);
        /*
        if (jenaObject instanceof Literal) {
          if (((Literal)jenaObject).getDatatype() == null)  {
            object = new PlainLiteralNodeImpl((Literal)jenaObject);
          } else {
View Full Code Here

private static void addGraphToModel(Graph graph, Model model) {
    AnonymousMapper mapper = new AnonymousMapper(model);
    // int i = 0;
    for (Iterator iter = graph.iterator(); iter.hasNext();) {
      Triple currentTriple = (Triple) iter.next();
      Node subject = currentTriple.getSubject();
      Resource targetSubject;
      if (subject instanceof NamedNode) {
        targetSubject = model.createResource(((NamedNode)subject).getURIRef());
      } else {
        targetSubject  = mapper.getResource(subject);
      }
      Property targetPredicate = model.createProperty(currentTriple.getPredicate().getURIRef());
      Node object = currentTriple.getObject();
      RDFNode targetObject;
      if (object instanceof GroundedNode) {
        if (object instanceof TypedLiteralNode) {
          TypedLiteralNode literal = (TypedLiteralNode)object;
          targetObject = model.createTypedLiteral(literal.getLexicalForm(),  TypeMapper.getInstance().getSafeTypeByName(literal.getDataType().toString()));
View Full Code Here

  }

  public static boolean isValidMapping(Map<Node, Node> mapping, Graph g1, Graph g2) {
    for (Iterator iter = g1.iterator(); iter.hasNext();) {
      Triple triple = (Triple) iter.next();
      Node subject = triple.getSubject();
      PropertyNode predicate = triple.getPredicate();
      Node object = triple.getObject();
      if (!(subject instanceof GroundedNode)) {
        subject = mapping.get(subject);
      }
      if (!(object instanceof GroundedNode)) {
        object = mapping.get(object);
View Full Code Here

  public static Graph applyMapping(Graph graph, Map mapping) {
    SimpleGraph result = new SimpleGraph();
    for (Iterator iter = graph.iterator(); iter.hasNext();) {
      Triple triple = (Triple) iter.next();
      Node subject = triple.getSubject();
      PropertyNode predicate = triple.getPredicate();
      Node object = triple.getObject();
      if (!(subject instanceof GroundedNode)) {
        subject = (Node) mapping.get(subject);
      }
      if (!(object instanceof GroundedNode)) {
        object = (Node) mapping.get(object);
View Full Code Here

  ContextGraph(Graph base) {
    Map<Node,ContextNode> map = new HashMap<Node,ContextNode>();
    for (Iterator iter = base.iterator(); iter.hasNext();) {
      Triple triple = (Triple) iter.next();
      Node subject = triple.getSubject();
      boolean subjectUbngn = !(subject instanceof GroundedNode);
      Node object = triple.getObject();
      boolean objectUbngn = !(object instanceof GroundedNode);
      ContextNode subjectContextNode = null;
      if (subjectUbngn) {
       
        subjectContextNode = map.get(subject);
View Full Code Here

TOP

Related Classes of org.wymiwyg.rdf.graphs.Node

Copyright © 2018 www.massapicom. 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.