use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class InspireDatasetFeedConfigurationPage method loadPreSelection.
@Override
public void loadPreSelection(IOConfiguration conf) {
Value createValue = conf.getProviderConfiguration().get(InspireInstanceWriter.PARAM_SPATIAL_DATA_SET_CREATE_FEED);
Value titleValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_TITLE);
Value subTitleValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_SUBTITLE);
Value rightsValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_RIGHTS);
Value authorNameValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_AUTHOR_NAME);
Value authorMailValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_AUTHOR_MAIL);
Value selfLinkValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_SELFLINK);
Value gmlLinkValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_GMLLINK);
if (create != null && createValue != null) {
// there is no other way to set the selection for the button except
// using the preference store
IPreferenceStore store = new PreferenceStore();
store.setValue(create.getPreferenceName(), createValue.as(Boolean.class, false));
create.setPreferenceStore(store);
create.load();
updateStatus();
}
if (title != null && titleValue != null) {
title.setStringValue(titleValue.as(String.class));
}
if (subTitle != null && subTitleValue != null) {
subTitle.setStringValue(subTitleValue.as(String.class));
}
if (rights != null && rightsValue != null) {
rights.setStringValue(rightsValue.as(String.class));
}
if (authorName != null && authorNameValue != null) {
authorName.setStringValue(authorNameValue.as(String.class));
}
if (authorMail != null && authorMailValue != null) {
authorMail.setStringValue(authorMailValue.as(String.class));
}
if (selfLink != null && selfLinkValue != null) {
selfLink.setStringValue(selfLinkValue.as(String.class));
}
if (gmlLink != null && gmlLinkValue != null) {
gmlLink.setStringValue(gmlLinkValue.as(String.class));
}
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class SpatialDataSetConfigurationPage method loadPreSelection.
/**
* @see eu.esdihumboldt.hale.ui.io.IOWizardPage#loadPreSelection(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)
*/
@Override
public void loadPreSelection(IOConfiguration conf) {
Value localId = conf.getProviderConfiguration().get(InspireInstanceWriter.PARAM_SPATIAL_DATA_SET_LOCALID);
Value namespace = conf.getProviderConfiguration().get(InspireInstanceWriter.PARAM_SPATIAL_DATA_SET_NAMESPACE);
Value metadata = conf.getProviderConfiguration().get(InspireInstanceWriter.PARAM_SPATIAL_DATA_SET_METADATA_FILE);
if (localId != null)
localIdEditor.setAsText(localId.getStringRepresentation());
if (namespace != null)
namespaceEditor.setAsText(namespace.getStringRepresentation());
if (metadata != null)
metadataFile.setStringValue(metadata.getStringRepresentation());
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class SpatiaLiteInstanceReader method loadConfiguration.
@Override
public void loadConfiguration(Map<String, Value> configuration) {
super.loadConfiguration(configuration);
Value source = configuration.get(PARAM_SOURCE);
if (source != null && !source.isEmpty()) {
setSource(new DefaultInputSupplier(URI.create(source.as(String.class))));
}
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class SpatiaLiteSchemaReader method loadConfiguration.
@Override
public void loadConfiguration(Map<String, Value> configuration) {
super.loadConfiguration(configuration);
Value source = configuration.get(PARAM_SOURCE);
if (source != null && !source.isEmpty()) {
setSource(new DefaultInputSupplier(URI.create(source.as(String.class))));
}
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class PreferencesGroovyService method getScriptHash.
/**
* Calculates the current alignments script hash.
*
* @return the current alignments script hash
*/
private synchronized String getScriptHash() {
if (scriptHash == null) {
List<String> scripts = new ArrayList<>();
// get all Groovy scripts
for (Cell cell : alignmentService.getAlignment().getCells()) {
ListMultimap<String, ParameterValue> parameters = cell.getTransformationParameters();
if (parameters == null)
continue;
// Groovy transformations
if (cell.getTransformationIdentifier().contains("groovy")) {
List<ParameterValue> val = parameters.get(GroovyConstants.PARAMETER_SCRIPT);
if (!val.isEmpty()) {
String script = getScriptString(val.get(0));
if (script != null) {
scripts.add(script);
}
}
}
// GroovyScript function parameters
for (ParameterValue value : parameters.values()) {
if (GroovyScript.GROOVY_SCRIPT_ID.equals(value.getType())) {
String script = getScriptString(value);
if (script != null) {
scripts.add(script);
}
}
}
}
// Groovy scripts of custom property functions
for (CustomPropertyFunction customFunction : alignmentService.getAlignment().getAllCustomPropertyFunctions().values()) {
if (customFunction instanceof DefaultCustomPropertyFunction) {
DefaultCustomPropertyFunction cf = (DefaultCustomPropertyFunction) customFunction;
if (CustomPropertyFunctionType.GROOVY.equals(cf.getFunctionType())) {
Value functionDef = cf.getFunctionDefinition();
if (functionDef != null && !functionDef.isEmpty()) {
String script = getScriptString(functionDef);
if (script != null) {
scripts.add(script);
}
}
}
}
}
// order scripts (for consistent hash)
Collections.sort(scripts);
// modify the script in a undetectable way
try {
MessageDigest md = MessageDigest.getInstance("MD5");
for (String script : scripts) md.update(script.getBytes("UTF-8"));
byte[] hash = md.digest();
StringBuilder sb = new StringBuilder(2 * hash.length);
for (byte b : hash) {
sb.append(String.format("%02x", b & 0xff));
}
scriptHash = sb.toString();
// Both exceptions cannot happen in a valid Java platform.
// Anyways, if they happen, execution should stop here!
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("No MD5 MessageDigest!");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("No UTF-8 Charset!");
}
}
return scriptHash;
}
Aggregations