Search in sources :

Example 6 with Value

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));
    }
}
Also used : Value(eu.esdihumboldt.hale.common.core.io.Value) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) PreferenceStore(org.eclipse.jface.preference.PreferenceStore)

Example 7 with Value

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

Example 8 with Value

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))));
    }
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) Value(eu.esdihumboldt.hale.common.core.io.Value)

Example 9 with Value

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))));
    }
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) Value(eu.esdihumboldt.hale.common.core.io.Value)

Example 10 with Value

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;
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) Value(eu.esdihumboldt.hale.common.core.io.Value) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) MessageDigest(java.security.MessageDigest) Cell(eu.esdihumboldt.hale.common.align.model.Cell) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)

Aggregations

Value (eu.esdihumboldt.hale.common.core.io.Value)81 ValueList (eu.esdihumboldt.hale.common.core.io.ValueList)12 LookupTable (eu.esdihumboldt.hale.common.lookup.LookupTable)12 HashMap (java.util.HashMap)12 ValueProperties (eu.esdihumboldt.hale.common.core.io.ValueProperties)11 LookupTableImpl (eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl)11 IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)10 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)9 ArrayList (java.util.ArrayList)9 URI (java.net.URI)8 Test (org.junit.Test)6 StyledString (org.eclipse.jface.viewers.StyledString)5 Composite (org.eclipse.swt.widgets.Composite)5 DefaultCustomPropertyFunction (eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction)4 PropertyValue (eu.esdihumboldt.hale.common.align.transformation.function.PropertyValue)4 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)4 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)4 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)4 IOException (java.io.IOException)4 Locale (java.util.Locale)4