use of eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor in project hale by halestudio.
the class AbstractTargetAction method run.
@Override
public void run() {
// if Display not the active Thread
if (Display.getCurrent() == null) {
// execute in display thread
PlatformUI.getWorkbench().getDisplay().asyncExec(this);
return;
}
if (params == null || params.isEmpty()) {
return;
}
// retrieve the target schema
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
SchemaSpace targetSchema = ss.getSchemas(SchemaSpaceID.TARGET);
// find type
QName typeName = QName.valueOf(params.get(0));
TypeDefinition type = targetSchema.getType(typeName);
if (type == null) {
// check all mapping relevant types for local name only
for (TypeDefinition candidate : targetSchema.getMappingRelevantTypes()) {
if (candidate.getName().getLocalPart().equals(params.get(0))) {
// use the first found
type = candidate;
break;
}
}
}
if (type != null) {
EntityDefinition entity = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
if (params.size() > 1) {
// determine property entity
EntityAccessor accessor = new EntityAccessor(entity);
for (int i = 1; i < params.size(); i++) {
QName propertyName = QName.valueOf(params.get(i));
String namespace = propertyName.getNamespaceURI();
if (namespace != null && namespace.isEmpty()) {
// treat empty namespace as ignoring namespace
namespace = null;
}
accessor = accessor.findChildren(propertyName.getLocalPart(), namespace);
}
entity = accessor.toEntityDefinition();
}
if (entity != null) {
run(entity, manager);
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", "The schema element was not found in the target schema, please make sure the correct schema is loaded.");
}
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", MessageFormat.format("The type {0} was not found in the target schema, please make sure the correct schema is loaded.", typeName.getLocalPart()));
}
}
Aggregations