Package org.wymiwyg.rdf.graphs.fgnodes.impl

Examples of org.wymiwyg.rdf.graphs.fgnodes.impl.FunctionallyGroundedNodeImpl


    };
  }

  private FunctionallyGroundedNode functionalyze(FunctionallyGroundedNode node) {
    FunctionallyGroundedNodeImpl result = new FunctionallyGroundedNodeImpl();
    for (NonTerminalMolecule molecule : node.getGroundingMolecules()) {
      result.addMolecule(functionalyze(molecule));
    }
    result.markFinalized();
    return result;
  }
View Full Code Here


      }
    }
  }

  private FunctionallyGroundedNode functionalyze(NamedNode node) {
    FunctionallyGroundedNodeImpl result = new FunctionallyGroundedNodeImpl();
    Node afgn = new NodeImpl();
    SimpleNonTerminalMolecule molecule = new SimpleNonTerminalMolecule(afgn);
    String uriString = node.getURIRef();
    LiteralNode uriLit = new TypedLiteralNodeImpl(uriString, anyURIDataType);
    Triple triple = new TripleImpl(afgn, nameProp, uriLit);
    molecule.add(triple);
    molecule.markFinalized();
    result.addMolecule(molecule);
    result.markFinalized();
    result.notifyAllFinalized();
    return result;
  }
View Full Code Here

  }
 
  private FunctionallyGroundedNode getFgNodeFromPathNode(ZipFile zipFile,
      PathNode pathNode, NamedNode describingResource) throws IOException {
    Node afgn = null;
    FunctionallyGroundedNodeImpl result = functionallyGroundedBuilder.createFGNode();
    descriptionPathToFgNode.put(describingResource, result);
    for (String moleculeNodeName : pathNode.list()) {
      PathNode moleculePathNode = pathNode.getSubPath(moleculeNodeName);
      Model model = ModelFactory.createDefaultModel();
      model
          .read(moleculePathNode.getInputStream(),
              ReferencingNaturalizer.rootURL
                  + moleculePathNode.getPath());
      /*
       * StmtIterator specialStmtIter = model.listStatements(null,
       * MODELDIFF.functionallyGroundedIn, (Resource)null); Statement
       * specialStmt = specialStmtIter.nextStatement();
       * specialStmtIter.close(); Resource groundedNodedRes =
       * specialStmt.getSubject(); specialStmt.remove();
       */
      Graph graph = JenaUtil.getGraphFromModel(model, false);
      Graph tripleSet = new SimpleGraph();
      Node currentAfgn = null;
      Map<Node, FunctionallyGroundedNode> innerReplacements = new HashMap<Node, FunctionallyGroundedNode>();
      for (Triple triple : graph) {
        if (triple.getPredicate().equals(
            new PropertyNodeImpl(MODELDIFF.functionallyGroundedIn
                .getURI()))) {
          Node subject = triple.getSubject();
          if (!describingResource.equals(triple.getObject())) {
            // throw new RuntimeException("invalid diff");
            // now legal as fg-nodes may reference to others in
            // their nt-molecules
            //infinite recursion by cache
            FunctionallyGroundedNode replacement = getFgNodeFromDescribingNode(zipFile,
                (NamedNode) triple.getObject());
            innerReplacements.put(subject, replacement);
           
          } else {
            currentAfgn = subject;
          }
        } else {
          tripleSet.add(triple);
        }
      }
      if (afgn == null) {
        afgn = currentAfgn;
      } else {
        tripleSet = replaceNode(currentAfgn, afgn, tripleSet);
      }
      for (Entry<Node, FunctionallyGroundedNode> entry : innerReplacements.entrySet()) {
        tripleSet = replaceNode(entry.getKey(), entry.getValue(), tripleSet);
      }
      NonTerminalMolecule ntMolecule = functionallyGroundedBuilder.createNTMolecule(afgn);
      ntMolecule.addAll(tripleSet);
      result.addMolecule(ntMolecule);
    }
   
    return result;
  }
View Full Code Here

TOP

Related Classes of org.wymiwyg.rdf.graphs.fgnodes.impl.FunctionallyGroundedNodeImpl

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.