Search in sources :

Example 6 with Cell

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

the class JoinParameterPage method onShowPage.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    super.onShowPage(firstShow);
    Cell cell = getWizard().getUnfinishedCell();
    List<? extends Entity> sourceEntities = cell.getSource().get(JOIN_TYPES);
    List<TypeEntityDefinition> types = new ArrayList<TypeEntityDefinition>();
    Iterator<? extends Entity> iter = sourceEntities.iterator();
    while (iter.hasNext()) {
        types.add(AlignmentUtil.getTypeEntity(iter.next().getDefinition()));
    }
    if (sameTypes(this.types, types)) {
        return;
    }
    if (containsDuplicateType(types)) {
        setPageComplete(false);
        setErrorMessage("The selected source types contain duplicates.");
        this.types.clear();
        table.setInput(null);
        return;
    } else {
        setErrorMessage(null);
    }
    JoinParameter initialValue = null;
    if (firstShow && !getInitialValues().get(PARAMETER_JOIN).isEmpty()) {
        initialValue = getInitialValues().get(PARAMETER_JOIN).get(0).as(JoinParameter.class);
        if (initialValue != null) {
            // use ordering of the initial value (needs to be modifiable)
            List<TypeEntityDefinition> tmp = new ArrayList<>(initialValue.getTypes());
            // append any type that were added, or remove types that were
            // removed
            tmp.retainAll(types);
            List<TypeEntityDefinition> more = new ArrayList<>(types);
            more.removeAll(tmp);
            tmp.addAll(more);
            types = tmp;
            // apply potentially changed type list
            initialValue = new JoinParameter(types, initialValue.getConditions());
            if (initialValue.validate(true) != null) {
                // try to fix config
                // not recoverable
                initialValue = null;
            }
        }
    }
    this.types = types;
    for (ConditionPage page : pages) {
        page.dispose();
    }
    pages.clear();
    if (table != null) {
        table.setInput(types);
    }
    for (int i = 1; i < types.size(); i++) {
        ConditionPage conditionPage = new ConditionPage(i);
        conditionPage.setWizard(getWizard());
        pages.add(conditionPage);
    }
    if (initialValue != null) {
        // add initial conditions
        for (JoinCondition condition : initialValue.getConditions()) {
            TypeEntityDefinition joinType = AlignmentUtil.getTypeEntity(condition.joinProperty);
            int typeIndex = types.indexOf(joinType);
            int pageIndex = typeIndex - 1;
            pages.get(pageIndex).conditions.add(condition);
            pages.get(pageIndex).updateCompletionStatus();
        }
    }
    // order is always valid, will trigger updateButtons
    setPageComplete(true);
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) ViewerCell(org.eclipse.jface.viewers.ViewerCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Example 7 with Cell

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

the class RegexAnalysisParameterPage method onShowPage.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    super.onShowPage(firstShow);
    // should never be null here, but better be safe than sorry
    Cell unfinishedCell = getWizard().getUnfinishedCell();
    if (unfinishedCell.getTarget() != null) {
        PropertyDefinition propDef = (PropertyDefinition) unfinishedCell.getTarget().values().iterator().next().getDefinition().getDefinition();
        if (!propDef.equals(target)) {
            // target property definition changed, rebuild editor
            target = propDef;
            createContent(page);
            page.layout();
            setDefaultData(unfinishedCell);
        }
    }
}
Also used : Cell(eu.esdihumboldt.hale.common.align.model.Cell) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)

Example 8 with Cell

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

the class SourceListParameterPage method onShowPage.

/**
 * @see HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    Cell cell = getWizard().getUnfinishedCell();
    // update variables as they could have changed
    variables.clear();
    List<? extends Entity> sourceEntities = cell.getSource().get(getSourcePropertyName());
    for (Entity entity : sourceEntities) {
        variables.add(entity.getDefinition());
    }
    Map<EntityDefinition, String> varsAndNames = determineDefaultVariableNames(variables);
    varTable.setInput(varsAndNames.entrySet());
    // Update project variables content provider
    projectVariablesProposalsProvider.reload();
    // inform subclasses
    sourcePropertiesChanged(varsAndNames.keySet());
    ((Composite) getControl()).layout();
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Composite(org.eclipse.swt.widgets.Composite) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Example 9 with Cell

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

the class HtmlMappingExporter method createImages.

private void createImages(File filesDir) {
    Collection<? extends Cell> cells = alignment.getCells();
    Iterator<? extends Cell> ite = cells.iterator();
    while (ite.hasNext()) {
        Cell cell = ite.next();
        saveImageToFile(cell, filesDir);
    }
}
Also used : Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 10 with Cell

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

the class GroovyCreatePage method validate.

@Override
protected boolean validate(String document) {
    super.validate(document);
    Type typeEntity = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
    if (typeEntity == null) {
        // not yet selected (NewRelationWizard)
        return false;
    }
    InstanceBuilder builder = new InstanceBuilder(false);
    Cell cell = getWizard().getUnfinishedCell();
    CellLog log = new CellLog(new DefaultTransformationReporter("dummy", false), cell);
    ExecutionContext context = new DummyExecutionContext(HaleUI.getServiceProvider());
    Binding binding = GroovyUtil.createBinding(builder, cell, cell, log, context, typeEntity.getDefinition().getDefinition());
    binding.setProperty(BINDING_INDEX, 0);
    GroovyService service = HaleUI.getServiceProvider().getService(GroovyService.class);
    Script script = null;
    try {
        script = service.parseScript(document, binding);
        GroovyUtil.evaluateAll(script, builder, typeEntity.getDefinition().getDefinition(), service, log);
    } catch (final Exception e) {
        return handleValidationResult(script, e);
    }
    return handleValidationResult(script, null);
}
Also used : Binding(groovy.lang.Binding) Script(groovy.lang.Script) Type(eu.esdihumboldt.hale.common.align.model.Type) ExecutionContext(eu.esdihumboldt.hale.common.align.transformation.function.ExecutionContext) DefaultTransformationReporter(eu.esdihumboldt.hale.common.align.transformation.report.impl.DefaultTransformationReporter) Cell(eu.esdihumboldt.hale.common.align.model.Cell) CellLog(eu.esdihumboldt.hale.common.align.transformation.report.impl.CellLog) GroovyService(eu.esdihumboldt.util.groovy.sandbox.GroovyService) InstanceBuilder(eu.esdihumboldt.hale.common.instance.groovy.InstanceBuilder)

Aggregations

Cell (eu.esdihumboldt.hale.common.align.model.Cell)123 ArrayList (java.util.ArrayList)33 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)28 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)28 Test (org.junit.Test)27 Entity (eu.esdihumboldt.hale.common.align.model.Entity)24 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)24 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)18 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)16 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)16 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)16 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)15 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)13 HashSet (java.util.HashSet)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Type (eu.esdihumboldt.hale.common.align.model.Type)11 List (java.util.List)11 ModifiableCell (eu.esdihumboldt.hale.common.align.model.ModifiableCell)9 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)9 Property (eu.esdihumboldt.hale.common.align.model.Property)8