use of eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression in project hale by halestudio.
the class OmlRdfGenerator method getJAXBValueExpressions.
private Collection<? extends ValueExprType> getJAXBValueExpressions(List<IValueExpression> value) {
List<ValueExprType> vExpressions = new ArrayList<ValueExprType>(value.size());
Iterator<?> iterator = value.iterator();
ValueExprType veType;
while (iterator.hasNext()) {
ValueExpression ve = (ValueExpression) iterator.next();
veType = new ValueExprType();
if (ve.getLiteral() != null) {
veType.setLiteral(ve.getLiteral());
}
if (ve.getMax() != null) {
veType.setMax(ve.getMax());
}
if (ve.getMin() != null) {
veType.setMin(ve.getMin());
}
if (ve.getApply() != null) {
veType.setApply(getApplayType(ve.getApply()));
}
vExpressions.add(veType);
}
return vExpressions;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression in project hale by halestudio.
the class ContainsComparator method evaluate.
/*
* (non-Javadoc)
*
* @see
* eu.esdihumboldt.goml.omwg.comparator.IComparator#evaluate(eu.esdihumboldt
* .goml.omwg.Restriction, org.opengis.feature.Property)
*/
@Override
public boolean evaluate(Restriction sourceRestriction, Property sourceProp) {
List<IValueExpression> sourceValues = sourceRestriction.getValue();
Object sourcePropValue = sourceProp.getValue();
LOG.debug("There are " + sourceValues.size() + " source values in the " + sourceRestriction);
LOG.debug("The source property value is: " + sourcePropValue);
// TODO Will there be a collection of source values for equals?.
for (IValueExpression value : sourceValues) {
if (sourcePropValue.equals(value.getLiteral())) {
LOG.debug("Found a match between " + sourcePropValue + " and " + value.getLiteral());
// Found value in the sourceProp so we can return true.
return true;
}
}
LOG.debug("No matches found for " + sourcePropValue);
return false;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression in project hale by halestudio.
the class NotEqualComparator method evaluate.
/*
* (non-Javadoc)
*
* @see
* eu.esdihumboldt.goml.omwg.comparator.IComparator#evaluate(eu.esdihumboldt
* .goml.omwg.Restriction, org.opengis.feature.Property)
*/
@Override
public boolean evaluate(Restriction sourceRestriction, Property sourceProp) {
List<IValueExpression> sourceValues = sourceRestriction.getValue();
Object sourcePropValue = sourceProp.getValue();
LOG.debug("There are " + sourceValues.size() + " source values in the " + sourceRestriction);
LOG.debug("The source property value is: " + sourcePropValue);
// TODO Will there be a collection of source values for not equals?.
for (IValueExpression value : sourceValues) {
if (sourcePropValue.equals(value.getLiteral())) {
LOG.debug("Found a match between " + sourcePropValue + " and " + value.getLiteral());
// The value is equal so we must return false.
return false;
}
}
LOG.debug("No matches found for " + sourcePropValue);
return true;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression 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.io.oml.internal.model.align.ext.IValueExpression in project hale by halestudio.
the class OmlRdfGenerator method getValueExpressionTypes.
// /**
// * Converts from OML Restriction to the JAXB PropertyValueRestrictionType
// *
// * @param restriction
// * @return
// */
// private PropValueRestrictionType getPropertyValueRestrictionType(Restriction restriction) {
// PropValueRestrictionType pvrType = new PropValueRestrictionType();
// if (restriction != null) {
// if (restriction.getComparator() != null) {
// pvrType.setComparator(getComparator(restriction.getComparator()));
// }
// if (restriction.getValue() != null) {
// pvrType.getValue().addAll(getValueExpressionTypes(restriction.getValue()));
// }
// }
// return pvrType;
// }
/**
* Converts from List of ValueExpression to the Collection of ValueExprType
*
* @param value
* @return
*/
private Collection<? extends ValueExprType> getValueExpressionTypes(List<IValueExpression> values) {
if (values != null) {
ArrayList<ValueExprType> veTypes = new ArrayList<ValueExprType>(values.size());
ValueExprType veType;
ValueExpression expression;
Iterator<?> iterator = values.iterator();
while (iterator.hasNext()) {
expression = (ValueExpression) iterator.next();
veType = getValueExprType(expression);
veTypes.add(veType);
}
return veTypes;
}
return new ArrayList<ValueExprType>();
}
Aggregations