本文整理汇总了Java中org.apache.jena.rdf.model.SimpleSelector类的典型用法代码示例。如果您正苦于以下问题:Java SimpleSelector类的具体用法?Java SimpleSelector怎么用?Java SimpleSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleSelector类属于org.apache.jena.rdf.model包,在下文中一共展示了SimpleSelector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteOutgoingEdges
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
public void deleteOutgoingEdges(final Collection<Resource> vertices, final String edgeType) throws IOException {
final Property property = model.getProperty(RdfConstants.BASE_PREFIX + edgeType);
for (final Resource vertex : vertices) {
final Selector selector = new SimpleSelector(vertex, property, (RDFNode) null);
final StmtIterator edges = model.listStatements(selector);
final List<Statement> statementsToRemove = new ArrayList<>();
while (edges.hasNext()) {
final Statement edge = edges.next();
statementsToRemove.add(edge);
}
for (final Statement statement : statementsToRemove) {
model.remove(statement);
}
}
}
示例2: activate
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
@Override
public void activate(final Collection<JenaPosLengthMatch> matches) throws IOException {
final Model model = driver.getModel();
final Property lengthProperty = model.getProperty(BASE_PREFIX + LENGTH);
for (final JenaPosLengthMatch match : matches) {
final Resource segment = match.getSegment();
final int length = match.getLength().getInt();
final int newLength = -length + 1;
final Selector selector = new SimpleSelector(segment, lengthProperty, (RDFNode) null);
final StmtIterator statementsToRemove = model.listStatements(selector);
if (statementsToRemove.hasNext()) {
final Statement oldStatement = statementsToRemove.next();
model.remove(oldStatement);
}
final Statement newStatement = model.createLiteralStatement(segment, lengthProperty, newLength);
model.add(newStatement);
}
}
示例3: activate
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
@Override
public void activate(final Collection<JenaPosLengthInjectMatch> matches) throws IOException {
final Model model = driver.getModel();
final Property lengthProperty = model.getProperty(BASE_PREFIX + LENGTH);
for (final JenaPosLengthInjectMatch match : matches) {
final Resource segment = match.getSegment();
final Selector selector = new SimpleSelector(segment, lengthProperty, (RDFNode) null);
final StmtIterator oldStatements = model.listStatements(selector);
if (!oldStatements.hasNext()) {
continue;
}
final Statement oldStatement = oldStatements.next();
model.remove(oldStatement);
final Statement newStatement = model.createLiteralStatement(segment, lengthProperty, 0);
model.add(newStatement);
}
}
示例4: getValue
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
/**
* getValue.
*
* @param model Model
* @param resourceProperty String
* @return retval
*/
private static ArrayList<RDFNode> getValue(final Model model, final String resourceProperty) {
final Property property = model.getProperty(resourceProperty);
final ArrayList<RDFNode> retval = new ArrayList<>();
final StmtIterator it =
model.listStatements(new SimpleSelector(null, property, (Resource) null));
while (it.hasNext()) {
final Statement st = it.next();
retval.add(st.getObject());
}
return retval;
}
示例5: getChilden
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
/**
* getChilden.
*
* @param model Model
* @return retval
*/
private static ArrayList<String> getChilden(final Model model) {
final String NS = "http://www.w3.org/ns/ldp#";
final Property ldpcontains = model.getProperty(NS + "contains");
final ArrayList<String> retval = new ArrayList<>();
final StmtIterator it =
model.listStatements(new SimpleSelector(null, ldpcontains, (Resource) null));
while (it.hasNext()) {
final Statement st = it.next();
retval.add(st.getObject().toString());
}
return retval;
}
示例6: getValue
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
/**
* getValue.
*
* @param model Model
* @param resourceProperty String
* @return retval
*/
private static ArrayList<Integer> getValue(final Model model, final String resourceProperty) {
final Property property = model.getProperty(resourceProperty);
final ArrayList<Integer> retval = new ArrayList<>();
final StmtIterator it =
model.listStatements(new SimpleSelector(null, property, (Resource) null));
while (it.hasNext()) {
final Statement st = it.next();
retval.add(st.getInt());
}
return retval;
}
示例7: getChilden
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
private static ArrayList<String> getChilden(final Model model) {
final String NS = "http://www.w3.org/ns/ldp#";
final Property ldpcontains = model.getProperty(NS + "contains");
final ArrayList<String> retval = new ArrayList<>();
final StmtIterator it =
model.listStatements(new SimpleSelector(null, ldpcontains, (Resource) null));
while (it.hasNext()) {
final Statement st = it.next();
retval.add(st.getObject().toString());
}
return retval;
}
示例8: activate
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
@Override
public void activate(final Collection<JenaConnectedSegmentsMatch> matches) throws IOException {
final Model model = driver.getModel();
final Property connectsToProperty = model.getProperty(BASE_PREFIX + ModelConstants.LENGTH);
for (final JenaConnectedSegmentsMatch match : matches) {
final Resource segment2 = match.getSegment2();
// delete segment2 by removing all (segment2, _, _) and (_, _, segment2) triples
final Collection<Statement> statementsToRemove = new ArrayList<>();
final Selector selectorOutgoingEdges = new SimpleSelector(segment2, null, (RDFNode) null);
final StmtIterator statementsOutgoingEdges = model.listStatements(selectorOutgoingEdges);
while (statementsOutgoingEdges.hasNext()) {
statementsToRemove.add(statementsOutgoingEdges.next());
}
final Selector selectorIncomingEdges = new SimpleSelector(null, null, segment2);
final StmtIterator statementsIncomingEdges = model.listStatements(selectorIncomingEdges);
while (statementsIncomingEdges.hasNext()) {
statementsToRemove.add(statementsIncomingEdges.next());
}
for (final Statement statement : statementsToRemove) {
model.remove(statement);
}
// insert (segment1)-[:connectsTo]->(segment3) edge
model.add(model.createStatement(match.getSegment1(), connectsToProperty, match.getSegment3()));
}
}
示例9: activate
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
@Override
public void activate(final Collection<JenaSwitchSetInjectMatch> matches) {
final Model model = driver.getModel();
final Property currentPositionProperty = model.getProperty(BASE_PREFIX + CURRENTPOSITION);
for (final JenaSwitchSetInjectMatch match : matches) {
final Resource sw = match.getSw();
final Selector selector = new SimpleSelector(sw, currentPositionProperty, (RDFNode) null);
final StmtIterator statementsToRemove = model.listStatements(selector);
if (!statementsToRemove.hasNext()) {
continue;
}
// delete old statement
final Statement oldStatement = statementsToRemove.next();
model.remove(oldStatement);
// get next enum value
final Resource currentPositionResource = oldStatement.getObject().asResource();
final String currentPositionRDFString = currentPositionResource.getLocalName();
final String currentPositionString = RdfHelper.removePrefix(Position.class, currentPositionRDFString);
final Position currentPosition = Position.valueOf(currentPositionString);
final Position newCurrentPosition = Position.values()[(currentPosition.ordinal() + 1) % Position.values().length];
final String newCurrentPositionString = RdfHelper.addEnumPrefix(newCurrentPosition);
final Resource newCurrentPositionResource = model.createResource(BASE_PREFIX + newCurrentPositionString);
// set new value
final Statement newStatement = model.createLiteralStatement(sw, currentPositionProperty, newCurrentPositionResource);
model.add(newStatement);
}
}
示例10: testModel
import org.apache.jena.rdf.model.SimpleSelector; //导入依赖的package包/类
/**
* @param model
*/
protected void testModel(final Model model) {
final Resource resourceSubject = createResource(baseUrl + path);
final Resource eventSubject = createResource(eventResourceId);
final Resource blankNode = null;
assertTrue(model.contains(resourceSubject, type, createResource(REPOSITORY_NAMESPACE + "Resource")));
assertTrue(model.contains(resourceSubject, type, createResource(REPOSITORY_NAMESPACE + "Container")));
assertTrue(model.contains(resourceSubject, type, createResource(PROV_NAMESPACE + "Entity")));
assertTrue(model.contains(resourceSubject, type, createResource("http://example.com/SampleType")));
assertTrue(model.contains(eventSubject, type, createResource(EventType.RESOURCE_MODIFICATION.getType())));
assertTrue(model.contains(eventSubject, createProperty(ACTIVITY_STREAMS_NAMESPACE + "object"),
resourceSubject));
assertTrue(model.contains(eventSubject, createProperty(ACTIVITY_STREAMS_NAMESPACE + "published"),
(RDFNode) null));
final AtomicInteger actors = new AtomicInteger();
model.listStatements(new SimpleSelector(eventSubject, createProperty(ACTIVITY_STREAMS_NAMESPACE + "actor"),
blankNode))
.forEachRemaining(statement -> {
final Resource r = statement.getResource();
if (r.hasProperty(type, createResource(ACTIVITY_STREAMS_NAMESPACE + "Person"))) {
assertTrue(r.hasProperty(type, createResource(ACTIVITY_STREAMS_NAMESPACE + "Person")));
assertEquals(getAgentIRI(), r.toString());
} else {
assertTrue(r.hasProperty(type, createResource(ACTIVITY_STREAMS_NAMESPACE + "Application")));
assertTrue(r.hasProperty(createProperty(ACTIVITY_STREAMS_NAMESPACE + "name"), softwareAgent));
}
actors.incrementAndGet();
});
assertEquals(actors.get(), 2);
final AtomicInteger eventName = new AtomicInteger();
model.listStatements(new SimpleSelector(eventSubject, createProperty(ACTIVITY_STREAMS_NAMESPACE + "name"),
blankNode))
.forEachRemaining(statement -> {
assertEquals(EventType.RESOURCE_MODIFICATION.getName(), statement.getString());
eventName.incrementAndGet();
});
assertEquals(1, eventName.get());
}