Search in sources :

Example 1 with PropertyBean

use of eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean 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;
}
Also used : ArrayList(java.util.ArrayList) ChildContextBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean) NamedEntityBean(eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean) ParameterValueBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean) PropertyBean(eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean) HashSet(java.util.HashSet)

Example 2 with PropertyBean

use of eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean 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);
    }
}
Also used : QName(javax.xml.namespace.QName) TypeBean(eu.esdihumboldt.hale.common.align.io.impl.internal.TypeBean) ComposedFeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedFeatureClass) ComposedFeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedFeatureClass) FeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass) ChildContextBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean) NamedEntityBean(eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) IDetailedAbout(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.IDetailedAbout) List(java.util.List) ArrayList(java.util.ArrayList) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property) PropertyBean(eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean)

Example 3 with PropertyBean

use of eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean 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;
}
Also used : ChildContextBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean) QName(javax.xml.namespace.QName) ParameterValueBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean) ArrayList(java.util.ArrayList) PropertyBean(eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean)

Aggregations

ChildContextBean (eu.esdihumboldt.hale.common.align.io.impl.internal.ChildContextBean)3 PropertyBean (eu.esdihumboldt.hale.common.align.io.impl.internal.PropertyBean)3 ArrayList (java.util.ArrayList)3 NamedEntityBean (eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean)2 ParameterValueBean (eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean)2 QName (javax.xml.namespace.QName)2 TypeBean (eu.esdihumboldt.hale.common.align.io.impl.internal.TypeBean)1 ComposedFeatureClass (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedFeatureClass)1 ComposedProperty (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty)1 FeatureClass (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass)1 Property (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property)1 IDetailedAbout (eu.esdihumboldt.hale.io.oml.internal.goml.rdf.IDetailedAbout)1 HashSet (java.util.HashSet)1 List (java.util.List)1