Search in sources :

Example 41 with Value

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

the class SpatiaLiteInstanceWriter method loadConfiguration.

@Override
public void loadConfiguration(Map<String, Value> configuration) {
    super.loadConfiguration(configuration);
    Value target = configuration.get(PARAM_TARGET);
    if (target != null && !target.isEmpty()) {
        File file = new File(URI.create(target.as(String.class)));
        setTarget(new FileIOSupplier(file));
    }
}
Also used : Value(eu.esdihumboldt.hale.common.core.io.Value) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) File(java.io.File)

Example 42 with Value

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

the class SQLArrayFactory method restore.

@Override
public SQLArray restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
    ValueProperties props = value.as(ValueProperties.class);
    if (props != null) {
        // read element class
        Class<?> elementType = null;
        String className = props.getSafe(NAME_ELEMENT_CLASS).as(String.class);
        if (className != null) {
            elementType = resolver.loadClass(className);
        }
        // read element database type name
        String elementTypeName = props.getSafe(NAME_ELEMENT_TYPE_NAME).as(String.class);
        // read dimension
        int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
        // read array dimension sizes
        int[] sizes = null;
        ValueList sizeList = props.getSafe(NAME_SIZES).as(ValueList.class);
        if (sizeList != null) {
            sizes = new int[sizeList.size()];
            int index = 0;
            for (Value size : sizeList) {
                sizes[index] = size.as(Integer.class, 0);
                index++;
            }
        }
        return new SQLArray(elementType, elementTypeName, dimension, sizes);
    }
    return SQLArray.NO_ARRAY;
}
Also used : ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) ValueList(eu.esdihumboldt.hale.common.core.io.ValueList) Value(eu.esdihumboldt.hale.common.core.io.Value) SQLArray(eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray)

Example 43 with Value

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

the class CustomFunctionExplanationPage method createMainPart.

private void createMainPart(Composite page, @Nullable Map<Locale, Value> initialContent) {
    Composite main = new Composite(page, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(main);
    // left part - editor tabs
    tabFolder = new TabFolder(main, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tabFolder);
    if (initialContent != null && !initialContent.isEmpty()) {
        for (Entry<Locale, Value> entry : initialContent.entrySet()) {
            addTab(entry.getKey(), entry.getValue().as(eu.esdihumboldt.hale.common.core.io.Text.class));
        }
    } else {
        // per default, add an empty explanation for the root locale
        addTab(Locale.ROOT, null);
    }
    // right part - controls
    Composite actions = new Composite(main, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(actions);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(actions);
// TODO add a language
// Button addLanguage = new Button(actions, SWT.PUSH | SWT.FLAT);
// addLanguage.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_ADD));
// addLanguage.setToolTipText("Add another explanation language");
// TODO remove a language (prevent removing default)
}
Also used : Locale(java.util.Locale) Composite(org.eclipse.swt.widgets.Composite) TabFolder(org.eclipse.swt.widgets.TabFolder) Value(eu.esdihumboldt.hale.common.core.io.Value) Text(org.eclipse.swt.widgets.Text)

Example 44 with Value

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

the class CustomFunctionExplanationPage method createContent.

@Override
protected void createContent(Composite page) {
    DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
    DefaultCustomFunctionExplanation expl = cf.getExplanation();
    Map<Locale, Value> initialContent = null;
    if (expl != null) {
        initialContent = expl.getTemplates();
    }
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(page);
    // top part - editor and locale controls
    createMainPart(page, initialContent);
// bottom part - explanation preview
// createPreviewPart(page);
}
Also used : Locale(java.util.Locale) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) Value(eu.esdihumboldt.hale.common.core.io.Value) DefaultCustomFunctionExplanation(eu.esdihumboldt.hale.common.align.custom.DefaultCustomFunctionExplanation)

Example 45 with Value

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

the class CustomFunctionExplanationPage method apply.

@Override
public void apply() {
    DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
    if (cf == null)
        return;
    Map<Locale, Value> templates = new HashMap<>();
    tabs.forEach((locale, group) -> {
        String text = group.getEditor().getText();
        if (text != null && !text.isEmpty()) {
            templates.put(locale, Value.of(new eu.esdihumboldt.hale.common.core.io.Text(text)));
        }
    });
    DefaultCustomFunctionExplanation explanation = new DefaultCustomFunctionExplanation(templates);
    cf.setExplanation(explanation);
}
Also used : Locale(java.util.Locale) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) HashMap(java.util.HashMap) Value(eu.esdihumboldt.hale.common.core.io.Value) DefaultCustomFunctionExplanation(eu.esdihumboldt.hale.common.align.custom.DefaultCustomFunctionExplanation) Text(org.eclipse.swt.widgets.Text)

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