-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows editing of experimental variables (#322)
Introduces editing functionality for experimental variables. Co-authored-by: Tobias Koch <[email protected]>
- Loading branch information
Showing
13 changed files
with
410 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
projectmanagement/src/main/java/life/qbic/projectmanagement/application/DeletionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package life.qbic.projectmanagement.application; | ||
|
||
import static java.util.Objects.*; | ||
|
||
import java.util.Objects; | ||
import life.qbic.application.commons.Result; | ||
import life.qbic.projectmanagement.application.sample.SampleInformationService; | ||
import life.qbic.projectmanagement.domain.project.experiment.ExperimentId; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* <b>Deletion Service</b> | ||
* | ||
* <p>Service that orchestrates deletion use cases in the application</p> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Service | ||
public class DeletionService { | ||
|
||
private final ExperimentInformationService experimentInformationService; | ||
|
||
private final SampleInformationService sampleInformationService; | ||
|
||
@Autowired | ||
public DeletionService(ExperimentInformationService experimentInformationService, | ||
SampleInformationService sampleInformationService) { | ||
this.experimentInformationService = requireNonNull(experimentInformationService, | ||
"experimentInformationService must not be null"); | ||
this.sampleInformationService = requireNonNull(sampleInformationService, | ||
"sampleInformationService must not be null"); | ||
} | ||
|
||
/** | ||
* Deletes all experiment variables and groups in a given experiment. | ||
* <p> | ||
* Will contain an error, if samples are available and attached to the experiment. In this case, | ||
* no variables and groups will be deleted. | ||
* | ||
* @param id the experiment id | ||
* @return a result containing the experiment id on success or an error {@link ResponseCode} | ||
* @since 1.0.0 | ||
*/ | ||
public Result<ExperimentId, ResponseCode> deleteAllExperimentalVariables(ExperimentId id) { | ||
var queryResult = sampleInformationService.retrieveSamplesForExperiment(id); | ||
if (queryResult.isError()) { | ||
return Result.fromError(ResponseCode.QUERY_FAILED); | ||
} | ||
if (queryResult.isValue() && queryResult.getValue().size() > 0) { | ||
return Result.fromError(ResponseCode.SAMPLES_STILL_ATTACHED_TO_EXPERIMENT); | ||
} | ||
experimentInformationService.deleteAllExperimentalVariables(id); | ||
return Result.fromValue(id); | ||
} | ||
|
||
public enum ResponseCode { | ||
SAMPLES_STILL_ATTACHED_TO_EXPERIMENT, QUERY_FAILED | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.