use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class PropertyFunctionScriptPage method apply.
@Override
public void apply() {
DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
if (cf == null)
return;
cf.setFunctionType(CustomPropertyFunctionType.GROOVY);
List<ParameterValue> script = getConfiguration().get(PARAMETER_SCRIPT);
if (script != null && !script.isEmpty()) {
cf.setFunctionDefinition(script.get(0));
} else {
cf.setFunctionDefinition(Value.NULL);
}
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class SpatialJoinParameterPage method getConfiguration.
/**
* @see eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage#getConfiguration()
*/
@Override
public ListMultimap<String, ParameterValue> getConfiguration() {
ListMultimap<String, ParameterValue> result = ArrayListMultimap.create(1, 1);
Set<SpatialJoinCondition> conditions = new HashSet<>();
for (ConditionPage page : pages) {
conditions.addAll(page.conditions);
}
SpatialJoinParameter param = new SpatialJoinParameter(types, conditions);
result.put(PARAMETER_SPATIAL_JOIN, new ParameterValue(new ComplexValue(param)));
return result;
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class GroovyJoinPage method validate.
@Override
protected boolean validate(String document) {
ParameterValue param = CellUtil.getFirstParameter(getWizard().getUnfinishedCell(), JoinFunction.PARAMETER_JOIN);
JoinParameter joinParameter = param.as(JoinParameter.class);
// check Join parameter
if (joinParameter == null) {
// setValidationError("Missing join configuration");
return false;
} else {
String error = joinParameter.validate();
if (!setValidationError(error)) {
return false;
}
}
// target type
Type targetType = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetType == null) {
// not yet selected (NewRelationWizard)
return false;
}
/*
* FIXME use JoinParameter to fake joined instances!
*
* XXX for now just base instance
*/
TypeEntityDefinition sourceType = joinParameter.getTypes().get(0);
InstanceBuilder builder = new InstanceBuilder(false);
Instance instance = getTestValues().get(sourceType);
if (instance == null) {
// use an empty instance as input for the script
instance = new DefaultInstance(sourceType.getDefinition(), DataSet.SOURCE);
}
FamilyInstance source = new FamilyInstanceImpl(instance);
// prepare binding
Cell cell = getWizard().getUnfinishedCell();
CellLog log = new CellLog(new DefaultTransformationReporter("dummy", false), cell);
ExecutionContext context = new DummyExecutionContext(HaleUI.getServiceProvider());
Binding binding = GroovyRetype.createBinding(source, cell, builder, log, context, targetType.getDefinition().getDefinition());
GroovyService service = HaleUI.getServiceProvider().getService(GroovyService.class);
Script script = null;
try {
script = service.parseScript(document, binding);
GroovyUtil.evaluateAll(script, builder, targetType.getDefinition().getDefinition(), service, log);
} catch (final Exception e) {
return handleValidationResult(script, e);
}
return handleValidationResult(script, null);
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class GroovyJoinPage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
PageHelp.createToolItem(toolbar, this);
// FIXME TypeStructureTray does not support FamilyInstances
// XXX for now only use Join base type
JoinTypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
ParameterValue param = CellUtil.getFirstParameter(getWizard().getUnfinishedCell(), JoinFunction.PARAMETER_JOIN);
JoinParameter joinParameter = param.as(JoinParameter.class);
if (joinParameter != null && joinParameter.getTypes() != null && !joinParameter.getTypes().isEmpty()) {
return Collections.singleton(joinParameter.getTypes().get(0).getDefinition());
}
return Collections.emptyList();
}
});
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Type targetType = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetType != null) {
return Collections.singleton(targetType.getDefinition().getDefinition());
}
return Collections.emptyList();
}
});
PageFunctions.createToolItem(toolbar, this);
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class GeographicalNamePage method getConfiguration.
/**
* @see ParameterPage#getConfiguration()
*/
@Override
public ListMultimap<String, ParameterValue> getConfiguration() {
// page was built
if (namePronounciationIPA == null) {
return ArrayListMultimap.create();
}
ListMultimap<String, ParameterValue> configuration = ArrayListMultimap.create(10, 1);
if (spellings != null && spellings.size() != 0) {
for (SpellingType sp : spellings) {
String script = sp.getScript();
String trans = sp.getTransliteration();
configuration.put(PROPERTY_SCRIPT, new ParameterValue(script));
configuration.put(PROPERTY_TRANSLITERATION, new ParameterValue(trans));
}
}
configuration.put(PROPERTY_PRONUNCIATIONSOUNDLINK, new ParameterValue(namePronounciationSounds.getText()));
configuration.put(PROPERTY_PRONUNCIATIONIPA, new ParameterValue(namePronounciationIPA.getText()));
configuration.put(PROPERTY_LANGUAGE, new ParameterValue(nameLanguageText.getText()));
String sourceOfName = nameSourceText.getText();
if (SOURCE_OF_NAME_PROMT.equals(sourceOfName)) {
sourceOfName = "";
}
configuration.put(PROPERTY_SOURCEOFNAME, new ParameterValue(sourceOfName));
configuration.put(PROPERTY_NAMESTATUS, new ParameterValue(nameStatusCombo.getText()));
configuration.put(PROPERTY_NATIVENESS, new ParameterValue(nameNativenessCombo.getText()));
configuration.put(PROPERTY_GRAMMA_GENDER, new ParameterValue(nameGenderCombo.getText()));
configuration.put(PROPERTY_GRAMMA_NUMBER, new ParameterValue(nameNumberCombo.getText()));
return configuration;
}
Aggregations