Search in sources :

Example 21 with IOConfiguration

use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.

the class ExecTransformation method setupWriter.

private void setupWriter() {
    String preset = context.getPreset();
    String customProvider = context.getTargetProviderId();
    if (preset == null && customProvider == null) {
        fail("Please specify the name of a data export configuration preset or provide a specific provider ID for the instance writer");
    }
    // create I/O configuration
    IOConfiguration conf = null;
    if (preset != null) {
        conf = env.getExportPresets().get(preset);
    }
    if (conf == null) {
        if (customProvider == null) {
            throw fail("Data export configration preset not found: " + preset + " (please make sure you created it and saved it as part of the project)");
        } else {
            conf = new IOConfiguration();
        }
    }
    if (customProvider != null) {
        conf.setProviderId(customProvider);
    }
    // apply custom settings to configuration
    conf.getProviderConfiguration().putAll(context.getTargetSettings());
    // create I/O provider
    String writerId = conf.getProviderId();
    target = HaleIO.createIOProvider(InstanceWriter.class, null, writerId);
    target.setTarget(createTargetSupplier(context.getTarget()));
    target.setTargetSchema(env.getTargetSchema());
    // determine content type to use based on file extension
    IOProviderDescriptor factory = HaleIO.findIOProviderFactory(InstanceWriter.class, null, writerId);
    if (factory == null) {
        throw fail("Instance writer with ID " + writerId + " not found");
    }
    String path = context.getTarget().getPath();
    List<IContentType> cts;
    if (path != null) {
        cts = HaleIO.findContentTypesFor(factory.getSupportedTypes(), null, path);
    } else {
        cts = new ArrayList<>(factory.getSupportedTypes());
    }
    if (!cts.isEmpty()) {
        target.setContentType(cts.get(0));
    }
    // apply configuration (may override content type)
    target.loadConfiguration(conf.getProviderConfiguration());
}
Also used : InstanceWriter(eu.esdihumboldt.hale.common.instance.io.InstanceWriter) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 22 with IOConfiguration

use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.

the class ExportWizard method setPreset.

/**
 * Set the given preset.
 *
 * @param preset the preset name
 * @return if the preset was successfully set
 */
public boolean setPreset(String preset) {
    IOConfiguration config = projectService.getExportConfiguration(preset);
    if (config != null) {
        IOProviderDescriptor descriptor = IOProviderExtension.getInstance().getFactory(config.getProviderId());
        if (descriptor != null) {
            descriptor = new PresetDescriptor(descriptor, preset);
            setProviderFactory(descriptor);
            getProvider().loadConfiguration(config.getProviderConfiguration());
            setContentType(getProvider().getContentType());
            return true;
        }
    }
    setProviderFactory(null);
    return false;
}
Also used : IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)

Example 23 with IOConfiguration

use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.

the class SaveConfigurationInstanceExportPage method update.

/**
 * Update the page state.
 */
protected void update() {
    if (fileFormats.getSelection().isEmpty()) {
        setErrorMessage("Please select a format");
        setPageComplete(false);
        return;
    }
    String confName = name.getText();
    if (confName == null || confName.isEmpty()) {
        setErrorMessage("Please provide a name for the preset to easily identify it");
        setPageComplete(false);
        return;
    }
    setErrorMessage(null);
    // configuration with that name already present?
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    IOConfiguration conf = ps.getExportConfiguration(confName);
    if (conf == null) {
        setMessage(null);
    } else {
        setMessage("Overrides an existing configuration with the same name", DialogPage.WARNING);
    }
    setPageComplete(true);
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 24 with IOConfiguration

use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.

the class SaveConfigurationInstanceExportWizard method performFinish.

@Override
public boolean performFinish() {
    if (!applyConfiguration()) {
        return false;
    }
    IOConfiguration configuration = new IOConfiguration();
    // store the (export) configuration of the provider in the new IO
    // configuration
    configuration.setActionId(getActionId());
    configuration.setProviderId(getProviderFactory().getIdentifier());
    getProvider().storeConfiguration(configuration.getProviderConfiguration());
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    // target is not set here and also not needed for the configuration
    configuration.getProviderConfiguration().remove(ExportProvider.PARAM_TARGET);
    // add the new configuration to the export configurations of the project
    ps.addExportConfiguration(configurationName, configuration);
    log.userInfo(MessageFormat.format("Created export configuration ''{0}''", configurationName));
    return true;
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 25 with IOConfiguration

use of eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration in project hale by halestudio.

the class SaveProjectWizard method updateConfiguration.

/**
 * @see IOWizard#updateConfiguration(IOProvider)
 */
@Override
protected void updateConfiguration(ProjectWriter provider) {
    super.updateConfiguration(provider);
    // project has been set and can be adapted
    // populate and set the save configuration
    IOConfiguration saveConfiguration = new IOConfiguration();
    saveConfiguration.setActionId(ADVISOR_PROJECT_SAVE);
    saveConfiguration.setProviderId(getProviderFactory().getIdentifier());
    provider.storeConfiguration(saveConfiguration.getProviderConfiguration());
    provider.getProject().setSaveConfiguration(saveConfiguration);
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)

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