use of org.openrdf.sail.SailException in project backstage by zepheira.
the class Database method createTypeRecord.
private TypeRecord createTypeRecord(URI type, SailConnection sc) {
String id = getTypeId(type, sc);
String label = SailUtilities.getStringObject(sc, type, RDFS.LABEL, id);
Properties properties = new Properties();
CloseableIteration<? extends Statement, SailException> i = null;
try {
i = sc.getStatements(type, null, null, true);
} catch (SailException e) {
_logger.error("Failed to get all statements in order to get type record", e);
return null;
}
if (i != null) {
try {
while (i.hasNext()) {
Statement s = i.next();
URI p = s.getPredicate();
Value o = s.getObject();
if (!p.equals(RDFS.LABEL) && !p.equals(ExhibitOntology.ID)) {
properties.put(p.getLocalName(), SailUtilities.valueToString(o));
}
}
} catch (SailException e) {
_logger.warn("Failed to iterate through statements", e);
} finally {
try {
i.close();
} catch (SailException e) {
_logger.warn("Failed to close statement iterator", e);
}
}
}
return new TypeRecord(type, id, label, properties);
}
use of org.openrdf.sail.SailException in project backstage by zepheira.
the class Database method abbreviateItems.
protected synchronized void abbreviateItems() {
if (_abbreviatedItems) {
return;
}
_abbreviatedItems = true;
getRepository();
SailConnection sc = null;
try {
sc = _sail.getConnection();
} catch (SailException e) {
_logger.error("Failed to open sail connection in order to compute cached information", e);
}
if (sc != null) {
try {
CloseableIteration<? extends Statement, SailException> i;
try {
i = sc.getStatements(null, RDF.TYPE, null, true);
} catch (SailException e) {
_logger.error("Failed to get all statements in order to abbreviate items", e);
return;
}
try {
while (i.hasNext()) {
Statement s = i.next();
Resource r = s.getSubject();
if (r instanceof URI) {
getItemId((URI) r, sc);
}
}
} catch (SailException e) {
_logger.warn("Failed to iterate through statements", e);
} finally {
try {
i.close();
} catch (SailException e) {
_logger.warn("Failed to close statement iterator", e);
}
}
} finally {
try {
sc.close();
} catch (SailException e) {
_logger.warn("Failed to close sail connection", e);
}
}
}
}
use of org.openrdf.sail.SailException in project backstage by zepheira.
the class Database method internalBuildTypeRecords.
private void internalBuildTypeRecords(SailConnection sc) {
_typeRecords = new LinkedList<TypeRecord>();
_typeIDToRecord = new HashMap<String, TypeRecord>();
getRepository();
CloseableIteration<? extends Statement, SailException> i;
try {
i = sc.getStatements(null, RDF.TYPE, null, true);
} catch (SailException e) {
_logger.error("Failed to get all statements in order to get type records", e);
return;
}
Set<URI> types = new HashSet<URI>();
try {
while (i.hasNext()) {
Statement s = i.next();
types.add((URI) s.getObject());
}
} catch (SailException e) {
_logger.warn("Failed to iterate through statements", e);
} finally {
try {
i.close();
} catch (SailException e) {
_logger.warn("Failed to close statement iterator", e);
}
}
for (URI type : types) {
TypeRecord r = createTypeRecord(type, sc);
if (r != null) {
_typeRecords.add(r);
_typeIDToRecord.put(r.id, r);
}
}
}
Aggregations