Search in sources :

Example 11 with Condition

use of eu.esdihumboldt.hale.common.align.model.Condition in project hale by halestudio.

the class EntityDefinitionServiceImpl method getTypeEntities.

/**
 * @see EntityDefinitionService#getTypeEntities(TypeDefinition,
 *      SchemaSpaceID)
 */
@Override
public Collection<? extends TypeEntityDefinition> getTypeEntities(TypeDefinition type, SchemaSpaceID schemaSpace) {
    TypeEntityDefinition ted = new TypeEntityDefinition(type, schemaSpace, null);
    Set<Condition> conditions;
    synchronized (conditionContexts) {
        conditions = conditionContexts.get(ted);
    }
    List<TypeEntityDefinition> result = new ArrayList<TypeEntityDefinition>();
    // add default type entity
    result.add(ted);
    // type entity definitions with filters
    for (Condition condition : conditions) {
        result.add(new TypeEntityDefinition(type, schemaSpace, condition.getFilter()));
    }
    return result;
}
Also used : Condition(eu.esdihumboldt.hale.common.align.model.Condition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) ArrayList(java.util.ArrayList)

Example 12 with Condition

use of eu.esdihumboldt.hale.common.align.model.Condition in project hale by halestudio.

the class EditConditionContextHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof EntityDefinition) {
            EntityDefinition entityDef = (EntityDefinition) element;
            String title;
            if (entityDef.getPropertyPath().isEmpty())
                title = "Edit type condition";
            else
                title = "Edit property condition";
            Condition condition = AlignmentUtil.getContextCondition(entityDef);
            if (condition != null && condition.getFilter() != null) {
                Pair<String, String> filterDef = FilterDefinitionManager.getInstance().asPair(condition.getFilter());
                if (filterDef != null && filterDef.getFirst() != null) {
                    String filterId = filterDef.getFirst();
                    // retrieve filter UI from extension point
                    FilterDialogDefinition def = FilterUIExtension.getInstance().getFactory(filterId);
                    if (def != null) {
                        Filter filter = null;
                        try {
                            filter = def.createExtensionObject().openDialog(HandlerUtil.getActiveShell(event), entityDef, title, "Define the condition for the new context");
                        } catch (Exception e) {
                            log.userError("Failed to create editor for filter", e);
                        }
                        if (filter != null) {
                            EntityDefinitionService eds = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
                            eds.editConditionContext((EntityDefinition) element, filter);
                        }
                    } else {
                        log.userError("No editor for this kind of filter available");
                    }
                } else {
                    log.error("No filter definition for filter found, definition ID could not be determined");
                }
            }
        }
    }
    return null;
}
Also used : Condition(eu.esdihumboldt.hale.common.align.model.Condition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Filter(eu.esdihumboldt.hale.common.instance.model.Filter) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FilterDialogDefinition(eu.esdihumboldt.hale.ui.filter.extension.FilterDialogDefinition) ExecutionException(org.eclipse.core.commands.ExecutionException) EntityDefinitionService(eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService)

Aggregations

Condition (eu.esdihumboldt.hale.common.align.model.Condition)12 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)8 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)8 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)6 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)6 Filter (eu.esdihumboldt.hale.common.instance.model.Filter)4 ArrayList (java.util.ArrayList)4 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 EntityDefinitionService (eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Predicate (com.google.common.base.Predicate)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)1 Property (eu.esdihumboldt.hale.common.align.model.Property)1 JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)1 SourceNode (eu.esdihumboldt.hale.common.align.model.transformation.tree.SourceNode)1