use of com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell 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;
}
}
Aggregations