@@ -32,13 +32,17 @@ public ProjectDto create(ProjectDto template) throws AqualityException {
32
32
33
33
@ Override
34
34
public List <ProjectDto > get (ProjectDto template ) throws AqualityException {
35
+ return get (template , true );
36
+ }
37
+
38
+ public List <ProjectDto > get (ProjectDto template , boolean withChildren ) throws AqualityException {
35
39
if (baseUser .getApiSessionProjectId () != null ) {
36
40
template .setId (baseUser .getApiSessionProjectId ());
37
41
} else {
38
42
template .setUser_id (baseUser .getId ());
39
43
}
40
44
List <ProjectDto > projects = projectDao .searchAll (template );
41
- return fillCustomers (projects );
45
+ return fillCustomers (projects , withChildren );
42
46
}
43
47
44
48
@ Override
@@ -53,7 +57,7 @@ public boolean delete(ProjectDto template) throws AqualityException {
53
57
public boolean isStepsEnabled (Integer projectId ) throws AqualityException {
54
58
ProjectDto project = new ProjectDto ();
55
59
project .setId (projectId );
56
- List <ProjectDto > projects = get (project );
60
+ List <ProjectDto > projects = get (project , false );
57
61
58
62
if (projects .size () < 1 ) {
59
63
throw new AqualityException ("Project with id %s does not exists!" , projectId );
@@ -81,9 +85,13 @@ private void updatePermissions(Integer customer_id, Integer project_id) throws A
81
85
}
82
86
83
87
//TODO Refactoring
84
- private List <ProjectDto > fillCustomers (List <ProjectDto > projects ) throws AqualityException {
88
+ private List <ProjectDto > fillCustomers (List <ProjectDto > projects , boolean withChildren ) throws AqualityException {
85
89
List <ProjectDto > filledProjects = new ArrayList <>();
86
- List <CustomerDto > customerDtoList = customerController .get (new CustomerDto (), true );
90
+ CustomerDto customerTemplate = new CustomerDto ();
91
+ if (projects .size () == 1 ) {
92
+ customerTemplate .setId (projects .get (0 ).getCustomer_id ());
93
+ }
94
+ List <CustomerDto > customerDtoList = customerController .get (new CustomerDto (), withChildren );
87
95
for (ProjectDto filledProject : projects ) {
88
96
if (filledProject .getCustomer_id () != null ) {
89
97
int customerId = filledProject .getCustomer_id ();
0 commit comments