diff --git a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchInformationLayout.java b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchInformationLayout.java index 737e08424..36854c04e 100644 --- a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchInformationLayout.java +++ b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchInformationLayout.java @@ -4,15 +4,9 @@ import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Span; -import com.vaadin.flow.component.icon.Icon; -import com.vaadin.flow.component.icon.VaadinIcon; -import com.vaadin.flow.component.orderedlayout.HorizontalLayout; -import com.vaadin.flow.component.radiobutton.RadioButtonGroup; -import com.vaadin.flow.component.radiobutton.RadioGroupVariant; import com.vaadin.flow.component.select.Select; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.data.binder.Binder; -import com.vaadin.flow.data.renderer.ComponentRenderer; import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; @@ -29,7 +23,6 @@ public class BatchInformationLayout extends Div { public final TextField batchNameField = new TextField("Batch Name"); - public final RadioButtonGroup dataTypeSelection = new RadioButtonGroup<>(); public final Button cancelButton = new Button("Cancel"); public final Button nextButton = new Button("Next"); public final Select experimentSelect = new Select<>(); @@ -43,7 +36,6 @@ public BatchInformationLayout() { private void initContent() { initBatchLayout(); - initDataTypeLayout(); initButtonLayout(); } @@ -57,38 +49,10 @@ private void initBatchLayout() { batchLayout.add(batchInformationHeader); batchLayout.add(experimentSelect); batchLayout.add(batchNameField); + batchNameField.setRequired(true); add(batchLayout); } - private void initDataTypeLayout() { - Div dataTypeLayout = new Div(); - dataTypeLayout.addClassName("data-type-information"); - Span dataTypeHeader = new Span("Type of Data"); - dataTypeHeader.addClassName("title"); - dataTypeLayout.add(dataTypeHeader); - Div dataTypeDescription = new Div(); - dataTypeDescription.add( - "There is a minimum amount of information required. All samples must conform the expected metadata values. The most suitable checklist for sample registration depends on the type of the sample."); - dataTypeLayout.add(dataTypeDescription); - initDataTypeSelection(); - dataTypeLayout.add(dataTypeSelection); - add(dataTypeLayout); - } - - private void initDataTypeSelection() { - dataTypeSelection.setItems(MetadataType.values()); - dataTypeSelection.setReadOnly(true); - dataTypeSelection.setValue(MetadataType.TRANSCRIPTOMICS_GENOMICS); - dataTypeSelection.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); - dataTypeSelection.setRenderer(new ComponentRenderer<>(metadataType -> { - Span metadataTypeSpan = new Span(metadataType.label); - Icon infoIcon = new Icon(VaadinIcon.INFO_CIRCLE); - infoIcon.addClassName("info-icon"); - infoIcon.setTooltipText(metadataType.description); - return new HorizontalLayout(metadataTypeSpan, infoIcon); - })); - } - private void initButtonLayout() { Span batchInformationButtons = new Span(); batchInformationButtons.addClassName("buttons"); @@ -138,7 +102,6 @@ private void reset() { } private void resetChildValues() { - dataTypeSelection.setValue(MetadataType.TRANSCRIPTOMICS_GENOMICS); experimentSelect.clear(); batchNameField.clear(); } diff --git a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchRegistrationDialog.java b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchRegistrationDialog.java index 53eb0e6d4..0d04ccdd4 100644 --- a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchRegistrationDialog.java +++ b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/BatchRegistrationDialog.java @@ -151,8 +151,7 @@ private void generateSampleRegistrationLayout() { if (sampleSpreadsheetLayout.getExperiment() == null || !selectedExperimentId.equals( sampleSpreadsheetLayout.getExperiment())) { sampleSpreadsheetLayout.setExperiment(batchInformationLayout.experimentSelect.getValue()); - sampleSpreadsheetLayout.generateSampleRegistrationSheet( - batchInformationLayout.dataTypeSelection.getValue()); + sampleSpreadsheetLayout.generateSampleRegistrationSheet(); } } diff --git a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/MetadataType.java b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/MetadataType.java deleted file mode 100644 index e08111281..000000000 --- a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/MetadataType.java +++ /dev/null @@ -1,23 +0,0 @@ -package life.qbic.datamanager.views.projects.project.samples.registration.batch; - - -/** - * MetadataType enums are used in {@link BatchInformationLayout}, to indicate which type of Sample - * Metadata will be provided during Sample Registration. Additionally, they host a detailed - * description for the respective metadata type - * - * @since 1.0.0 - */ -enum MetadataType { - LIGANDOMICS("Ligandomics", "Detailed Explanation for Ligandomics"), METABOLOMICS("Metabolomics", - "Detailed Explanation for Metabolomics"), TRANSCRIPTOMICS_GENOMICS("Transcriptomics/Genomics", - "Detailed Explanation for Transcriptomics/Genomics"), PROTEOMICS("Proteomics", - "Detailed Explanation for Proteomics"); - final String label; - final String description; - - MetadataType(String label, String description) { - this.label = label; - this.description = description; - } -} diff --git a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleRegistrationSpreadsheet.java b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleRegistrationSpreadsheet.java index ae2b09812..bb69917cd 100644 --- a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleRegistrationSpreadsheet.java +++ b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleRegistrationSpreadsheet.java @@ -45,7 +45,7 @@ public class SampleRegistrationSpreadsheet extends Spreadsheet implements Serial @Serial private static final long serialVersionUID = 573778360298068552L; private SpreadsheetDropdownFactory dropdownCellFactory; - private List header; + private List header; private static List species; private static List specimens; private static List analytes; @@ -80,22 +80,18 @@ public static void setExperimentMetadata(Experiment experiment) { prepareConditionItems(groups); } - public void addSheetToSpreadsheet(MetadataType metaDataType) { + public void addSheetToSpreadsheet() { dropdownCellFactory = new SpreadsheetDropdownFactory(); this.createNewSheet("SampleRegistrationSheet", 1, 1); this.deleteSheet(0); sampleRegistrationSheet = this.getActiveSheet(); - switch (metaDataType) { - case PROTEOMICS -> addProteomicsSheet(retrieveProteomics()); - case LIGANDOMICS -> addLigandomicsSheet(retrieveLigandomics()); - case TRANSCRIPTOMICS_GENOMICS -> addGenomicsSheet(retrieveGenomics()); - case METABOLOMICS -> addMetabolomicsSheet(retrieveMetabolomics()); - } + addSheet(retrieveSheetHeaders()); this.setActiveSheetProtected("password-needed-to-lock"); this.setSpreadsheetComponentFactory(dropdownCellFactory); //initialise first rows based on known sample size addRowsForInitialSamples(numberOfSamples); + sampleRegistrationSheet.createFreezePane(0, 1); } private void addRowsForInitialSamples(int numberOfSamples) { @@ -140,7 +136,7 @@ private List getReplicateLabels() { public void addRow() { int lastRowIndex = 1 + sampleRegistrationSheet.getLastRowNum(); for (int columnIndex = 0; columnIndex < header.size(); columnIndex++) { - SamplesheetHeaderName colHeader = header.get(columnIndex); + SampleSheetHeaderName colHeader = header.get(columnIndex); switch (colHeader) { case SPECIES -> prefillCellsToRow(columnIndex, lastRowIndex, species); case SPECIMEN -> prefillCellsToRow(columnIndex, lastRowIndex, specimens); @@ -185,12 +181,12 @@ private void prefillCellsToRow(int colIndex, int rowIndex, List items) { } private void setupCommonDropDownColumns() { - initDropDownColumn(header.indexOf(SamplesheetHeaderName.SPECIES), species); - initDropDownColumn(header.indexOf(SamplesheetHeaderName.SPECIMEN), specimens); - initDropDownColumn(header.indexOf(SamplesheetHeaderName.ANALYTE), analytes); - initDropDownColumn(header.indexOf(SamplesheetHeaderName.CONDITION), + initDropDownColumn(header.indexOf(SampleSheetHeaderName.SPECIES), species); + initDropDownColumn(header.indexOf(SampleSheetHeaderName.SPECIMEN), specimens); + initDropDownColumn(header.indexOf(SampleSheetHeaderName.ANALYTE), analytes); + initDropDownColumn(header.indexOf(SampleSheetHeaderName.CONDITION), conditionsToReplicates.keySet().stream().toList()); - initDropDownColumn(header.indexOf(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID), + initDropDownColumn(header.indexOf(SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID), getReplicateLabels()); } @@ -203,7 +199,7 @@ private void initDropDownColumn(int colIndex, List items) { } } - private void prepareColumnHeaderAndWidth(LinkedHashMap> headerToPresets) { CellStyle boldHeaderStyle = this.getWorkbook().createCellStyle(); Font font = this.getWorkbook().createFont(); @@ -211,7 +207,7 @@ private void prepareColumnHeaderAndWidth(LinkedHashMap updatedCells = new ArrayList<>(); int columnIndex = 0; - for (SamplesheetHeaderName columnHeader : headerToPresets.keySet()) { + for (SampleSheetHeaderName columnHeader : headerToPresets.keySet()) { List presets = headerToPresets.get(columnHeader); String columnLabel = columnHeader.label; this.fixColumnWidth(columnIndex, columnLabel, @@ -225,23 +221,6 @@ private void prepareColumnHeaderAndWidth(LinkedHashMap> headerToPresets = new LinkedHashMap<>(); - for (SamplesheetHeaderName label : header) { - headerToPresets.put(label, new ArrayList<>()); - } - headerToPresets.put(SamplesheetHeaderName.SPECIES, species); - headerToPresets.put(SamplesheetHeaderName.SPECIMEN, specimens); - headerToPresets.put(SamplesheetHeaderName.ANALYTE, analytes); - headerToPresets.put(SamplesheetHeaderName.CONDITION, - conditionsToReplicates.keySet().stream().toList()); - headerToPresets.put(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, getReplicateLabels()); - prepareColumnHeaderAndWidth(headerToPresets); - this.reload(); - setupCommonDropDownColumns(); - } - - public int findLastRow() { int res = 0; for (int row = 1; row <= Integer.MAX_VALUE; row++) { @@ -306,43 +285,24 @@ void fixColumnWidth(int colIndex, String colLabel, this.getCell(0, colIndex).setCellValue(oldValue); } - - private void addProteomicsSheet(List header) { - this.header = header; - prepareCommonSheetTasks(); - setDefaultColumnCount(header.size()); - } - - private void addMetabolomicsSheet(List header) { - this.header = header; - prepareCommonSheetTasks(); - setDefaultColumnCount(header.size()); - } - - private void addLigandomicsSheet(List header) { - this.header = header; - prepareCommonSheetTasks(); - setDefaultColumnCount(header.size()); - } - - private void addGenomicsSheet(List header) { + private void addSheet(List header) { this.header = header; - LinkedHashMap> headerToPresets = new LinkedHashMap<>(); + LinkedHashMap> headerToPresets = new LinkedHashMap<>(); setDefaultColumnCount(header.size()); - for (SamplesheetHeaderName head : header) { + for (SampleSheetHeaderName head : header) { headerToPresets.put(head, new ArrayList<>()); } - headerToPresets.put(SamplesheetHeaderName.SPECIES, species); - headerToPresets.put(SamplesheetHeaderName.SPECIMEN, specimens); - headerToPresets.put(SamplesheetHeaderName.ANALYTE, analytes); - headerToPresets.put(SamplesheetHeaderName.CONDITION, + headerToPresets.put(SampleSheetHeaderName.SPECIES, species); + headerToPresets.put(SampleSheetHeaderName.SPECIMEN, specimens); + headerToPresets.put(SampleSheetHeaderName.ANALYTE, analytes); + headerToPresets.put(SampleSheetHeaderName.CONDITION, conditionsToReplicates.keySet().stream().toList()); - headerToPresets.put(SamplesheetHeaderName.SEQ_ANALYSIS_TYPE, + headerToPresets.put(SampleSheetHeaderName.SEQ_ANALYSIS_TYPE, Arrays.stream(SequenceAnalysisType .values()) .map(e -> e.label) .collect(Collectors.toList())); - headerToPresets.put(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, getReplicateLabels()); + headerToPresets.put(SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID, getReplicateLabels()); prepareColumnHeaderAndWidth(headerToPresets); this.reload(); DropdownColumn analysisTypeColumn = new DropdownColumn().withItems( @@ -351,24 +311,22 @@ private void addGenomicsSheet(List header) { .map(e -> e.label) .collect(Collectors.toList())); analysisTypeColumn.toRowIndex(0) - .atColIndex(header.indexOf(SamplesheetHeaderName.SEQ_ANALYSIS_TYPE)); - + .atColIndex(header.indexOf(SampleSheetHeaderName.SEQ_ANALYSIS_TYPE)); dropdownCellFactory.addDropdownColumn(analysisTypeColumn); setupCommonDropDownColumns(); - } /** - * The SamplesheetHeaderName enum contains the labels which are used to refer to the headers + * The SampleSheetHeaderName enum contains the labels which are used to refer to the headers * employed during sample batch registration for different data technologies * * @since 1.0.0 */ - public enum SamplesheetHeaderName { + public enum SampleSheetHeaderName { SEQ_ANALYSIS_TYPE("Analysis to be performed", true), SAMPLE_LABEL( "Sample label", true), BIOLOGICAL_REPLICATE_ID( - "Biological replicate id", true), CONDITION("Condition", + "Biological replicate id", true), CONDITION("Condition", true), SPECIES("Species", true), SPECIMEN("Specimen", true), ANALYTE("Analyte", true), CUSTOMER_COMMENT( "Customer comment", false); @@ -376,42 +334,18 @@ public enum SamplesheetHeaderName { public final String label; public final boolean isMandatory; - SamplesheetHeaderName(String label, boolean isMandatory) { + SampleSheetHeaderName(String label, boolean isMandatory) { this.label = label; this.isMandatory = isMandatory; } } - public List retrieveProteomics() { - return List.of(SamplesheetHeaderName.SAMPLE_LABEL, - SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, SamplesheetHeaderName.CONDITION, - SamplesheetHeaderName.SPECIES, SamplesheetHeaderName.SPECIMEN, - SamplesheetHeaderName.ANALYTE, - SamplesheetHeaderName.CUSTOMER_COMMENT); - } - - public List retrieveLigandomics() { - return List.of(SamplesheetHeaderName.SAMPLE_LABEL, - SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, SamplesheetHeaderName.CONDITION, - SamplesheetHeaderName.SPECIES, SamplesheetHeaderName.SPECIMEN, - SamplesheetHeaderName.ANALYTE, - SamplesheetHeaderName.CUSTOMER_COMMENT); - } - - public List retrieveMetabolomics() { - return List.of(SamplesheetHeaderName.SAMPLE_LABEL, - SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, SamplesheetHeaderName.CONDITION, - SamplesheetHeaderName.SPECIES, SamplesheetHeaderName.SPECIMEN, - SamplesheetHeaderName.ANALYTE, - SamplesheetHeaderName.CUSTOMER_COMMENT); - } - - public List retrieveGenomics() { - return List.of(SamplesheetHeaderName.SEQ_ANALYSIS_TYPE, SamplesheetHeaderName.SAMPLE_LABEL, - SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID, SamplesheetHeaderName.CONDITION, - SamplesheetHeaderName.SPECIES, SamplesheetHeaderName.SPECIMEN, - SamplesheetHeaderName.ANALYTE, - SamplesheetHeaderName.CUSTOMER_COMMENT); + public List retrieveSheetHeaders() { + return List.of(SampleSheetHeaderName.SEQ_ANALYSIS_TYPE, SampleSheetHeaderName.SAMPLE_LABEL, + SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID, SampleSheetHeaderName.CONDITION, + SampleSheetHeaderName.SPECIES, SampleSheetHeaderName.SPECIMEN, + SampleSheetHeaderName.ANALYTE, + SampleSheetHeaderName.CUSTOMER_COMMENT); } public Result areInputsValid() { @@ -419,7 +353,7 @@ public Result areInputsValid() { for (int rowId = 2; rowId <= sampleRegistrationSheet.getLastRowNum(); rowId++) { Row row = sampleRegistrationSheet.getRow(rowId); List mandatoryInputs = new ArrayList<>(); - for (SamplesheetHeaderName name : SamplesheetHeaderName.values()) { + for (SampleSheetHeaderName name : SampleSheetHeaderName.values()) { if (name.isMandatory) { mandatoryInputs.add(SpreadsheetMethods.cellToStringOrNull(row.getCell( header.indexOf(name)))); @@ -437,7 +371,7 @@ public Result areInputsValid() { } String replicateIDInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID))).trim(); + header.indexOf(SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID))).trim(); // Sample uniqueness needs to be guaranteed by condition and replicate ID if (!isUniqueSampleRow(concatenatedSampleIDs, row)) { return Result.fromError(new InvalidSpreadsheetRow( @@ -449,9 +383,9 @@ public Result areInputsValid() { private boolean isUniqueSampleRow(Set knownIDs, Row row) { String replicateIDInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID))).trim(); + header.indexOf(SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID))).trim(); String conditionInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.CONDITION))).trim(); + header.indexOf(SampleSheetHeaderName.CONDITION))).trim(); // Sample uniqueness needs to be guaranteed by condition and replicate ID String concatenatedSampleID = replicateIDInput + conditionInput; if(knownIDs.contains(concatenatedSampleID)) { @@ -469,21 +403,21 @@ public List getFilledRows() { Row row = sampleRegistrationSheet.getRow(rowId); String analysisTypeInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.SEQ_ANALYSIS_TYPE))); + header.indexOf(SampleSheetHeaderName.SEQ_ANALYSIS_TYPE))); String sampleLabelInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.SAMPLE_LABEL))); + header.indexOf(SampleSheetHeaderName.SAMPLE_LABEL))); String replicateIDInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.BIOLOGICAL_REPLICATE_ID))); + header.indexOf(SampleSheetHeaderName.BIOLOGICAL_REPLICATE_ID))); String conditionInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.CONDITION))); + header.indexOf(SampleSheetHeaderName.CONDITION))); String speciesInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.SPECIES))); + header.indexOf(SampleSheetHeaderName.SPECIES))); String specimenInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.SPECIMEN))); + header.indexOf(SampleSheetHeaderName.SPECIMEN))); String analyteInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.ANALYTE))); + header.indexOf(SampleSheetHeaderName.ANALYTE))); String commentInput = SpreadsheetMethods.cellToStringOrNull(row.getCell( - header.indexOf(SamplesheetHeaderName.CUSTOMER_COMMENT))); + header.indexOf(SampleSheetHeaderName.CUSTOMER_COMMENT))); // break when cells in row are undefined if (Stream.of(analysisTypeInput, sampleLabelInput, diff --git a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleSpreadsheetLayout.java b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleSpreadsheetLayout.java index a857dd25b..81ad398d7 100644 --- a/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleSpreadsheetLayout.java +++ b/vaadinfrontend/src/main/java/life/qbic/datamanager/views/projects/project/samples/registration/batch/SampleSpreadsheetLayout.java @@ -86,9 +86,9 @@ private void styleSampleRegistrationSpreadSheet() { sampleRegistrationSpreadsheet.setFunctionBarVisible(false); } - public void generateSampleRegistrationSheet(MetadataType metaDataType) { + public void generateSampleRegistrationSheet() { sampleRegistrationSpreadsheet.reset(); - sampleRegistrationSpreadsheet.addSheetToSpreadsheet(metaDataType); + sampleRegistrationSpreadsheet.addSheetToSpreadsheet(); sampleRegistrationSpreadsheet.reload(); }