本文整理汇总了Java中org.openrdf.model.Model.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java Model.addAll方法的具体用法?Java Model.addAll怎么用?Java Model.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.Model
的用法示例。
在下文中一共展示了Model.addAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModel
import org.openrdf.model.Model; //导入方法依赖的package包/类
public static Model getModel( InsightManager im, User user ) {
Model statements = new LinkedHashModel();
int idx = 0;
RDFParser parser = new TurtleParser();
StatementCollector coll = new StatementCollector();
parser.setRDFHandler( coll );
try ( InputStream is = IEngine.class.getResourceAsStream( "/models/sempers.ttl" ) ) {
parser.parse( is, SEMPERS.BASE_URI );
}
catch ( Exception e ) {
log.warn( "could not include sempers.ttl ontology in statements", e );
}
statements.addAll( coll.getStatements() );
ValueFactory vf = new ValueFactoryImpl();
for ( Perspective p : im.getPerspectives() ) {
statements.addAll( getStatements( p, user ) );
statements.add( new StatementImpl( p.getId(), OLO.index,
vf.createLiteral( idx++ ) ) );
}
return statements;
}
示例2: SaveRdf
import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
* Saves as RDF the graph created.
*
* @throws RepositoryException
* @throws RDFHandlerException
* @throws IOException
*/
private void SaveRdf() throws RepositoryException, RDFHandlerException, IOException {
RepositoryResult statements = src.getStatements(null, null, null, true);
Model model = new LinkedHashModel();
java.util.ArrayList arr = new java.util.ArrayList();
while (statements.hasNext()) {
arr.add(statements.next());
}
model.addAll(arr);
model.setNamespace("rdf", RDF.NAMESPACE);
model.setNamespace("rdfs", RDFS.NAMESPACE);
model.setNamespace("xsd", XMLSchema.NAMESPACE);
model.setNamespace("foaf", FOAF.NAMESPACE);
model.setNamespace("ex", "");
Rio.write(model, new java.io.FileWriter(new java.io.File(outputFileName),false), RDFFormat.TURTLE);
CloseAllConnections();
}
示例3: addTranslations
import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
* Add translations to the translation cache
* Only adds new translations
*
* @param statementList
* @throws RepositoryException
*/
public void addTranslations(Collection<TranslatedStatement> statementList) throws RepositoryException {
Model translations = new LinkedHashModel();
for (TranslatedStatement s : statementList) {
String orig = s.getOriginalStatement().getObject().stringValue();
String trans = s.getTranslatedStatement().getObject().stringValue();
translations.addAll(modelTranslation(orig, trans));
}
con.add(translations, translatorCache);
}
示例4: createEdgeProps
import org.openrdf.model.Model; //导入方法依赖的package包/类
private Model createEdgeProps( List<URI> concepts, List<URI> edges,
Map<String, URI> structurelkp, UriBuilder schema,
Map<Resource, String> labels ) {
String cimplosion = Utility.implode( concepts );
String eimplosion = Utility.implode( edges );
String propq = "SELECT DISTINCT ?stype ?rtype ?otype ?prop WHERE {\n"
+ " ?s a|rdfs:subClassOf+ ?stype .\n"
+ " ?o a|rdfs:subClassOf+ ?otype .\n"
+ " ?r a|rdfs:subPropertyOf+ ?rtype .\n"
+ " ?s ?r ?o .\n"
+ " ?r ?prop ?propval . FILTER( ?prop != rdfs:label && isLiteral( ?propval ) ) .\n"
+ " VALUES ?stype {" + cimplosion + "} .\n"
+ " VALUES ?otype {" + cimplosion + "} .\n"
+ " VALUES ?rtype {" + eimplosion + "} .\n"
+ "}";
Model model = new LinkedHashModel();
VoidQueryAdapter vqa = new VoidQueryAdapter( propq ) {
@Override
public void handleTuple( BindingSet set, ValueFactory fac ) {
URI domain = URI.class.cast( set.getValue( "stype" ) );
URI pred = URI.class.cast( set.getValue( "rtype" ) );
URI range = URI.class.cast( set.getValue( "otype" ) );
URI prop = URI.class.cast( set.getValue( "prop" ) );
String sub = labels.get( domain );
String rel = labels.get( pred );
String obj = labels.get( range );
String name = sub + "_" + rel + "_" + obj;
model.addAll( getPropStructure( pred, domain, range, prop, schema,
structurelkp, name ) );
}
};
engine.queryNoEx( vqa );
return model;
}
示例5: getStatements
import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
* Converts the Perspective, its Insights and Parameters (and ordering!) to
* Statements for adding to a Repository. If any Perspective, Insight, or
* Parameter is missing an ID, a new one will be generated for it, and set on
* the object
*
* @param p the perspective to convert.
* @param user
* @return a list of statements that completely represent the perspective tree
*/
public static Model getStatements( Perspective p, User user ) {
Model statements = new LinkedHashModel();
UriBuilder urib = UriBuilder.getBuilder( SEMPERS.NAMESPACE );
// if we're creating statements, mark our repository as an insights db
statements.add( new StatementImpl( SEMPERS.INSIGHT_DB, RDF.TYPE,
SEMPERS.INSIGHT_CORE_TYPE ) );
ValueFactory vf = new ValueFactoryImpl();
if ( null == p.getId() ) {
p.setId( urib.build( p.getLabel() ) );
}
statements.addAll( getPerspectiveStatements( p, vf, urib, user ) );
for ( Insight i : p.getInsights() ) {
final String piname = p.getLabel() + "-" + i.getLabel();
if ( null == i.getId() ) {
i.setId( urib.build( piname ) );
}
statements.addAll( getInsightStatements( i, vf, urib, user ) );
for ( Parameter a : i.getInsightParameters() ) {
final String pianame = piname + "-" + a.getLabel();
URI predicateUri = urib.build( pianame + "-pred" );
URI queryUri = urib.build( pianame + "-query" );
if ( null == a.getId() ) {
a.setId( urib.build( pianame ) );
}
statements.addAll( getParameterStatements( a, predicateUri, queryUri,
vf, urib, user ) );
}
statements.addAll( getConstraintStatements( i, i.getInsightParameters() ) );
}
statements.addAll( getOrderingStatements( p, p.getInsights(), vf, urib ) );
return statements;
}