Search in sources :

Example 31 with TypeEntityDefinition

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;
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) Condition(eu.esdihumboldt.hale.common.align.model.Condition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Filter(eu.esdihumboldt.hale.common.instance.model.Filter) QName(javax.xml.namespace.QName) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)

Example 32 with TypeEntityDefinition

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()));
    }
}
Also used : EntityAccessor(eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) QName(javax.xml.namespace.QName) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 33 with TypeEntityDefinition

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();
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)

Example 34 with TypeEntityDefinition

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];
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Pair(eu.esdihumboldt.util.Pair) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 35 with TypeEntityDefinition

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());
}
Also used : Type(eu.esdihumboldt.hale.common.align.model.Type) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) RetypeHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.RetypeHandler) Test(org.junit.Test)

Aggregations

TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)64 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)23 ArrayList (java.util.ArrayList)19 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)16 Type (eu.esdihumboldt.hale.common.align.model.Type)16 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)16 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)15 Cell (eu.esdihumboldt.hale.common.align.model.Cell)14 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)12 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)11 JoinParameter (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter)10 QName (javax.xml.namespace.QName)9 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)8 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)8 JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)6 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)6 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)6 LinkedList (java.util.LinkedList)6 Entity (eu.esdihumboldt.hale.common.align.model.Entity)5 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)5