From 8e8bf7f7be64afac5f373c340c3e874e124caa5c Mon Sep 17 00:00:00 2001 From: Tim Bernhard Date: Thu, 26 Sep 2024 20:18:05 +0200 Subject: [PATCH] Implement column and filter for collection nr --- .../mcz/imagecapture/entity/Specimen.java | 9 +++++++++ .../imagecapture/ui/dialog/SearchDialog.java | 19 +++++++++++++++++++ .../ui/tablemodel/SpecimenListTableModel.java | 16 +++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/mcz/imagecapture/entity/Specimen.java b/src/main/java/edu/harvard/mcz/imagecapture/entity/Specimen.java index 98af821..40ec569 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/entity/Specimen.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/entity/Specimen.java @@ -1170,6 +1170,15 @@ public void setNumbers(Set numbers) { this.numbers = numbers; } + public String getFirstNumberWithType(String type) { + for (Number number : numbers) { + if (number.getNumberType().equals(type)) { + return number.getNumber(); + } + } + return null; + } + public Set getICImages() { return this.ICImages; } diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SearchDialog.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SearchDialog.java index f22f949..b5ed344 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SearchDialog.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SearchDialog.java @@ -63,6 +63,7 @@ public class SearchDialog extends JDialog { private JTextField jTextFieldFamily = null; private JTextField jTextFieldGenus = null; private JTextField jTextFieldSpecies = null; + private JTextField jTextFieldCollectionNr = null; private JComboBox jComboBoxCollection = null; private JComboBox jComboBoxWorkflowStatus = null; private JTextField jTextFieldImageFilename = null; @@ -283,6 +284,10 @@ public Predicate toPredicate(Root root, CriteriaQuery query, Cri ); } } + if (jTextFieldCollectionNr.getText() != null && jTextFieldCollectionNr.getText().length() > 0) { + query.put("numbers.numberType", "Collection Number"); + query.put("numbers.number", jTextFieldCollectionNr.getText()); + } if (jComboBoxEntryBy.getSelectedItem() != null) { if (!jComboBoxEntryBy.getSelectedItem().toString().equals("")) { query.put( @@ -342,6 +347,7 @@ private JScrollPane getJPanelWithFields() { "State/Province", "Country", "Collection", + "Collection Nr.", "Collector", "Interpreted Date", "Workflow Status", @@ -370,6 +376,7 @@ private JScrollPane getJPanelWithFields() { this.getPrimaryDivisionJComboBox(), this.getCountryJComboBox(), this.getCollectionJComboBox(), + this.getCollectionNrJTextField(), this.getCollectorsJComboBox(), this.getInterpretedDateTextField(), this.getWorkflowsJComboBox(), @@ -408,6 +415,18 @@ private JScrollPane getJPanelWithFields() { return scrollPane; } + private JTextField getCollectionNrJTextField() { + if (jTextFieldCollectionNr == null) { + jTextFieldCollectionNr = new JTextField(); + jTextFieldCollectionNr.setColumns(10); + // jTextFieldCollectionNr.setInputVerifier(MetadataRetriever.getInputVerifier(Specimen.class, + // "CollectionNr", jTextFieldCollectionNr)); +// jTextFieldCollectionNr.setToolTipText( +// MetadataRetriever.getFieldHelp(Specimen.class, "CollectionNr")); + } + return jTextFieldCollectionNr; + } + private JComboBox getOrderJTextField() { if (jTextFieldOrder == null) { jTextFieldOrder = new JComboBox<>(); diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/tablemodel/SpecimenListTableModel.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/tablemodel/SpecimenListTableModel.java index ad05762..4f7bd82 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/tablemodel/SpecimenListTableModel.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/tablemodel/SpecimenListTableModel.java @@ -44,7 +44,9 @@ public class SpecimenListTableModel extends AbstractTableModel { public static final int COL_COUNTRY = 10; public static final int COL_DIVISION = 11; public static final int COL_VERBLOCALITY = 12; - public static final int COLUMCOUNT = 13; + public static final int COL_COLLECTION = 13; + public static final int COL_COLLECTION_NR = 14; + public static final int COLUMCOUNT = 15; private static final Logger log = LoggerFactory.getLogger(SpecimenListTableModel.class); private static final long serialVersionUID = -8394267503927374758L; @@ -134,6 +136,12 @@ public Object getValueAt(int rowIndex, int columnIndex) { case COL_DIVISION: result = s.getPrimaryDivison(); break; + case COL_COLLECTION: + result = s.getCollection(); + break; + case COL_COLLECTION_NR: + result = s.getFirstNumberWithType("Collection Number"); + break; } } return result; @@ -206,6 +214,12 @@ public String getColumnName(int columnIndex) { case COL_DIVISION: result = "State/Province"; break; + case COL_COLLECTION: + result = "Collection"; + break; + case COL_COLLECTION_NR: + result = "Collection Nr."; + break; } } return result;