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