use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.
the class ProjectServiceImpl method getExportConfigurationNames.
@Override
public Collection<String> getExportConfigurationNames(Class<? extends IOProvider> providerClass) {
Set<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (Entry<String, IOConfiguration> entry : main.getExportConfigurations().entrySet()) {
IOConfiguration conf = entry.getValue();
String providerId = conf.getProviderId();
IOProviderDescriptor descr = IOProviderExtension.getInstance().getFactory(providerId);
if (descr != null && providerClass.isAssignableFrom(descr.getProviderType())) {
result.add(entry.getKey());
}
}
return result;
}
use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.
the class ProjectServiceImpl method executeConfiguration.
/**
* Execute a single I/O configuration.
*
* @param conf the I/O configuration
*/
private void executeConfiguration(final IOConfiguration conf) {
// work with a cloned configuration for the case that we make a relative
// URI absolute
IOConfiguration cloned = conf.clone();
updater.updateIOConfiguration(cloned, false);
ProjectResourcesUtil.executeConfiguration(cloned, new CacheCallback() {
@Override
public void update(Value cache) {
// update the original configuration with the new cache value
conf.setCache(cache);
// set the project status to changed
setChanged();
}
});
}
use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration 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.IOConfiguration in project hale by halestudio.
the class ProjectServiceImpl method rememberIO.
/**
* @see ProjectService#rememberIO(String, String, IOProvider)
*/
@Override
public void rememberIO(String actionId, String providerId, IOProvider provider) {
// populate an IOConfiguration from the given data
IOConfiguration conf = new IOConfiguration();
conf.setActionId(actionId);
conf.setProviderId(providerId);
provider.storeConfiguration(conf.getProviderConfiguration());
if (provider instanceof CachingImportProvider) {
conf.setCache(((CachingImportProvider) provider).getCache());
}
// add configuration to project
synchronized (this) {
main.getResources().add(conf);
}
setChanged();
notifyResourceAdded(actionId, new IOConfigurationResource(conf, projectLocation));
}
use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.
the class ProjectServiceImpl method reloadSourceData.
@Override
public void reloadSourceData() {
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Reload source data", IProgressMonitor.UNKNOWN);
monitor.subTask("Clear loaded instances");
// drop the existing instances
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
is.dropInstances();
// reload the instances
for (IOConfiguration conf : main.getResources()) {
if (InstanceIO.ACTION_LOAD_SOURCE_DATA.equals(conf.getActionId())) {
executeConfiguration(conf);
}
}
monitor.done();
}
};
try {
ThreadProgressMonitor.runWithProgressDialog(op, false);
} catch (Exception e) {
log.error("Executing data reload failed", e);
}
}
Aggregations