Skip to content

Commit

Permalink
Merge branch 'fix/add-filter-functionality-in-sample-overview-grid' of
Browse files Browse the repository at this point in the history
…https://github.com/qbicsoftware/data-manager-app into fix/add-filter-functionality-in-sample-overview-grid
  • Loading branch information
Steffengreiner committed Jul 13, 2023
2 parents f13d5e5 + 13f3503 commit 30372f1
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class SamplePreview {
private String bioReplicateLabel;
@Column(name = "label")
private String sampleLabel;
private String comment;
@Column(name = "analysis_type")
private String analysisType;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "experimentalGroupId")
private ExperimentalGroup experimentalGroup;
Expand All @@ -58,7 +61,7 @@ protected SamplePreview() {
private SamplePreview(ExperimentId experimentId, SampleId sampleId, String sampleCode,
String batchLabel, String bioReplicateLabel,
String sampleLabel, ExperimentalGroup experimentalGroup, String species, String specimen,
String analyte) {
String analyte, String analysisType, String comment) {
Objects.requireNonNull(experimentId);
Objects.requireNonNull(sampleId);
Objects.requireNonNull(sampleCode);
Expand All @@ -79,6 +82,9 @@ private SamplePreview(ExperimentId experimentId, SampleId sampleId, String sampl
this.species = species;
this.specimen = specimen;
this.analyte = analyte;
// optional columns
this.comment = comment;
this.analysisType = analysisType;
}

/**
Expand All @@ -100,15 +106,17 @@ private SamplePreview(ExperimentId experimentId, SampleId sampleId, String sampl
* preview
* @param analyte the {@link Analyte} for the {@link Sample} associated with this
* preview
* @param analysisType the type of analysis to be performed for this {@link Sample}
* @param comment an optional comment pertaining to the associated {@link Sample}
* @return the sample preview
*/
public static SamplePreview create(ExperimentId experimentId, SampleId sampleId,
String sampleCode,
String batchLabel, String bioReplicateLabel,
String sampleLabel, ExperimentalGroup experimentalGroup, String species, String specimen,
String analyte) {
String analyte, String analysisType, String comment) {
return new SamplePreview(experimentId, sampleId, sampleCode, batchLabel, bioReplicateLabel,
sampleLabel, experimentalGroup, species, specimen, analyte);
sampleLabel, experimentalGroup, species, specimen, analyte, analysisType, comment);
}

public ExperimentId experimentId() {
Expand Down Expand Up @@ -146,6 +154,12 @@ public String specimen() {
public String analyte() {
return analyte;
}
public String analysisType() {
return analysisType;
}
public String comment() {
return comment;
}

public ExperimentalGroup experimentalGroup() {
return experimentalGroup;
Expand All @@ -167,14 +181,15 @@ public boolean equals(Object o) {
that.sampleLabel)
&& Objects.equals(species, that.species) && Objects.equals(specimen,
that.specimen) && Objects.equals(analyte, that.analyte) && Objects.equals(
experimentalGroup, that.experimentalGroup);
experimentalGroup, that.experimentalGroup) && Objects.equals(analysisType,
that.analysisType) && Objects.equals(comment, that.comment);
}

@Override
public int hashCode() {
return Objects.hash(experimentId, sampleCode, sampleId, batchLabel, bioReplicateLabel,
sampleLabel,
species, specimen, analyte, experimentalGroup);
species, specimen, analyte, experimentalGroup, analysisType, comment);
}

@Override
Expand All @@ -189,6 +204,8 @@ public String toString() {
", species='" + species + '\'' +
", specimen='" + specimen + '\'' +
", analyte='" + analyte + '\'' +
", analysisType='" + analysisType + '\'' +
", comment='" + comment + '\'' +
", conditions=" + experimentalGroup +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import java.util.Objects;
import java.util.Optional;
import life.qbic.projectmanagement.domain.project.experiment.BiologicalReplicateId;
import life.qbic.projectmanagement.domain.project.experiment.ExperimentId;

Expand Down Expand Up @@ -37,14 +38,17 @@ public class Sample {
@AttributeOverride(name = "uuid", column = @Column(name = "sample_id"))
private SampleId id;
private String label;
private String comment;
@Column(name = "analysis_type")
private String analysisType;
@Embedded
private SampleCode sampleCode;
@Embedded
private SampleOrigin sampleOrigin;

private Sample(SampleId id, SampleCode sampleCode, BatchId assignedBatch, String label,
ExperimentId experimentId, Long experimentalGroupId, SampleOrigin sampleOrigin,
BiologicalReplicateId replicateReference
BiologicalReplicateId replicateReference, String analysisType, String comment
) {
this.id = id;
this.sampleCode = Objects.requireNonNull(sampleCode);
Expand All @@ -54,6 +58,8 @@ private Sample(SampleId id, SampleCode sampleCode, BatchId assignedBatch, String
this.sampleOrigin = sampleOrigin;
this.biologicalReplicateId = replicateReference;
this.assignedBatch = assignedBatch;
this.analysisType = analysisType;
this.comment = comment;
}

protected Sample() {
Expand All @@ -75,7 +81,8 @@ public static Sample create(
sampleRegistrationRequest.assignedBatch(),
sampleRegistrationRequest.label(), sampleRegistrationRequest.experimentId(),
sampleRegistrationRequest.experimentalGroupId(),
sampleRegistrationRequest.sampleOrigin(), sampleRegistrationRequest.replicateReference());
sampleRegistrationRequest.sampleOrigin(), sampleRegistrationRequest.replicateReference(),
sampleRegistrationRequest.analysisType(), sampleRegistrationRequest.comment());
}

public BatchId assignedBatch() {
Expand All @@ -98,6 +105,14 @@ public String label() {
return this.label;
}

public Optional<String> analysisType() {
return Optional.ofNullable(analysisType);
}

public Optional<String> comment() {
return Optional.ofNullable(comment);
}

public Long experimentalGroupId() {
return this.experimentalGroupId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.qbic.projectmanagement.domain.project.sample;

import java.util.Objects;
import java.util.Optional;
import life.qbic.projectmanagement.domain.project.experiment.BiologicalReplicateId;
import life.qbic.projectmanagement.domain.project.experiment.ExperimentId;

Expand All @@ -15,21 +16,26 @@
* @param experimentalGroupId the experimental group id the sample is part of
* @param replicateReference the biological replicated reference the sample has been taken from
* @param sampleOrigin information about the sample origin.
* @param analysisType analysis to be performed
* @param comment comment relating to the sample
* @since 1.0.0
*/
public record SampleRegistrationRequest(String label, BatchId assignedBatch,
ExperimentId experimentId, Long experimentalGroupId,
BiologicalReplicateId replicateReference,
SampleOrigin sampleOrigin) {
SampleOrigin sampleOrigin, String analysisType, String comment) {

public SampleRegistrationRequest(String label, BatchId assignedBatch, ExperimentId experimentId,
Long experimentalGroupId, BiologicalReplicateId replicateReference,
SampleOrigin sampleOrigin) {
SampleOrigin sampleOrigin, String analysisType, String comment) {
this.label = Objects.requireNonNull(label);
this.assignedBatch = Objects.requireNonNull(assignedBatch);
this.experimentId = Objects.requireNonNull(experimentId);
this.experimentalGroupId = Objects.requireNonNull(experimentalGroupId);
this.replicateReference = Objects.requireNonNull(replicateReference);
this.sampleOrigin = Objects.requireNonNull(sampleOrigin);
this.comment = comment;
this.analysisType = analysisType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SampleRegistrationServiceSpec extends Specification {
def "Invalid SampleRegistrationRequests returns a Result containing a SAMPLE_REGISTRATION_FAILED response code"() {
given:
SampleOrigin sampleOrigin = SampleOrigin.create(new Species("species"), new Specimen("specimen"), new Analyte("analyte"))
SampleRegistrationRequest sampleRegistrationRequest = new SampleRegistrationRequest("my_label", BatchId.create(), ExperimentId.create(), 5, BiologicalReplicateId.create(), sampleOrigin)
SampleRegistrationRequest sampleRegistrationRequest = new SampleRegistrationRequest("my_label", BatchId.create(), ExperimentId.create(), 5, BiologicalReplicateId.create(), sampleOrigin, "mytype", "no comment")
SampleCode sampleCode = SampleCode.create("QABCDE")
sampleCodeService.generateFor(projectId) >> Result.fromValue(sampleCode)
Map<SampleCode, SampleRegistrationRequest> sampleCodesToRegistrationRequests = new HashMap<>()
Expand All @@ -53,7 +53,7 @@ class SampleRegistrationServiceSpec extends Specification {
def "Valid SampleRegistrationRequests returns a Result with the list of registered Samples"() {
given:
SampleOrigin sampleOrigin = SampleOrigin.create(new Species("species"), new Specimen("specimen"), new Analyte("analyte"))
SampleRegistrationRequest sampleRegistrationRequest = new SampleRegistrationRequest("my_label", BatchId.create(), ExperimentId.create(), 4, BiologicalReplicateId.create(), sampleOrigin)
SampleRegistrationRequest sampleRegistrationRequest = new SampleRegistrationRequest("my_label", BatchId.create(), ExperimentId.create(), 4, BiologicalReplicateId.create(), sampleOrigin, "this analysis type", "a comment")
SampleCode sampleCode = SampleCode.create("QABCDE")
Sample sample = Sample.create(sampleCode, sampleRegistrationRequest)
sampleCodeService.generateFor(projectId) >> Result.fromValue(sampleCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SampleDomainServiceSpec extends Specification {

def "When a sample has been successfully registered, a sample registered event is dispatched"() {
given:
Sample testSample = Sample.create(SampleCode.create("test"), new SampleRegistrationRequest("test sample", BatchId.create(), ExperimentId.create(), 1L, BiologicalReplicateId.create(), new SampleOrigin(new Species("test"), new Specimen("test"), new Analyte("test"))))
Sample testSample = Sample.create(SampleCode.create("test"), new SampleRegistrationRequest("test sample", BatchId.create(), ExperimentId.create(), 1L, BiologicalReplicateId.create(), new SampleOrigin(new Species("test"), new Specimen("test"), new Analyte("test")), "DNA analysis", ""))

and:
SampleRepository testRepo = Mock(SampleRepository)
Expand Down Expand Up @@ -54,7 +54,7 @@ class SampleDomainServiceSpec extends Specification {

when:
Result<Sample, SampleDomainService.ResponseCode> result = sampleDomainService.registerSample(SampleCode.create("test"),
new SampleRegistrationRequest("test sample", BatchId.create(), ExperimentId.create(), 1L, BiologicalReplicateId.create(), new SampleOrigin(new Species("test"), new Specimen("test"), new Analyte("test"))))
new SampleRegistrationRequest("test sample", BatchId.create(), ExperimentId.create(), 1L, BiologicalReplicateId.create(), new SampleOrigin(new Species("test"), new Specimen("test"), new Analyte("test")), "DNA analysis", ""))

then:
sampleRegistered.batchIdOfEvent.equals(result.getValue().assignedBatch())
Expand Down
16 changes: 14 additions & 2 deletions vaadinfrontend/frontend/themes/datamanager/components/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
}

.main.experiment {
grid-template-columns: minmax(250px, 0.8fr) minmax(250px, 0.2fr);
grid-template-rows: minmax(150px, 0.1fr) minmax(250px, 1fr);
grid-template-columns: minmax(600px, 80%) minmax(300px, 20%);
grid-template-rows: minmax(150px, 10%) minmax(250px, 100%);
grid-template-areas:
"navbar support"
"content support";
Expand All @@ -26,3 +26,15 @@
.main.project {
flex-direction: column;
}

/*Large devices (large desktops, 1200px and up)*/
@media only screen and (max-width: 1200px) {
.main.experiment {
grid-template-columns: minmax(1200px, 1fr);
grid-template-areas:
"navbar"
"content"
"support";
grid-auto-rows: auto;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package life.qbic.datamanager;

import java.time.ZoneId;
import life.qbic.authentication.application.notification.NotificationService;
import life.qbic.authentication.application.user.password.NewPassword;
import life.qbic.authentication.application.user.password.NewPasswordInput;
Expand All @@ -14,11 +13,8 @@
import life.qbic.authentication.domain.user.repository.UserRepository;
import life.qbic.broadcasting.Exchange;
import life.qbic.broadcasting.MessageBusSubmission;
import life.qbic.datamanager.ClientDetailsProvider.ClientDetails;
import life.qbic.datamanager.views.projects.overview.components.ProjectCollection;
import life.qbic.domain.concepts.SimpleEventStore;
import life.qbic.domain.concepts.TemporaryEventRepository;
import life.qbic.projectmanagement.application.ProjectInformationService;
import life.qbic.projectmanagement.application.api.SampleCodeService;
import life.qbic.projectmanagement.application.batch.BatchRegistrationService;
import life.qbic.projectmanagement.application.policy.ProjectRegisteredPolicy;
Expand All @@ -30,8 +26,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.SessionScope;

/**
* <b>App bean configuration class</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import life.qbic.datamanager.views.notifications.SuccessMessage;
import life.qbic.datamanager.views.projects.create.ProjectDraft;
import life.qbic.datamanager.views.projects.create.AddProjectDialog;
import life.qbic.datamanager.views.projects.overview.components.ProjectCollection;
import life.qbic.datamanager.views.projects.overview.components.ProjectCollectionComponent;
import life.qbic.projectmanagement.application.ProjectRegistrationService;
import life.qbic.projectmanagement.domain.project.Project;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -32,14 +32,14 @@ public class ProjectOverviewPage extends Div {
@Serial
private static final long serialVersionUID = 4625607082710157069L;

private final ProjectCollection projectCollection;
private final ProjectCollectionComponent projectCollectionComponent;
private final AddProjectDialog addProjectDialog;
private final ProjectRegistrationService projectRegistrationService;

public ProjectOverviewPage(@Autowired ProjectCollection projectCollection,
public ProjectOverviewPage(@Autowired ProjectCollectionComponent projectCollectionComponent,
AddProjectDialog addProjectDialog,
ProjectRegistrationService projectRegistrationService) {
this.projectCollection = projectCollection;
this.projectCollectionComponent = projectCollectionComponent;
this.addProjectDialog = addProjectDialog;
this.projectRegistrationService = projectRegistrationService;
layoutPage();
Expand All @@ -49,11 +49,11 @@ public ProjectOverviewPage(@Autowired ProjectCollection projectCollection,
}

private void layoutPage() {
add(projectCollection);
add(projectCollectionComponent);
}

private void configurePage() {
projectCollection.addListener(projectCreationClickedEvent ->
projectCollectionComponent.addListener(projectCreationClickedEvent ->
addProjectDialog.open()
);
addProjectDialog.addCancelEventListener(projectCreationDialogUserCancelEvent ->
Expand Down Expand Up @@ -82,7 +82,7 @@ private void createProject(ProjectDraft projectCreationContent) {
.onValue(result -> {
displaySuccessfulProjectCreationNotification();
addProjectDialog.resetAndClose();
projectCollection.refresh();
projectCollectionComponent.refresh();
})
.onError(e -> {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*
* @since 1.0.0
*/
public class ProjectAddSubmitEvent extends ComponentEvent<ProjectCollection> {
public class ProjectAddSubmitEvent extends ComponentEvent<ProjectCollectionComponent> {

@Serial
private static final long serialVersionUID = 28673255958404464L;

public ProjectAddSubmitEvent(ProjectCollection source, boolean fromClient) {
public ProjectAddSubmitEvent(ProjectCollectionComponent source, boolean fromClient) {
super(source, fromClient);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
@SpringComponent
@UIScope
public class ProjectCollection extends PageArea {
public class ProjectCollectionComponent extends PageArea {

private Div controlSection = new Div();
private Div gridSection = new Div();
Expand All @@ -62,8 +62,8 @@ public class ProjectCollection extends PageArea {
private final List<ComponentEventListener<ProjectAddSubmitEvent>> projectCreationClickedListeners = new ArrayList<>();

@Autowired
public ProjectCollection(ClientDetailsProvider clientDetailsProvider,
ProjectInformationService projectInformationService) {
public ProjectCollectionComponent(ClientDetailsProvider clientDetailsProvider,
ProjectInformationService projectInformationService) {
this.title = "Projects";
this.clientDetailsProvider = clientDetailsProvider;
this.projectInformationService = projectInformationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void addExperimentalGroupSubmitListener(

public AddExperimentalGroupsDialog() {
super();
setConfirmButtonLabel("Create");
setConfirmButtonLabel("Add");
setCancelButtonLabel("Cancel");
addClassName("experiment-group-dialog");
setHeaderTitle("Please enter group information");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ExperimentCreationDialog(ExperimentalDesignSearchService experimentalDesi
experimentCreationDialogHandler = new ExperimentCreationDialogHandler();
setHeaderTitle(TITLE);
add(defineExperimentComponent);
setConfirmButtonLabel("Create");
setConfirmButtonLabel("Add");
setCancelButtonLabel("Cancel");
getFooter().add(cancelButton, confirmButton);
}
Expand Down
Loading

0 comments on commit 30372f1

Please sign in to comment.