use of com.revolsys.record.io.RecordStoreExtension in project com.revolsys.open by revolsys.
the class RecordStoreSchema method refresh.
@Override
public synchronized void refresh() {
this.initialized = true;
final AbstractRecordStore recordStore = getRecordStore();
if (recordStore != null) {
recordStore.initialize();
final Collection<RecordStoreExtension> extensions = recordStore.getRecordStoreExtensions();
for (final RecordStoreExtension extension : extensions) {
try {
if (extension.isEnabled(recordStore)) {
extension.preProcess(this);
}
} catch (final Throwable e) {
Logs.error(extension, "Unable to pre-process schema: " + this, e);
}
}
try {
final Map<PathName, ? extends RecordStoreSchemaElement> elementsByPath = recordStore.refreshSchemaElements(this);
final Set<PathName> removedPaths = new HashSet<>(this.elementsByPath.keySet());
for (final Entry<PathName, ? extends RecordStoreSchemaElement> entry : elementsByPath.entrySet()) {
final PathName path = entry.getKey();
removedPaths.remove(path);
final RecordStoreSchemaElement newElement = entry.getValue();
final RecordStoreSchemaElement oldElement = this.elementsByPath.get(path);
if (oldElement == null) {
addElement(newElement);
} else {
replaceElement(path, oldElement, newElement);
}
}
for (final PathName removedPath : removedPaths) {
removeElement(removedPath);
}
for (final RecordDefinition recordDefinition : getRecordDefinitions()) {
recordStore.initRecordDefinition(recordDefinition);
}
} catch (final Throwable e) {
Logs.error(this, "Unable to refresh schema: " + this, e);
}
for (final RecordStoreExtension extension : extensions) {
try {
if (extension.isEnabled(recordStore)) {
extension.postProcess(this);
}
} catch (final Throwable e) {
Logs.error(extension, "Unable to post-process schema: " + this, e);
}
}
}
}
Aggregations