private void writeFileRefs(DbSession session, Map<String, Reference> refByComponentKey, ShowResponse.Builder response, @Nullable String branch, @Nullable String pullRequest) { Map<String, ComponentDto> projectsByUuid = new HashMap<>(); Map<String, ComponentDto> parentModulesByUuid = new HashMap<>(); for (Map.Entry<String, Reference> entry : refByComponentKey.entrySet()) { Reference ref = entry.getValue(); ComponentDto file = ref.getDto(); if (file != null) { ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session); ComponentDto parentModule = getParentProject(file.moduleUuid(), parentModulesByUuid, session); response.putFiles(ref.getId(), toWsFile(file, project, parentModule, branch, pullRequest)); } else { response.putFiles(ref.getId(), toWsFile(ref.getComponentKey(), branch, pullRequest)); } } }
private void writeFiles(DbSession session, ShowResponse.Builder response, Map<String, String> refByComponentKey, @Nullable String branch, @Nullable String pullRequest) { Map<String, ComponentDto> projectsByUuid = newHashMap(); Map<String, ComponentDto> parentModulesByUuid = newHashMap(); Map<String, Duplications.File> filesByRef = response.getMutableFiles(); for (Map.Entry<String, String> entry : refByComponentKey.entrySet()) { String componentKey = entry.getKey(); String ref = entry.getValue(); Optional<ComponentDto> fileOptional = componentDao.selectByKey(session, componentKey); if (fileOptional.isPresent()) { ComponentDto file = fileOptional.get(); ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session); ComponentDto parentModule = getParentProject(file.getRootUuid(), parentModulesByUuid, session); filesByRef.put(ref, toWsFile(file, project, parentModule, branch, pullRequest)); } } }