private Graph getOrCreatePermisionGraph() { try { return tcManager.getMGraph(permissionGraphName); } catch (NoSuchEntityException e) { return tcManager.createGraph(permissionGraphName); } }
private LockableMGraph getDataGraph() { try { return tcm.getMGraph(DATA_GRAPH_URI); } catch (NoSuchEntityException e) { return tcm.createMGraph(DATA_GRAPH_URI); } }
@BeforeClass public static final void initYard() { initTestData(); // create the graphs in Clerezza tcManager = TcManager.getInstance(); MGraph graph = tcManager.createMGraph(READ_WRITEGRAPH_URI); // add the test data to the MGrpah for (TripleCollection tc : entityData.values()) { graph.addAll(tc); } // create the read only graph tcManager.createGraph(READ_ONLY_GRAPH_URI, graph); // init the ClerezzaYards for the created Clerezza graphs ClerezzaYardConfig readWriteConfig = new ClerezzaYardConfig("readWriteYardId"); readWriteConfig.setName("Clerezza read/write Yard"); readWriteConfig.setDescription("Tests config with pre-existing MGraph"); readWriteConfig.setGraphUri(READ_WRITEGRAPH_URI); readwriteYard = new ClerezzaYard(readWriteConfig); ClerezzaYardConfig readOnlyYardConfig = new ClerezzaYardConfig("readOnlyYardId"); readOnlyYardConfig.setName("Clerezza read-only Yard"); readOnlyYardConfig.setDescription("Tests config with pre-existing Graph"); readOnlyYardConfig.setGraphUri(READ_ONLY_GRAPH_URI); readonlyYard = new ClerezzaYard(readOnlyYardConfig); }
private static MGraph createClerezzaModel() { TcManager manager = TcManager.getInstance(); UriRef graphUri = new UriRef(HTTP_EXAMPLE_COM); if (manager.listMGraphs().contains(graphUri)) { manager.deleteTripleCollection(graphUri); } return manager.createMGraph(graphUri); }
private Collection<String> getRequiredPermissionStrings(final IRI GraphUri, IRI property) { try { final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName); Lock l = permissionMGraph.getLock().readLock(); l.lock(); try { Triple t = permissionMGraph.filter(GraphUri, property, null).next(); BlankNodeOrIRI list = (BlankNodeOrIRI) t.getObject(); LinkedList<String> result = new LinkedList<String>(); readList(list, permissionMGraph, result); return result; } catch (NoSuchElementException e) { return new ArrayList<String>(0); } finally { l.unlock(); } } catch (NoSuchEntityException e) { return new ArrayList<String>(0); } }
@AfterClass public static void cleanup() { tcManager.deleteTripleCollection(READ_ONLY_GRAPH_URI); tcManager.deleteTripleCollection(READ_WRITEGRAPH_URI); }