-
Notifications
You must be signed in to change notification settings - Fork 0
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
Show comments for NGS and ProteomicsMeasurements #962
Merged
sven1103
merged 4 commits into
development
from
feature/dm-938-proteomics-measurements-don't-show-comment
Jan 14, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ba17d92
Show comments for pooled and unpooled ProteomicsMeasurement and NGSMe…
Steffengreiner 40a6cf4
Merge branch 'development' into feature/dm-938-proteomics-measurement…
Steffengreiner 080421f
Merge branch 'development' into feature/dm-938-proteomics-measurement…
sven1103 05000b7
Remove elseThrows method and invert isPooledMeasurement Methods for p…
Steffengreiner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,10 +70,10 @@ | |
@PermitAll | ||
public class MeasurementDetailsComponent extends PageArea implements Serializable { | ||
|
||
public static final String CLICKABLE = "clickable"; | ||
@Serial | ||
private static final long serialVersionUID = 5086686432247130622L; | ||
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm"; | ||
public static final String CLICKABLE = "clickable"; | ||
private final TabSheet registeredMeasurementsTabSheet = new TabSheet(); | ||
private final MultiSelectLazyLoadingGrid<NGSMeasurement> ngsMeasurementGrid = new MultiSelectLazyLoadingGrid<>(); | ||
private final MultiSelectLazyLoadingGrid<ProteomicsMeasurement> proteomicsMeasurementGrid = new MultiSelectLazyLoadingGrid<>(); | ||
|
@@ -156,7 +156,7 @@ private void resetTabsInTabsheet() { | |
} | ||
|
||
private void addMeasurementTab(GridLazyDataView<?> gridLazyDataView) { | ||
if(gridLazyDataView.getItems().findAny().isEmpty()) { | ||
if (gridLazyDataView.getItems().findAny().isEmpty()) { | ||
return; | ||
} | ||
if (gridLazyDataView.getItem(0) instanceof ProteomicsMeasurement) { | ||
|
@@ -186,18 +186,18 @@ private void createNGSMeasurementGrid() { | |
.setAutoWidth(true) | ||
.setFlexGrow(0); | ||
ngsMeasurementGrid.addComponentColumn(measurement -> { | ||
if (measurement.samplePoolGroup().isEmpty()) { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
return new Span( | ||
String.join(" ", groupSampleInfoIntoCodeAndLabel(measurement.measuredSamples()))); | ||
} | ||
MeasurementPooledSamplesDialog measurementPooledSamplesDialog = new MeasurementPooledSamplesDialog( | ||
measurement); | ||
Icon expandIcon = VaadinIcon.EXPAND_SQUARE.create(); | ||
expandIcon.addClassName("expand-icon"); | ||
Span expandSpan = new Span(new Span("Pooled sample"), expandIcon); | ||
expandSpan.addClassNames("sample-column-cell", CLICKABLE); | ||
expandSpan.addClickListener(event -> measurementPooledSamplesDialog.open()); | ||
return expandSpan; | ||
return createNGSPooledSampleComponent(measurement); | ||
}) | ||
.setTooltipGenerator(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
return String.join(" ", groupSampleInfoIntoCodeAndLabel(measurement.measuredSamples())); | ||
} else { | ||
return ""; | ||
} | ||
}) | ||
.setHeader("Samples") | ||
.setAutoWidth(true); | ||
|
@@ -242,6 +242,28 @@ private void createNGSMeasurementGrid() { | |
ngsMeasurement -> asClientLocalDateTime(ngsMeasurement.registrationDate()) | ||
.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT))) | ||
.setAutoWidth(true); | ||
ngsMeasurementGrid.addComponentColumn(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
Span singularComment = new Span(); | ||
singularComment.setText( | ||
measurement.specificMeasurementMetadata().stream().findFirst().orElseThrow().comment() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what happens here. I also think, that we should handle the |
||
.orElse("")); | ||
return singularComment; | ||
} else { | ||
return createNGSPooledSampleComponent(measurement); | ||
} | ||
}) | ||
.setHeader("Comment") | ||
.setTooltipGenerator(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
return measurement.specificMeasurementMetadata().stream().findFirst().orElseThrow() | ||
.comment() | ||
.orElse(""); | ||
} else { | ||
return ""; | ||
} | ||
}) | ||
.setAutoWidth(true); | ||
GridLazyDataView<NGSMeasurement> ngsGridDataView = ngsMeasurementGrid.setItems(query -> { | ||
List<SortOrder> sortOrders = query.getSortOrders().stream().map( | ||
it -> new SortOrder(it.getSorted(), it.getDirection().equals(SortDirection.ASCENDING))) | ||
|
@@ -281,16 +303,15 @@ private void createProteomicsGrid() { | |
return new Span( | ||
String.join(" ", groupSampleInfoIntoCodeAndLabel(measurement.measuredSamples()))); | ||
} | ||
MeasurementPooledSamplesDialog measurementPooledSamplesDialog = new MeasurementPooledSamplesDialog( | ||
measurement); | ||
Icon expandIcon = VaadinIcon.EXPAND_SQUARE.create(); | ||
expandIcon.addClassName("expand-icon"); | ||
Span expandSpan = new Span(new Span("Pooled sample"), expandIcon); | ||
expandSpan.addClassNames("sample-column-cell", CLICKABLE); | ||
expandSpan.addClickListener(event -> measurementPooledSamplesDialog.open()); | ||
return expandSpan; | ||
return createProteomicsPooledSampleComponent(measurement); | ||
}) | ||
.setHeader("Samples") | ||
.setTooltipGenerator(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
return String.join(" ", groupSampleInfoIntoCodeAndLabel(measurement.measuredSamples())); | ||
} | ||
return ""; | ||
}) | ||
.setAutoWidth(true); | ||
proteomicsMeasurementGrid.addComponentColumn( | ||
proteomicsMeasurement -> renderOrganisation(proteomicsMeasurement.organisation())) | ||
|
@@ -339,21 +360,37 @@ private void createProteomicsGrid() { | |
.setTooltipGenerator(measurement -> asClientLocalDateTime(measurement.registrationDate()) | ||
.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT))) | ||
.setAutoWidth(true); | ||
proteomicsMeasurementGrid.addColumn(measurement -> measurement.comment().orElse("")) | ||
proteomicsMeasurementGrid.addComponentColumn(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
Span singularComment = new Span(); | ||
singularComment.setText( | ||
measurement.specificMetadata().stream().findFirst().orElseThrow().comment().orElse("")); | ||
return singularComment; | ||
} else { | ||
return createProteomicsPooledSampleComponent(measurement); | ||
} | ||
}) | ||
.setHeader("Comment") | ||
.setTooltipGenerator(measurement -> measurement.comment().orElse("")) | ||
.setTooltipGenerator(measurement -> { | ||
if (!measurement.isPooledSampleMeasurement()) { | ||
return measurement.specificMetadata().stream().findFirst().orElseThrow().comment() | ||
.orElse(""); | ||
} else { | ||
return ""; | ||
} | ||
}) | ||
.setAutoWidth(true); | ||
GridLazyDataView<ProteomicsMeasurement> proteomicsGridDataView = proteomicsMeasurementGrid.setItems( | ||
query -> { | ||
List<SortOrder> sortOrders = query.getSortOrders().stream().map( | ||
it -> new SortOrder(it.getSorted(), | ||
it.getDirection().equals(SortDirection.ASCENDING))) | ||
.collect(Collectors.toList()); | ||
sortOrders.add(SortOrder.of("measurementCode").ascending()); | ||
return measurementService.findProteomicsMeasurements(searchTerm, | ||
context.experimentId().orElseThrow(), | ||
query.getOffset(), query.getLimit(), sortOrders, context.projectId().orElseThrow()) | ||
.stream(); | ||
sortOrders.add(SortOrder.of("measurementCode").ascending()); | ||
return measurementService.findProteomicsMeasurements(searchTerm, | ||
context.experimentId().orElseThrow(), | ||
query.getOffset(), query.getLimit(), sortOrders, context.projectId().orElseThrow()) | ||
.stream(); | ||
|
||
}); | ||
proteomicsGridDataView | ||
|
@@ -365,6 +402,28 @@ private void createProteomicsGrid() { | |
measurementsGridDataViews.add(proteomicsGridDataView); | ||
} | ||
|
||
private Span createProteomicsPooledSampleComponent(ProteomicsMeasurement measurement) { | ||
MeasurementPooledSamplesDialog measurementPooledSamplesDialog = new MeasurementPooledSamplesDialog( | ||
measurement); | ||
Icon expandIcon = VaadinIcon.EXPAND_SQUARE.create(); | ||
expandIcon.addClassName("expand-icon"); | ||
Span expandSpan = new Span(new Span("Pooled sample"), expandIcon); | ||
expandSpan.addClassNames("sample-column-cell", CLICKABLE); | ||
expandSpan.addClickListener(event -> measurementPooledSamplesDialog.open()); | ||
return expandSpan; | ||
} | ||
|
||
private Span createNGSPooledSampleComponent(NGSMeasurement measurement) { | ||
MeasurementPooledSamplesDialog measurementPooledSamplesDialog = new MeasurementPooledSamplesDialog( | ||
measurement); | ||
Icon expandIcon = VaadinIcon.EXPAND_SQUARE.create(); | ||
expandIcon.addClassName("expand-icon"); | ||
Span expandSpan = new Span(new Span("Pooled sample"), expandIcon); | ||
expandSpan.addClassNames("sample-column-cell", CLICKABLE); | ||
expandSpan.addClickListener(event -> measurementPooledSamplesDialog.open()); | ||
return expandSpan; | ||
} | ||
|
||
private void updateSelectedMeasurementsInfo(boolean isFromClient) { | ||
listeners.forEach(listener -> listener.onComponentEvent( | ||
new MeasurementSelectionChangedEvent(this, isFromClient))); | ||
|
@@ -473,6 +532,54 @@ public MeasurementSelectionChangedEvent(MeasurementDetailsComponent source, | |
} | ||
} | ||
|
||
public static class MeasurementTechnologyTab extends Tab { | ||
|
||
private final Span countBadge; | ||
private final Span technologyNameComponent; | ||
private final String technology; | ||
|
||
public MeasurementTechnologyTab(String technology, int measurementCount) { | ||
this.technology = technology; | ||
technologyNameComponent = new Span(); | ||
this.countBadge = createBadge(); | ||
Span sampleCountComponent = new Span(); | ||
sampleCountComponent.add(countBadge); | ||
this.add(technologyNameComponent, sampleCountComponent); | ||
setTechnologyName(technology); | ||
setMeasurementCount(measurementCount); | ||
addClassName("tab-with-count"); | ||
} | ||
|
||
/** | ||
* Helper method for creating a badge. | ||
*/ | ||
private static Span createBadge() { | ||
Tag tag = new Tag(String.valueOf(0)); | ||
tag.setTagColor(TagColor.CONTRAST); | ||
return tag; | ||
} | ||
|
||
public String getTabLabel() { | ||
return technology; | ||
} | ||
|
||
/** | ||
* Setter method for specifying the number of measurements of the technology type shown in this | ||
* component | ||
* | ||
* @param measurementCount number of samples associated with the experiment shown in this | ||
* component | ||
*/ | ||
public void setMeasurementCount(int measurementCount) { | ||
countBadge.setText(String.valueOf(measurementCount)); | ||
} | ||
|
||
public void setTechnologyName(String technologyName) { | ||
this.technologyNameComponent.setText(technologyName); | ||
} | ||
|
||
} | ||
|
||
public class MeasurementPooledSamplesDialog extends Dialog { | ||
|
||
/** | ||
|
@@ -542,6 +649,10 @@ private void setPooledProteomicSampleDetails( | |
.setHeader("Measurement Label") | ||
.setTooltipGenerator(ProteomicsSpecificMeasurementMetadata::label) | ||
.setAutoWidth(true); | ||
sampleDetailsGrid.addColumn(metadata -> metadata.comment().orElse("")) | ||
.setHeader("comment") | ||
.setTooltipGenerator(metadata -> metadata.comment().orElse("")) | ||
.setAutoWidth(true); | ||
sampleDetailsGrid.setItems(proteomicsSpecificMeasurementMetadata); | ||
add(sampleDetailsGrid); | ||
} | ||
|
@@ -611,51 +722,4 @@ private Span pooledMeasurementEntry(String propertyLabel, String propertyValue) | |
} | ||
} | ||
|
||
public static class MeasurementTechnologyTab extends Tab { | ||
|
||
private final Span countBadge; | ||
private final Span technologyNameComponent; | ||
private final String technology; | ||
|
||
public MeasurementTechnologyTab(String technology, int measurementCount) { | ||
this.technology = technology; | ||
technologyNameComponent = new Span(); | ||
this.countBadge = createBadge(); | ||
Span sampleCountComponent = new Span(); | ||
sampleCountComponent.add(countBadge); | ||
this.add(technologyNameComponent, sampleCountComponent); | ||
setTechnologyName(technology); | ||
setMeasurementCount(measurementCount); | ||
addClassName("tab-with-count"); | ||
} | ||
|
||
public String getTabLabel() { | ||
return technology; | ||
} | ||
|
||
/** | ||
* Helper method for creating a badge. | ||
*/ | ||
private static Span createBadge() { | ||
Tag tag = new Tag(String.valueOf(0)); | ||
tag.setTagColor(TagColor.CONTRAST); | ||
return tag; | ||
} | ||
|
||
/** | ||
* Setter method for specifying the number of measurements of the technology type shown in | ||
* this component | ||
* | ||
* @param measurementCount number of samples associated with the experiment shown in this component | ||
*/ | ||
public void setMeasurementCount(int measurementCount) { | ||
countBadge.setText(String.valueOf(measurementCount)); | ||
} | ||
|
||
public void setTechnologyName(String technologyName) { | ||
this.technologyNameComponent.setText(technologyName); | ||
} | ||
|
||
} | ||
|
||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negations are harder to read and understand, especially that "!" is not part our natural language. I suggest to include a method like
isSingleSampleMeasurement()
to reflect the positive case you are looking for.