本文整理汇总了Java中org.eclipse.rdf4j.model.vocabulary.RDF.TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java RDF.TYPE属性的具体用法?Java RDF.TYPE怎么用?Java RDF.TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.rdf4j.model.vocabulary.RDF
的用法示例。
在下文中一共展示了RDF.TYPE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateTriple
/**
* Test method for {@link info.rmapproject.core.rmapservice.impl.rdf4j.ORMapObjectMgr#createStatement(info.rmapproject.core.rmapservice.impl.rdf4j.triplestore.Rdf4jTriplestore, org.eclipse.rdf4j.model.Statement)}.
*/
@Test
public void testCreateTriple() {
try {
java.net.URI id1 =null;
id1 = rmapIdService.createId();
IRI subject = ORAdapter.uri2Rdf4jIri(id1);
IRI predicate = RDF.TYPE;
IRI object = RMAP.DISCO;
IRI context = subject;
Statement stmt = ORAdapter.getValueFactory().createStatement(subject, predicate, object,context);
discomgr.createStatement(triplestore, stmt);
Statement gStmt = null;
gStmt = triplestore.getStatement(subject, predicate, object, context);
assertNotNull(gStmt);
assertEquals(subject, gStmt.getSubject());
assertEquals(predicate, gStmt.getPredicate());
assertEquals(object, gStmt.getObject());
assertEquals(context, gStmt.getContext());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例2: getResourceAssertingAgents
/**
* Get list of RMap Agent IRIs that have a statement containing the resource.
*
* @param resource a Resource IRI
* @param ts the triplestore instance
* @return a set of IRIs for Agents that asserted a statement about the Resource
* @throws RMapException the RMap exception
* @throws RMapDefectiveArgumentException the RMap defective argument exception
*/
public List<IRI> getResourceAssertingAgents(IRI resource, RMapSearchParams params, Rdf4jTriplestore ts)
throws RMapException, RMapDefectiveArgumentException {
if (resource==null){
throw new RMapDefectiveArgumentException ("Null value provided for the Resource IRI");
}
Set<org.eclipse.rdf4j.model.IRI> systemAgents = ORAdapter.uriSet2Rdf4jIriSet(params.getSystemAgents());
String sResource = Rdf4jSparqlUtils.convertIriToSparqlParam(resource);
String sysAgentSparql = Rdf4jSparqlUtils.convertSysAgentIriListToSparqlFilter(systemAgents);
String statusFilterSparql = Rdf4jSparqlUtils.convertRMapStatusToSparqlFilter(params.getStatusCode(), "?rmapObjId");
String dateFilterSparql = Rdf4jSparqlUtils.convertDateRangeToSparqlFilter(params.getDateRange(), "?startDate");
String limitOffsetSparql = Rdf4jSparqlUtils.convertLimitOffsetToSparqlFilter(params.getLimitForQuery(), params.getOffset());
StringBuilder sparqlQuery =
new StringBuilder("SELECT DISTINCT ?agentId "
+ "WHERE { "
+ " GRAPH ?rmapObjId "
+ " {"
+ " {?s ?p " + sResource + "} UNION "
+ " {" + sResource + " ?p ?o} ."
+ " } . "
+ " GRAPH ?eventId {"
+ " ?eventId <" + RDF.TYPE + "> <" + RMAP.EVENT + "> ."
+ " {?eventId <" + PROV.GENERATED + "> ?rmapObjId} UNION"
+ " {?eventId <" + RMAP.DERIVEDOBJECT + "> ?rmapObjId} ."
+ " ?eventId <" + PROV.WASASSOCIATEDWITH + "> ?agentId . ");
if (dateFilterSparql.length()>0){
sparqlQuery.append(" ?eventId <" + PROV.STARTEDATTIME + "> ?startDate .");
}
sparqlQuery.append(sysAgentSparql
+ " } "
+ statusFilterSparql
+ dateFilterSparql
+ "} ");
if (params.getOrderBy()==OrderBy.SELECT_ORDER){
sparqlQuery.append("ORDER BY ?agentId");
}
sparqlQuery.append(limitOffsetSparql);
List<IRI> assertingAgents = Rdf4jSparqlUtils.bindQueryToIriList(sparqlQuery.toString(), ts, "agentId");
return assertingAgents;
}
示例3: getRelatedObjects
/**
* Get set of RMap object IRIs that have a statement containing the resource, filtered by type (DiSCO or Agent).
*
* @param resource a Resource IRI
* @param the search filter parameters
* @param ts the triplestore instance
* @param rmapType the RMap type to filter by
* @return Set of IRIs for RMap objects that contain a reference to the Resource ID
* @throws RMapException the RMap exception
* @throws RMapDefectiveArgumentException the RMap defective argument exception
*/
protected List<IRI> getRelatedObjects(IRI resource, RMapSearchParams params, Rdf4jTriplestore ts, IRI rmapType)
throws RMapException, RMapDefectiveArgumentException {
if (resource==null){
throw new RMapDefectiveArgumentException ("Null value provided for the Resource IRI");
}
Set<org.eclipse.rdf4j.model.IRI> systemAgents = ORAdapter.uriSet2Rdf4jIriSet(params.getSystemAgents());
String sResource = Rdf4jSparqlUtils.convertIriToSparqlParam(resource);
String sysAgentSparql = Rdf4jSparqlUtils.convertSysAgentIriListToSparqlFilter(systemAgents);
String statusFilterSparql = Rdf4jSparqlUtils.convertRMapStatusToSparqlFilter(params.getStatusCode(), "?rmapObjId");
String dateFilterSparql = Rdf4jSparqlUtils.convertDateRangeToSparqlFilter(params.getDateRange(), "?startDate");
String limitOffsetSparql = Rdf4jSparqlUtils.convertLimitOffsetToSparqlFilter(params.getLimitForQuery(), params.getOffset());
StringBuilder sparqlQuery =
new StringBuilder("SELECT DISTINCT ?rmapObjId "
+ "WHERE { "
+ " GRAPH ?rmapObjId "
+ " {"
+ " {?s ?p " + sResource + "} UNION "
+ " {" + sResource + " ?p ?o} ."
+ " ?rmapObjId <" + RDF.TYPE + "> <" + rmapType + "> . "
+ " } . "
+ " GRAPH ?eventId {"
+ " ?eventId <" + RDF.TYPE + "> <" + RMAP.EVENT + "> ."
+ " {?eventId <" + PROV.GENERATED + "> ?rmapObjId} UNION"
+ " {?eventId <" + RMAP.DERIVEDOBJECT + "> ?rmapObjId} .");
if (dateFilterSparql.length()>0){
sparqlQuery.append(" ?eventId <" + PROV.STARTEDATTIME + "> ?startDate .");
}
sparqlQuery.append(sysAgentSparql
+ " } "
+ statusFilterSparql
+ dateFilterSparql
+ "} ");
if (params.getOrderBy()==OrderBy.SELECT_ORDER){
sparqlQuery.append("ORDER BY ?rmapObjId");
}
sparqlQuery.append(limitOffsetSparql);
List<IRI> rmapObjectIds = Rdf4jSparqlUtils.bindQueryToIriList(sparqlQuery.toString(), ts, "rmapObjId");
return rmapObjectIds;
}
示例4: getResourceRelatedEvents
/**
* Get list of Events IRIs that are associated with an object that references the resource passed in.
*
* @param resource a Resource IRI
* @param the search filter parameters
* @param ts the triplestore instance
* @return a set of IRIs for Events that produced a statement referencing the Resource IRI
* @throws RMapException the RMap exception
* @throws RMapDefectiveArgumentException the RMap defective argument exception
*/
public List<IRI> getResourceRelatedEvents(IRI resource, RMapSearchParams params, Rdf4jTriplestore ts)
throws RMapException, RMapDefectiveArgumentException {
if (resource==null){
throw new RMapDefectiveArgumentException ("null IRI");
}
String sResource = Rdf4jSparqlUtils.convertIriToSparqlParam(resource);
Set<org.eclipse.rdf4j.model.IRI> systemAgents = ORAdapter.uriSet2Rdf4jIriSet(params.getSystemAgents());
String sysAgentSparql = Rdf4jSparqlUtils.convertSysAgentIriListToSparqlFilter(systemAgents);
String dateFilterSparql = Rdf4jSparqlUtils.convertDateRangeToSparqlFilter(params.getDateRange(), "?startDate");
String limitOffsetSparql = Rdf4jSparqlUtils.convertLimitOffsetToSparqlFilter(params.getLimitForQuery(), params.getOffset());
String statusFilterSparql = Rdf4jSparqlUtils.convertRMapStatusToSparqlFilter(params.getStatusCode(), "?rmapObjId");
//query gets eventIds and startDates of created DiSCOs that contain Resource
/* SELECT DISTINCT ?eventId ?startDate
WHERE {
GRAPH ?rmapObjId
{
{?s ?p <http://dx.doi.org/10.1109/InPar.2012.6339604>} UNION
{<http://dx.doi.org/10.1109/InPar.2012.6339604> ?p ?o} .
} .
GRAPH ?eventId {
?eventId <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/rmap#Event> .
?eventId ?eventtype ?rmapObjId .
?eventId <http://www.w3.org/ns/prov#startedAtTime> ?startDate .
{?eventId <http://www.w3.org/ns/prov#wasAssociatedWith> <ark:/22573/rmd18nd2m3>} UNION
{?eventId <http://www.w3.org/ns/prov#wasAssociatedWith> <ark:/22573/rmd18nd2p4>} .
}
}
ORDER BY ?startDate ?eventId
LIMIT 10 OFFSET 10
*/
StringBuilder sparqlQuery =
new StringBuilder("SELECT DISTINCT ?eventId "
+ "WHERE { "
+ " GRAPH ?rmapObjId "
+ " {"
+ " {?s ?p " + sResource + "} UNION "
+ " {" + sResource + " ?p ?o} ."
+ " } . "
+ " GRAPH ?eventId {"
+ " ?eventId <" + RDF.TYPE + "> <" + RMAP.EVENT + "> ."
+ " {?eventId ?eventType ?rmapObjId} .");
if (dateFilterSparql.length()>0){
sparqlQuery.append(" ?eventId <" + PROV.STARTEDATTIME + "> ?startDate .");
}
sparqlQuery.append(sysAgentSparql
+ " } "
+ statusFilterSparql
+ dateFilterSparql
+ "} ");
if (params.getOrderBy()==OrderBy.SELECT_ORDER){
sparqlQuery.append("ORDER BY ?eventId");
}
sparqlQuery.append(limitOffsetSparql);
List<IRI> events = Rdf4jSparqlUtils.bindQueryToIriList(sparqlQuery.toString(), ts, "eventId");
return events;
}
示例5: getAgentDiSCOs
/**
* Get a list of URIs for DiSCOs that were created by the Agent provided, filtered by the parameters provided.
*
* @param agentId the Agent IRI
* @param params the search filter parameters
* @param ts the triplestore instance
* @return a list of URIs for DiSCOs that were created by the Agent
* @throws RMapException the RMap exception
* @throws RMapDefectiveArgumentException the RMap defective argument exception
*/
public List<IRI> getAgentDiSCOs(IRI agentId, RMapSearchParams params, Rdf4jTriplestore ts)
throws RMapException, RMapDefectiveArgumentException {
if (agentId==null){
throw new RMapDefectiveArgumentException ("null agentId");
}
/*
* Query gets DiSCOs created by a specific agent.
* SELECT DISTINCT ?rmapObjId ?startDate
WHERE {
GRAPH ?rmapObjId
{
?rmapObjId <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/rmap#DiSCO> .
} .
GRAPH ?eventId {
?eventId <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/rmap#Event> .
{?eventId <http://www.w3.org/ns/prov#generated> ?rmapObjId} UNION
{?eventId <http://purl.org/ontology/rmap#derivedObject> ?rmapObjId} .
?eventId <http://www.w3.org/ns/prov#startedAtTime> ?startDate .
?eventId <http://www.w3.org/ns/prov#wasAssociatedWith> <ark:/22573/rmaptestagent> .
} .
FILTER NOT EXISTS {?statusChangeEventId <http://purl.org/ontology/rmap#tombstonedObject> ?rmapObjId} .
FILTER NOT EXISTS {?statusChangeEventId <http://purl.org/ontology/rmap#inactivatedObject> ?rmapObjId}
}
*/
String statusFilterSparql = Rdf4jSparqlUtils.convertRMapStatusToSparqlFilter(params.getStatusCode(), "?rmapObjId");
String dateFilterSparql = Rdf4jSparqlUtils.convertDateRangeToSparqlFilter(params.getDateRange(), "?startDate");
String limitFiltersSparql = Rdf4jSparqlUtils.convertLimitOffsetToSparqlFilter(params.getLimitForQuery(), params.getOffset());
StringBuilder sparqlQuery =
new StringBuilder("SELECT DISTINCT ?rmapObjId "
+ "WHERE { "
+ " GRAPH ?rmapObjId "
+ " {"
+ " ?rmapObjId <" + RDF.TYPE + "> <" + RMAP.DISCO + "> . "
+ " } . "
+ " GRAPH ?eventId {"
+ " ?eventId <" + RDF.TYPE + "> <" + RMAP.EVENT + "> ."
+ " {?eventId <" + PROV.GENERATED + "> ?rmapObjId} UNION "
+ " {?eventId <" + RMAP.DERIVEDOBJECT + "> ?rmapObjId} ."
+ " ?eventId <" + PROV.WASASSOCIATEDWITH + "> <" + agentId.toString() + "> . ");
if (dateFilterSparql.length()>0){
sparqlQuery.append(" ?eventId <" + PROV.STARTEDATTIME + "> ?startDate .");
}
sparqlQuery.append(" } "
+ statusFilterSparql
+ dateFilterSparql
+ "} ");
if (params.getOrderBy()==OrderBy.SELECT_ORDER){
sparqlQuery.append("ORDER BY ?rmapObjId");
}
sparqlQuery.append(limitFiltersSparql);
List<IRI> discos = Rdf4jSparqlUtils.bindQueryToIriList(sparqlQuery.toString(), ts, "rmapObjId");
return discos;
}
示例6: getAgentEventsInitiated
/**
* Get a list of IRIs for Events initiated by an Agent, filtered by the search parameters provided.
*
* @param agentId the Agent IRI
* @param params the search filter parameters
* @param ts the triplestore instance
* @return a list of IRIs for Events initiated by the Agent.
* @throws RMapException the RMap exception
* @throws RMapDefectiveArgumentException the RMap defective argument exception
*/
public List<IRI> getAgentEventsInitiated(IRI agentId, RMapSearchParams params, Rdf4jTriplestore ts)
throws RMapException, RMapDefectiveArgumentException {
if (agentId==null){
throw new RMapDefectiveArgumentException ("null agentId");
}
String sAgentId = Rdf4jSparqlUtils.convertIriToSparqlParam(agentId);
String dateFilterSparql = Rdf4jSparqlUtils.convertDateRangeToSparqlFilter(params.getDateRange(), "?startDate");
String limitOffsetSparql = Rdf4jSparqlUtils.convertLimitOffsetToSparqlFilter(params.getLimitForQuery(), params.getOffset());
//query gets eventIds and startDates of Events initiated by agent
/* PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?eventId
WHERE {
GRAPH ?eventId {
?eventId <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/rmap#Event> .
?eventId <http://www.w3.org/ns/prov#startedAtTime> ?startDate .
?eventId <http://www.w3.org/ns/prov#wasAssociatedWith> <ark:/27927/rmp2543q5> .
}
FILTER (?startDate >= "2016-03-22T13:51:30Z"^^xsd:dateTime) .
FILTER (?startDate <= "2016-03-22T13:51:31Z"^^xsd:dateTime) .
}
ORDER BY ?eventId
LIMIT 100 OFFSET 0
*/
StringBuilder sparqlQuery =
new StringBuilder("SELECT DISTINCT ?eventId "
+ "WHERE { "
+ " GRAPH ?eventId {"
+ " ?eventId <" + RDF.TYPE + "> <" + RMAP.EVENT + "> ."
+ " ?eventId <" + PROV.WASASSOCIATEDWITH + "> " + sAgentId + " . ");
if (dateFilterSparql.length()>0){
sparqlQuery.append(" ?eventId <" + PROV.STARTEDATTIME + "> ?startDate .");
}
sparqlQuery.append(" } "
+ dateFilterSparql
+ "} ");
if (params.getOrderBy()==OrderBy.SELECT_ORDER){
sparqlQuery.append("ORDER BY ?eventId");
}
sparqlQuery.append(limitOffsetSparql);
List<IRI> events = Rdf4jSparqlUtils.bindQueryToIriList(sparqlQuery.toString(), ts, "eventId");
return events;
}