Skip to content

Commit

Permalink
fix(core): Fetch "extensionOf" branch state from the code system's...
Browse files Browse the repository at this point in the history
...repository, not the one available from the context. The latter only
stores resource metadata and no branches outside MAIN exist in it.
  • Loading branch information
apeteri committed Apr 27, 2022
1 parent 3eb2dc0 commit 0d581a3
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
import com.b2international.snowowl.core.version.Version;
import com.b2international.snowowl.core.version.Versions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimaps;
import com.google.common.collect.TreeMultimap;
import com.google.common.collect.*;

/**
* @since 7.6
Expand Down Expand Up @@ -80,8 +77,18 @@ private void expandExtensionOfBranchState(List<CodeSystem> results) {
}

// extensionOf branches are the parent branches of the CodeSystem, so simple branch state calculation is enough
BaseRevisionBranching branching = context().service(BaseRevisionBranching.class);
final RepositoryManager repositoryManager = context().service(RepositoryManager.class);
final Set<String> toolingIds = results.stream()
.map(CodeSystem::getToolingId)
.collect(Collectors.toSet());

final Map<String, BaseRevisionBranching> branchingMap = toolingIds.stream()
.collect(ImmutableMap.toImmutableMap(
id -> id,
id -> repositoryManager.get(id).service(BaseRevisionBranching.class)));

for (CodeSystem result : results) {
BaseRevisionBranching branching = branchingMap.get(result.getToolingId());
RevisionBranch branch = branching.getBranch(result.getBranchPath());
BranchState branchState = branching.getBranchState(branch);
result.setExtensionOfBranchInfo(new BranchInfo(branch.getPath(), branchState, branch.getBaseTimestamp(), branch.getHeadTimestamp()));
Expand Down

1 comment on commit 0d581a3

@cmark
Copy link
Member

@cmark cmark commented on 0d581a3 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Please sign in to comment.