Search in sources :

Example 26 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class InstanceIndexUpdateServiceImpl method alignmentChanged.

@Override
public void alignmentChanged() {
    getIndexService().clearAll();
    AlignmentService alignmentService = serviceProvider.getService(AlignmentService.class);
    getIndexService().addPropertyMappings(alignmentService.getAlignment().getActiveTypeCells(), serviceProvider);
    reindex();
}
Also used : AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService)

Example 27 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class FeatureChainingConfigurationPage method onShowPage.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    super.onShowPage(firstShow);
    if (firstShow) {
        for (ChainPage page : pages) page.dispose();
        pages.clear();
        AlignmentService alignmentService = HaleUI.getServiceProvider().getService(AlignmentService.class);
        Alignment alignment = alignmentService.getAlignment();
        int pageIdx = 0;
        Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
        for (Cell typeCell : typeCells) {
            if (AppSchemaMappingUtils.isJoin(typeCell)) {
                JoinParameter joinParameter = getJoinParameter(typeCell);
                List<JoinCondition> conditions = getSortedJoinConditions(joinParameter);
                TypeEntityDefinition joinTarget = getTargetType(typeCell).getDefinition();
                for (int i = 0; i < joinParameter.getTypes().size() - 1; i++) {
                    ChainPage chainPage = new ChainPage(pageIdx, typeCell.getId(), i, joinParameter.getTypes(), conditions, joinTarget);
                    chainPage.setWizard(getWizard());
                    pages.add(chainPage);
                    pageIdx++;
                }
            }
        }
    }
    setPageComplete(true);
    if (!goingBack) {
        getContainer().showPage(getNextPage());
    } else {
        getContainer().showPage(getPreviousPage());
    }
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) AppSchemaMappingUtils.getJoinParameter(eu.esdihumboldt.hale.io.appschema.writer.AppSchemaMappingUtils.getJoinParameter) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) Cell(eu.esdihumboldt.hale.common.align.model.Cell) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Example 28 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class GroovyTransformationPage method validate.

@Override
protected boolean validate(String document) {
    super.validate(document);
    List<PropertyValue> values = new ArrayList<PropertyValue>();
    for (EntityDefinition var : getVariables()) {
        if (var instanceof PropertyEntityDefinition) {
            PropertyEntityDefinition property = (PropertyEntityDefinition) var;
            values.add(new PropertyValueImpl(testValues.get(property), property));
        }
    }
    Property targetProperty = (Property) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
    if (targetProperty == null) {
        // not yet selected (NewRelationWizard)
        return false;
    }
    InstanceBuilder builder = GroovyTransformation.createBuilder(targetProperty.getDefinition());
    Cell cell = getWizard().getUnfinishedCell();
    boolean useInstanceValues = CellUtil.getOptionalParameter(cell, GroovyTransformation.PARAM_INSTANCE_VARIABLES, Value.of(false)).as(Boolean.class);
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    GroovyService gs = HaleUI.getServiceProvider().getService(GroovyService.class);
    Script script = null;
    try {
        Collection<? extends Cell> typeCells = as.getAlignment().getTypeCells(cell);
        // select one matching type cell, the script has to run for all
        // matching cells
        // if there is no matching cell it may produce a npe, which is okay
        Cell typeCell = null;
        if (!typeCells.isEmpty()) {
            typeCell = typeCells.iterator().next();
        }
        CellLog log = new CellLog(new DefaultTransformationReporter("dummy", false), cell);
        ExecutionContext context = new DummyExecutionContext(HaleUI.getServiceProvider());
        groovy.lang.Binding binding;
        if (cell.getTransformationIdentifier().equals(GroovyGreedyTransformation.ID)) {
            binding = GroovyGreedyTransformation.createGroovyBinding(values, null, cell, typeCell, builder, useInstanceValues, log, context, targetProperty.getDefinition().getDefinition().getPropertyType());
        } else {
            binding = GroovyTransformation.createGroovyBinding(values, null, cell, typeCell, builder, useInstanceValues, log, context, targetProperty.getDefinition().getDefinition().getPropertyType());
        }
        script = gs.parseScript(document, binding);
        GroovyTransformation.evaluate(script, builder, targetProperty.getDefinition().getDefinition().getPropertyType(), gs, log);
    } catch (NoResultException e) {
    // continue
    } catch (final Exception e) {
        return handleValidationResult(script, e);
    }
    return handleValidationResult(script, null);
}
Also used : Script(groovy.lang.Script) ArrayList(java.util.ArrayList) DefaultTransformationReporter(eu.esdihumboldt.hale.common.align.transformation.report.impl.DefaultTransformationReporter) PropertyValue(eu.esdihumboldt.hale.common.align.transformation.function.PropertyValue) NoResultException(eu.esdihumboldt.hale.common.align.transformation.function.impl.NoResultException) GroovyService(eu.esdihumboldt.util.groovy.sandbox.GroovyService) NoResultException(eu.esdihumboldt.hale.common.align.transformation.function.impl.NoResultException) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) ExecutionContext(eu.esdihumboldt.hale.common.align.transformation.function.ExecutionContext) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) Property(eu.esdihumboldt.hale.common.align.model.Property) Cell(eu.esdihumboldt.hale.common.align.model.Cell) CellLog(eu.esdihumboldt.hale.common.align.transformation.report.impl.CellLog) PropertyValueImpl(eu.esdihumboldt.hale.common.align.transformation.function.impl.PropertyValueImpl) InstanceBuilder(eu.esdihumboldt.hale.common.instance.groovy.InstanceBuilder)

Example 29 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class NewRelationWizard method performFinish.

/**
 * @see MultiWizard#performFinish()
 */
@Override
public boolean performFinish() {
    // performFinish of the function wizard was called first
    FunctionWizard functionWizard = getSelectionPage().getFunctionWizard();
    if (functionWizard == null) {
        return false;
    }
    MutableCell cell = functionWizard.getResult();
    if (cell != null) {
        AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
        as.addCell(cell);
    }
    createdCell = cell;
    // save page configuration
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    getSelectionPage().store(ps.getConfigurationService());
    return true;
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) FunctionWizard(eu.esdihumboldt.hale.ui.function.FunctionWizard)

Example 30 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class FunctionsView method createViewControl.

/**
 * @see eu.esdihumboldt.hale.ui.views.properties.PropertiesViewPart#createViewControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createViewControl(Composite parent) {
    viewer = new TreeViewer(parent);
    viewer.setLabelProvider(new FunctionLabelProvider());
    viewer.setContentProvider(new FunctionContentProvider(HaleUI.getServiceProvider()));
    IToolBarManager manager = getViewSite().getActionBars().getToolBarManager();
    IAction filterAction = new FilterAction("Filter incompatible functions", Action.AS_CHECK_BOX, CommonSharedImages.getImageRegistry().getDescriptor("IMG_FILTER_CLEAR"));
    manager.add(filterAction);
    filterAction.setChecked(true);
    filterAction.run();
    CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
    cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {

        @Override
        public void currentObjectChanged(CompatibilityMode current, CompatibilityModeFactory definition) {
            // refresh the viewer when the compatibility mode is
            // changed
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    viewer.refresh();
                }
            });
        }
    });
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    as.addListener(alignListener = new AlignmentServiceAdapter() {

        @Override
        public void alignmentCleared() {
            customFunctionsChanged();
        }

        @Override
        public void customFunctionsChanged() {
            // refresh the viewer when the compatibility mode is changed
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    viewer.refresh();
                }
            });
        }
    });
    // no input needed, but we have to set something
    viewer.setInput(Boolean.TRUE);
    new ViewerMenu(getSite(), viewer);
    getSite().setSelectionProvider(viewer);
}
Also used : IAction(org.eclipse.jface.action.IAction) CompatibilityModeFactory(eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory) CompatibilityMode(eu.esdihumboldt.hale.common.align.compatibility.CompatibilityMode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExclusiveExtensionListener(de.fhg.igd.eclipse.util.extension.exclusive.ExclusiveExtension.ExclusiveExtensionListener) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu) FunctionLabelProvider(eu.esdihumboldt.hale.ui.common.function.viewer.FunctionLabelProvider) IToolBarManager(org.eclipse.jface.action.IToolBarManager) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) CompatibilityService(eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityService) FunctionContentProvider(eu.esdihumboldt.hale.ui.common.function.viewer.FunctionContentProvider) AlignmentServiceAdapter(eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter) Display(org.eclipse.swt.widgets.Display)

Aggregations

AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)43 Cell (eu.esdihumboldt.hale.common.align.model.Cell)16 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ArrayList (java.util.ArrayList)8 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)6 ISelection (org.eclipse.jface.viewers.ISelection)6 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)5 AlignmentServiceAdapter (eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter)5 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)4 CompatibilityService (eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityService)4 HashSet (java.util.HashSet)4 Display (org.eclipse.swt.widgets.Display)4 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)3 IAction (org.eclipse.jface.action.IAction)3 ControlAdapter (org.eclipse.swt.events.ControlAdapter)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3