7
7
import main .annotations .DataBaseSearchable ;
8
8
import main .exceptions .AqualityException ;
9
9
import main .model .db .dao .project .MilestoneDao ;
10
+ import main .model .db .dao .project .TestDao ;
10
11
import main .model .db .dao .project .TestSuiteDao ;
11
12
import main .utils .BooleanUtil ;
12
13
@@ -94,15 +95,10 @@ public boolean isFromGlobalManagement(){
94
95
}
95
96
96
97
public ProjectUserDto getProjectUser (Integer projectId ){
97
- ProjectUserDto emptyPU = new ProjectUserDto ();
98
- emptyPU .setViewer (0 );
99
- emptyPU .setAdmin (0 );
100
- emptyPU .setManager (0 );
101
- emptyPU .setEngineer (0 );
102
98
if (projectUsers != null ){
103
- return projectUsers .stream ().filter (x -> x .getProject_id ().equals (projectId )).findFirst ().orElse (emptyPU );
99
+ return projectUsers .stream ().filter (x -> x .getProject_id ().equals (projectId )).findFirst ().orElse (getEmptyProjectUser () );
104
100
}
105
- return emptyPU ;
101
+ return getEmptyProjectUser () ;
106
102
}
107
103
108
104
public ProjectUserDto getProjectUserBySuiteId (Integer suite_id ) throws AqualityException {
@@ -113,6 +109,19 @@ public ProjectUserDto getProjectUserBySuiteId(Integer suite_id) throws AqualityE
113
109
return getProjectUser (template .getProject_id ());
114
110
}
115
111
112
+ public ProjectUserDto getProjectUserByTest (TestDto testDto ) throws AqualityException {
113
+ if (testDto .getProject_id () != null ){
114
+ return getProjectUser (testDto .getProject_id ());
115
+ }
116
+
117
+ try {
118
+ TestDao testDao = new TestDao ();
119
+ return getProjectUser (testDao .searchAll (testDto ).get (0 ).getProject_id ());
120
+ }catch (IndexOutOfBoundsException e ){
121
+ throw new AqualityException ("Cannot define project id" );
122
+ }
123
+ }
124
+
116
125
public ProjectUserDto getProjectUserByMilestoneId (Integer milestone_id ) throws AqualityException {
117
126
MilestoneDao milestoneDao = new MilestoneDao ();
118
127
MilestoneDto template = new MilestoneDto ();
@@ -126,4 +135,13 @@ public UserDto toPublic(){
126
135
this .setSession_code ("" );
127
136
return this ;
128
137
}
138
+
139
+ private ProjectUserDto getEmptyProjectUser (){
140
+ ProjectUserDto emptyPU = new ProjectUserDto ();
141
+ emptyPU .setViewer (0 );
142
+ emptyPU .setAdmin (0 );
143
+ emptyPU .setManager (0 );
144
+ emptyPU .setEngineer (0 );
145
+ return emptyPU ;
146
+ }
129
147
}
0 commit comments