xdi2.core.Graph.close()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中xdi2.core.Graph.close()方法的一些代码示例,展示了Graph.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.close()方法的具体详情如下:
包路径:xdi2.core.Graph
类名称:Graph
方法名:close

Graph.close介绍

[英]Closes the graph. This should be called when work on the graph is done.
[中]关闭图形。当图形上的工作完成时,应调用此函数。

代码示例

代码示例来源:origin: projectdanube/xdi2

@Override
public void shutdown() throws Exception {
  super.shutdown();
  this.graph.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testManipulateAndReopenGraph() throws Exception {
  if (! this.supportsPersistence()) return;
  Graph graph9 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-9");
  makeGraph(graph9);
  graph9.close();
  graph9 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-9");
  manipulateGraph(graph9);
  graph9.close();
  graph9 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-9");
  testManipulatedGraph(graph9);
  graph9.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testReopenGraph() throws Exception {
  if (! this.supportsPersistence()) return;
  Graph graph2 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-2");
  makeGraph(graph2);
  graph2.close();
  graph2 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-2");
  testGraph(graph2);
  graph2.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testMakeGraph() throws Exception {
  Graph graph1 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-1");
  makeGraph(graph1);
  testGraph(graph1);
  graph1.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testManipulate() throws Exception {
  Graph graph8 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-8");
  makeGraph(graph8);
  manipulateGraph(graph8);
  testManipulatedGraph(graph8);
  graph8.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testReadJson() throws Exception {
  Graph graph3 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-3");
  XDIReader reader = XDIReaderRegistry.forFormat("XDI/JSON", null);
  reader.read(graph3, AbstractGraphTest.class.getResourceAsStream("test.json")).close();
  testGraph(graph3);
  graph3.getRootContextNode().clear();
  assertTrue(graph3.isEmpty());
  graph3.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testGetOwnerXDIAddress() throws Exception {
  
  Graph graph = MemoryGraphFactory.getInstance().parseGraph(TEST_GRAPH_DEREFERENCE);
  assertEquals(GraphUtil.getOwnerPeerRootXDIArc(graph), XDIArc.fromComponent(TEST_CONTEXTNODE_1111));
  
  graph.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testTimestampsOnContextNode() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    ContextNode contextNode = graph.getRootContextNode().setContextNode(XDIArc.create("=markus"));

    GregorianCalendar calendar = new GregorianCalendar(2010, 11, 22, 11, 22, 33);
    calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date timestamp = calendar.getTime();

    Timestamps.setTimestamp(XdiAbstractContext.fromContextNode(contextNode), timestamp);
    assertEquals(timestamp, Timestamps.getTimestamp(XdiAbstractContext.fromContextNode(contextNode)));

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testPeerRoots() throws Exception {
  Graph graph = MemoryGraphFactory.getInstance().openGraph();
  assertEquals(XdiCommonRoot.findCommonRoot(graph).getPeerRoot(XDIAddress.create("=!1111"), true).getContextNode().getXDIAddress(), XDIArc.create("(=!1111)"));
  
  graph.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testDeleteCyclicRelation() throws Exception {
  Graph graph31 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-31");
  graph31.setStatement(XDIStatement.create("=a=b=c=d=e/+x/=a=b=c"));
  graph31.setStatement(XDIStatement.create("=m=n=o/+y/=a=b=c=d"));
  graph31.getDeepContextNode(XDIAddress.create("=a=b")).delete();
  assertEquals(graph31.getRootContextNode().getAllContextNodeCount(), 4);
  assertEquals(graph31.getRootContextNode().getAllRelationCount(), 0);
  assertEquals(graph31.getRootContextNode().getAllStatementCount(), 4);
  graph31.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testNoExceptions() throws Exception {
  Graph graph17 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-17");
  graph17.setStatement(XDIStatement.create("=markus<#email>/&/\"Markus Sabadello\""));
  graph17.setStatement(XDIStatement.create("=markus/#friend/=neustar=les"));
  ContextNode root = graph17.getRootContextNode();
  ContextNode markus = graph17.getDeepContextNode(XDIAddress.create("=markus"));
  ContextNode les = graph17.getDeepContextNode(XDIAddress.create("=neustar=les"));
  root.setContextNode(XDIArc.create("=markus"));
  markus.setDeepContextNode(XDIAddress.create("<#email>")).setLiteralNode("test");
  markus.setRelation(XDIAddress.create("#friend"), les);
  graph17.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testNormalizedSerialization() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    graph.setStatement(XDIStatement.create("=markus<#email>/&/\"markus@projectdanube.org\""));
    graph.setStatement(XDIStatement.create("=markus/#friend/=animesh"));

    ContextNode contextNode = graph.getDeepContextNode(XDIAddress.create("=markus"));

    String normalizedSerialization = "{\"/\":[\"=animesh\",\"=markus\"],\"=markus/\":[\"<#email>\"],\"=markus/#friend\":[\"=animesh\"],\"=markus<#email>/&\":\"markus@projectdanube.org\"}";

    assertEquals(Normalization.serialize(contextNode, null), normalizedSerialization);

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testCommonRoot() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();

    assertEquals(XdiCommonRoot.findCommonRoot(graph).getContextNode(), graph.getRootContextNode());
    assertEquals(XdiCommonRoot.findCommonRoot(graph).getContextNode().getXDIAddress(), XDIConstants.XDI_ADD_ROOT);

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testOwnsPeerRootXDIArc() throws Exception {
    
    Graph graph = MemoryGraphFactory.getInstance().parseGraph(TEST_GRAPH_DEREFERENCE);

    assertTrue(GraphUtil.ownsPeerRootXDIArc(graph, XDIArc.fromComponent(TEST_CONTEXTNODE_1111)));
    assertTrue(GraphUtil.ownsPeerRootXDIArc(graph, XDIArc.fromComponent(TEST_CONTEXTNODE_1a1a)));
    assertTrue(GraphUtil.ownsPeerRootXDIArc(graph, XDIArc.fromComponent(TEST_CONTEXTNODE_1b1b)));
    
    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testDeleteDeep() throws Exception {
  Graph graph12 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-12");
  assertEquals(graph12.getRootContextNode(), graph12.getDeepContextNode(XDIConstants.XDI_ADD_ROOT));
  assertEquals(graph12.getRootContextNode().getXDIAddress(), XDIConstants.XDI_ADD_ROOT);
  graph12.setDeepContextNode(XDIAddress.create("=markus")).setRelation(XDIAddress.create("#friend"), XDIAddress.create("=someone"));
  graph12.getDeepContextNode(XDIAddress.create("=markus")).delete();
  graph12.setDeepContextNode(XDIAddress.create("=markus"));
  assertNull(graph12.getDeepContextNode(XDIAddress.create("=markus")).getRelation(XDIAddress.create("#friend")));
  graph12.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testSubGraph() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot localRoot = XdiCommonRoot.findCommonRoot(graph);
    XdiPeerRoot peerRoot = localRoot.getPeerRoot(XDIAddress.create("=!:uuid:91f28153-f600-ae24-91f2-8153f600ae24"), true);
    XdiInnerRoot innerRoot = peerRoot.getInnerRoot(XDIAddress.create("=!1111"), XDIAddress.create("$add"), true);
    
    assertTrue(XdiAbstractContext.fromContextNode(localRoot.getContextNode()) instanceof XdiCommonRoot);
    assertTrue(XdiAbstractContext.fromContextNode(peerRoot.getContextNode()) instanceof XdiPeerRoot);
    assertTrue(XdiAbstractContext.fromContextNode(innerRoot.getContextNode()) instanceof XdiInnerRoot);
    
    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testSelfPeerRoots() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot.findCommonRoot(graph).setSelfPeerRoot(XDIAddress.create("=!1111"));

    XdiPeerRoot selfPeerRoot = XdiCommonRoot.findCommonRoot(graph).getSelfPeerRoot();

    assertEquals(selfPeerRoot.getContextNode().getXDIAddress(), XDIAddress.create("(=!1111)"));
    assertEquals(XdiCommonRoot.findCommonRoot(graph).getPeerRoot(XDIAddress.create("=!1111"), false), selfPeerRoot);
    assertTrue(selfPeerRoot.isSelfPeerRoot());

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testLinkContractTemplate() throws Exception {
  XDIAddress XDIaddress = XDIAddress.create("=markus#registration{$contract}");
  Graph graph = MemoryGraphFactory.getInstance().openGraph();
  ContextNode contextNode = graph.setDeepContextNode(XDIaddress);
  LinkContractTemplate l1 = LinkContractTemplate.findLinkContractTemplate(graph, XDIAddress.create("=markus#registration"), false);
  assertNotNull(l1);
  assertEquals(l1.getTemplateAuthorityAndId(), XDIAddress.create("=markus#registration"));
  LinkContractTemplate l2 = LinkContractTemplate.fromXdiEntitySingletonVariable(XdiEntitySingleton.Variable.fromContextNode(contextNode));
  assertNotNull(l2);
  assertEquals(l2.getTemplateAuthorityAndId(), XDIAddress.create("=markus#registration"));
  assertEquals(l1, l2);
  graph.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testLinkContracts() throws Exception {
  Graph graph = MemoryGraphFactory.getInstance().openGraph();
  ContextNode contextNode1 = graph.setDeepContextNode(XDIAddress.create("(=alice/$public)$contract"));
  ContextNode contextNode2 = graph.setDeepContextNode(XDIAddress.create("(=alice/=alice)$contract"));
  assertTrue(LinkContract.isValid(XdiAbstractEntity.fromContextNode(contextNode1)));
  assertTrue(LinkContract.isValid(XdiAbstractEntity.fromContextNode(contextNode2)));
  LinkContract linkContract1 = LinkContract.fromXdiEntity(XdiAbstractEntity.fromContextNode(contextNode1));
  LinkContract linkContract2 = LinkContract.fromXdiEntity(XdiAbstractEntity.fromContextNode(contextNode2));
  assertTrue(new IteratorContains<LinkContract> (LinkContracts.getAllLinkContracts(graph), linkContract1).contains());
  assertTrue(new IteratorContains<LinkContract> (LinkContracts.getAllLinkContracts(graph), linkContract2).contains());
  graph.close();
}

代码示例来源:origin: projectdanube/xdi2

public void testConnectLinkContract() throws Exception {
  Graph graph = MemoryGraphFactory.getInstance().openGraph();
  GraphUtil.setOwnerXDIAddress(graph, XDIAddress.create("=markus"));
  assertEquals(GraphUtil.getOwnerXDIAddress(graph), XDIAddress.create("=markus"));
  ConnectLinkContract l = ConnectLinkContract.findConnectLinkContract(graph, true);
  assertNotNull(l);
  assertEquals(l.getXdiEntity().getXDIAddress(), XDIAddress.create("(=markus/$connect)$contract"));
  assertNotNull(ConnectLinkContract.findConnectLinkContract(graph, false));
  assertTrue(LinkContract.fromXdiEntity(l.getXdiEntity()) instanceof ConnectLinkContract);
  assertEquals(l.getRequestingAuthority(), XDILinkContractConstants.XDI_ADD_CONNECT);
  assertEquals(l.getAuthorizingAuthority(), XDIAddress.create("=markus"));
  assertNull(l.getTemplateAuthorityAndId());
  graph.close();
}

相关文章