use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class ProjectToJaxb method toIOConfigurationType.
/**
* Converts an I/O configuration to its JAXB representation.
*
* @param config the I/O configuration
* @return the JAXB representation
*/
public static IOConfigurationType toIOConfigurationType(IOConfiguration config) {
if (config == null) {
return null;
}
IOConfigurationType result = new IOConfigurationType();
result.setActionId(config.getActionId());
result.setProviderId(config.getProviderId());
for (Entry<String, Value> setting : config.getProviderConfiguration().entrySet()) {
Object property = createProperty(setting.getKey(), setting.getValue());
if (property instanceof PropertyType) {
result.getAbstractSetting().add(of.createSetting((PropertyType) property));
} else if (property instanceof ComplexPropertyType) {
result.getAbstractSetting().add(of.createComplexSetting((ComplexPropertyType) property));
}
}
// cache
Value cache = config.getCache();
if (cache != null && cache.getValue() != null) {
ValueType value = new ValueType();
if (cache.isRepresentedAsDOM()) {
value.setAny(cache.getDOMRepresentation());
} else {
value.setValue(cache.getStringRepresentation());
}
result.setCache(value);
}
return result;
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class LocationUpdater method updateIOConfiguration.
/**
* Updates the source location of the given configuration.
*
* @param configuration the configuration to update
* @param keepRelative whether to keep working relative URI as is or make it
* absolute
*/
public void updateIOConfiguration(IOConfiguration configuration, boolean keepRelative) {
final Map<String, Value> conf = configuration.getProviderConfiguration();
final URI uri = URI.create(conf.get(ImportProvider.PARAM_SOURCE).as(String.class));
URI resolved = findLocation(uri, true, true, keepRelative);
if (resolved != null)
conf.put(ImportProvider.PARAM_SOURCE, Value.of(resolved.toString()));
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class Message method applyFromValue.
/**
* Apply from a given {@link Value}, if the value represents a
* {@link Message}.
*
* @param value the value to interpret as {@link Message}
* @return this for chaining
*/
@Nullable
public Message applyFromValue(Value value) {
ValueProperties props = value.as(ValueProperties.class);
if (props != null) {
String text = props.get("text").as(String.class);
if (text != null && !text.isEmpty()) {
//
setText(text).setAuthor(//
props.getSafe("author").as(String.class)).setFormat(//
props.getSafe("format").as(String.class)).setCategory(//
props.getSafe("category").as(String.class)).setDismissed(//
props.getSafe("dismissed").as(Boolean.class, false)).setCustomPayload(props.get("payload"));
ValueList tags = props.getSafe("tags").as(ValueList.class);
this.tags.clear();
if (tags != null) {
for (Value tag : tags) {
String tagString = tag.as(String.class);
if (tagString != null) {
addTag(tagString);
}
}
}
ValueList comments = props.getSafe("comments").as(ValueList.class);
this.comments.clear();
if (comments != null) {
for (Value commentVal : comments) {
Optional<Comment> comment = Comment.fromValue(commentVal);
comment.ifPresent(c -> addComment(c));
}
}
}
}
return this;
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class HaleConnectTarget method updateConfiguration.
@Override
public boolean updateConfiguration(HaleConnectProjectWriter provider) {
provider.setParameter(HaleConnectProjectWriter.ENABLE_VERSIONING, Value.of(enableVersioning.getSelection()));
provider.setParameter(HaleConnectProjectWriter.SHARING_PUBLIC, Value.of(publicAccess.getSelection()));
Value ownerValue = Value.of(ownerUser.getSelection() ? OwnerType.USER.getJsonValue() : OwnerType.ORGANISATION.getJsonValue());
provider.setParameter(HaleConnectProjectWriter.OWNER_TYPE, ownerValue);
provider.setParameter(ArchiveProjectWriter.EXLUDE_DATA_FILES, Value.of(excludeData.getSelection()));
provider.setParameter(ArchiveProjectWriter.INCLUDE_WEB_RESOURCES, Value.of(includeWebResources.getSelection()));
provider.setParameter(ArchiveProjectWriter.EXCLUDE_CACHED_RESOURCES, Value.of(excludeCachedResources.getSelection()));
provider.setTarget(new LocatableOutputSupplier<OutputStream>() {
@Override
public OutputStream getOutput() throws IOException {
return null;
}
@Override
public URI getLocation() {
if (createNewProject) {
// create a new hale connect transformation project
return null;
} else if (targetProject != null) {
return HaleConnectUrnBuilder.buildProjectUrn(targetProject.getOwner(), targetProject.getProjectId());
} else {
throw new IllegalStateException("No target project selected.");
}
}
});
return true;
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class InterpolationSettingPage method updateConfiguration.
@Override
public boolean updateConfiguration(IOProvider provider) {
// set interpolation algorithm
Value alg = null;
ISelection sel = algorithms.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof InterpolationAlgorithmFactory) {
String id = ((InterpolationAlgorithmFactory) selected).getIdentifier();
alg = Value.of(id);
}
}
provider.setParameter(InterpolationHelper.PARAMETER_INTERPOLATION_ALGORITHM, alg);
// set maximum positional error
provider.setParameter(InterpolationHelper.PARAMETER_MAX_POSITION_ERROR, Value.of(error.getText()));
// set move to grid flag
provider.setParameter(GridInterpolation.PARAMETER_MOVE_ALL_TO_GRID, Value.of(moveToGrid.getSelection()));
return true;
}
Aggregations