use of eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean in project hale by halestudio.
the class OmlReader method setParameters.
private void setParameters(CellBean cellBean, IEntity entity, IOReporter reporter, ICell cell) {
String transId = entity.getTransformation().getService().getLocation();
// get the list of parameters
List<IParameter> list = entity.getTransformation().getParameters();
// create a list of ParameterValue (because
// setTransformationParameters needs a list)
List<ParameterValueBean> params = new ArrayList<ParameterValueBean>();
for (int i = 0; i < list.size(); i++) {
String name = list.get(i).getName();
String value = list.get(i).getValue();
// create the ParameterValue for the CellBean
ParameterValueBean paramVal = new ParameterValueBean(name, value);
// add the ParameterValue
params.add(paramVal);
}
// set the new transformation parameters
if (map.containsKey(transId)) {
cellBean.setTransformationParameters(map.get(transId).getNewParameters(params, cellBean, reporter, cell));
} else {
cellBean.setTransformationParameters(params);
}
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean in project hale by halestudio.
the class ClassificationMappingTranslator method getNewParameters.
/**
* @see eu.esdihumboldt.hale.io.oml.helper.FunctionTranslator#getNewParameters(java.util.List,
* eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean,
* eu.esdihumboldt.hale.common.core.io.report.IOReporter,
* eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
List<ParameterValueBean> newList = new ArrayList<ParameterValueBean>();
List<Restriction> sourceRest = new ArrayList<Restriction>();
List<Restriction> tarRest = new ArrayList<Restriction>();
sourceRest = ((Property) cell.getEntity1()).getValueCondition();
tarRest = ((Property) cell.getEntity2()).getValueCondition();
for (int i = 0; i < sourceRest.size(); i++) {
Restriction r1 = sourceRest.get(i);
Restriction r2 = tarRest.get(i);
Joiner joiner = Joiner.on(" ").skipNulls();
List<String> encodedParams = new ArrayList<String>();
// first encode and add the associated value to the string list ...
for (IValueExpression ival : r2.getValue()) {
String temp = null;
try {
temp = URLEncoder.encode(ival.getLiteral(), "UTF-8");
} catch (UnsupportedEncodingException e) {
reporter.error(new IOMessageImpl("Parameter could not be encoded.", null));
e.printStackTrace();
}
encodedParams.add(temp);
}
// then encode and add the value expressions to the string list
for (IValueExpression ival : r1.getValue()) {
String temp = null;
try {
temp = URLEncoder.encode(ival.getLiteral(), "UTF-8");
} catch (UnsupportedEncodingException e) {
reporter.error(new IOMessageImpl("Parameter could not be encoded.", null));
e.printStackTrace();
}
encodedParams.add(temp);
}
String encodedParameter = joiner.join(encodedParams);
newList.add(new ParameterValueBean(PARAMETER_CLASSIFICATIONS, encodedParameter));
}
return newList;
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean in project hale by halestudio.
the class FormattedStringTranslator method getNewParameters.
/**
* @see eu.esdihumboldt.hale.io.oml.helper.FunctionTranslator#getNewParameters(java.util.List,
* eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean,
* eu.esdihumboldt.hale.common.core.io.report.IOReporter,
* eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
List<ParameterValueBean> newList = new ArrayList<ParameterValueBean>();
// default separator
String separator = "";
String concatenation = "";
for (ParameterValueBean val : params) {
// get original separator parameter
if (val.getName().equals(SEPARATOR)) {
separator = val.getValue();
}
// get original concatenation parameter
if (val.getName().equals(CONCATENATION)) {
concatenation = val.getValue();
}
}
String[] concat = concatenation.split(INTERNALSEPERATOR);
List<NamedEntityBean> src = cellBean.getSource();
// create list of valid source variables
Set<String> sourceVars = new HashSet<String>();
for (NamedEntityBean bean : src) {
if (bean.getEntity() instanceof PropertyBean) {
List<ChildContextBean> props = ((PropertyBean) bean.getEntity()).getProperties();
String[] children = new String[props.size()];
for (int i = 0; i < props.size(); i++) {
children[i] = props.get(i).getChildName().getLocalPart();
}
sourceVars.add(Joiner.on('.').join(children));
}
}
StringBuffer pattern = new StringBuffer();
boolean first = true;
for (String thisElement : concat) {
// append separator between elements
if (first) {
first = false;
} else {
pattern.append(separator);
}
String[] properties = thisElement.split(String.valueOf(DetailedAbout.PROPERTY_DELIMITER));
String varString = Joiner.on('.').join(properties);
if (sourceVars.contains(varString)) {
// thisElement represents a variable
pattern.append('{');
pattern.append(varString);
pattern.append('}');
} else {
// thisElement is just a string
// TODO any escaping of {?
pattern.append(thisElement);
}
}
// add pattern parameter
newList.add(new ParameterValueBean(PARAMETER_PATTERN, pattern.toString()));
return newList;
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean in project hale by halestudio.
the class GeographicalNameTranslator method getNewParameters.
/**
* @see eu.esdihumboldt.hale.io.oml.helper.FunctionTranslator#getNewParameters(java.util.List,
* eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean,
* eu.esdihumboldt.hale.common.core.io.report.IOReporter,
* eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
// create the new parameter list
List<ParameterValueBean> newParams = new ArrayList<ParameterValueBean>();
IEntity source = cell.getEntity1();
if (source instanceof ComposedProperty) {
ComposedProperty cp = (ComposedProperty) source;
// usually the composed property should only have one element in the
// collection
Property coll = cp.getCollection().get(0);
// that should be a composed property too
if (coll instanceof ComposedProperty) {
ComposedProperty comProp = (ComposedProperty) coll;
// parameters defined by the parameter page
List<IParameter> pageParams = comProp.getTransformation().getParameters();
// add each parameter defined by the parameter page
for (IParameter p : pageParams) {
newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
}
// the collection of the collection contains the parameters
// defined for the spellings
List<Property> props = comProp.getCollection();
for (Property prop : props) {
// each property has a list of 3 parameters (text, script,
// transliterationScheme)
List<IParameter> spellingParams = prop.getTransformation().getParameters();
for (IParameter p : spellingParams) {
newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
}
}
}
}
return newParams;
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean in project hale by halestudio.
the class MathematicalExpressionTranslator method getNewParameters.
/**
* @see eu.esdihumboldt.hale.io.oml.helper.FunctionTranslator#getNewParameters(java.util.List,
* eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean,
* eu.esdihumboldt.hale.common.core.io.report.IOReporter,
* eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
List<ParameterValueBean> newList = new ArrayList<ParameterValueBean>();
for (ParameterValueBean val : params) {
// translate "math_expression" to "expression"
if (val.getName().equals("math_expression")) {
newList.add(new ParameterValueBean(PARAMETER_EXPRESSION, val.getValue()));
} else {
newList.add(val);
}
}
List<NamedEntityBean> src = cellBean.getSource();
for (NamedEntityBean bean : src) {
bean.setName(ENTITY_VARIABLE);
}
return newList;
}
Aggregations