use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.
the class CQLFilterDialogFactory method openDialog.
@Override
public Filter openDialog(Shell shell, EntityDefinition entityDef, String title, String message) {
TypeEntityDefinition parentType;
if (entityDef.getPropertyPath().isEmpty())
parentType = AlignmentUtil.getTypeEntity(entityDef);
else {
Definition<?> def = entityDef.getDefinition();
TypeDefinition propertyType = ((PropertyDefinition) def).getPropertyType();
// create a dummy type for the filter
TypeDefinition dummyType = new DefaultTypeDefinition(new QName("ValueFilterDummy"));
// create dummy type entity
Condition condition = AlignmentUtil.getContextCondition(entityDef);
Filter filter = condition == null ? null : condition.getFilter();
parentType = new TypeEntityDefinition(dummyType, entityDef.getSchemaSpace(), filter);
// with the property type being contained as value
// property
new DefaultPropertyDefinition(new QName("value"), dummyType, propertyType);
// and the parent type as parent property
new DefaultPropertyDefinition(new QName("parent"), dummyType, ((PropertyDefinition) def).getParentType());
}
CQLFilterDialog dialog = new CQLFilterDialog(shell, parentType, title, message);
if (dialog.open() == CQLFilterDialog.OK) {
return dialog.getFilter();
}
return null;
}
use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition 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()));
}
}
use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.
the class JoinParameterPage method swapTypes.
/**
* Swaps the given types, their pages and validates all affected pages
* conditions after the change.
*
* @param lowerTypeIndex the lower type index
* @param higherTypeIndex the higher type index
*/
private void swapTypes(int lowerTypeIndex, int higherTypeIndex) {
TypeEntityDefinition lowerType = types.get(lowerTypeIndex);
types.set(lowerTypeIndex, types.get(higherTypeIndex));
types.set(higherTypeIndex, lowerType);
table.refresh();
// swap pages accordingly
int lowerPageIndex = lowerTypeIndex - 1;
int higherPageIndex = higherTypeIndex - 1;
if (lowerPageIndex != -1) {
// swap the page positions together with their types
// so it is possible to keep some conditions from before
ConditionPage lowerPage = pages.get(lowerPageIndex);
ConditionPage higherPage = pages.get(higherPageIndex);
lowerPage.typeIndex = higherTypeIndex;
pages.set(higherPageIndex, lowerPage);
higherPage.typeIndex = lowerTypeIndex;
pages.set(lowerPageIndex, higherPage);
}
// check and refresh pages in between
for (ConditionPage page : pages.subList(Math.max(0, lowerPageIndex), higherPageIndex + 1)) page.checkAndRefresh();
getContainer().updateButtons();
}
use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.
the class TypeMetaPairContentProvider method getElements.
/**
* @see TypeIndexContentProvider#getElements(Object)
*/
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Pair<?, ?>) {
Pair<?, ?> pair = (Pair<?, ?>) inputElement;
Object type = pair.getFirst();
if (type instanceof TypeDefinition) {
type = new TypeEntityDefinition((TypeDefinition) type, getSchemaSpace(), null);
}
// second item will be a set of metadata keys
return new Object[] { type, pair.getSecond() };
} else
return new Object[0];
}
use of eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition in project hale by halestudio.
the class AppSchemaMappingTest method testRetypeHandler.
@Test
public void testRetypeHandler() {
DefaultCell cell = new DefaultCell();
cell.setTransformationIdentifier(RetypeFunction.ID);
ListMultimap<String, Type> source = ArrayListMultimap.create();
source.put(null, new DefaultType(new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null)));
ListMultimap<String, Type> target = ArrayListMultimap.create();
target.put(null, new DefaultType(new TypeEntityDefinition(landCoverUnitType, SchemaSpaceID.TARGET, null)));
cell.setSource(source);
cell.setTarget(target);
RetypeHandler handler = new RetypeHandler();
FeatureTypeMapping ftMapping = handler.handleTypeTransformation(cell, new AppSchemaMappingContext(mappingWrapper));
assertEquals(SOURCE_UNIT_DENORM, ftMapping.getSourceType());
assertEquals("lcv:LandCoverUnit", ftMapping.getTargetElement());
}
Aggregations