11
11
import life .qbic .logging .api .Logger ;
12
12
import life .qbic .projectmanagement .domain .project .ExperimentalDesignDescription ;
13
13
import life .qbic .projectmanagement .domain .project .OfferIdentifier ;
14
+ import life .qbic .projectmanagement .domain .project .PersonReference ;
14
15
import life .qbic .projectmanagement .domain .project .Project ;
15
16
import life .qbic .projectmanagement .domain .project .ProjectCode ;
16
17
import life .qbic .projectmanagement .domain .project .ProjectIntent ;
@@ -41,13 +42,16 @@ public ProjectCreationService(ProjectRepository projectRepository) {
41
42
* @return the created project
42
43
*/
43
44
public Result <Project , ApplicationException > createProject (String title , String objective ,
44
- String experimentalDesign , String sourceOffer ) {
45
+ String experimentalDesign , String sourceOffer , PersonReference projectManager ,
46
+ PersonReference principalInvestigator ) {
45
47
try {
46
48
Project project ;
47
49
if (Objects .isNull (experimentalDesign ) || experimentalDesign .isEmpty ()) {
48
- project = createProjectWithoutExperimentalDesign (title , objective );
50
+ project = createProjectWithoutExperimentalDesign (title , objective , projectManager ,
51
+ principalInvestigator );
49
52
} else {
50
- project = createProjectWithExperimentalDesign (title , objective , experimentalDesign );
53
+ project = createProjectWithExperimentalDesign (title , objective , experimentalDesign ,
54
+ projectManager , principalInvestigator );
51
55
}
52
56
Optional .ofNullable (sourceOffer )
53
57
.flatMap (it -> it .isBlank () ? Optional .empty () : Optional .of (it ))
@@ -72,14 +76,17 @@ private ProjectCode createRandomCode() {
72
76
return code ;
73
77
}
74
78
75
- private Project createProjectWithoutExperimentalDesign (String title , String objective ) {
79
+ private Project createProjectWithoutExperimentalDesign (String title , String objective ,
80
+ PersonReference projectManager ,
81
+ PersonReference principalInvestigator ) {
76
82
ProjectIntent intent = getProjectIntent (title , objective );
77
- return Project .create (intent , createRandomCode ());
83
+ return Project .create (intent , createRandomCode (), projectManager , principalInvestigator );
78
84
}
79
85
80
86
private Project createProjectWithExperimentalDesign (String title ,
81
87
String objective ,
82
- String experimentalDesign ) {
88
+ String experimentalDesign , PersonReference projectManager ,
89
+ PersonReference principalInvestigator ) {
83
90
84
91
ExperimentalDesignDescription experimentalDesignDescription ;
85
92
try {
@@ -91,13 +98,13 @@ private Project createProjectWithExperimentalDesign(String title,
91
98
}
92
99
93
100
ProjectIntent intent = getProjectIntent (title , objective ).with (experimentalDesignDescription );
94
- return Project .create (intent , createRandomCode ());
101
+ return Project .create (intent , createRandomCode (), projectManager , principalInvestigator );
95
102
}
96
103
97
104
private static ProjectIntent getProjectIntent (String title , String objective ) {
98
105
ProjectTitle projectTitle ;
99
106
try {
100
- projectTitle = ProjectTitle .create (title );
107
+ projectTitle = ProjectTitle .of (title );
101
108
} catch (RuntimeException e ) {
102
109
log .error (e .getMessage (), e );
103
110
throw new ProjectManagementException (ErrorCode .INVALID_PROJECT_TITLE ,
0 commit comments