本文整理匯總了Java中org.openrdf.model.vocabulary.RDF類的典型用法代碼示例。如果您正苦於以下問題:Java RDF類的具體用法?Java RDF怎麽用?Java RDF使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RDF類屬於org.openrdf.model.vocabulary包,在下文中一共展示了RDF類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getId
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
public static Resource getId( DbInfo t, RepositoryConnection rc )
throws RepositoryException {
List<Statement> stmts = Iterations.asList( rc.getStatements( null, RDF.TYPE,
WEBDS.DBINFO, false ) );
Resource idToRemove = null;
for ( Statement s : stmts ) {
Resource sbj = s.getSubject();
List<Statement> individuals
= Iterations.asList( rc.getStatements( sbj, RDFS.LABEL, null, false ) );
for ( Statement ind : individuals ) {
if ( ind.getObject().stringValue().equals( t.getName() ) ) {
idToRemove = sbj;
}
}
}
return idToRemove;
}
示例2: getId
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private static Resource getId( User t, RepositoryConnection rc )
throws RepositoryException {
List<Statement> stmts = Iterations.asList( rc.getStatements( null, RDF.TYPE,
FOAF.PERSON, false ) );
Resource idToRemove = null;
for ( Statement s : stmts ) {
Resource sbj = s.getSubject();
List<Statement> individuals
= Iterations.asList( rc.getStatements( sbj, FOAF.ACCOUNT, null, false ) );
for ( Statement ind : individuals ) {
if ( ind.getObject().stringValue().equals( t.getUsername() ) ) {
idToRemove = sbj;
}
}
}
return idToRemove;
}
示例3: getCreateStatements
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private static Collection<Statement> getCreateStatements( Resource id, User t,
ValueFactory vf ) {
List<Statement> stmts = new ArrayList<>();
stmts.add( new StatementImpl( id, RDF.TYPE, FOAF.PERSON ) );
stmts.add( new StatementImpl( id, FOAF.ACCOUNT, vf.createLiteral( t.getUsername() ) ) );
for ( Map.Entry<UserProperty, URI> en : PROPMAP.entrySet() ) {
UserProperty prop = en.getKey();
String str = t.getProperty( prop );
if ( !str.trim().isEmpty() ) {
stmts.add( new StatementImpl( id, en.getValue(), vf.createLiteral( str ) ) );
}
}
return stmts;
}
示例4: handleTuple
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
@Override
public void handleTuple( BindingSet set, ValueFactory fac ) {
URI pred = fac.createURI( set.getValue( "p" ).stringValue() );
Value val = set.getValue( "o" );
// for baseuri, we need the subject, not the object
// and also, we use the VOID_DS as the key elsewhere in the code
if ( RDF.TYPE.equals( pred ) ) {
pred = SEMTOOL.Database;
val = set.getValue( "db" );
}
else if ( pred.getNamespace().equals( DC.NAMESPACE ) ) {
// silently handle the old DC namespace (ignore our DC-specific URIs)
if ( !( MetadataConstants.DCT_CREATED.equals( pred )
|| MetadataConstants.DCT_MODIFIED.equals( pred ) ) ) {
pred = fac.createURI( DCTERMS.NAMESPACE, pred.getLocalName() );
}
}
result.put( pred, val );
}
示例5: getPerspectiveStatements
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
protected static Model getPerspectiveStatements( Perspective p,
ValueFactory vf, UriBuilder urib, User user ) {
Model statements = new LinkedHashModel();
URI pid = p.getId();
Date now = new Date();
statements.add( new StatementImpl( pid, RDF.TYPE, SEMPERS.Perspective ) );
statements.add( new StatementImpl( pid, RDFS.LABEL,
vf.createLiteral( p.getLabel() ) ) );
if ( null != p.getDescription() ) {
statements.add( new StatementImpl( pid, DCTERMS.DESCRIPTION,
vf.createLiteral( p.getDescription() ) ) );
}
statements.add( new StatementImpl( pid, DCTERMS.CREATED,
vf.createLiteral( now ) ) );
statements.add( new StatementImpl( pid, DCTERMS.MODIFIED,
vf.createLiteral( now ) ) );
statements.add( new StatementImpl( pid, DCTERMS.CREATOR,
vf.createLiteral( getAuthorInfo( user ) ) ) );
return statements;
}
示例6: testGetInstancesNoPropsAvailable
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
@Test
public void testGetInstancesNoPropsAvailable() throws Exception {
// this is just extra stuff that shouldn't be returned in the tests
final URI REL = OWLB.getRelationUri().build();
final URI EXTRA = OWLB.build( "AnotherRelType" );
final URI EXTRAIMPL = DATAB.build( "AnotherRel" );
final URI ALAN = DATAB.build( "Alan" );
final URI CADILLAC = DATAB.build( "Cadillac" );
engine.getRawConnection().add( EXTRA, RDFS.SUBPROPERTYOF, REL );
engine.getRawConnection().add( EXTRAIMPL, RDF.TYPE, REL );
Model expected = new LinkedHashModel();
expected.add( YURI, YPY, YUGO );
expected.add( ALAN, PURCHASE, CADILLAC );
Model model = NodeDerivationTools.getInstances( HUMAN, PURCHASE, CAR,
null, engine );
assertEquals( expected, model );
}
示例7: testImportRDF
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
@Test
public void testImportRDF() throws Exception {
engine.setBuilders( UriBuilder.getBuilder( DATAURI ),
UriBuilder.getBuilder( SCHEMAURI ) );
ImportData errors = new ImportData();
EngineLoader el = new EngineLoader();
el.loadToEngine( Arrays.asList( TICKET584_EXP ), engine, true, errors );
// cleanup
engine.getRawConnection().remove( (Resource) null, RDF.TYPE, SEMTOOL.Database );
el.release();
if ( log.isTraceEnabled() ) {
File tmpdir = FileUtils.getTempDirectory();
try ( Writer w = new BufferedWriter( new FileWriter( new File( tmpdir,
"import-rdf.nt" ) ) ) ) {
engine.getRawConnection().export( new NTriplesWriter( w ) );
}
}
compareData( engine.getRawConnection(), getExpectedGraph( TICKET584_EXP ),
engine.getSchemaBuilder(), engine.getDataBuilder() );
}
示例8: compareData
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private void compareData( RepositoryConnection testRc, Model expected,
UriBuilder owl, UriBuilder base ) throws Exception {
List<Statement> stmts
= Iterations.asList( testRc.getStatements( null, null, null, false ) );
Model test = new LinkedHashModel( stmts );
assertEquals( "dataset size", expected.size(), test.size() );
compare( "category concept", expected, test, null, RDF.TYPE,
owl.getConceptUri( "Category" ) );
compare( "beverages concept", expected, test,
base.getConceptUri().add( "Category" ).add( "Beverages" ).build(),
null, null );
compare( "dairy products", expected, test,
null, RDFS.LABEL, new LiteralImpl( "Dairy Products" ) );
compare( "chai-beverages link", expected, test,
null, RDFS.LABEL, new LiteralImpl( "Chai Category Beverages" ) );
URI bev
= base.getRelationUri().add( "Category" ).add( "Chai_x_Beverages" ).build();
compare( "chai-beverages category", expected, test,
bev, RDFS.SUBPROPERTYOF, owl.getRelationUri( "Category" ) );
}
示例9: buildPropertyHTMLString
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private String buildPropertyHTMLString( List<URI> properties, GraphElement vertex ) {
StringBuilder propertiesHTMLString = new StringBuilder();
for ( URI prop : properties ) {
if ( vertex.hasProperty( prop ) ) {
Value val = vertex.getValue( prop );
if ( 0 != propertiesHTMLString.length() ) {
propertiesHTMLString.append( "<br>" );
}
if ( displayLabelFor( prop ) ) {
propertiesHTMLString.append( getLabel( prop ) ).append( ": " );
}
String str = ( RDF.TYPE.equals( prop )
? getLabel( URI.class.cast( val ) ) : val.stringValue() );
propertiesHTMLString.append( str );
}
}
return propertiesHTMLString.toString();
}
示例10: setRenderer
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private void setRenderer( RetrievingLabelCache cacher ) {
cacher.put( Constants.ANYNODE, "SELECT ALL" );
cacher.put( RDF.SUBJECT, "URI" );
cacher.put( RDFS.LABEL, "Label" );
cacher.put( RDF.TYPE, "Type" );
cacher.put( Constants.IN_EDGE_CNT, "Inputs" );
cacher.put( Constants.OUT_EDGE_CNT, "Outputs" );
LabeledPairTableCellRenderer<Value> renderer
= LabeledPairTableCellRenderer.getValuePairRenderer( cacher );
for ( JTable jt : new JTable[]{ nodes, edges, nodelabels, edgelabels, selecteds } ) {
jt.setDefaultRenderer( URI.class, renderer );
jt.setDefaultRenderer( Value.class, renderer );
}
}
示例11: buildSelect
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
private String buildSelect( List<QueryOrder> ordering ) {
StringBuilder select = new StringBuilder( "SELECT" );
boolean hasone = false;
for ( QueryOrder qo : ordering ) {
QueryGraphElement v = qo.base;
URI prop = qo.property;
boolean issubj = RDF.SUBJECT.equals( prop );
if ( v.isSelected( prop ) ) {
select.append( " ?" ).
append( issubj ? v.getQueryId() : v.getLabel( prop ) );
hasone = true;
}
}
if ( !hasone ) {
select.append( " *" );
}
return select.toString();
}
示例12: SparqlResultTableModel
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
public SparqlResultTableModel( List<QueryGraphElement> elements,
List<QueryOrder> ordering ) {
Set<QueryOrder> seen = new HashSet<>( ordering );
list.addAll( ordering );
for( QueryGraphElement element : elements ){
for ( URI prop : element.getAllValues().keySet() ) {
if ( !RDF.SUBJECT.equals( prop ) ) {
QueryOrder qo = new QueryOrder( element, prop );
if( !seen.contains( qo )){
list.add( qo );
}
}
}
}
}
示例13: actionPerformed
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
@Override
public void actionPerformed( ActionEvent e ) {
Set<URI> props = new HashSet<>( nodeedge.getAllValues().keySet() );
props.remove( RDF.SUBJECT );
props.remove( RDF.TYPE );
JList<URI> cons = new JList<>( props.toArray( new URI[0] ) );
LabeledPairRenderer<URI> renderer = LabeledPairRenderer.getUriPairRenderer();
renderer.cache( Utility.getInstanceLabels( props, pnl.getEngine() ) );
cons.setCellRenderer( renderer );
String[] choices = { "OK", "Cancel" };
int ans = JOptionPane.showOptionDialog( null, new JScrollPane( cons ),
"Constraints to Remove", JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE, null, choices, choices[0] );
if ( 0 == ans ) {
for ( URI u : cons.getSelectedValuesList() ) {
nodeedge.removeProperty( u );
}
pnl.update();
}
}
示例14: populateRows
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
public final void populateRows() {
rows = new ArrayList<>();
URI datatypeURI;
for ( GraphElement vertex : pickedVertices ) {
for ( Map.Entry<URI, Value> entry : vertex.getValues().entrySet() ) {
// don't edit the SUBJECT field (it's just an ID for the vertex)
if( !RDF.SUBJECT.equals( entry.getKey()) ){
if ( entry.getValue() instanceof Literal ) {
Literal literal = (Literal) entry.getValue();
if ( literal.getDatatype() == null ) {
datatypeURI = XMLSchema.STRING;
}
else {
datatypeURI = literal.getDatatype();
}
rows.add( new PropertyEditorRow( vertex, entry.getKey(), datatypeURI,
entry.getValue() ) );
}
else if ( entry.getValue() instanceof URI ) {
rows.add( new PropertyEditorRow( vertex, entry.getKey(), XMLSchema.ANYURI,
entry.getValue() ) );
}
}
}
}
}
示例15: statementCollector
import org.openrdf.model.vocabulary.RDF; //導入依賴的package包/類
void statementCollector(Statement statement) {
Value object = statement.getObject();
IRI predicate = statement.getPredicate();
if (predicate.equals(RDFS.SUBCLASSOF)) {
fastRdfsForwardChainingSail.subClassOfStatemenets.add(statement);
} else if (predicate.equals(RDF.TYPE) && object.equals(RDF.PROPERTY)) {
fastRdfsForwardChainingSail.propertyStatements.add(statement);
} else if (predicate.equals(RDFS.SUBPROPERTYOF)) {
fastRdfsForwardChainingSail.subPropertyOfStatemenets.add(statement);
} else if (predicate.equals(RDFS.RANGE)) {
fastRdfsForwardChainingSail.rangeStatemenets.add(statement);
} else if (predicate.equals(RDFS.DOMAIN)) {
fastRdfsForwardChainingSail.domainStatemenets.add(statement);
}
}
開發者ID:hmottestad,項目名稱:FastRdfsForwardChainingSail,代碼行數:18,代碼來源:FastRdfsForwardChainingSailConnetion.java