Search in sources :

Example 6 with Alignment

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

the class TestUtil method loadAlignment.

/**
 * Loads the specified alignment. Assumes that its base alignments don't
 * need a location update.
 *
 * @param location the URI specifying the location of the alignment
 * @param sourceTypes the source type index
 * @param targetTypes the target type index
 * @return the loaded alignment
 * @throws Exception if the alignment or other resources could not be loaded
 */
public static Alignment loadAlignment(final URI location, Schema sourceTypes, Schema targetTypes) throws Exception {
    DefaultInputSupplier input = new DefaultInputSupplier(location);
    IOReporter report = new DefaultIOReporter(new Locatable() {

        @Override
        public URI getLocation() {
            return location;
        }
    }, "Load alignment", AlignmentIO.ACTION_LOAD_ALIGNMENT, true);
    Alignment alignment;
    try {
        alignment = CastorAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null));
    } catch (Exception e) {
        alignment = JaxbAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null), null, null);
    }
    assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
    return alignment;
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) PathUpdate(eu.esdihumboldt.hale.common.core.io.PathUpdate) URI(java.net.URI) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Example 7 with Alignment

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

the class AbstractDefaultFunctionService method getPropertyFunctions.

@Override
public Collection<? extends PropertyFunctionDefinition> getPropertyFunctions() {
    Collection<? extends PropertyFunctionDefinition> functions = super.getPropertyFunctions();
    Alignment al = getCurrentAlignment();
    if (al != null) {
        List<PropertyFunctionDefinition> cfs = new ArrayList<>();
        for (CustomPropertyFunction cf : al.getAllCustomPropertyFunctions().values()) {
            cfs.add(new AlignmentFunctionDescriptor(cf.getDescriptor()));
        }
        cfs.addAll(functions);
        functions = cfs;
    }
    return functions;
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) ArrayList(java.util.ArrayList) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)

Example 8 with Alignment

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

the class AbstractDefaultFunctionService method getPropertyFunctions.

@Override
public Collection<? extends PropertyFunctionDefinition> getPropertyFunctions(String categoryId) {
    Collection<? extends PropertyFunctionDefinition> functions = super.getPropertyFunctions(categoryId);
    Alignment al = getCurrentAlignment();
    if (al != null) {
        List<PropertyFunctionDefinition> cfs = new ArrayList<>();
        for (CustomPropertyFunction cf : al.getAllCustomPropertyFunctions().values()) {
            PropertyFunctionDefinition descriptor = cf.getDescriptor();
            if (Objects.equal(categoryId, descriptor.getCategoryId())) {
                cfs.add(new AlignmentFunctionDescriptor(descriptor));
            }
        }
        cfs.addAll(functions);
        functions = cfs;
    }
    return functions;
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) ArrayList(java.util.ArrayList) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)

Example 9 with Alignment

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

the class AlignmentView method updateRelation.

/**
 * Update the selected type relation to a cell that is related to the given
 * schema selection.
 *
 * @param selection the schema selection
 */
private void updateRelation(SchemaSelection selection) {
    Cell typeCell = sourceTargetSelector.getSelectedCell();
    if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) && associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
        // type cell is associated with source and target, don't change
        return;
    }
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Alignment alignment = as.getAlignment();
    // find type cell associated with both source and target
    for (Cell cell : alignment.getTypeCells()) {
        if ((associatedWithType(cell.getSource(), selection.getSourceItems())) && associatedWithType(cell.getTarget(), selection.getTargetItems())) {
            // typeRelations.setSelection(new StructuredSelection(cell));
            sourceTargetSelector.setSelection(new StructuredSelection(cell));
            return;
        }
    }
    if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) || associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
        // type cell is associated with source or target, don't change
        return;
    }
    // find type cell associated with source or target
    for (Cell cell : alignment.getTypeCells()) {
        if ((associatedWithType(cell.getSource(), selection.getSourceItems())) || associatedWithType(cell.getTarget(), selection.getTargetItems())) {
            sourceTargetSelector.setSelection(new StructuredSelection(cell));
            // typeRelations.setSelection(new StructuredSelection(cell));
            return;
        }
    }
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 10 with Alignment

use of eu.esdihumboldt.hale.common.align.model.Alignment 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)

Aggregations

Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)23 Cell (eu.esdihumboldt.hale.common.align.model.Cell)12 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)10 ArrayList (java.util.ArrayList)9 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)6 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)5 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)5 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)5 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)4 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)3 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)3 URI (java.net.URI)3 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ATransaction (de.fhg.igd.slf4jplus.ATransaction)2 PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)2 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)2 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)2