Search in sources :

Example 1 with IEntity

use of eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity in project hale by halestudio.

the class NotSupportedTranslator 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) {
    IEntity entity1 = cell.getEntity1();
    IEntity entity2 = cell.getEntity2();
    String id = null;
    if (entity1.getTransformation() != null || entity2.getTransformation() != null) {
        if (entity1.getTransformation() != null) {
            id = entity1.getTransformation().getService().getLocation();
        } else {
            id = entity2.getTransformation().getService().getLocation();
        }
    }
    reporter.error(new IOMessageImpl("The function '" + id + "' is not supported in this hale studio version", null));
    return params;
}
Also used : IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)

Example 2 with IEntity

use of eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity 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();
    }
}
Also used : IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) ArrayList(java.util.ArrayList) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) Alignment(eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment) CellBean(eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean) NamedEntityBean(eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean) AlignmentBean(eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentBean) PathUpdate(eu.esdihumboldt.hale.common.core.io.PathUpdate) OmlRdfReader(eu.esdihumboldt.hale.io.oml.internal.goml.oml.io.OmlRdfReader)

Example 3 with IEntity

use of eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity in project hale by halestudio.

the class GeographicalNameTranslator 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) {
    // create the new parameter list
    List<ParameterValueBean> newParams = new ArrayList<ParameterValueBean>();
    IEntity source = cell.getEntity1();
    if (source instanceof ComposedProperty) {
        ComposedProperty cp = (ComposedProperty) source;
        // usually the composed property should only have one element in the
        // collection
        Property coll = cp.getCollection().get(0);
        // that should be a composed property too
        if (coll instanceof ComposedProperty) {
            ComposedProperty comProp = (ComposedProperty) coll;
            // parameters defined by the parameter page
            List<IParameter> pageParams = comProp.getTransformation().getParameters();
            // add each parameter defined by the parameter page
            for (IParameter p : pageParams) {
                newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
            }
            // the collection of the collection contains the parameters
            // defined for the spellings
            List<Property> props = comProp.getCollection();
            for (Property prop : props) {
                // each property has a list of 3 parameters (text, script,
                // transliterationScheme)
                List<IParameter> spellingParams = prop.getTransformation().getParameters();
                for (IParameter p : spellingParams) {
                    newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
                }
            }
        }
    }
    return newParams;
}
Also used : IParameter(eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IParameter) IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) ParameterValueBean(eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean) ArrayList(java.util.ArrayList) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property)

Example 4 with IEntity

use of eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity in project hale by halestudio.

the class OmlRdfReader method getEntity.

/**
 * Converts from the JAXB generated EntityType to the {@link IEntity}
 *
 * @param entity
 * @return
 */
private IEntity getEntity(JAXBElement<? extends EntityType> jaxbEntity) {
    EntityType entityType = jaxbEntity.getValue();
    // TODO allow to instantiate entity as Property, FeatureClass, Relation,
    // ComposedFeatureClass, ComposedFeatureType, composedRelation
    // instantiate entity es property
    Entity entity = null;
    IAbout about = null;
    // TODO add convertion to the RelationType if needed
    if (entityType instanceof PropertyType) {
        // make decision whether it is ComposedProperty
        if (((PropertyType) entityType).getPropertyComposition() != null) {
            PropertyCompositionType propCompType = ((PropertyType) entityType).getPropertyComposition();
            // instantiate entity as ComposedProperty
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new ComposedProperty(getOperator(propCompType.getOperator()), about);
            if (propCompType.getCollection() != null && propCompType.getCollection().getItem().size() > 0) {
                // set collection
                ((ComposedProperty) entity).setCollection(getPropertyCollection(propCompType.getCollection()));
            } else if (propCompType.getProperty() != null) {
                // set Property
                ((ComposedProperty) entity).getCollection().add(getProperty(propCompType.getProperty()));
            } else if (propCompType.getRelation() != null) {
                // set Relation
                ((ComposedProperty) entity).setRelation(getOMLRelation(propCompType.getRelation()));
            }
        // set ComposedProperty specific members
        } else {
            // instantiate entity as property
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new Property(about);
        }
        // set property-specific members to the entity
        PropertyType propertyType = ((PropertyType) entityType);
        // set domainRestriction
        if (propertyType.getDomainRestriction() != null) {
            ((Property) entity).setDomainRestriction(getDomainRestriction(propertyType.getDomainRestriction()));
        }
        // set typeCondition
        if (propertyType.getTypeCondition() != null) {
            ((Property) entity).setTypeCondition(propertyType.getTypeCondition());
        }
        // set value conditions
        if (propertyType.getValueCondition() != null) {
            ((Property) entity).setValueCondition(getValueCondition(propertyType.getValueCondition()));
        }
    } else if (entityType instanceof ClassType) {
        // initiates entity as FeatureType
        ClassType cType = (ClassType) entityType;
        if (entityType.getAbout() != null) {
            about = new About(entityType.getAbout());
        }
        entity = new FeatureClass(about);
        // set attribute occurence conditions if exist
        if (cType.getAttributeOccurenceCondition() != null) {
            ((FeatureClass) entity).setAttributeOccurenceCondition(getRestrictions(cType.getAttributeOccurenceCondition()));
        }
        // set attribute type conditions if exist
        if (cType.getAttributeTypeCondition() != null) {
            ((FeatureClass) entity).setAttributeTypeCondition(getRestrictions(cType.getAttributeTypeCondition()));
        }
        // set attribute value conditions if exist
        if (cType.getAttributeValueCondition() != null) {
            ((FeatureClass) entity).setAttributeValueCondition(getRestrictions(cType.getAttributeValueCondition()));
        }
    } else {
        throw new IllegalArgumentException("Illegal entity type given");
    }
    if (entityType.getTransf() != null) {
        // set Transformation to Entity
        Transformation transformation = getTransformation(entityType.getTransf());
        entity.setTransformation(transformation);
    }
    // set About
    About eabout = new About(UUID.randomUUID());
    if (entityType.getAbout() != null) {
        eabout.setAbout(entityType.getAbout());
    }
    entity.setAbout(eabout);
    // set Labels
    if (entityType.getLabel() != null) {
        entity.setLabel(entityType.getLabel());
    }
    return entity;
}
Also used : EntityType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.EntityType) PropertyCompositionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType) Entity(eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity) IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) Transformation(eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) PropertyType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyType) ClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType) ValueClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property) FeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Aggregations

IEntity (eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity)4 ComposedProperty (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty)2 Property (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property)2 ArrayList (java.util.ArrayList)2 AlignmentBean (eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentBean)1 CellBean (eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean)1 NamedEntityBean (eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean)1 ParameterValueBean (eu.esdihumboldt.hale.common.align.io.impl.internal.ParameterValueBean)1 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)1 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 Alignment (eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment)1 Entity (eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity)1 Transformation (eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation)1 OmlRdfReader (eu.esdihumboldt.hale.io.oml.internal.goml.oml.io.OmlRdfReader)1 FeatureClass (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass)1 About (eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About)1 ICell (eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)1 IParameter (eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IParameter)1 ClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType)1