Search in sources :

Example 1 with IDetailedAbout

use of eu.esdihumboldt.commons.goml.rdf.IDetailedAbout 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 2 with IDetailedAbout

use of eu.esdihumboldt.commons.goml.rdf.IDetailedAbout in project hale by halestudio.

the class AlignmentToModelAlignmentDigester method createStaticAssignment.

private ModelStaticAssignmentCell createStaticAssignment(ICell original, Property targetEntity, Map<String, SchemaElement> targetFeatures) {
    String function = targetEntity.getTransformation().getService().getLocation();
    if (ConstantValueFunction.class.getName().equals(function)) {
        // constant value
        String content = null;
        for (IParameter param : targetEntity.getTransformation().getParameters()) {
            if (param.getName().equals(ConstantValueFunction.DEFAULT_VALUE_PARAMETER_NAME)) {
                content = param.getValue();
                break;
            }
        }
        IDetailedAbout targetAbout = DetailedAbout.getDetailedAbout(targetEntity.getAbout(), true);
        try {
            return new ModelStaticAssignmentCell(createAttributePath(targetAbout, targetFeatures), content);
        } catch (TranslationException e) {
            report.setFailed(original, e.getMessage());
            return null;
        }
    } else if (NilReasonFunction.class.getName().equals(function)) {
        // nil reason
        String reason = null;
        for (IParameter param : targetEntity.getTransformation().getParameters()) {
            if (param.getName().equals(NilReasonFunction.PARAMETER_NIL_REASON_TYPE)) {
                reason = param.getValue();
                break;
            }
        }
        // $NON-NLS-1$
        report.setWarning(original, "The nil reason will be set regardless of whether a value for its parent is set or not");
        IDetailedAbout targetAbout = DetailedAbout.getDetailedAbout(targetEntity.getAbout(), true);
        List<String> properties = new ArrayList<String>(targetAbout.getProperties());
        // XXX this is an attribute does it make any difference? //$NON-NLS-1$
        properties.add("nilReason");
        targetAbout = new DetailedAbout(targetAbout.getNamespace(), targetAbout.getFeatureClass(), properties);
        try {
            return new ModelStaticAssignmentCell(createAttributePath(targetAbout, targetFeatures), reason);
        } catch (TranslationException e) {
            report.setFailed(original, e.getMessage());
            return null;
        }
    } else {
        // not supported
        // $NON-NLS-1$
        report.setFailed(original, "Only default value augmentations supported");
        return null;
    }
}
Also used : IParameter(eu.esdihumboldt.specification.cst.align.ext.IParameter) ConstantValueFunction(eu.esdihumboldt.cst.corefunctions.ConstantValueFunction) ModelStaticAssignmentCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell) IDetailedAbout(eu.esdihumboldt.commons.goml.rdf.IDetailedAbout) DetailedAbout(eu.esdihumboldt.commons.goml.rdf.DetailedAbout) IDetailedAbout(eu.esdihumboldt.commons.goml.rdf.IDetailedAbout) TranslationException(com.onespatial.jrc.tns.oml_to_rif.api.TranslationException) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TranslationException (com.onespatial.jrc.tns.oml_to_rif.api.TranslationException)2 IDetailedAbout (eu.esdihumboldt.commons.goml.rdf.IDetailedAbout)2 ModelAttributeMappingCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell)1 ModelStaticAssignmentCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell)1 ComposedProperty (eu.esdihumboldt.commons.goml.omwg.ComposedProperty)1 FeatureClass (eu.esdihumboldt.commons.goml.omwg.FeatureClass)1 DetailedAbout (eu.esdihumboldt.commons.goml.rdf.DetailedAbout)1 ConstantValueFunction (eu.esdihumboldt.cst.corefunctions.ConstantValueFunction)1 IParameter (eu.esdihumboldt.specification.cst.align.ext.IParameter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1