use of com.b2international.snowowl.core.merge.ConflictingAttribute in project snow-owl by b2ihealthcare.
the class SnomedMergeConflictTest method changedInSourceDetachedInTargetMergeConflict.
@Test
public void changedInSourceDetachedInTargetMergeConflict() {
String memberId = createNewRefSetMember(branchPath);
IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
branching.createBranch(a).statusCode(201);
LocalDate nextEffectiveTime = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
String nextEffectiveTimeAsString = EffectiveTimes.format(nextEffectiveTime, DateFormats.SHORT);
Map<?, ?> effectiveTimeUpdateRequest = ImmutableMap.builder().put("effectiveTime", nextEffectiveTimeAsString).put("commitComment", "Updated effective time on reference set member").build();
updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, effectiveTimeUpdateRequest, true).statusCode(204);
deleteComponent(a, SnomedComponentType.MEMBER, memberId, false).statusCode(204);
Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased reference set member deletion over effective time update").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
assertEquals(1, conflicts.size());
MergeConflict conflict = Iterables.getOnlyElement(conflicts);
assertEquals(memberId, conflict.getComponentId());
assertEquals("member", conflict.getComponentType());
assertEquals(ConflictType.DELETED_WHILE_CHANGED, conflict.getType());
Map<String, ConflictingAttribute> expectedAttributes = newHashMap();
expectedAttributes.put("effectiveTime", ConflictingAttribute.builder().property("effectiveTime").sourceValue(nextEffectiveTimeAsString).build());
expectedAttributes.put("released", ConflictingAttribute.builder().property("released").oldValue("false").sourceValue("true").build());
for (ConflictingAttribute attribute : conflict.getConflictingAttributes()) {
ConflictingAttribute expected = expectedAttributes.remove(attribute.getProperty());
assertNotNull(expected);
assertEquals(expected.toDisplayName(), attribute.toDisplayName());
}
assertThat(expectedAttributes).isEmpty();
}
use of com.b2international.snowowl.core.merge.ConflictingAttribute in project snow-owl by b2ihealthcare.
the class SnomedMergeConflictTest method addedInTargetDetachedInSourceMergeConflict.
@Test
public void addedInTargetDetachedInSourceMergeConflict() {
String conceptId = createNewConcept(branchPath);
IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
branching.createBranch(a).statusCode(201);
deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
String relationshipId = createNewRelationship(a, Concepts.ROOT_CONCEPT, Concepts.PART_OF, conceptId);
Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new relationship over deleted concept").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
assertEquals(1, conflicts.size());
ConflictingAttribute attribute = ConflictingAttribute.builder().property("destinationId").sourceValue(conceptId).build();
MergeConflict conflict = Iterables.getOnlyElement(conflicts);
assertEquals(relationshipId, conflict.getComponentId());
assertEquals("relationship", conflict.getComponentType());
assertEquals(ConflictType.HAS_MISSING_REFERENCE, conflict.getType());
assertEquals(attribute.toDisplayName(), Iterables.getOnlyElement(conflict.getConflictingAttributes()).toDisplayName());
}
use of com.b2international.snowowl.core.merge.ConflictingAttribute in project snow-owl by b2ihealthcare.
the class AbstractBranchChangeRequest method toMergeConflict.
private MergeConflict toMergeConflict(ObjectId objectId, Collection<Conflict> conflicts) {
final MergeConflict.Builder conflict = MergeConflict.builder().componentId(objectId.id()).componentType(objectId.type()).type(ConflictType.CONFLICTING_CHANGE);
final List<ConflictingAttribute> conflictingAttributes = conflicts.stream().filter(ChangedInSourceAndTargetConflict.class::isInstance).map(ChangedInSourceAndTargetConflict.class::cast).map(c -> ConflictingAttribute.builder().property(c.getSourceChange().getProperty()).oldValue(c.getSourceChange().getOldValue()).sourceValue(c.getSourceChange().getNewValue()).targetValue(c.getTargetChange().getNewValue()).build()).collect(Collectors.toList());
if (!conflictingAttributes.isEmpty()) {
return conflict.conflictingAttributes(conflictingAttributes).build();
} else {
// XXX multiple conflicts are not expected here for a single object
Conflict c = Iterables.getFirst(conflicts, null);
if (c instanceof AddedInSourceAndTargetConflict) {
return conflict.message(c.getMessage()).conflictingAttribute(ConflictingAttribute.builder().property(Revision.Fields.ID).build()).build();
} else if (c instanceof ChangedInSourceAndDetachedInTargetConflict) {
return conflict.message(c.getMessage()).type(ConflictType.DELETED_WHILE_CHANGED).conflictingAttributes(((ChangedInSourceAndDetachedInTargetConflict) c).getChanges().stream().map(attributeChange -> ConflictingAttribute.builder().property(attributeChange.getProperty()).oldValue(attributeChange.getOldValue()).sourceValue(attributeChange.getNewValue()).build()).collect(Collectors.toList())).build();
} else if (c instanceof AddedInSourceAndDetachedInTargetConflict) {
return conflict.message(c.getMessage()).type(ConflictType.CAUSES_MISSING_REFERENCE).componentId(((AddedInSourceAndDetachedInTargetConflict) c).getDetachedOnTarget().id()).componentType(((AddedInSourceAndDetachedInTargetConflict) c).getDetachedOnTarget().type()).build();
} else if (c instanceof AddedInTargetAndDetachedInSourceConflict) {
return conflict.message(c.getMessage()).type(ConflictType.HAS_MISSING_REFERENCE).componentId(((AddedInTargetAndDetachedInSourceConflict) c).getAddedOnTarget().id()).componentType(((AddedInTargetAndDetachedInSourceConflict) c).getAddedOnTarget().type()).conflictingAttribute(ConflictingAttribute.builder().property(((AddedInTargetAndDetachedInSourceConflict) c).getFeatureName()).targetValue(((AddedInTargetAndDetachedInSourceConflict) c).getDetachedOnSource().id()).build()).build();
} else {
return conflict.message("Not implemented conflict mapping").build();
}
}
}
use of com.b2international.snowowl.core.merge.ConflictingAttribute in project snow-owl by b2ihealthcare.
the class SnomedMergeConflictTest method addedInSourceAndTargetMergeConflict.
@Test
public void addedInSourceAndTargetMergeConflict() {
IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
branching.createBranch(a).statusCode(201);
String descriptionId = createNewDescription(branchPath);
Map<?, ?> requestBody = ImmutableMap.builder().put("id", descriptionId).put("conceptId", Concepts.ROOT_CONCEPT).put("moduleId", Concepts.MODULE_SCT_CORE).put("typeId", Concepts.SYNONYM).put("term", "Synonym of root concept").put("languageCode", "en").put("acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP).put("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE).put("commitComment", "Created new synonym with duplicate SCTID").build();
createComponent(a, SnomedComponentType.DESCRIPTION, requestBody).statusCode(201);
Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new description over new description with same SCTID").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
assertEquals(1, conflicts.size());
ConflictingAttribute attribute = ConflictingAttribute.builder().property("id").build();
MergeConflict conflict = Iterables.getOnlyElement(conflicts);
assertEquals(descriptionId, conflict.getComponentId());
assertEquals("description", conflict.getComponentType());
assertEquals(ConflictType.CONFLICTING_CHANGE, conflict.getType());
assertEquals(attribute.toDisplayName(), Iterables.getOnlyElement(conflict.getConflictingAttributes()).toDisplayName());
}
use of com.b2international.snowowl.core.merge.ConflictingAttribute in project snow-owl by b2ihealthcare.
the class SnomedMergeConflictTest method deleteReferencedComponentOnSourceMergeConflict.
@Test
public void deleteReferencedComponentOnSourceMergeConflict() {
String conceptId = createNewConcept(branchPath);
IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
branching.createBranch(a).statusCode(201);
deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
String memberId = createNewRefSetMember(a, conceptId);
Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new reference set member over deleted referenced component").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
assertEquals(1, conflicts.size());
ConflictingAttribute attribute = ConflictingAttribute.builder().property("container").sourceValue(conceptId).build();
MergeConflict conflict = Iterables.getOnlyElement(conflicts);
assertEquals(memberId, conflict.getComponentId());
assertEquals("member", conflict.getComponentType());
assertEquals(ConflictType.HAS_MISSING_REFERENCE, conflict.getType());
assertEquals(attribute.toDisplayName(), Iterables.getOnlyElement(conflict.getConflictingAttributes()).toDisplayName());
}
Aggregations