use of eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean 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.ChildContextBean in project hale by halestudio.
the class OmlReader method setBeanLists.
private void setBeanLists(IEntity entity, List<NamedEntityBean> list, TypeIndex schema) {
if (entity.getAbout().getAbout().equals(Entity.NULL_ENTITY.getAbout().getAbout())) {
return;
}
if (entity instanceof ComposedFeatureClass) {
ComposedFeatureClass cfc = (ComposedFeatureClass) entity;
List<FeatureClass> coll = cfc.getCollection();
for (FeatureClass fc : coll) {
setBeanLists(fc, list, schema);
}
} else if (entity instanceof ComposedProperty) {
ComposedProperty cp = (ComposedProperty) entity;
List<Property> coll = cp.getCollection();
for (Property prop : coll) {
setBeanLists(prop, list, schema);
}
} else if (entity instanceof FeatureClass) {
// get the detailed about-information
IDetailedAbout about = DetailedAbout.getDetailedAbout(entity.getAbout(), false);
TypeBean typeBean = new TypeBean();
setTypeNameBean(typeBean, about, schema);
NamedEntityBean namedEntityBean = new NamedEntityBean();
namedEntityBean.setEntity(typeBean);
namedEntityBean.setName(null);
list.add(namedEntityBean);
} else if (entity instanceof Property) {
// get the detailed about-information
IDetailedAbout about = DetailedAbout.getDetailedAbout(entity.getAbout(), true);
PropertyBean prop = new PropertyBean();
List<ChildContextBean> childList = new ArrayList<ChildContextBean>();
List<String> props = about.getProperties();
for (String property : props) {
ChildContextBean ccb = new ChildContextBean();
ccb.setChildName(new QName(property));
childList.add(ccb);
}
setTypeNameBean(prop, about, schema);
prop.setProperties(childList);
NamedEntityBean namedEntityBean = new NamedEntityBean();
namedEntityBean.setEntity(prop);
namedEntityBean.setName(null);
list.add(namedEntityBean);
}
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean in project hale by halestudio.
the class NilReasonTranslator method getNewParameters.
/**
* @see FunctionTranslator#getNewParameters(List, CellBean, IOReporter,
* ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
// update target, adding nilReason child to path
ChildContextBean nilReason = new ChildContextBean();
nilReason.setChildName(new QName("nilReason"));
PropertyBean target = (PropertyBean) cellBean.getTarget().get(0).getEntity();
target.getProperties().add(nilReason);
// updated parameters
List<ParameterValueBean> newList = new ArrayList<ParameterValueBean>();
for (ParameterValueBean val : params) {
// translate the nilReason type to the value being assigned
if (val.getName().equals(PARAMETER_NIL_REASON_TYPE)) {
newList.add(new ParameterValueBean(PARAMETER_VALUE, val.getValue()));
} else {
newList.add(val);
}
}
return newList;
}
Aggregations