use of eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean 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.NamedEntityBean in project hale by halestudio.
the class OmlReader method loadAlignment.
@Override
protected MutableAlignment loadAlignment(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
try {
progress.begin("Load ontology mapping file", ProgressIndicator.UNKNOWN);
OmlRdfReader reader = new OmlRdfReader();
Alignment alignment = reader.read(getSource().getLocation().toURL());
AlignmentBean align = new AlignmentBean();
List<CellBean> cells = new ArrayList<CellBean>();
List<ICell> map = alignment.getMap();
for (ICell cell : map) {
// create a new CellBean for each ICell
CellBean cellBean = new CellBean();
IEntity entity = cell.getEntity1();
IEntity entity2 = cell.getEntity2();
// temporary list to be copied into the CellBean
List<NamedEntityBean> temp_source = new ArrayList<NamedEntityBean>();
List<NamedEntityBean> temp_target = new ArrayList<NamedEntityBean>();
setBeanLists(entity, temp_source, getSourceSchema());
setBeanLists(entity2, temp_target, getTargetSchema());
// set source/target lists of the CellBean
cellBean.setSource(temp_source);
cellBean.setTarget(temp_target);
// check if one of the entities has a transformation
if (entity.getTransformation() != null || entity2.getTransformation() != null) {
// entity 1 if it has the transformation
if (entity.getTransformation() != null) {
setParameters(cellBean, entity, reporter, cell);
setTransformationId(cellBean, entity);
} else {
// else set parameters and transformation id from entity
// 2
setParameters(cellBean, entity2, reporter, cell);
setTransformationId(cellBean, entity2);
}
}
// add the CellBean to a list of CellBeans
cells.add(cellBean);
}
// set the cells for the alignment after the all iterations
align.setCells(cells);
MutableAlignment mutableAlignment = align.createAlignment(reporter, getSourceSchema(), getTargetSchema(), new PathUpdate(null, null));
reporter.setSuccess(true);
return mutableAlignment;
} finally {
progress.end();
}
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean 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.NamedEntityBean 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;
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean in project hale by halestudio.
the class OrdinatesToPointTranslator 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) {
reporter.warn(new IOMessageImpl("Behavior of this function has changed.", null));
List<NamedEntityBean> src = cellBean.getSource();
for (int i = 0; i < src.size(); i++) {
NamedEntityBean bean = src.get(i);
if (i == 0) {
bean.setName("X");
}
if (i == 1) {
bean.setName("Y");
}
if (i == 2) {
bean.setName("Z");
}
}
return params;
}
Aggregations