This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push:
new 2f618ac [DLAB-1801] Conveyed the list of buckets to the 'List of
report' page
2f618ac is described below
commit 2f618acbcbfbd169b35fa6008e8ae3210f190964
Author: Oleh Fuks <[email protected]>
AuthorDate: Wed May 13 15:08:24 2020 +0300
[DLAB-1801] Conveyed the list of buckets to the 'List of report' page
---
.../epam/dlab/backendapi/dao/ExploratoryDAO.java | 4 +-
.../impl/InfrastructureInfoServiceImpl.java | 60 +++++++++++-----------
2 files changed, 33 insertions(+), 31 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/ExploratoryDAO.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/ExploratoryDAO.java
index fc44569..8c5a7ce 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/ExploratoryDAO.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/ExploratoryDAO.java
@@ -113,8 +113,8 @@ public class ExploratoryDAO extends BaseDAO {
* @param user name
* @return list of user resources
*/
- public Iterable<Document> findExploratory(String user) {
- return find(USER_INSTANCES, eq(USER, user),
+ public Iterable<Document> findExploratories(String user, String
project) {
+ return find(USER_INSTANCES, and(eq(USER, user), eq(PROJECT,
project)),
fields(exclude(ExploratoryLibDAO.EXPLORATORY_LIBS,
ExploratoryLibDAO.COMPUTATIONAL_LIBS, SCHEDULER_DATA,
EXPLORATORY_USER,
EXPLORATORY_PASS)));
}
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
index 4063ca1..76d785c 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
@@ -25,6 +25,7 @@ import com.epam.dlab.backendapi.dao.BillingDAO;
import com.epam.dlab.backendapi.dao.ExploratoryDAO;
import com.epam.dlab.backendapi.domain.BillingReport;
import com.epam.dlab.backendapi.domain.EndpointDTO;
+import com.epam.dlab.backendapi.domain.ProjectDTO;
import com.epam.dlab.backendapi.domain.ProjectEndpointDTO;
import com.epam.dlab.backendapi.resources.dto.HealthStatusEnum;
import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO;
@@ -85,37 +86,14 @@ public class InfrastructureInfoServiceImpl implements
InfrastructureInfoService
public List<ProjectInfrastructureInfo> getUserResources(UserInfo user) {
log.debug("Loading list of provisioned resources for user {}",
user);
try {
- Iterable<Document> documents =
expDAO.findExploratory(user.getName());
List<EndpointDTO> allEndpoints =
endpointService.getEndpoints();
- return StreamSupport.stream(documents.spliterator(),
false)
- .collect(Collectors.groupingBy(d ->
d.getString("project")))
- .entrySet()
+ return projectService.getUserProjects(user, false)
.stream()
- .map(e -> {
- List<ProjectEndpointDTO>
endpoints = projectService.get(e.getKey()).getEndpoints();
- List<EndpointDTO>
endpointResult = allEndpoints.stream()
-
.filter(endpoint -> endpoints.stream()
-
.anyMatch(endpoint1 -> endpoint1.getName().equals(endpoint.getName())))
-
.collect(Collectors.toList());
-
- List<BillingReport> billingData
= e.getValue()
- .stream()
- .map(exp ->
-
billingService.getExploratoryBillingData(exp.getString("project"),
exp.getString("endpoint"),
-
exp.getString("exploratory_name"),
-
Optional.ofNullable(exp.get("computational_resources")).map(cr
-> (List<Document>) cr).get()
-
.stream()
-
.map(cr -> cr.getString("computational_name"))
-
.collect(Collectors.toList()))
- )
-
.collect(Collectors.toList());
-
- final Map<String, Map<String,
String>> projectEdges =
- endpoints
-
.stream()
-
.collect(Collectors.toMap(ProjectEndpointDTO::getName, this::getSharedInfo));
- return new
ProjectInfrastructureInfo(e.getKey(),
billingDAO.getBillingProjectQuoteUsed(e.getKey()),
- projectEdges,
e.getValue(), billingData, endpointResult);
+ .map(p -> {
+ Iterable<Document>
exploratories = expDAO.findExploratories(user.getName(), p.getName());
+ return new
ProjectInfrastructureInfo(p.getName(),
billingDAO.getBillingProjectQuoteUsed(p.getName()),
+
getSharedInfo(p.getName()), exploratories,
getExploratoryBillingData(exploratories),
+
getEndpoints(allEndpoints, p));
})
.collect(Collectors.toList());
} catch (Exception e) {
@@ -162,6 +140,30 @@ public class InfrastructureInfoServiceImpl implements
InfrastructureInfoService
.build();
}
+ private List<BillingReport>
getExploratoryBillingData(Iterable<Document> exploratories) {
+ return StreamSupport.stream(exploratories.spliterator(), false)
+ .map(exp ->
+
billingService.getExploratoryBillingData(exp.getString("project"),
exp.getString("endpoint"),
+
exp.getString("exploratory_name"),
+
Optional.ofNullable(exp.get("computational_resources")).map(cr ->
(List<Document>) cr).get()
+
.stream()
+
.map(cr -> cr.getString("computational_name"))
+
.collect(Collectors.toList()))
+ )
+ .collect(Collectors.toList());
+ }
+
+ private List<EndpointDTO> getEndpoints(List<EndpointDTO> allEndpoints,
ProjectDTO projectDTO) {
+ return allEndpoints.stream().filter(endpoint ->
projectDTO.getEndpoints().stream()
+ .anyMatch(endpoint1 ->
endpoint1.getName().equals(endpoint.getName())))
+ .collect(Collectors.toList());
+ }
+
+ private Map<String, Map<String, String>> getSharedInfo(String name) {
+ return projectService.get(name).getEndpoints().stream()
+
.collect(Collectors.toMap(ProjectEndpointDTO::getName, this::getSharedInfo));
+ }
+
private Map<String, String> getSharedInfo(ProjectEndpointDTO
endpointDTO) {
Optional<EdgeInfo> edgeInfo =
Optional.ofNullable(endpointDTO.getEdgeInfo());
if (!edgeInfo.isPresent()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]