use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class SecuredModelImpl method remove.
/**
* @sec.graph Update
* @sec.triple Delete on every statement in statements.
* @throws UpdateDeniedException
* @throws DeleteDeniedException
* @throws AuthenticationRequiredException if user is not authenticated and is
* required to be.
*/
@Override
public SecuredModel remove(final List<Statement> statements) throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
checkUpdate();
if (!canDelete(Triple.ANY)) {
for (final Statement s : statements) {
checkDelete(s);
}
}
holder.getBaseItem().remove(statements);
return holder.getSecuredItem();
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class SecuredModelImpl method remove.
/**
* @sec.graph Update
* @sec.triple Delete on every statement in baseModel.
* @throws UpdateDeniedException
* @throws DeleteDeniedException
* @throws AuthenticationRequiredException if user is not authenticated and is
* required to be.
*/
@Override
public SecuredModel remove(final Model m) throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
checkUpdate();
if (!canDelete(Triple.ANY)) {
final StmtIterator iter = m.listStatements();
try {
while (iter.hasNext()) {
final Statement stmt = iter.next();
checkDelete(stmt);
}
} finally {
iter.close();
}
}
holder.getBaseItem().remove(m);
return holder.getSecuredItem();
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class ShaclTests method processEntries.
private static void processEntries(String file, Resource manifest, List<ShaclTestItem> testCases) {
StmtIterator entriesStmts = manifest.listProperties(MF.entries);
for (; entriesStmts.hasNext(); ) {
Statement s = entriesStmts.nextStatement();
processEntry(file, s.getResource(), testCases);
}
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class ShaclTests method manifest.
private static void manifest(String manifestFile, List<String> manifests, List<ShaclTestItem> testCases) {
if (manifests.contains(manifestFile))
return;
manifests.add(manifestFile);
// System.err.println("Load: "+manifestFile);
Model model = RDFDataMgr.loadModel(manifestFile);
List<String> includedFiles = new ArrayList<>();
StmtIterator manifestStmts = model.listStatements(null, RDF.type, MF.Manifest);
for (; manifestStmts.hasNext(); ) {
Statement stmt = manifestStmts.next();
Resource manifest = stmt.getSubject();
parseIncludes(manifest, manifests, testCases);
processEntries(manifestFile, manifest, testCases);
}
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class DefineAnalyzersAssembler method open.
public static boolean open(Assembler a, Resource list) {
Resource current = list;
boolean isMultilingualSupport = false;
while (current != null && !current.equals(RDF.nil)) {
Statement firstStmt = current.getProperty(RDF.first);
if (firstStmt == null) {
throw new TextIndexException("parameter list not well formed: " + current);
}
RDFNode first = firstStmt.getObject();
if (!first.isResource()) {
throw new TextIndexException("parameter specification must be an anon resource : " + first);
}
// process the current list element to add an analyzer
Resource adding = (Resource) first;
if (adding.hasProperty(TextVocab.pAnalyzer)) {
Statement analyzerStmt = adding.getProperty(TextVocab.pAnalyzer);
RDFNode analyzerNode = analyzerStmt.getObject();
if (!analyzerNode.isResource()) {
throw new TextIndexException("addAnalyzers text:analyzer must be an analyzer spec resource: " + analyzerNode);
}
// calls GenericAnalyzerAssembler
Analyzer analyzer = (Analyzer) a.open((Resource) analyzerNode);
if (adding.hasProperty(TextVocab.pDefAnalyzer)) {
Statement defStmt = adding.getProperty(TextVocab.pDefAnalyzer);
Resource id = defStmt.getResource();
if (id.getURI() != null) {
Util.defineAnalyzer(id, analyzer);
} else {
throw new TextIndexException("addAnalyzers text:defineAnalyzer property must be a uri resource: " + adding);
}
}
if (adding.hasProperty(TextVocab.pAddLang)) {
Statement langStmt = adding.getProperty(TextVocab.pAddLang);
String langCode = langStmt.getString();
if (StringUtils.isNotBlank(langCode)) {
Util.addAnalyzer(langCode, analyzer);
isMultilingualSupport = true;
if (adding.hasProperty(TextVocab.pSearchFor)) {
Statement searchForStmt = adding.getProperty(TextVocab.pSearchFor);
List<String> tags = getStringList(searchForStmt, "text:searchFor");
Util.addSearchForTags(langCode, tags);
}
if (adding.hasProperty(TextVocab.pAuxIndex)) {
Statement auxIndexStmt = adding.getProperty(TextVocab.pAuxIndex);
List<String> tags = getStringList(auxIndexStmt, "text:auxIndex");
Util.addAuxIndexes(langCode, tags);
log.trace("addAuxIndexes for {} with tags: {}", langCode, tags);
}
if (adding.hasProperty(TextVocab.pIndexAnalyzer)) {
Statement indexStmt = adding.getProperty(TextVocab.pIndexAnalyzer);
Resource key = indexStmt.getResource();
Analyzer indexer = Util.getDefinedAnalyzer(key);
Util.addIndexAnalyzer(langCode, indexer);
log.trace("addIndexAnalyzer lang: {} with analyzer: {}", langCode, indexer);
}
} else {
throw new TextIndexException("text:addLang property must be a non-blank string: " + adding);
}
}
}
Statement restStmt = current.getProperty(RDF.rest);
if (restStmt == null) {
throw new TextIndexException("parameter list not terminated by rdf:nil");
}
RDFNode rest = restStmt.getObject();
if (!rest.isResource()) {
throw new TextIndexException("parameter list node is not a resource : " + rest);
}
current = (Resource) rest;
}
Util.finishCaching();
return isMultilingualSupport;
}
Aggregations