Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Node


   * @param triple
   * @param nodeMap
   * @return
   */
  private static Triple getLabelableTriple(Triple triple, Map<Node, LabelableNode> nodeMap) {
    Node subject = getLabelableNode(triple.getSubject(), nodeMap);
    Node object = getLabelableNode(triple.getObject(), nodeMap);
    TripleImpl result = new TripleImpl(subject, triple.getPredicate(), object);
    return null;
  }
View Full Code Here


   */
  private static void deleteStatementsWith(Graph graph, Node resource) {
    Iterator stmtIter = graph.iterator();
      while (stmtIter.hasNext()) {
        Triple statement = (Triple) stmtIter.next();
        Node subject = statement.getSubject();
        if (resource.equals(subject)) {
          stmtIter.remove();
          continue;
        }
        Node object = statement.getObject();
        if (resource.equals(object)) {
          stmtIter.remove();
          continue;
        }

View Full Code Here

   * @return
   */
  private static Triple replaceInStmt(Triple statement, Node n1,
      Node n2) {

    Node subject = statement.getSubject();
    if ((subject.equals(n1))) {
      subject = (Node) n2;
    }
    Node object = statement.getObject();
    if ((object.equals(n1))) {
      object = n2;
    }
    return new TripleImpl(subject, statement.getPredicate(), object);
  }
View Full Code Here

   *
   * @see org.wymiwyg.rdf.graphs.fgnodes.impl.Naturalizer#naturalize(org.wymiwyg.rdf.graphs.fgnodes.FunctionallyGroundedNode,
   *      org.wymiwyg.rdf.graphs.Graph)
   */
  public Node naturalize(FunctionallyGroundedNode fgNode, Graph graph) {
    Node anonymousNode = new NodeImpl();
    graph.add(new TripleImpl(anonymousNode, new PropertyNodeImpl(
        MODELDIFF.functionallyGroundedIn.getURI()),
        getGroundedIn(fgNode)));
    return anonymousNode;
  }
View Full Code Here

        moleculePath.append(Util.createRandomString(8));
        moleculePath.append(".rdf");
        ZipEntry entry = new ZipEntry(moleculePath.toString());
        zipOut.putNextEntry(entry);
        Graph graph = new SimpleGraph();
        Node naturalNode = naturalizer.naturalize(fgNode, graph);
        Graph addition;
        try {
          addition = new GraphUtil<Graph>().replaceNode(molecule,
              fgNode, naturalNode, new SimpleGraph());
        } catch (SourceNodeNotFoundException e) {
View Full Code Here

public class FgNodeMergerTest {

  @Test
  public void simple() {
    SimpleGraph graph = new SimpleGraph();
    Node nanmedNode = new NamedNodeImpl("http://1.example.org/");
    graph.add(new TripleImpl(new NodeImpl(),
        new InverseFunctionalPropertyNodeImpl(
            "http://example.org/functional"), nanmedNode));
    Node fg2 = new NodeImpl();
    graph.add(new TripleImpl(fg2, new InverseFunctionalPropertyNodeImpl(
        "http://example.org/functional"), nanmedNode));
    graph.add(new TripleImpl(fg2, new InverseFunctionalPropertyNodeImpl(
        "http://example.org/f2"), new NamedNodeImpl(
        "http://2.example.org/")));
View Full Code Here

   */
  public AnonymizedGraph(Graph base) {
   
    for (Triple triple : base) {
      boolean modified = false;
      Node subject = triple.getSubject();
      if (subject instanceof NamedNode) {
        subject = getReplacement((NamedNode)subject);
        modified = true;
      }
      Node object = triple.getObject();
      if (object instanceof NamedNode) {
        object = getReplacement((NamedNode)object);
        modified = true;
      }
      if (modified) {
View Full Code Here

  /**
   * @param node
   * @return
   */
  private Node getReplacement(NamedNode namedResource) {
    Node replacement = replaceMap.get(namedResource);
    if (replacement == null) {
      replacement = new NodeImpl();
      replaceMap.put(namedResource, replacement);
    }
    return replacement;
View Full Code Here

   */
  public DeAnonymizedGraph(Graph base) {
    Set<Triple> nonMappingTriples = prepareMappingTable(base);
    for (Triple triple : nonMappingTriples) {
      boolean modified = false;
      Node subject = triple.getSubject();
      NamedNodeAlternatives subjectReplacementAlt = replaceMap.get(subject);
      if (subjectReplacementAlt != null) {
        subject = subjectReplacementAlt.getCanonical();
        modified = true;
      }
      Node object = triple.getObject();
      NamedNodeAlternatives objectReplacementAlt = replaceMap.get(object);
      if (objectReplacementAlt != null) {
        object = objectReplacementAlt.getCanonical();
        modified = true;
      }
View Full Code Here

  private Set<Triple> prepareMappingTable(Graph base) {
    Set<Triple> result = new HashSet<Triple>();
    for (Triple triple : base) {
      if (triple.getPredicate().equals(nameProp)) {
        NamedNode namedNode = new NamedNodeImpl(((TypedLiteralNode)triple.getObject()).getLexicalForm());
        Node subject = triple.getSubject();
        NamedNodeAlternatives namedNodeAlternatives = replaceMap.get(subject);
        if (namedNodeAlternatives == null) {
          namedNodeAlternatives = new NamedNodeAlternatives(namedNode);
          replaceMap.put(subject, namedNodeAlternatives);
        } else {
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.