Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for confounding variables #877

Draft
wants to merge 32 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c6cc4fd
add todo to open PR
KochTobi Oct 30, 2024
13e9651
add mermaid plot
KochTobi Nov 4, 2024
4178a4f
change to identifier
KochTobi Nov 4, 2024
784327d
add sequence diagrams
KochTobi Nov 4, 2024
57029c3
update sql scripts
KochTobi Nov 6, 2024
bc1f9df
Pass schema validation
KochTobi Nov 6, 2024
8d06b5b
Fix order of statements
KochTobi Nov 6, 2024
ca4e8c6
do not allow null values for measurement counts
KochTobi Nov 6, 2024
ecba811
refine diagram
KochTobi Nov 6, 2024
458c459
update sql so it only creates missing tables
KochTobi Nov 6, 2024
294b2e3
minimal example
KochTobi Nov 12, 2024
7477a5a
add javadoc
KochTobi Nov 13, 2024
98b6a1c
wip
KochTobi Nov 18, 2024
36d4e4b
add confounding variables to templates
KochTobi Nov 19, 2024
66f28da
move the `@Transactional` aspect to the implementing class
KochTobi Nov 25, 2024
8979218
wip
KochTobi Nov 26, 2024
ec74ed7
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Nov 26, 2024
aaba171
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Nov 27, 2024
f26fa2d
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Nov 28, 2024
a532a67
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Nov 29, 2024
559859d
wip
KochTobi Dec 4, 2024
e510f90
wip
KochTobi Dec 9, 2024
48b5f1c
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Dec 10, 2024
5aa1341
Fix file size formatting
KochTobi Dec 11, 2024
d7f0b89
Fix connection testing for openbis
KochTobi Dec 11, 2024
8bf584d
Add equals and hash code to Sample.java object
KochTobi Dec 11, 2024
e691014
implement the update case for confounding variables
KochTobi Dec 13, 2024
43ad0d5
Implement sample/batch deletion
KochTobi Dec 17, 2024
dc77c3e
extract methods for measurement and sample creation in openbis
KochTobi Dec 17, 2024
b5d2a49
Merge branch 'development' into feature-642/#642-editing-registered-m…
KochTobi Jan 7, 2025
2e396d0
Fix merge breaks
KochTobi Jan 7, 2025
9f090d0
fix test
KochTobi Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/processes/project-lifecycles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#bla

blubb

```mermaid
flowchart TB
start((Start))
cproject["Service call for create project"]
cprojectDB["Create the project in the data base"]
cprojectOpBis["Create the project in OpenBIS"]
start --> cproject
cproject --> cprojectDB
cprojectDB --> cprojectOpBis
cprojectOpBis -- rollback -->cprojectDB

cprojectDB -- rollback --> start
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
import life.qbic.projectmanagement.domain.model.sample.Sample;
import life.qbic.projectmanagement.domain.repository.BatchRepository;
import life.qbic.projectmanagement.infrastructure.sample.QbicSampleRepository;
import life.qbic.projectmanagement.infrastructure.sample.SampleJpaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

Expand All @@ -31,11 +31,11 @@ public class BatchJpaRepository implements BatchRepository {
private static final Logger log = logger(BatchJpaRepository.class);

private final QbicBatchRepo qbicBatchRepo;
private final QbicSampleRepository qbicSampleRepository;
private final SampleJpaRepository qbicSampleRepository;

@Autowired
public BatchJpaRepository(QbicBatchRepo qbicBatchRepo,
QbicSampleRepository qbicSampleRepository) {
SampleJpaRepository qbicSampleRepository) {
this.qbicBatchRepo = qbicBatchRepo;
this.qbicSampleRepository = qbicSampleRepository;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package life.qbic.projectmanagement.infrastructure.confounding;

import java.util.Collection;
import java.util.List;
import life.qbic.projectmanagement.domain.model.confounding.jpa.ConfoundingVariableData;
import org.springframework.data.repository.ListCrudRepository;

public interface ConfoundingVariableJpaRepository extends
ListCrudRepository<ConfoundingVariableData, Long> {

long countByExperimentIdEquals(String experimentId);

List<ConfoundingVariableData> findAllByExperimentIdEquals(String experimentId);

boolean existsDistinctByIdIsIn(Collection<Long> ids);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package life.qbic.projectmanagement.infrastructure.confounding;

import java.util.List;
import java.util.Optional;
import life.qbic.projectmanagement.domain.model.confounding.jpa.ConfoundingVariableLevelData;
import org.springframework.data.repository.ListCrudRepository;

public interface ConfoundingVariableLevelJpaRepository extends
ListCrudRepository<ConfoundingVariableLevelData, Long> {

List<ConfoundingVariableLevelData> findAllBySampleIdEquals(String sampleId);

List<ConfoundingVariableLevelData> findAllByVariableIdEquals(long variableId);

List<ConfoundingVariableLevelData> findAllByVariableIdIn(List<Long> variableIds);

Optional<ConfoundingVariableLevelData> findBySampleIdEqualsAndVariableIdEquals(String sampleId,
long variableId);

long countByVariableIdEquals(long variableId);

void deleteAllByVariableIdEquals(long variableId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package life.qbic.projectmanagement.infrastructure.confounding;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import life.qbic.projectmanagement.domain.model.confounding.jpa.ConfoundingVariableLevelData;
import life.qbic.projectmanagement.domain.repository.ConfoundingVariableLevelRepository;
import org.springframework.stereotype.Repository;

/**
* The implementation of the {@link ConfoundingVariableLevelRepository} interface.
* Delegates method calls to the corresponding JPA repositories.
* @since 1.6.0
*/
@Repository
public class ConfoundingVariableLevelRepositoryImpl implements ConfoundingVariableLevelRepository {

private final ConfoundingVariableLevelJpaRepository jpaRepository;

public ConfoundingVariableLevelRepositoryImpl(
ConfoundingVariableLevelJpaRepository jpaRepository) {
this.jpaRepository = jpaRepository;
}

@Override
public List<ConfoundingVariableLevelData> findAllForSample(String projectId, String sampleId) {
return jpaRepository.findAllBySampleIdEquals(sampleId);
}

@Override
public List<ConfoundingVariableLevelData> findAllForVariable(String projectId,
long variableId) {
return jpaRepository.findAllByVariableIdEquals(variableId);
}


@Override
public List<ConfoundingVariableLevelData> findAllForVariables(String projectId,
List<Long> variableIds) {
return jpaRepository.findAllByVariableIdIn(variableIds);
}

@Override
public Optional<ConfoundingVariableLevelData> findVariableLevelOfSample(String projectId,
String sampleId, long variableId) {
return jpaRepository.findBySampleIdEqualsAndVariableIdEquals(sampleId, variableId);
}


@Override
public <S extends ConfoundingVariableLevelData> S save(String projectId, S entity) {
return jpaRepository.save(entity);
}

@Override
public Optional<ConfoundingVariableLevelData> findById(String projectId, Long aLong) {
return jpaRepository.findById(aLong);
}

@Override
public long countLevelsOfVariable(String projectId, long variableId) {
return jpaRepository.countByVariableIdEquals(variableId);
}

@Override
public void deleteById(String projectId, Long aLong) {
jpaRepository.deleteById(aLong);
}

@Override
public void deleteAllForSample(String projectId, String sampleId) {
List<ConfoundingVariableLevelData> allBySampleIdEquals = jpaRepository.findAllBySampleIdEquals(
sampleId);
Set<Long> levelIds = allBySampleIdEquals.stream().map(ConfoundingVariableLevelData::getId)
.collect(Collectors.toSet());
jpaRepository.deleteAllById(levelIds);
}

@Override
public void deleteAllForVariable(String projectId, long variableId) {
jpaRepository.deleteAllByVariableIdEquals(variableId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package life.qbic.projectmanagement.infrastructure.confounding;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import life.qbic.projectmanagement.domain.model.confounding.jpa.ConfoundingVariableData;
import life.qbic.projectmanagement.domain.repository.ConfoundingVariableRepository;
import org.springframework.stereotype.Repository;

/**
* The implementation of the {@link ConfoundingVariableRepository} interface.
* Delegates method calls to the corresponding JPA repositories.
* @since 1.6.0
*/
@Repository
public class ConfoundingVariableRepositoryImpl implements ConfoundingVariableRepository {

private final ConfoundingVariableJpaRepository jpaRepository;

public ConfoundingVariableRepositoryImpl(ConfoundingVariableJpaRepository jpaRepository) {
this.jpaRepository = jpaRepository;
}

@Override
public <S extends ConfoundingVariableData> List<S> saveAll(String projectId,
Iterable<S> entities) {
return jpaRepository.saveAll(entities);
}

@Override
public List<ConfoundingVariableData> findAll(String projectId, String experimentId) {
return jpaRepository.findAllByExperimentIdEquals(experimentId);
}

@Override
public List<ConfoundingVariableData> findAllById(String projectId, Iterable<Long> longs) {
return jpaRepository.findAllById(longs);
}

@Override
public boolean existsAllById(String projectId, Collection<Long> longs) {
return jpaRepository.existsDistinctByIdIsIn(longs);
}

@Override
public <S extends ConfoundingVariableData> S save(String projectId, S entity) {
return jpaRepository.save(entity);
}

@Override
public Optional<ConfoundingVariableData> findById(String projectId, Long aLong) {
return jpaRepository.findById(aLong);
}

@Override
public long countVariablesOfExperiment(String projectId, String experimentId) {
return jpaRepository.countByExperimentIdEquals(experimentId);
}

@Override
public void deleteById(String projectId, Long aLong) {
jpaRepository.deleteById(aLong);
}

@Override
public void deleteAllById(String projectId, Iterable<Long> longs) {
jpaRepository.deleteAllById(longs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @since 1.0.0
*/
public interface QbicSampleDataRepo {
public interface SampleDataRepository {

/**
* Creates a reference to one or more {@link Sample}s in the data repository to connect project data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import life.qbic.projectmanagement.domain.model.sample.SampleId;
import org.springframework.data.jpa.repository.JpaRepository;

public interface QbicSampleRepository extends JpaRepository<Sample, SampleId> {
public interface SampleJpaRepository extends JpaRepository<Sample, SampleId> {

Collection<Sample> findAllByExperimentId(ExperimentId experimentId);

Expand Down
Loading
Loading