private CloseableIteration<? extends Statement, SailException> difference( CloseableIteration<? extends Statement, SailException> result, final Model excluded) { if (excluded.isEmpty()) { return result; } return new FilterIteration<Statement, SailException>(result) { protected boolean accept(Statement stmt) { return !excluded.contains(stmt); } }; }
private boolean conflicts(Model added, Model removed, OptimisticSail sail) { try { for (EvaluateOperation op : evaluateOps) { if (!added.isEmpty() && sail.effects(added, op)) return true; if (!removed.isEmpty() && sail.effects(removed, op)) return true; } return false; } catch (SailException e) { logger.error(e.toString(), e); return true; } }
private synchronized Model open(Model filtered) { Model model; if (additional == null) { model = new MemoryOverflowModel(filtered); } else { model = filtered; } if (model.isEmpty()) return new LinkedHashModel(); return model; }
synchronized void prepare(OptimisticConnection prepared) throws InterruptedException, SailException { while (preparedLock != null && preparedLock.isActive()) { wait(); } assert transactions.containsKey(prepared); preparedLock = preparing.getWriteLock(); this.prepared = prepared; synchronized (prepared) { Model added = prepared.getAddedModel(); Model removed = prepared.getRemovedModel(); if (added.isEmpty() && removed.isEmpty()) return; for (OptimisticConnection con : transactions.keySet()) { if (con == prepared) continue; con.changed(added, removed); } } }
/** * method to find the triplesmap node referenced in a parent join condition * * @param myModel * - the Model of mappings * @param predobjNode * - the pred obj node containing the join condition * @return the Resource node refferred to in the condition */ public Resource getReferencedTripleMap(Model myModel, Resource predobjNode) { // process OBJECTMAP Model m = myModel.filter(predobjNode, R2RMLVocabulary.objectMap, null); if (!m.isEmpty()) { Resource object = m.objectResource(); // look for parentTriplesMap declaration m = myModel.filter(object, R2RMLVocabulary.parentTriplesMap, null); if (!m.isEmpty()) { return m.objectResource(); } } return null; }
private CloseableIteration<? extends Statement, SailException> union( CloseableIteration<? extends Statement, SailException> result, Model included) { if (included.isEmpty()) { return result; } final Iterator<Statement> iter = included.iterator(); CloseableIteration<Statement, SailException> incl; incl = new CloseableIteratorIteration<Statement, SailException>(iter); return new UnionIteration<Statement, SailException>(incl, result); }
/** * Checks this change to see if it is inconsistent with the observed state * of the store. */ void changed(Model added, Model removed) throws SailException { synchronized (observations) { for (EvaluateOperation op : observations) { if (!added.isEmpty() && sail.effects(added, op)) { ConcurrencyException inc = inconsistency(op); changes.add(new InconsistentChange(added, removed, inc)); break; } else if (!removed.isEmpty() && sail.effects(removed, op)) { ConcurrencyException inc = inconsistency(op); changes.add(new InconsistentChange(added, removed, inc)); break; } } } }
/** * method to get the parent column in a join condition * * @param myModel * - the Model of mappings * @param predobjNode * - the pred obj node containing the join condition * @return the parent column condition as a string */ public String getParentColumn(Model myModel, Resource predobjNode) { // process OBJECTMAP Model m = myModel.filter(predobjNode, R2RMLVocabulary.objectMap, null); if (!m.isEmpty()) { Resource object = m.objectResource(); // look for joincondition declaration m = myModel.filter(object, R2RMLVocabulary.joinCondition, null); if (!m.isEmpty()) { Resource objectt = m.objectResource(); // look for parent declaration m = myModel.filter(objectt, R2RMLVocabulary.parent, null); if (!m.isEmpty()) { return trimTo1(m.objectString()); } } } return null; }
/** * method to get the child column in a join condition * * @param myModel * - the Model of mappings * @param predobjNode * - the pred obj node containing the join condition * @return the child column condition as a string */ public String getChildColumn(Model myModel, Resource predobjNode) { // process OBJECTMAP Model m = myModel.filter(predobjNode, R2RMLVocabulary.objectMap, null); if (!m.isEmpty()) { Resource object = m.objectResource(); // look for joincondition declaration m = myModel.filter(object, R2RMLVocabulary.joinCondition, null); if (!m.isEmpty()) { Resource objectt = m.objectResource(); // look for child declaration m = myModel.filter(objectt, R2RMLVocabulary.child, null); if (!m.isEmpty()) { return trimTo1(m.objectString()); } } } return null; }
for (final Value obj : this.valueComparator.sortedCopy(model.filter(node, pred, null) .objects())) { if (obj instanceof Literal || model.filter((Resource) obj, null, null).isEmpty()) { out.append(separator); renderObject(out, obj, model);
/** * Searches for observations that observed a subsequent state change of the store */ private ConcurrencyException detectPhantomRead(LinkedList<InconsistentChange> changes) throws SailException { for (InconsistentChange cs : changes) { Model added = cs.getAdded(); Model removed = cs.getRemoved(); for (EvaluateOperation op : cs.getSubsequentObservations()) { if (!added.isEmpty() && sail.effects(added, op)) { return phantom(op, cs.getInconsistency()); } if (!removed.isEmpty() && sail.effects(removed, op)) { return phantom(op, cs.getInconsistency()); } } } return null; }
if (!mentionModel.isEmpty()) { renderProperties(out, mentionModel, mentionID, false);
private void assertModel(final Model parseTsv) { Assert.assertFalse(parseTsv.isEmpty()); Assert.assertEquals(4, parseTsv.subjects().size()); Assert.assertEquals(6, parseTsv.predicates().size()); Assert.assertEquals(9, parseTsv.objects().size()); }
@Test public void testSES2104ConstructBGPSameURI() throws Exception { final String queryStr = "PREFIX : <urn:> CONSTRUCT {:x :p :x } WHERE {} "; conn.add(new StringReader("@prefix : <urn:> . :a :p :b . "), "", RDFFormat.TURTLE); final IRI x = conn.getValueFactory().createIRI("urn:x"); final IRI p = conn.getValueFactory().createIRI("urn:p"); GraphQuery query = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryStr); Model result = QueryResults.asModel(query.evaluate()); assertNotNull(result); assertFalse(result.isEmpty()); assertTrue(result.contains(x, p, x)); }
protected final Representation store(RepositoryConnection con, Representation representation,boolean allowCreate,boolean canNotCreateIsError) throws IllegalArgumentException, RepositoryException { if(representation == null) { return null; } log.debug("store Representation " + representation.getId()); URI subject = sesameFactory.createURI(representation.getId()); boolean contains = con.hasStatement(subject, null, null, includeInferred, contexts); con.remove(subject, null, null, contexts); if(!contains && !allowCreate){ if(canNotCreateIsError) { throw new IllegalArgumentException("Parsed Representation "+representation.getId()+" in not managed by this Yard "+getName()+"(id="+getId()+")"); } else { return null; } } //get the graph for the Representation and add it to the store RdfRepresentation toAdd = valueFactory.toRdfRepresentation(representation); if(toAdd.getModel().isEmpty()){ con.add(toAdd.getURI(),managedRepresentation,managedRepresentationState, contexts); } else { con.add(toAdd.getModel(), contexts); } return toAdd; }
@Override public void meet(StatementPattern sp) throws RuntimeException { super.meet(sp); ExternalModel externalR = new ExternalModel(sp, dataset, additional); ExternalModel externalA = new ExternalModel(sp, dataset, additional); Model minus = open(externalR.filter(removed, bindings)); Model union = open(externalA.filter(added, bindings)); TupleExpr node = sp; if (!minus.isEmpty()) { modified = true; externalR.setModel(minus); if (sp.getContextVar() == null) { // difference must compare context, but only works if non-null sp.setContextVar(newVar()); } Difference rpl = new Difference(node.clone(), externalR); node.replaceWith(rpl); node = rpl; } if (!union.isEmpty()) { modified = true; externalA.setModel(union); Union rpl = new Union(externalA, node.clone()); node.replaceWith(rpl); node = rpl; } }
if (!sup.equals(res) && !ds.match(sup, OWL.ONPROPERTY, prop).isEmpty()) { for (Value from : ds.match(sup, OWL.ALLVALUESFROM, null).objects()) { ds.add(node, RDFS.SUBCLASSOF, from);
if (!sup.equals(res) && !ds.match(sup, OWL.ONPROPERTY, prop).isEmpty()) { for (Value from : ds.match(sup, OWL.ALLVALUESFROM, null).objects()) { ds.add(node, RDFS.SUBCLASSOF, from);