use of com.b2international.snowowl.core.ComponentIdentifier in project snow-owl by b2ihealthcare.
the class BranchCompareRequest method execute.
@Override
public BranchCompareResult execute(RepositoryContext context) {
final RevisionIndex index = context.service(RevisionIndex.class);
final Branch branchToCompare = RepositoryRequests.branching().prepareGet(compare).build().execute(context);
final long compareHeadTimestamp = branchToCompare.headTimestamp();
final RevisionCompare compareResult;
final String baseBranchPath;
if (base != null) {
compareResult = index.compare(base, compare, limit, excludeComponentChanges);
baseBranchPath = base;
} else {
compareResult = index.compare(compare, limit, excludeComponentChanges);
baseBranchPath = branchToCompare.parentPath();
}
final BranchCompareResult.Builder result = BranchCompareResult.builder(baseBranchPath, compare, compareHeadTimestamp);
final Set<ComponentIdentifier> changedContainers = Sets.newHashSet();
for (RevisionCompareDetail detail : compareResult.getDetails()) {
final ObjectId affectedId;
if (detail.isComponentChange()) {
affectedId = detail.getComponent();
if (!detail.getObject().isRoot() && !excludeComponentChanges) {
changedContainers.add(ComponentIdentifier.of(detail.getObject().type(), detail.getObject().id()));
}
} else {
affectedId = detail.getObject();
}
final ComponentIdentifier identifier = ComponentIdentifier.of(affectedId.type(), affectedId.id());
switch(detail.getOp()) {
case ADD:
result.putNewComponent(identifier);
break;
case CHANGE:
result.putChangedComponent(identifier);
break;
case REMOVE:
result.putDeletedComponent(identifier);
break;
}
}
return result.totalNew(compareResult.getTotalAdded()).totalChanged(compareResult.getTotalChanged()).totalDeleted(compareResult.getTotalRemoved()).build(changedContainers);
}
use of com.b2international.snowowl.core.ComponentIdentifier in project snow-owl by b2ihealthcare.
the class ValidateRequest method fetchWhiteListEntries.
private Multimap<String, ComponentIdentifier> fetchWhiteListEntries(BranchContext context, final Set<String> ruleIds) {
// fetch all white list entries to determine whether an issue is whitelisted already or not
final Multimap<String, ComponentIdentifier> whiteListedEntries = HashMultimap.create();
ValidationWhiteListSearchRequestBuilder whiteListReq = ValidationRequests.whiteList().prepareSearch();
// fetch whitelist entries associated with the defined rules
if (!CompareUtils.isEmpty(ruleIds)) {
whiteListReq.filterByRuleIds(ruleIds);
}
whiteListReq.all().build().execute(context).stream().forEach(whitelist -> whiteListedEntries.put(whitelist.getRuleId(), whitelist.getComponentIdentifier()));
return whiteListedEntries;
}
use of com.b2international.snowowl.core.ComponentIdentifier in project snow-owl by b2ihealthcare.
the class BranchCompareRequestTest method compareBranchWithNewComponentOnExistingComponent.
@Test
public void compareBranchWithNewComponentOnExistingComponent() throws Exception {
final Set<ComponentIdentifier> componentsOnParentBranch = prepareBranchWithNewChanges(branchPath);
final String taskBranchPath = createBranch(branchPath, "taskBranch");
final ComponentIdentifier concept = componentsOnParentBranch.stream().filter(ci -> ci.getComponentType() == SnomedConcept.TYPE).findFirst().get();
final String newDescriptionId = SnomedRequests.prepareNewDescription().setIdFromNamespace(null).setConceptId(concept.getComponentId()).setTerm("New Description").setModuleId(Concepts.MODULE_SCT_CORE).setLanguageCode("en").setTypeId(Concepts.FULLY_SPECIFIED_NAME).build(taskBranchPath, RestExtensions.USER, "Create new Description on Concept: " + concept.getComponentId()).execute(bus).getSync(1, TimeUnit.MINUTES).getResultAs(String.class);
final ComponentIdentifier newDescription = ComponentIdentifier.of(SnomedDescription.TYPE, newDescriptionId);
final BranchCompareResult compareResult = compare(branchPath, taskBranchPath);
assertThat(compareResult.getNewComponents()).containsOnly(newDescription);
assertThat(compareResult.getChangedComponents()).containsOnly(concept);
assertThat(compareResult.getDeletedComponents()).isEmpty();
}
use of com.b2international.snowowl.core.ComponentIdentifier in project snow-owl by b2ihealthcare.
the class BranchCompareRequestTest method compareBranchWithNewComponents.
@Test
public void compareBranchWithNewComponents() throws Exception {
final Set<ComponentIdentifier> newIds = prepareBranchWithNewChanges(branchPath);
final BranchCompareResult compare = compare(null, branchPath);
assertThat(compare.getNewComponents()).containsAll(newIds);
assertThat(compare.getChangedComponents()).doesNotContainAnyElementsOf(newIds);
assertThat(compare.getDeletedComponents()).isEmpty();
}
use of com.b2international.snowowl.core.ComponentIdentifier in project snow-owl by b2ihealthcare.
the class BranchCompareRequestTest method remoteJobSupportCompareWithContent.
@Test
public void remoteJobSupportCompareWithContent() throws Exception {
final Set<ComponentIdentifier> newIds = prepareBranchWithNewChanges(branchPath);
final BranchCompareResult compare = compareOnJob(null, branchPath);
assertThat(compare.getNewComponents()).containsAll(newIds);
assertThat(compare.getChangedComponents()).doesNotContainAnyElementsOf(newIds);
assertThat(compare.getDeletedComponents()).isEmpty();
}
Aggregations