Search in sources :

Example 1 with MultiInstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection in project hale by halestudio.

the class Transformation method applyFilter.

private static InstanceCollection applyFilter(List<InstanceCollection> sourceData, InstanceFilterDefinition filterDefinition) {
    List<InstanceCollection> filteredData = new ArrayList<InstanceCollection>();
    for (int i = 0; i < sourceData.size(); i++) {
        InstanceCollection collection = sourceData.get(i);
        if (filterDefinition.isGlobalContext()) {
            // add unfiltered, later apply to whole collection
            filteredData.add(collection);
        } else {
            // filter individually
            filteredData.add(collection.select(filterDefinition));
        }
    }
    InstanceCollection filteredCollection = new MultiInstanceCollection(filteredData);
    if (filterDefinition.isGlobalContext()) {
        // apply filter to combined instance collection
        filteredCollection = FilteredInstanceCollection.applyFilter(filteredCollection, filterDefinition);
    }
    return filteredCollection;
}
Also used : MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) BrowseOrientInstanceCollection(eu.esdihumboldt.hale.common.instance.orient.storage.BrowseOrientInstanceCollection) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) FilteredInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.FilteredInstanceCollection) ArrayList(java.util.ArrayList)

Example 2 with MultiInstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection in project hale by halestudio.

the class OccurringValuesServiceImpl method updateOccuringValues.

/**
 * Update the occurring values for the given property entity.
 *
 * @param property the property entity definition
 * @param values the map containing the current occurring values
 * @return <code>true</code> if the task to update the information has been
 *         started, <code>false</code> if the information was up-to-date
 */
private boolean updateOccuringValues(PropertyEntityDefinition property, Map<PropertyEntityDefinition, OccurringValuesImpl> values) {
    synchronized (values) {
        OccurringValues ov = values.get(property);
        if (ov != null && ov.isUpToDate()) {
            return false;
        }
    }
    // determine occurring values
    // determine data set
    DataSet dataSet;
    switch(property.getSchemaSpace()) {
        case TARGET:
            dataSet = DataSet.TRANSFORMED;
            break;
        default:
            dataSet = DataSet.SOURCE;
    }
    // determine if external data should be used
    boolean useExternalData = false;
    if (dataSet.equals(DataSet.SOURCE)) {
        ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
        useExternalData = InstanceViewPreferences.occurringValuesUseExternalData(ps.getConfigurationService());
    }
    InstanceCollection collection;
    if (!useExternalData) {
        collection = instances.getInstances(dataSet);
    } else {
        // use complete project data sources
        final AtomicReference<InstanceCollection> source = new AtomicReference<>();
        IRunnableWithProgress op = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
                List<InstanceCollection> sources = new ArrayList<>();
                for (Resource resource : ps.getResources()) {
                    if (InstanceIO.ACTION_LOAD_SOURCE_DATA.equals(resource.getActionId())) {
                        // resource is source data
                        IOConfiguration conf = resource.copyConfiguration(true);
                        TransformDataImportAdvisor advisor = new TransformDataImportAdvisor();
                        ProjectResourcesUtil.executeConfiguration(conf, advisor, false, null);
                        if (advisor.getInstances() != null) {
                            sources.add(advisor.getInstances());
                        }
                    }
                }
                source.set(new MultiInstanceCollection(sources));
            }
        };
        try {
            ThreadProgressMonitor.runWithProgressDialog(op, false);
            collection = source.get();
        } catch (Exception e) {
            log.error("Error initializing data sources", e);
            return true;
        }
    }
    // go through instances to determine occurring values
    Job job = new OccurringValuesJob(property, values, collection);
    job.schedule();
    return true;
}
Also used : DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) AtomicReference(java.util.concurrent.atomic.AtomicReference) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TransformDataImportAdvisor(eu.esdihumboldt.hale.ui.transformation.TransformDataImportAdvisor) OccurringValues(eu.esdihumboldt.hale.ui.service.values.OccurringValues) Job(org.eclipse.core.runtime.jobs.Job)

Example 3 with MultiInstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection in project hale by halestudio.

the class TransformDataWizard method performFinish.

/**
 * @see org.eclipse.jface.wizard.Wizard#performFinish()
 */
@Override
public boolean performFinish() {
    InstanceCollection rawSources = new MultiInstanceCollection(sourceSelectionPage.getSourceInstances());
    // Create a copy of the current alignment to be independent and run
    // everything in a job.
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Alignment alignment = new DefaultAlignment(alignmentService.getAlignment());
    // schema service for getting source schema
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    Transformation.transform(rawSources, targetSink, sourceSelectionPage.getExportJob(), sourceSelectionPage.getValidationJob(), alignment, ss.getSchemas(SchemaSpaceID.SOURCE), DefaultReportHandler.getInstance(), HaleUI.getServiceProvider(), null);
    return true;
}
Also used : MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)

Aggregations

InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)3 MultiInstanceCollection (eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection)3 ArrayList (java.util.ArrayList)2 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)1 IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)1 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)1 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)1 FilteredInstanceCollection (eu.esdihumboldt.hale.common.instance.model.impl.FilteredInstanceCollection)1 BrowseOrientInstanceCollection (eu.esdihumboldt.hale.common.instance.orient.storage.BrowseOrientInstanceCollection)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)1 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)1 OccurringValues (eu.esdihumboldt.hale.ui.service.values.OccurringValues)1 TransformDataImportAdvisor (eu.esdihumboldt.hale.ui.transformation.TransformDataImportAdvisor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1