本文整理汇总了Java中org.openrdf.model.impl.TreeModel类的典型用法代码示例。如果您正苦于以下问题:Java TreeModel类的具体用法?Java TreeModel怎么用?Java TreeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeModel类属于org.openrdf.model.impl包,在下文中一共展示了TreeModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldProperlyConvertGraphToGraphVizModel
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Test
public void shouldProperlyConvertGraphToGraphVizModel() throws Exception {
ValueFactory v = new ValueFactoryImpl();
Graph graph = new TreeModel();
graph.add(v.createStatement(
v.createURI("http://test.urn"),
v.createURI("http://predicate"),
v.createLiteral("Test label")
));
graph.add(v.createStatement(
v.createURI("http://test.urn1"),
v.createURI("http://predicate1"),
v.createLiteral("Test label1")
));
String stringForm = new GraphConverter().getStringForm(graph);
Approvals.verify(stringForm, Paths.get("src/test/resources/approvals/shouldProperlyConvertGraphToGraphVizModel.dot"));
}
开发者ID:nikolavp,项目名称:approval,代码行数:22,代码来源:GraphConverterTest.java
示例2: shouldProperlyConvertTheDotFormatAndThenReportItInConfigredApplication
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Test
public void shouldProperlyConvertTheDotFormatAndThenReportItInConfigredApplication() throws Exception {
ValueFactory v = new ValueFactoryImpl();
Graph graph = new TreeModel();
graph.add(v.createStatement(
v.createURI("http://test.urn"),
v.createURI("http://predicate"),
v.createLiteral("Test label")
));
graph.add(v.createStatement(
v.createURI("http://test.urn1"),
v.createURI("http://predicate1"),
v.createLiteral("Test label1")
));
Approval<Graph> approval = Approval.of(Graph.class)
.withConveter(new GraphConverter())
.withReporter(GraphReporter.getInstance())
.build();
approval.verify(graph, Paths.get("src/test/resources/approvals/shouldProperlyConvertTheDotFormatAndThenReportItInConfigredApplication.dot"));
}
开发者ID:nikolavp,项目名称:approval,代码行数:24,代码来源:GraphReporterIT.java
示例3: writeObject
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Write the object reference to the stream.
*
* @param output the object output to write to
* @param object the object reference to write
* @throws java.io.IOException if an I/O error occurs
*/
@Override
public void writeObject(ObjectOutput output, TreeModel object) throws IOException {
output.writeInt(object.size());
for(Statement statement : object) {
output.writeObject(statement.getSubject());
output.writeObject(statement.getPredicate());
output.writeObject(statement.getContext());
if(statement.getContext() != null) {
output.writeBoolean(true);
output.writeObject(statement.getContext());
} else {
output.writeBoolean(false);
}
}
}
开发者ID:apache,项目名称:marmotta,代码行数:24,代码来源:ModelExternalizer.java
示例4: readObject
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Read an instance from the stream. The instance will have been written by the
* {@link #writeObject(java.io.ObjectOutput, Object)} method. Implementations are free
* to create instances of the object read from the stream in any way that they
* feel like. This could be via constructor, factory or reflection.
*
* @param input the object input to read from
* @return the object instance
* @throws java.io.IOException if an I/O error occurs
* @throws ClassNotFoundException if a class could not be found
*/
@Override
public TreeModel readObject(ObjectInput input) throws IOException, ClassNotFoundException {
TreeModel model = new TreeModel();
int size = input.readInt();
for(int i=0; i<size; i++) {
Resource subject = (Resource) input.readObject();
URI predicate = (URI) input.readObject();
Value object = (Value) input.readObject();
boolean hasContext = input.readBoolean();
if(hasContext) {
Resource context = (Resource) input.readObject();
model.add(new ContextStatementImpl(subject,predicate,object,context));
} else {
model.add(new StatementImpl(subject,predicate,object));
}
}
return null;
}
开发者ID:apache,项目名称:marmotta,代码行数:34,代码来源:ModelExternalizer.java
示例5: asModel
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Copy the contents of the given repository over to a newly created model, optionally applying the filters given
* as variable argument.
*
* @param repository
* @return
* @throws RepositoryException
*/
public static Model asModel(Repository repository, Predicate<Statement>... filters) throws RepositoryException {
Model model = new TreeModel();
RepositoryConnection con = repository.getConnection();
try {
con.begin();
add(model,con.getStatements(null,null,null,true), filters);
con.commit();
} catch(RepositoryException ex) {
con.rollback();
} finally {
con.close();
}
return model;
}
开发者ID:apache,项目名称:marmotta,代码行数:27,代码来源:ModelCommons.java
示例6: register
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@RequestMapping(value = "/register", method = RequestMethod.POST)
@ResponseBody
public void register(@RequestHeader("content-type") String contentType,
@RequestBody String rdfRegistration,
HttpServletResponse response) throws IOException {
try {
RDFFormat format = Rio.getParserFormatForMIMEType(contentType);
RDFParser parser = Rio.createParser(format);
Model model = new TreeModel();
StatementCollector handler = new StatementCollector(model);
parser.setRDFHandler(handler);
parser.parse(new StringReader(rdfRegistration), "");
registrationService.register(model);
response.setStatus(HttpServletResponse.SC_CREATED);
}
catch (OpenRDFException ex) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Could not parse provided registration document");
}
}
开发者ID:rsine,项目名称:rsine,代码行数:20,代码来源:RsineController.java
示例7: getMetadata
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Override
public Model getMetadata() throws LDFusionToolException {
if (metadataInput == null) {
return new EmptyMetadataModel();
}
Model metadata = new TreeModel();
RepositoryResult<Statement> metadataResult;
try (CloseableRepositoryConnection connection = new CloseableRepositoryConnection(metadataInput.getConnection())) {
metadataResult = connection.get().getStatements(null, null, null, false);
while (metadataResult.hasNext()) {
metadata.add(metadataResult.next());
}
return metadata;
} catch (RepositoryException | DataUnitException e) {
throw new LDFusionToolException("Error when loading metadata from input", e);
}
}
开发者ID:mifeet,项目名称:FusionTool-DPU,代码行数:18,代码来源:FusionToolDpuComponentFactory.java
示例8: toModel
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Creates a model from all the statements in this engine
* @return
* @throws RepositoryException
*/
public Model toModel() throws RepositoryException {
TreeModel model = new TreeModel();
RepositoryResult<Statement> stmts
= rc.getStatements( null, null, null, false );
while ( stmts.hasNext() ) {
model.add( stmts.next() );
}
return model;
}
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:InMemorySesameEngine.java
示例9: createJar
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Creates a new File object in the <code>targetDir</code> folder.
*
* @param filename
* @return
* @throws StoreConfigException
* @throws RepositoryException
*/
protected File createJar(String filename) throws Exception {
Model schema = new TreeModel();
OntologyLoader ontologies = new OntologyLoader(schema);
ontologies.loadOntologies(imports);
OWLCompiler compiler = new OWLCompiler();
compiler.setModel(schema);
compiler.setPrefixNamespaces(ontologies.getNamespaces());
File concepts = getConceptJar(targetDir, filename);
compiler.createJar(concepts);
return concepts;
}
开发者ID:anno4j,项目名称:anno4j,代码行数:20,代码来源:CodeGenTestCase.java
示例10: graphVerificationExample
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Test
public void graphVerificationExample() {
Graph graph = new TreeModel();
// populate our graph with statements(maybe from GraphQueryResult?
// Note: this is still thread safe...
Approval<Graph> graphApproval = Approval.of(Graph.class)
.withConveter(new GraphConverter())
.withReporter(GraphReporter.getInstance())
.build();
// Verify the graph, change the path accordingly
graphApproval.verify(graph, Paths.get("graph-result.dot"));
}
开发者ID:nikolavp,项目名称:approval,代码行数:16,代码来源:GraphApprovalExample.java
示例11: ClientResponse
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Deprecated
public ClientResponse(int httpStatus, Repository triples) {
this.expires = DateUtils.addDays(new Date(), DEFAULT_EXPIRATION_IN_DAYS);
this.httpStatus = httpStatus;
try {
this.data = ModelCommons.asModel(triples);
} catch (RepositoryException e) {
this.data = new TreeModel();
}
}
开发者ID:apache,项目名称:marmotta,代码行数:12,代码来源:ClientResponse.java
示例12: retrieveResource
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
@Override
public ClientResponse retrieveResource(String resource, LDClientService client, Endpoint endpoint) throws DataRetrievalException {
String account = java.net.URI.create(resource.replaceAll(" ", "%20")).getPath().substring(1);
String prefix = getEndpointSuffix(endpoint);
try {
final LdapConnection ldap = openLdapConnection(endpoint);
Model model = new TreeModel();
ValueFactory vf = ValueFactoryImpl.getInstance();
String userDN = buildDN(prefix, account, ldap);
Map<String, java.util.List<String>> accountData = getAccountData(userDN, ldap);
final URI subject = vf.createURI(resource);
for (String attr : MAPPING.keySet()) {
if (!accountData.containsKey(attr)) {
continue;
}
final PredicateObjectFactory factory = MAPPING.get(attr);
final URI predicate = factory.createPredicate(vf);
for (String val : accountData.get(attr)) {
for (Value object : factory.createObjects(val, vf)) {
model.add(vf.createStatement(subject, predicate, object));
}
}
}
final ClientResponse resp = new ClientResponse(200, model);
resp.setExpires(new Date());
return resp;
} catch (LdapException | CursorException | IOException e) {
log.warn("could not access LDAP repository: {}", e.getMessage());
throw new DataRetrievalException(e);
}
}
开发者ID:apache,项目名称:marmotta,代码行数:40,代码来源:LdapFoafProvider.java
示例13: get
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Refresh and return the resource passed as argument. If the resource is not yet cached or the cache entry is
* expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
* in the cache. Otherwise the method returns the cached entry. In case a cached entry does not exist, the method
* returns an empty Model.
*
* @param resource the resource to retrieve
* @param options options for refreshing
* @return a Sesame Model holding the triples representing the resource
*/
@Override
public Model get(URI resource, RefreshOpts... options) {
refresh(resource, options);
CacheEntry entry = backend.getEntry(resource);
if(entry != null) {
return entry.getTriples();
} else {
return new TreeModel();
}
}
开发者ID:apache,项目名称:marmotta,代码行数:23,代码来源:LDCache.java
示例14: getEntry
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Return the cache entry for the given resource, or null if this entry does not exist.
*
*
* @param resource the resource to retrieve the cache entry for
* @return
*/
@Override
public CacheEntry getEntry(URI resource) {
try {
// load metadata from disk
final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
if (!(dataFile.exists())) return null;
final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, getValueFactory());
if (FileBackendUtils.isExpired(ce)) return null;
// read triples for this entry from cache repository
RepositoryConnection con = cacheRepository.getConnection();
try {
con.begin();
Model triples = new TreeModel();
ModelCommons.add(triples, con.getStatements(resource,null,null,true));
ce.setTriples(triples);
con.commit();
} catch(RepositoryException ex) {
con.rollback();
} finally {
con.close();
}
return ce;
} catch (IOException | RepositoryException e) {
log.error("error while loading cache entry from file system:",e);
return null;
}
}
开发者ID:apache,项目名称:marmotta,代码行数:40,代码来源:LDCachingFileBackend.java
示例15: getEntry
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Return the cache entry for the given resource, or null if this entry does not exist.
*
*
* @param resource the resource to retrieve the cache entry for
* @return
*/
@Override
public CacheEntry getEntry(URI resource) {
try {
try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
// load cache entry from database
CacheEntry ce = dbcon.getCacheEntry(resource.stringValue());
// if entry exists, load triples for the resource from the cache context of the repository
if(ce != null) {
SailConnection con = store.getConnection();
try {
con.begin();
Model triples = new TreeModel();
ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
ce.setTriples(triples);
con.commit();
} catch(SailException ex) {
con.rollback();
} finally {
con.close();
}
}
return ce;
}
} catch (SailException | SQLException e) {
log.error("could not retrieve cached triples from repository",e);
}
return null;
}
开发者ID:apache,项目名称:marmotta,代码行数:43,代码来源:LDCachingKiWiBackend.java
示例16: getMetadata
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
/**
* Returns metadata for conflict resolution.
* @return metadata for conflict resolution
* @throws cz.cuni.mff.odcleanstore.fusiontool.exceptions.LDFusionToolException error
*/
@Override
public Model getMetadata() throws LDFusionToolException {
Collection<ConstructSource> metadataSources = getConstructSources(config.getMetadataSources());
Model metadata = new TreeModel();
for (ConstructSource source : metadataSources) {
MetadataLoader loader = new MetadataLoader(source);
loader.loadNamedGraphsMetadata(metadata);
}
return metadata;
}
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:16,代码来源:LDFusionToolComponentFactory.java
示例17: parseChangeSet
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
private Model parseChangeSet(String rdfChangeSet, RDFFormat rdfFormat) throws IOException, OpenRDFException {
RDFParser rdfParser = Rio.createParser(rdfFormat);
Model changeSet = new TreeModel();
StatementCollector collector = new StatementCollector(changeSet);
rdfParser.setRDFHandler(collector);
rdfParser.parse(new StringReader(rdfChangeSet), "");
return changeSet;
}
开发者ID:rsine,项目名称:rsine,代码行数:9,代码来源:RemoteChangeSetService.java
示例18: assembleChangeset
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
public Model assembleChangeset(Statement affectedStatement, Statement secondaryStatement, String changeType) {
Model model = new TreeModel(new HashSet<Namespace>(Arrays.asList(Namespaces.RSINE_NAMESPACE, Namespaces.CS_NAMESPACE)));
URI changeSet = valueFactory.createURI(
Namespaces.RSINE_NAMESPACE.getName(),
"cs" +System.currentTimeMillis()+"_" +Math.round(Math.random() * 1000));
model.add(new StatementImpl(changeSet,
RDF.TYPE,
valueFactory.createURI(Namespaces.CS_NAMESPACE.getName(), "ChangeSet")));
model.add(new StatementImpl(changeSet,
valueFactory.createURI(Namespaces.CS_NAMESPACE.getName(), "createdDate"),
valueFactory.createLiteral(new Date())));
model.add(new StatementImpl(changeSet,
valueFactory.createURI(Namespaces.RSINE_NAMESPACE.getName(), "createdTimeStamp"),
valueFactory.createLiteral(System.currentTimeMillis())));
if (changeType.equals(ChangeTripleService.CHANGETYPE_REMOVE)) {
addActionStatement(model, changeSet, affectedStatement, "removal");
}
else if (changeType.equals(ChangeTripleService.CHANGETYPE_ADD)) {
addActionStatement(model, changeSet, affectedStatement, "addition");
}
else if (changeType.equals(ChangeTripleService.CHANGETYPE_UPDATE)) {
addActionStatement(model, changeSet, affectedStatement, "removal");
addActionStatement(model, changeSet, secondaryStatement, "addition");
}
return model;
}
开发者ID:rsine,项目名称:rsine,代码行数:31,代码来源:ChangeSetCreator.java
示例19: createModelFromResourceFile
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
public static Model createModelFromResourceFile(String fileName, RDFFormat format)
throws RDFParseException, IOException, RDFHandlerException
{
RDFParser rdfParser = Rio.createParser(format);
Model model = new TreeModel();
StatementCollector collector = new StatementCollector(model);
rdfParser.setRDFHandler(collector);
rdfParser.parse(Rsine.class.getResourceAsStream(fileName), "");
return model;
}
开发者ID:rsine,项目名称:rsine,代码行数:11,代码来源:Helper.java
示例20: readChangeSet
import org.openrdf.model.impl.TreeModel; //导入依赖的package包/类
private void readChangeSet() throws RDFParseException, IOException, RDFHandlerException {
RDFParser rdfParser = Rio.createParser(RDFFormat.RDFXML);
changeSet = new TreeModel();
StatementCollector collector = new StatementCollector(changeSet);
rdfParser.setRDFHandler(collector);
rdfParser.parse(Rsine.class.getResourceAsStream("/changeset.rdf"), "");
}
开发者ID:rsine,项目名称:rsine,代码行数:8,代码来源:RemoteNotificationTest.java
注:本文中的org.openrdf.model.impl.TreeModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论