Skip to content

Commit

Permalink
RAP-85 Allow exporting ModuleDependency for Derivative modules
Browse files Browse the repository at this point in the history
  • Loading branch information
QuyenLy87 committed Jun 19, 2024
1 parent aab5054 commit effdf3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StopWatch;

import io.kaicode.elasticvc.api.BranchService;
Expand Down Expand Up @@ -350,7 +351,7 @@ private String determineClosestParentFromExistingHierarchy(String module, List<S

List<String> ancestors = findAncestorModules(module, selfMappedModules, moduleMap.get(module));
//If we only see a single ancestor, that's our closest parent
if (ancestors.size() == 0) {
if (ancestors.isEmpty()) {
return module;
} else if (ancestors.size() == 1) {
return ancestors.get(0);
Expand Down Expand Up @@ -522,21 +523,21 @@ private Map<String, String> getModuleOfModule(String branchPath, Set<String> mod
}
return moduleParentMap;
}

public boolean isExportable(ReferenceSetMember rm, boolean isExtension) {

public boolean isExportable(ReferenceSetMember rm, boolean isExtension, Set<String> modulesIncluded) {
if (!CollectionUtils.isEmpty(modulesIncluded) && modulesIncluded.contains(rm.getModuleId())) {
return true;
}

//Extensions don't list dependencies of core modules
if (isExtension && SI_MODULES.contains(rm.getModuleId())) {
return false;
}
if (excludeDerivativeModules && derivativeModules.contains(rm.getModuleId())) {
return false;
}

if (blockListedModules != null && blockListedModules.contains(rm.getModuleId())) {
return false;
}

return true;
}

return blockListedModules == null || !blockListedModules.contains(rm.getModuleId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private File exportRF2ArchiveFile(String branchPath, String filenameEffectiveDat
ExportFilter<ReferenceSetMember> exportFilter = null;
if (isMDRS) {
logger.info("MDRS being exported for " + (isExtension?"extension":"edition") + " package style.");
exportFilter = rm -> mdrService.isExportable(rm, isExtension);
exportFilter = rm -> mdrService.isExportable(rm, isExtension, moduleIds);
}
if (generateMDR && isMDRS) {
logger.info("MDR being generated rather than persisted.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public List<ReferenceSetMember> generateModuleDependencyPreview (
//Extensions only mention their own modules, despite being able to "see" those on MAIN
Branch branch = branchService.findBranchOrThrow(branchPath);
final boolean isExtension = (branch.getMetadata() != null && !StringUtils.isEmpty(branch.getMetadata().getString(BranchMetadataKeys.DEPENDENCY_PACKAGE)));
ExportFilter<ReferenceSetMember> exportFilter = rm -> moduleDependencyService.isExportable(rm, isExtension);
ExportFilter<ReferenceSetMember> exportFilter = rm -> moduleDependencyService.isExportable(rm, isExtension, modulesIncluded);

return moduleDependencyService.generateModuleDependencies(branchPath, effectiveDate, modulesIncluded, isDelta, null)
.stream()
Expand Down

0 comments on commit effdf3a

Please sign in to comment.