use of eu.esdihumboldt.hale.common.core.io.project.model.Resource in project hale by halestudio.
the class ProjectServiceImpl method removeResource.
@Override
public void removeResource(String resourceId) {
Resource removedResource = null;
synchronized (this) {
Iterator<IOConfiguration> iter = main.getResources().iterator();
while (iter.hasNext()) {
IOConfiguration conf = iter.next();
Value idValue = conf.getProviderConfiguration().get(ImportProvider.PARAM_RESOURCE_ID);
if (idValue != null) {
String id = idValue.as(String.class);
if (resourceId.equals(id)) {
// match found, remove
iter.remove();
removedResource = new IOConfigurationResource(conf, projectLocation);
break;
}
}
}
}
if (removedResource != null) {
setChanged();
notifyResourcesRemoved(removedResource.getActionId(), Collections.singletonList(removedResource));
}
}
use of eu.esdihumboldt.hale.common.core.io.project.model.Resource 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;
}
Aggregations