ppapou commented on a change in pull request #926:
URL: https://github.com/apache/incubator-datalab/pull/926#discussion_r508138747
##########
File path:
services/self-service/src/main/java/com/epam/dlab/backendapi/dao/OdahuDAOImpl.java
##########
@@ -69,23 +71,34 @@
fields(include(ODAHU_FIELD), excludeId()),
ProjectDTO.class);
- return projectDTO.flatMap(p -> p.getOdahu()
- .stream()
+ return projectDTO.flatMap(p -> p.getOdahu().stream()
.filter(odahu -> project.equals(odahu.getProject()) &&
endpoint.equals(odahu.getEndpoint()))
.findAny());
}
+ @Override
+ public List<OdahuDTO> getOdahuProjectClusters(String project, String
endpoint) {
+ Optional<ProjectDTO> projectDTO = findOne(PROJECTS_COLLECTION,
odahuProjectEndpointCondition(project, endpoint),
+ fields(include(ODAHU_FIELD), excludeId()),
+ ProjectDTO.class);
+
+ return projectDTO.map(p -> p.getOdahu().stream()
+ .filter(odahu -> project.equals(odahu.getProject()) &&
endpoint.equals(odahu.getEndpoint()))
+ .collect(Collectors.toList()))
+ .orElseThrow(() -> new DlabException("Unable to find the odahu
clusters in the " + project));
+ }
+
@Override
public OdahuFieldsDTO getFields(String name, String project, String
endpoint) {
- Optional<Document> one = findOne(PROJECTS_COLLECTION,
odahuProjectEndpointCondition(name, project, endpoint),
- fields(include(ODAHU_FIELD), excludeId()));
- OdahuFieldsDTO odahuFields = null;
- if (one.isPresent()) {
- List<OdahuFieldsDTO> list =
convertFromDocument(one.get().get(ODAHU_FIELD, ArrayList.class), new
TypeReference<List<OdahuFieldsDTO>>() {
- });
- odahuFields = list.get(0);
- }
- return odahuFields;
+ Document odahuDocument = findOne(PROJECTS_COLLECTION,
odahuProjectEndpointCondition(name, project, endpoint),
+ fields(include(ODAHU_FIELD), excludeId()))
+ .orElseThrow(() -> new DlabException(project.toString() + "{}
does not contain odahu {}" + name.toString() + "cluster"));
Review comment:
Message has been changed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]