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;
}
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;
}
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;
}
Aggregations