Search in sources :

Example 26 with IOConfiguration

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;
}
Also used : IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) TreeSet(java.util.TreeSet)

Example 27 with IOConfiguration

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();
        }
    });
}
Also used : CacheCallback(eu.esdihumboldt.hale.ui.service.project.CacheCallback) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) Value(eu.esdihumboldt.hale.common.core.io.Value)

Example 28 with IOConfiguration

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));
    }
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) IOConfigurationResource(eu.esdihumboldt.hale.common.core.io.project.model.IOConfigurationResource) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) Value(eu.esdihumboldt.hale.common.core.io.Value) IOConfigurationResource(eu.esdihumboldt.hale.common.core.io.project.model.IOConfigurationResource)

Example 29 with IOConfiguration

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));
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) CachingImportProvider(eu.esdihumboldt.hale.common.core.io.CachingImportProvider) IOConfigurationResource(eu.esdihumboldt.hale.common.core.io.project.model.IOConfigurationResource)

Example 30 with IOConfiguration

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);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) InvocationTargetException(java.lang.reflect.InvocationTargetException) ExecutionException(java.util.concurrent.ExecutionException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)31 Value (eu.esdihumboldt.hale.common.core.io.Value)10 URI (java.net.URI)9 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)8 File (java.io.File)8 IOException (java.io.IOException)6 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)5 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)5 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)5 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ArrayList (java.util.ArrayList)5 IOConfigurationResource (eu.esdihumboldt.hale.common.core.io.project.model.IOConfigurationResource)4 Project (eu.esdihumboldt.hale.common.core.io.project.model.Project)4 ProjectFileInfo (eu.esdihumboldt.hale.common.core.io.project.model.ProjectFileInfo)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)3 ProjectFile (eu.esdihumboldt.hale.common.core.io.project.model.ProjectFile)3 LocationUpdater (eu.esdihumboldt.hale.common.core.io.project.util.LocationUpdater)3