Search in sources :

Example 1 with FeatureClass

use of eu.esdihumboldt.commons.goml.omwg.FeatureClass in project hale by halestudio.

the class AlignmentToModelAlignmentDigester method translate.

/**
 * Translates a {@link HaleAlignment} into an intermediate
 * {@link ModelAlignment} format.
 *
 * @param hal the HALE alignment
 * @return {@link ModelAlignment}
 * @throws TranslationException
 *             if any problems occurred during translation
 */
@Override
public ModelAlignment translate(HaleAlignment hal) throws TranslationException {
    List<ModelClassMappingCell> classMappings = new ArrayList<ModelClassMappingCell>();
    List<ModelAttributeMappingCell> attributeMappings = new ArrayList<ModelAttributeMappingCell>();
    ArrayList<ModelStaticAssignmentCell> staticAssigments = new ArrayList<ModelStaticAssignmentCell>();
    Alignment source = hal.getAlignment();
    Map<String, SchemaElement> sourceFeatures = hal.getSourceElements();
    Map<String, SchemaElement> targetFeatures = hal.getTargetElements();
    for (ICell cell : source.getMap()) {
        IEntity sourceEntity = cell.getEntity1();
        IEntity targetEntity = cell.getEntity2();
        boolean sourceIsFeatureClass = sourceEntity instanceof FeatureClass;
        boolean targetIsFeatureClass = targetEntity instanceof FeatureClass;
        if (sourceIsFeatureClass && targetIsFeatureClass) {
            // type mapping
            classMappings.add(createCell((FeatureClass) sourceEntity, (FeatureClass) targetEntity, sourceFeatures, targetFeatures));
        } else if (!sourceIsFeatureClass && !targetIsFeatureClass) {
            // property mapping
            ModelAttributeMappingCell modelCell = createAttribute(cell, (Property) sourceEntity, (Property) targetEntity, sourceFeatures, targetFeatures);
            if (modelCell != null) {
                attributeMappings.add(modelCell);
            }
        } else if (sourceIsFeatureClass && !targetIsFeatureClass) {
            // augmentations
            ModelStaticAssignmentCell modelCell = createStaticAssignment(cell, (Property) targetEntity, targetFeatures);
            if (modelCell != null) {
                staticAssigments.add(modelCell);
            }
        } else {
            // $NON-NLS-1$
            throw new TranslationException("Unhandled combination");
        }
    }
    return new ModelAlignment(classMappings, attributeMappings, staticAssigments);
}
Also used : ModelClassMappingCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelClassMappingCell) IEntity(eu.esdihumboldt.specification.cst.align.IEntity) ModelStaticAssignmentCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell) ArrayList(java.util.ArrayList) ModelAlignment(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAlignment) TranslationException(com.onespatial.jrc.tns.oml_to_rif.api.TranslationException) FeatureClass(eu.esdihumboldt.commons.goml.omwg.FeatureClass) ICell(eu.esdihumboldt.specification.cst.align.ICell) ModelAlignment(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAlignment) Alignment(eu.esdihumboldt.commons.goml.align.Alignment) HaleAlignment(com.onespatial.jrc.tns.oml_to_rif.HaleAlignment) ModelAttributeMappingCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell) SchemaElement(eu.esdihumboldt.hale.schemaprovider.model.SchemaElement) Property(eu.esdihumboldt.commons.goml.omwg.Property) ComposedProperty(eu.esdihumboldt.commons.goml.omwg.ComposedProperty)

Example 2 with FeatureClass

use of eu.esdihumboldt.commons.goml.omwg.FeatureClass in project hale by halestudio.

the class AlignmentToModelAlignmentDigester method createAttribute.

private ModelAttributeMappingCell createAttribute(ICell original, Property sourceEntity, Property targetEntity, Map<String, SchemaElement> sourceFeatures, Map<String, SchemaElement> targetFeatures) {
    // FIXME what about composed properties?
    if (sourceEntity instanceof ComposedProperty || targetEntity instanceof ComposedProperty) {
        // $NON-NLS-1$
        report.setFailed(original, "Composed properties not supported");
        return null;
    }
    List<FeatureClass> filter = sourceEntity.getDomainRestriction();
    if (filter != null && !filter.isEmpty()) {
        // $NON-NLS-1$
        report.setWarning(original, "Filters on attributive functions currently not supported in the RIF export");
    }
    String function = sourceEntity.getTransformation().getService().getLocation();
    if (!RenameAttributeFunction.class.getName().equals(function)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        report.setWarning(original, "Function " + function + " not recognized");
    }
    IDetailedAbout sourceAbout = DetailedAbout.getDetailedAbout(sourceEntity.getAbout(), true);
    IDetailedAbout targetAbout = DetailedAbout.getDetailedAbout(targetEntity.getAbout(), true);
    try {
        return new ModelAttributeMappingCell(createAttributePath(sourceAbout, sourceFeatures), createAttributePath(targetAbout, targetFeatures));
    } catch (TranslationException e) {
        report.setFailed(original, e.getMessage());
        return null;
    }
}
Also used : ModelAttributeMappingCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell) ComposedProperty(eu.esdihumboldt.commons.goml.omwg.ComposedProperty) IDetailedAbout(eu.esdihumboldt.commons.goml.rdf.IDetailedAbout) TranslationException(com.onespatial.jrc.tns.oml_to_rif.api.TranslationException) FeatureClass(eu.esdihumboldt.commons.goml.omwg.FeatureClass)

Example 3 with FeatureClass

use of eu.esdihumboldt.commons.goml.omwg.FeatureClass in project hale by halestudio.

the class MismatchPropertiesBlock method getDummyCell.

private Object getDummyCell() {
    Mismatch a = new Mismatch(MismatchType.AggregationLevelMismatch);
    a.setReason(new Reason(new FeatureClass(new About("FC1")), new FeatureClass(new About("FC2")), EntityCharacteristic.AssociationCardinalityConstraint));
    a.getConsequences().add(new Consequence());
    a.getConsequences().add(new Consequence());
    a.getConsequences().add(new Consequence());
    a.setProvenance("HALE MDL Inference Engine");
    Mismatch b = new Mismatch(MismatchType.StructureMismatch);
    b.setReason(new Reason(new Property(new About("Prop1Name")), new Property(new About("Prop2Name")), EntityCharacteristic.AttributeTypeConstraint));
    b.getReason().setReasonRule(new ReasonRule(new ReasonSet("Prop1Name"), new ReasonSet("Prop2Name")));
    List<ReasonCondition> conditions = new ArrayList<ReasonCondition>();
    conditions.add(new ReasonCondition("attributeName", "attributeFilterValue", null));
    b.getReason().getReasonRule().getSet1().setConditions(conditions);
    b.getReason().getReasonRule().getSet1().setSubSet(new ReasonSet("SubProp1Name"));
    b.getConsequences().add(new Consequence());
    b.setProvenance("User");
    Mismatch c = new Mismatch(MismatchType.AbstractionMismatch);
    c.setReason(new Reason(new Property(new About("Prop3Name")), new Property(new About("Prop4Name")), EntityCharacteristic.AttributeDerivedPopulatedValues));
    c.getReason().setReasonRule(new ReasonRule(new ReasonSet("Prop3Name"), new ReasonSet("Prop4Name")));
    c.getConsequences().add(new Consequence());
    c.getConsequences().add(new Consequence());
    c.setProvenance("HALE MDL Inference Engine");
    MismatchCell mc = new MismatchCell();
    mc.getMismatches().add(a);
    mc.getMismatches().add(b);
    mc.getMismatches().add(c);
    return mc;
}
Also used : ReasonRule(eu.xsdi.mdl.model.reason.ReasonRule) ReasonSet(eu.xsdi.mdl.model.reason.ReasonSet) ArrayList(java.util.ArrayList) Consequence(eu.xsdi.mdl.model.Consequence) ReasonCondition(eu.xsdi.mdl.model.reason.ReasonCondition) MismatchCell(eu.xsdi.mdl.model.MismatchCell) Mismatch(eu.xsdi.mdl.model.Mismatch) FeatureClass(eu.esdihumboldt.commons.goml.omwg.FeatureClass) Property(eu.esdihumboldt.commons.goml.omwg.Property) Reason(eu.xsdi.mdl.model.Reason) About(eu.esdihumboldt.commons.goml.rdf.About)

Aggregations

FeatureClass (eu.esdihumboldt.commons.goml.omwg.FeatureClass)3 TranslationException (com.onespatial.jrc.tns.oml_to_rif.api.TranslationException)2 ModelAttributeMappingCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell)2 ComposedProperty (eu.esdihumboldt.commons.goml.omwg.ComposedProperty)2 Property (eu.esdihumboldt.commons.goml.omwg.Property)2 ArrayList (java.util.ArrayList)2 HaleAlignment (com.onespatial.jrc.tns.oml_to_rif.HaleAlignment)1 ModelAlignment (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAlignment)1 ModelClassMappingCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelClassMappingCell)1 ModelStaticAssignmentCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell)1 Alignment (eu.esdihumboldt.commons.goml.align.Alignment)1 About (eu.esdihumboldt.commons.goml.rdf.About)1 IDetailedAbout (eu.esdihumboldt.commons.goml.rdf.IDetailedAbout)1 SchemaElement (eu.esdihumboldt.hale.schemaprovider.model.SchemaElement)1 ICell (eu.esdihumboldt.specification.cst.align.ICell)1 IEntity (eu.esdihumboldt.specification.cst.align.IEntity)1 Consequence (eu.xsdi.mdl.model.Consequence)1 Mismatch (eu.xsdi.mdl.model.Mismatch)1 MismatchCell (eu.xsdi.mdl.model.MismatchCell)1 Reason (eu.xsdi.mdl.model.Reason)1