Skip to content

Commit

Permalink
MAINT-2370 Change the Annotation language to a new column in RF2
Browse files Browse the repository at this point in the history
  • Loading branch information
QuyenLy87 committed Oct 26, 2023
1 parent 753e2dc commit e240656
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

public class Annotation extends ReferenceSetMember implements AnnotationView {

private static final Pattern ANNOTATION_LANGUAGE_TYPE_PATTERN = Pattern.compile("^@+\\S.*\\\".*\\\"$");

@JsonView(value = View.Component.class)
private String annotationId;
@JsonView(value = View.Component.class)
Expand Down Expand Up @@ -98,14 +96,8 @@ public Annotation fromRefsetMember(ReferenceSetMember fromMember) {
setReferencedComponentId(fromMember.getReferencedComponentId());
setReleased(fromMember.isReleased());
setAnnotationTypeId(fromMember.getAdditionalField(AnnotationFields.ANNOTATION_TYPE_ID));

String annotationValue = fromMember.getAdditionalField(AnnotationFields.ANNOTATION_VALUE);
if (StringUtils.isNotEmpty(annotationValue) && ANNOTATION_LANGUAGE_TYPE_PATTERN.matcher(annotationValue).matches()) {
setAnnotationLanguage(annotationValue.substring(1, annotationValue.indexOf("\"")).trim());
setAnnotationValue(annotationValue.substring(annotationValue.indexOf("\"") + 1, annotationValue.lastIndexOf("\"")));
} else {
setAnnotationValue(annotationValue);
}
setAnnotationValue(fromMember.getAdditionalField(AnnotationFields.ANNOTATION_VALUE));
setAnnotationLanguage(fromMember.getAdditionalField(AnnotationFields.ANNOTATION_LANGUAGE));
return this;
}

Expand All @@ -115,7 +107,8 @@ public ReferenceSetMember toRefsetMember() {
String moduleId = getModuleId() != null ? getModuleId() : Concepts.CORE_MODULE;
ReferenceSetMember member = new ReferenceSetMember(annotationId, getEffectiveTimeI(), isActive(), moduleId, refsetId, getReferencedComponentId());
member.setAdditionalField(AnnotationFields.ANNOTATION_TYPE_ID, getAnnotationTypeId());
member.setAdditionalField(AnnotationFields.ANNOTATION_VALUE, getAnnotationLanguage() != null ? "@" + getAnnotationLanguage() + "\"" + getAnnotationValue() + "\"" : getAnnotationValue());
member.setAdditionalField(AnnotationFields.ANNOTATION_VALUE, getAnnotationValue());
member.setAdditionalField(AnnotationFields.ANNOTATION_LANGUAGE, getAnnotationLanguage());
return member;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public interface MRCMAttributeDomainFields {
public interface AnnotationFields {
String ANNOTATION_TYPE_ID = "annotationTypeId";
String ANNOTATION_VALUE = "annotationValue";
String ANNOTATION_LANGUAGE = "annotationLanguage";
}

@JsonView(value = View.Component.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,19 @@ private void reapplyAnnotationMemberChanges(Map<String, ReferenceSetMember> sour
sourceReferenceSetMember.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_VALUE)
)
);
mergedReferenceSetMember.setAdditionalField(
ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE,
getValueChanged(
targetReferenceSetMemberOld.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE),
targetReferenceSetMemberNew.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE),
sourceReferenceSetMember.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE)
)
);
} else {
mergedReferenceSetMember.setRefsetId(sourceReferenceSetMember.getRefsetId());
mergedReferenceSetMember.setAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_TYPE_ID, sourceReferenceSetMember.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_TYPE_ID));
mergedReferenceSetMember.setAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_VALUE, sourceReferenceSetMember.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_VALUE));
mergedReferenceSetMember.setAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE, sourceReferenceSetMember.getAdditionalField(ReferenceSetMember.AnnotationFields.ANNOTATION_LANGUAGE));
}

// Re-apply mutable fields
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ refset.types.Language=900000000000506000|Language|c|acceptabilityId
refset.types.AssociationReference=900000000000521006|Content|c|targetComponentId
refset.types.AttributeValue=900000000000480006|Content|c|valueId
refset.types.Simple=446609009|Content||
refset.types.Annotation=1292992004|Content|cs|annotationTypeId,annotationValue
refset.types.Annotation=1292992004|Content|css|annotationTypeId,annotationValue,annotationLanguage
refset.types.SimpleMapToSCT=1187636009|Map|s|mapSource
refset.types.SimpleMapFromSCT=900000000000496009|Map|s|mapTarget
refset.types.SimpleMapCorrelationToSCT=1193543008|Map|sc|mapSource,correlationId
Expand Down

0 comments on commit e240656

Please sign in to comment.