use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.SchemaUpdateException in project timbuctoo by HuygensING.
the class BdbSchemaStore method finish.
@Override
public void finish() {
LOG.info("Finished processing entities");
importStatus.setStatus("Finished processing entities");
// Step 3: Add type information to inverse predicates
for (Map.Entry<String, Type> typeEntry : types.entrySet()) {
Type type = typeEntry.getValue();
String typeName = typeEntry.getKey();
for (Predicate predicate : type.getPredicates()) {
predicate.finish();
if (predicate.getDirection() == Direction.IN) {
continue;
}
for (String referenceType : predicate.getReferenceTypes().keySet()) {
try {
types.get(referenceType).getPredicate(predicate.getName(), // There must be an inverse for each outward predicate
Direction.IN).incReferenceType(type.getName(), 1);
} catch (Exception e) {
String cause = "Referenced type " + referenceType + " not found";
try {
if (types.containsKey(referenceType)) {
cause = "type does not have the inverse predicate " + predicate.getName();
if (types.get(referenceType).getPredicate(predicate.getName(), Direction.IN) != null) {
cause = "Something failed during addreferencetype(" + typeName + ")";
}
}
LOG.error("Error during inverse generation (ignored): " + cause, e);
importStatus.addError("Error during inverse generation (ignored): " + cause, e);
} catch (Exception e2) {
LOG.error("Error during inverse generation " + cause, e);
importStatus.addError("Error during inverse generation " + cause, e);
LOG.error("Error during recovery generation ", e2);
importStatus.addError("Error during recovery generation ", e2);
}
}
}
}
}
try {
try {
String serializedValue = objectMapper.writeValueAsString(types);
dataStore.setValue(serializedValue);
dataStore.commit();
stableTypes = readTypes(serializedValue);
} catch (IOException | DatabaseWriteException e) {
throw new SchemaUpdateException(e);
}
} catch (SchemaUpdateException e) {
e.printStackTrace();
}
}
Aggregations