Search in sources :

Example 1 with Restriction

use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction in project hale by halestudio.

the class OmlRdfGenerator method getValueConditions.

/**
 * Converts from the list of restrictions to the collection of the
 * ValueConditionType
 *
 * @param restrictions
 * @return
 */
private Collection<? extends ValueConditionType> getValueConditions(List<Restriction> restrictions) {
    if (restrictions != null) {
        ArrayList<ValueConditionType> vcTypes = new ArrayList<ValueConditionType>(restrictions.size());
        ValueConditionType vcType;
        Restriction restriction;
        Iterator<?> iterator = restrictions.iterator();
        while (iterator.hasNext()) {
            restriction = (Restriction) iterator.next();
            vcType = getValueConditionType(restriction);
            vcTypes.add(vcType);
        }
        return vcTypes;
    }
    return new ArrayList<ValueConditionType>();
}
Also used : Restriction(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction) ArrayList(java.util.ArrayList) ValueConditionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueConditionType)

Example 2 with Restriction

use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction in project hale by halestudio.

the class OmlRdfGenerator method getConditions.

/**
 * Converts from List of OML Restrictions to the List of the Jaxb
 * ClassConditionType
 *
 * @param attributeTypeCondition
 * @return
 */
private Collection<? extends ClassConditionType> getConditions(List<Restriction> restrictions) {
    if (restrictions != null) {
        ArrayList<ClassConditionType> conditions = new ArrayList<ClassConditionType>(restrictions.size());
        ClassConditionType condition;
        Restriction restriction;
        Iterator<?> iterator = restrictions.iterator();
        while (iterator.hasNext()) {
            restriction = (Restriction) iterator.next();
            if (restriction != null) {
                condition = new ClassConditionType();
                condition.setRestriction(getRestrictionType(restriction));
                conditions.add(condition);
            }
        }
        return conditions;
    }
    return new ArrayList<ClassConditionType>();
}
Also used : ClassConditionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassConditionType) Restriction(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction) ArrayList(java.util.ArrayList)

Example 3 with Restriction

use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction 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;
}
Also used : Restriction(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction) Joiner(com.google.common.base.Joiner) IValueExpression(eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression) ParameterValueBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean) ArrayList(java.util.ArrayList) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 4 with Restriction

use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction in project hale by halestudio.

the class OmlRdfReader method getRestrictions.

/**
 * converts from a list of the ClassConditionType to the list of the
 * Restriction type
 *
 * @param List of ClassConditionType
 * @return
 */
private List<Restriction> getRestrictions(List<ClassConditionType> classConditions) {
    List<Restriction> restrictions = new ArrayList<Restriction>(classConditions.size());
    Iterator<ClassConditionType> iterator = classConditions.iterator();
    Restriction restriction = null;
    ClassConditionType classCondition;
    while (iterator.hasNext()) {
        classCondition = iterator.next();
        RestrictionType rType = classCondition.getRestriction();
        if (rType != null) {
            // set value expression if exist
            if (rType.getValue() != null) {
                List<ValueExprType> valueExpr = rType.getValue();
                restriction = new Restriction(getValueExpression(valueExpr));
            } else {
                throw new IllegalStateException("Can't create restriction");
            }
            // set value class to add about and resource document
            ValueClass vClass = new ValueClass();
            ValueClassType vcType = rType.getValueClass();
            if (vcType != null) {
                vClass.setAbout(vcType.getAbout());
                vClass.setResource(vcType.getResource());
                vClass.getValue().addAll(getValueExpression(vcType.getValue()));
                restriction.setValueClass(vClass);
            }
            if (rType.getComparator() != null) {
                restriction.setComparator(getComparator(rType.getComparator()));
            }
            if (rType.getCqlStr() != null) {
                restriction.setCqlStr(rType.getCqlStr());
            }
        }
        // TODO clear with MdV
        // restriction = new Restriction(null,
        // getValueExpression(valueExpr));
        restrictions.add(restriction);
    }
    return restrictions;
}
Also used : ClassConditionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassConditionType) Restriction(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction) ValueClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType) ArrayList(java.util.ArrayList) ValueExprType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueExprType) IValueClass(eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueClass) ValueClass(eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.ValueClass) DomainRestrictionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.DomainRestrictionType) RestrictionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RestrictionType) RangeRestrictionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RangeRestrictionType)

Example 5 with Restriction

use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction in project hale by halestudio.

the class OmlRdfReader method getValueCondition.

/**
 * Converts from List<ValueConditionType> to List<Restriction>
 *
 * @param valueCondition
 * @return
 */
private List<Restriction> getValueCondition(List<ValueConditionType> valueCondition) {
    List<Restriction> restrictions = new ArrayList<Restriction>(valueCondition.size());
    Iterator<ValueConditionType> iterator = valueCondition.iterator();
    Restriction restriction;
    List<ValueExprType> valueExpr = null;
    while (iterator.hasNext()) {
        ValueConditionType condition = iterator.next();
        // get List<ValueExpressionType>
        if (condition.getRestriction() != null && condition.getRestriction().getValue() != null) {
            valueExpr = condition.getRestriction().getValue();
        }
        if ((valueExpr == null || valueExpr.size() == 0) && condition.getRestriction().getValueClass() != null) {
            valueExpr = condition.getRestriction().getValueClass().getValue();
        }
        // TODO:clear with MdV
        // restriction = new Restriction(null,
        // getValueExpression(valueExpr));
        restriction = new Restriction(getValueExpression(valueExpr));
        if (condition.getRestriction() != null && condition.getRestriction().getComparator() != null) {
            restriction.setComparator(getComparator(condition.getRestriction().getComparator()));
        }
        // add Sequence ID if it exists
        if (condition.getSeq() != null) {
            restriction.setSeq(condition.getSeq());
        }
        // TODO add Property onAttribute
        restrictions.add(restriction);
    }
    return restrictions;
}
Also used : Restriction(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction) ArrayList(java.util.ArrayList) ValueExprType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueExprType) ValueConditionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueConditionType)

Aggregations

Restriction (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Restriction)5 ArrayList (java.util.ArrayList)5 ClassConditionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassConditionType)2 ValueConditionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueConditionType)2 ValueExprType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueExprType)2 Joiner (com.google.common.base.Joiner)1 ParameterValueBean (eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 ValueClass (eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.ValueClass)1 IValueClass (eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueClass)1 IValueExpression (eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IValueExpression)1 DomainRestrictionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.DomainRestrictionType)1 RangeRestrictionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RangeRestrictionType)1 RestrictionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RestrictionType)1 ValueClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1