use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class GeographicalNamePage method setParameter.
/**
* @see ParameterPage#setParameter(Set, ListMultimap)
*/
@Override
public void setParameter(Set<FunctionParameterDefinition> params, ListMultimap<String, ParameterValue> initialValues) {
if (initialValues != null && initialValues.size() != 0) {
// set the initial values if they exist
gender = initialValues.get(PROPERTY_GRAMMA_GENDER).get(0).as(String.class);
number = initialValues.get(PROPERTY_GRAMMA_NUMBER).get(0).as(String.class);
language = initialValues.get(PROPERTY_LANGUAGE).get(0).as(String.class);
nameStatus = initialValues.get(PROPERTY_NAMESTATUS).get(0).as(String.class);
nativeness = initialValues.get(PROPERTY_NATIVENESS).get(0).as(String.class);
ipa = initialValues.get(PROPERTY_PRONUNCIATIONIPA).get(0).as(String.class);
try {
sound = initialValues.get(PROPERTY_PRONUNCIATIONSOUNDLINK).get(0).as(String.class);
} catch (Exception e) {
sound = "";
}
sourceOfName = initialValues.get(PROPERTY_SOURCEOFNAME).get(0).as(String.class);
// script and transliteration can have more than one value, so set
// lists for them
List<ParameterValue> tmp;
if (initialValues.get(PROPERTY_SCRIPT) != null) {
tmp = initialValues.get(PROPERTY_SCRIPT);
scripts = new ArrayList<String>(tmp.size());
for (ParameterValue value : tmp) scripts.add(value.as(String.class));
} else
scripts = Collections.emptyList();
if (initialValues.get(PROPERTY_TRANSLITERATION) != null) {
tmp = initialValues.get(PROPERTY_TRANSLITERATION);
trans = new ArrayList<String>(tmp.size());
for (ParameterValue value : tmp) trans.add(value.as(String.class));
} else
trans = Collections.emptyList();
}
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class SequentialIDParameterPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).spacing(10, 8).create());
Label label;
GridDataFactory labelLayout = GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER);
GridDataFactory controlLayout = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
// select sequence type
if (getParametersToHandle().containsKey(PARAM_SEQUENCE)) {
label = new Label(page, SWT.NONE);
label.setText("Sequence");
labelLayout.applyTo(label);
sequence = new ComboViewer(page);
sequence.setContentProvider(EnumContentProvider.getInstance());
sequence.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof Sequence) {
switch((Sequence) element) {
case overall:
return "Over all sequential IDs";
case type:
return "Per target instance type";
}
}
return super.getText(element);
}
});
sequence.setInput(Sequence.class);
controlLayout.applyTo(sequence.getControl());
Sequence initialValue = Sequence.valueOf(getOptionalInitialValue(PARAM_SEQUENCE, new ParameterValue(Sequence.type.name())).as(String.class));
sequence.setSelection(new StructuredSelection(initialValue));
sequence.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateStatus();
}
});
}
// specify prefix
if (getParametersToHandle().containsKey(PARAM_PREFIX)) {
label = new Label(page, SWT.NONE);
label.setText("Prefix");
labelLayout.applyTo(label);
prefix = new Text(page, SWT.SINGLE | SWT.BORDER);
controlLayout.applyTo(prefix);
prefix.setText(getOptionalInitialValue(PARAM_PREFIX, new ParameterValue("")).as(String.class));
prefix.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateStatus();
}
});
ContentProposalAdapter adapter = new ContentProposalAdapter(prefix, new TextContentAdapter(), contentProposalProvider, ProjectVariablesContentProposalProvider.CTRL_SPACE, new char[] { '{' });
adapter.setAutoActivationDelay(0);
final ControlDecoration infoDeco = new ControlDecoration(prefix, SWT.TOP | SWT.LEFT);
infoDeco.setDescriptionText("Type Ctrl+Space for project variable content assistance");
infoDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
infoDeco.setMarginWidth(2);
}
// specify suffix
if (getParametersToHandle().containsKey(PARAM_SUFFIX)) {
label = new Label(page, SWT.NONE);
label.setText("Suffix");
labelLayout.applyTo(label);
suffix = new Text(page, SWT.SINGLE | SWT.BORDER);
controlLayout.applyTo(suffix);
suffix.setText(getOptionalInitialValue(PARAM_SUFFIX, new ParameterValue("")).as(String.class));
suffix.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateStatus();
}
});
ContentProposalAdapter adapter = new ContentProposalAdapter(suffix, new TextContentAdapter(), contentProposalProvider, ProjectVariablesContentProposalProvider.CTRL_SPACE, new char[] { '{' });
adapter.setAutoActivationDelay(0);
final ControlDecoration infoDeco = new ControlDecoration(suffix, SWT.TOP | SWT.LEFT);
infoDeco.setDescriptionText("Type Ctrl+Space for project variable content assistance");
infoDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
infoDeco.setShowOnlyOnFocus(true);
}
// show example
if (sequence != null && prefix != null && suffix != null) {
label = new Label(page, SWT.NONE);
label.setText("Example");
labelLayout.applyTo(label);
example = new Label(page, SWT.NONE);
example.setFont(JFaceResources.getTextFont());
controlLayout.applyTo(example);
// error decoration
exampleDecoration = new ControlDecoration(example, SWT.LEFT | SWT.TOP, page);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
exampleDecoration.setImage(fieldDecoration.getImage());
exampleDecoration.hide();
}
updateStatus();
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class OMLReaderTest method testNetworkExpansion1.
/**
* Test for network expansion function in alignment4
*/
@Test
public void testNetworkExpansion1() {
Collection<? extends Cell> cells = alignment4.getCells();
Iterator<? extends Cell> it = cells.iterator();
Cell cell = null;
while (it.hasNext()) {
Cell temp = it.next();
if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.cst.functions.geometric.networkexpansion")) {
cell = temp;
break;
}
}
ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
List<ParameterValue> values = params.get("bufferWidth");
assertEquals(1, values.size());
// size is always 1
String temp = values.get(0).as(String.class);
assertEquals("0.005", temp);
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class OMLReaderTest method testDateExtraction.
/**
* Test for date extraction function in alignment
*/
@Test
public void testDateExtraction() {
Collection<? extends Cell> cells = alignment.getCells();
Iterator<? extends Cell> it = cells.iterator();
Cell cell = null;
while (it.hasNext()) {
Cell temp = it.next();
if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.cst.functions.string.dateextraction")) {
cell = temp;
break;
}
}
ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
List<ParameterValue> values = params.get("dateFormat");
assertEquals(1, values.size());
String date = values.get(0).as(String.class);
assertEquals("yyyy-MM-dd HH:mm:ss", date);
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class OMLReaderTest method testAssign3.
/**
* Test for assign function in alignment5
*/
@Test
@Ignore
public // because now NilReasonFunction also produces assign cells
void testAssign3() {
Collection<? extends Cell> cells = alignment5.getCells();
Iterator<? extends Cell> it = cells.iterator();
List<Cell> assignCells = new ArrayList<Cell>();
while (it.hasNext()) {
Cell temp = it.next();
if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.hale.align.assign")) {
assignCells.add(temp);
}
}
// test all cells that have an assign function
for (int i = 0; i < assignCells.size(); i++) {
Cell cell = assignCells.get(i);
ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
List<ParameterValue> values = params.get("value");
assertEquals(1, values.size());
// size is always 1
String temp = values.get(0).as(String.class);
// test cell #1
if (i == 0) {
assertEquals("2000", temp);
}
// test cell #2
if (i == 1) {
assertEquals("20", temp);
}
// test cell #3
if (i == 2) {
assertEquals("20", temp);
}
// test cell #4
if (i == 3) {
assertEquals("2", temp);
}
// test cell #5
if (i == 4) {
assertEquals("Katastralgemeinde", temp);
}
// test cell #6
if (i == 5) {
assertEquals("m2", temp);
}
// test cell #7
if (i == 6) {
assertEquals("m2", temp);
}
// test cell #8
if (i == 7) {
assertEquals("m", temp);
}
// test cell #9
if (i == 8) {
assertEquals("m", temp);
}
}
// check if all cells with an assign function were tested
assertEquals(9, assignCells.size());
}
Aggregations