Skip to content

Commit

Permalink
Merge branch 'development' into feature-642/#642-editing-registered-m…
Browse files Browse the repository at this point in the history
…etadata-to-add-confounding-variables
  • Loading branch information
KochTobi committed Jan 22, 2025
2 parents aad7966 + 756c23d commit c97bf21
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private static void evaluateMandatoryMetadata(NGSMethodMetadata method)
}

/**
* Creates a new pooled {@link NGSMeasurement} object instance, that describes an NGS measurement entity
* with many describing properties about provenance and instrumentation.
* Creates a new pooled {@link NGSMeasurement} object instance, that describes an NGS measurement
* entity with many describing properties about provenance and instrumentation.
*
* @param projectId the project id the measurement belongs to
* @param samplePool the sample pool label the measurement represents
Expand Down Expand Up @@ -201,6 +201,17 @@ public void updateMethod(NGSMethodMetadata methodMetadata) {
setMethod(methodMetadata);
}

/**
* Convenience method to query if the measurement was derived from a single sample.
*
* @return true, if the measurement was performed on a single sample, else returns false if the
* measurement was derived from pooled samples
* @since 1.0.0
*/
public boolean isSingleSampleMeasurement() {
return specificMetadata.size() <= 1;
}


public MeasurementCode measurementCode() {
return this.measurementCode;
Expand All @@ -209,6 +220,7 @@ public MeasurementCode measurementCode() {
public MeasurementId measurementId() {
return measurementId;
}

public ProjectId projectId() {
return projectId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,14 @@ public void addSpecificMetadata(ProteomicsSpecificMeasurementMetadata specificMe
}

/**
* Convenience method to query if the measurement was derived from a pooled sample.
* Convenience method to query if the measurement was derived from a single Sample.
*
* @return true, if the measurement was performed on a pooled sample, else returns false
* @return true, if the measurement was performed on a single Sample, else returns false if the
* measurement was derived from pooled samples
* @since 1.0.0
*/
public boolean isPooledSampleMeasurement() {
return specificMetadata.size() > 1;
public boolean isSingleSampleMeasurement() {
return specificMetadata.size() <= 1;
}

public MeasurementCode measurementCode() {
Expand Down Expand Up @@ -253,7 +254,7 @@ public String lcmsMethod() {
public Instant registrationDate() {
return registration;
}

public void updateMethod(ProteomicsMethodMetadata method) {
setMethodMetadata(method);
emitUpdatedEvent();
Expand Down Expand Up @@ -320,10 +321,6 @@ public int hashCode() {
return measurementId != null ? measurementId.hashCode() : 0;
}

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

public Optional<String> technicalReplicateName() {
return Optional.ofNullable(technicalReplicateName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import java.util.Objects;
import java.util.Optional;
import life.qbic.projectmanagement.domain.model.sample.SampleId;

/**
Expand Down Expand Up @@ -80,8 +81,8 @@ public String fractionName() {
return fractionName;
}

public String comment() {
return comment;
public Optional<String> comment() {
return comment.isBlank() ? Optional.empty() : Optional.of(comment);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public byte[] getContent() {
}

var startIndex = 1; // start in row number 2 with index 1 as the header row has number 1 index 0
var helperStopIndex = 1; //stop in row number 2 with index 1 as the header row has number 1 index 0
int rowIndex = startIndex;
for (NGSMeasurementEntry measurement : measurements) {
Row row = getOrCreateRow(sheet, rowIndex);
Expand Down Expand Up @@ -195,7 +196,7 @@ public byte[] getContent() {
column.columnIndex(),
startIndex,
column.columnIndex(),
DEFAULT_GENERATED_ROW_COUNT - 1,
helperStopIndex,
helper.exampleValue(),
helper.description())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public byte[] getContent() {
}

var startIndex = 1; // start in row number 2 with index 1 as the header row has number 1 index 0
var helperStopIndex = 1; //stop in row number 2 with index 1 as the header row has number 1 index 0
// make sure to create the visible sheet first
Sheet hiddenSheet = workbook.createSheet("hidden");
Name sequencingReadTypeArea = createOptionArea(hiddenSheet,
Expand All @@ -128,7 +129,7 @@ public byte[] getContent() {
column.columnIndex(),
startIndex,
column.columnIndex(),
DEFAULT_GENERATED_ROW_COUNT - 1,
helperStopIndex,
helper.exampleValue(),
helper.description()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public byte[] getContent() {
}

var startIndex = 1; // start in row number 2 with index 1 skipping the header in the first row
var helperStopIndex = 1; //stop in row number 2 with index 1 as the header row has number 1 index 0
var rowIndex = startIndex;

for (ProteomicsMeasurementEntry pxpEntry : measurements) {
Expand Down Expand Up @@ -199,7 +200,7 @@ public byte[] getContent() {
column.columnIndex(),
startIndex,
column.columnIndex(),
DEFAULT_GENERATED_ROW_COUNT - 1,
helperStopIndex,
helper.exampleValue(),
helper.description())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public byte[] getContent() {
}

var startIndex = 1; // start in row number 2 with index 1 skipping the header in the first row

var helperStopIndex = 1; //stop in row number 2 with index 1 as the header row has number 1 index 0
// make sure to create the visible sheet first
Sheet hiddenSheet = workbook.createSheet("hidden");
Name digestionMethodArea = createOptionArea(hiddenSheet, "Digestion Method",
Expand All @@ -141,7 +141,7 @@ public byte[] getContent() {
column.columnIndex(),
startIndex,
column.columnIndex(),
DEFAULT_GENERATED_ROW_COUNT - 1,
helperStopIndex,
helper.exampleValue(),
helper.description())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static XSSFWorkbook createRegistrationTemplate(List<String> conditions,
}

var startIndex = 1; //start in the second row with index 1.
var helperStopIndex = 1; //stop in the second row with index 1

var hiddenSheet = workbook.createSheet("hidden");
Name analysisToBePerformedOptions = createOptionArea(hiddenSheet, "Analysis to be performed",
Expand Down Expand Up @@ -175,7 +176,7 @@ public static XSSFWorkbook createRegistrationTemplate(List<String> conditions,
column.columnIndex(),
startIndex,
column.columnIndex(),
MAX_ROW_INDEX_TO,
helperStopIndex,
helper.exampleValue(),
helper.description())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static XSSFWorkbook createUpdateTemplate(List<Sample> samples, List<Strin
}

var startIndex = 1; //start in the second row with index 1.
var helperStopIndex = 1; //stop in the second row with index 1.
int rowIndex = startIndex;
for (Sample sample : samples) {
Row row = getOrCreateRow(sheet, rowIndex);
Expand Down Expand Up @@ -187,7 +188,7 @@ public static XSSFWorkbook createUpdateTemplate(List<Sample> samples, List<Strin
column.columnIndex(),
startIndex,
column.columnIndex(),
MAX_ROW_INDEX_TO,
helperStopIndex,
helper.exampleValue(),
helper.description())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package life.qbic.datamanager.views.demo;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.Unit;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.progressbar.ProgressBar;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.value.ValueChangeMode;
Expand All @@ -18,6 +20,7 @@
import life.qbic.datamanager.views.general.Card;
import life.qbic.datamanager.views.general.DetailBox;
import life.qbic.datamanager.views.general.DetailBox.Header;
import java.util.concurrent.CompletableFuture;
import life.qbic.datamanager.views.general.dialog.AppDialog;
import life.qbic.datamanager.views.general.dialog.DialogBody;
import life.qbic.datamanager.views.general.dialog.DialogFooter;
Expand All @@ -31,6 +34,8 @@
import life.qbic.datamanager.views.general.dialog.stepper.StepperDisplay;
import life.qbic.datamanager.views.general.icon.IconFactory;
import life.qbic.datamanager.views.projects.project.info.SimpleParagraph;
import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
Expand All @@ -53,9 +58,13 @@ public class ComponentDemo extends Div {
public static final String HEADING_3 = "heading-3";
public static final String GAP_04 = "gap-04";
public static final String FLEX_VERTICAL = "flex-vertical";
public static final String NORMAL_BODY_TEXT = "normal-body-text";
Div title = new Div("Data Manager - Component Demo");
private final MessageSourceNotificationFactory messageFactory;

public ComponentDemo() {
@Autowired
public ComponentDemo(MessageSourceNotificationFactory messageSourceNotificationFactory) {
this.messageFactory = Objects.requireNonNull(messageSourceNotificationFactory);
title.addClassName("heading-1");
addClassNames("padding-left-right-07", "padding-top-bottom-04");
add(title);
Expand All @@ -66,6 +75,7 @@ public ComponentDemo() {
add(detailBoxShowCase());
add(dialogShowCase());
add(cardShowCase());
add(toastShowCase());
}

private static Div clickableShowCase() {
Expand Down Expand Up @@ -101,7 +111,7 @@ private static Div headingShowcase() {
heading.addClassName("heading-" + i);
heading.setText("Heading " + i);
Div description = new Div();
description.addClassName("normal-body-text");
description.addClassName(NORMAL_BODY_TEXT);
description.setText("CSS class: %s".formatted(".heading-" + i));
container.add(heading, description);
}
Expand Down Expand Up @@ -243,6 +253,49 @@ private static Div dialogShowCase(AppDialog dialog, String dialogType) {
return content;
}

private Div toastShowCase() {
var title = new Div("Toast it!");
title.addClassName(HEADING_2);
var description = new Div(
"Let's see how toasts work and also how to use them when we want to indicate a background task to the user.");
description.addClassName(NORMAL_BODY_TEXT);
var content = new Div();
content.addClassNames(FLEX_VERTICAL, GAP_04);

content.add(title);
content.add(description);

var button = new Button("Show Toast");

content.add(button);

button.addClickListener(e ->
{
var progressBar = new ProgressBar();
progressBar.setIndeterminate(true);
var toast = messageFactory.pendingTaskToast("task.in-progress", new Object[]{"Doing something really heavy here"}, getLocale());
var succeededToast = messageFactory.toast("task.finished", new Object[]{"Heavy Task #1"}, getLocale());
toast.open();
var ui = UI.getCurrent();
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(5000);

} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}).thenRunAsync(() -> {
ui.access(() -> {
toast.close();
succeededToast.open();
}
);
});
});
content.add(button);
return content;
}

private static Div detailBoxShowCase() {
Div container = new Div();
container.add(createHeading2("Detail Box"));
Expand Down Expand Up @@ -337,7 +390,7 @@ private static Div cardShowCase() {
private static class BodyFontStyles {

static String[] fontStyles = new String[]{
"normal-body-text",
NORMAL_BODY_TEXT,
"small-body-text",
"extra-small-body-text",
"field-label-text",
Expand All @@ -354,7 +407,8 @@ private static class ExampleUserInput extends Div implements UserInput {
Binder<StringBean> binder;

ExampleUserInput(String prefill) {
var dialogSection = DialogSection.with("User Input Validation", "Try correct and incorrect input values in the following field.");
var dialogSection = DialogSection.with("User Input Validation",
"Try correct and incorrect input values in the following field.");
originalValue = prefill;
var textField = new TextField();
textField.setLabel("Correct input is 'Riddikulus'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.progressbar.ProgressBar;
import com.vaadin.flow.router.RouteParameters;
import com.vaadin.flow.spring.annotation.SpringComponent;
import java.time.Duration;
Expand All @@ -17,8 +18,8 @@
import org.springframework.context.NoSuchMessageException;

/**
* Notifications created by this factory can be shown to the user.
* There are multiply types of notifications.
* Notifications created by this factory can be shown to the user. There are multiply types of
* notifications.
* <ul>
* <li>Toast notification</li>
* <li>Notification dialog</li>
Expand All @@ -33,8 +34,8 @@
@SpringComponent
public class MessageSourceNotificationFactory {

private static final Logger log = logger(MessageSourceNotificationFactory.class);
public static final Object[] EMPTY_PARAMETERS = new Object[]{};
private static final Logger log = logger(MessageSourceNotificationFactory.class);
private static final String DEFAULT_CONFIRM_TEXT = "Okay";
private static final NotificationLevel DEFAULT_LEVEL = NotificationLevel.INFO;
private static final MessageType DEFAULT_MESSAGE_TYPE = MessageType.HTML;
Expand Down Expand Up @@ -109,6 +110,34 @@ public Toast routingToast(String key, Object[] messageArgs, Object[] routeArgs,
return toast.withRouting(linkText, navigationTarget, routeParameters);
}

/**
* Creates a toast that indicates a pending task. The display duration is set to
* {@link Duration#ZERO}, since it is the client's job to close the toast explicitly after the
* pending task has finished.
* <p>
* The following message keys have to be present:
* <ul>
* <li>{@code <key>.message.type}
* <li>{@code <key>.message.text}
* <li>{@code <key>.routing.link.text}
* </ul>
* <p>
* For more information please see toast-notifications.properties
*
* @param key the key for the messages
* @param messageArgs the parameters shown in the message
* @param locale the locale for which to load the message
* @return a Toast with loaded content
* @see #toast(String, Object[], Locale)
*/
public Toast pendingTaskToast(String key, Object[] messageArgs, Locale locale) {
var toast = toast(key, messageArgs, locale);
var progressBar = new ProgressBar();
progressBar.setIndeterminate(true);
toast.setDuration(Duration.ZERO);
return toast.add(progressBar);
}

/**
* Creates a dialog notification with the contents found for the message key. This method produces
* a notification dialog with the link text read from the message properties file.
Expand Down
Loading

0 comments on commit c97bf21

Please sign in to comment.