Skip to content

Commit

Permalink
Implement column and filter for collection nr
Browse files Browse the repository at this point in the history
  • Loading branch information
GenieTim committed Sep 26, 2024
1 parent f271ba0 commit 8e8bf7f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,15 @@ public void setNumbers(Set<Number> 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<ICImage> getICImages() {
return this.ICImages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> jComboBoxCollection = null;
private JComboBox<Object> jComboBoxWorkflowStatus = null;
private JTextField jTextFieldImageFilename = null;
Expand Down Expand Up @@ -283,6 +284,10 @@ public Predicate toPredicate(Root<Specimen> root, CriteriaQuery<Long> 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(
Expand Down Expand Up @@ -342,6 +347,7 @@ private JScrollPane getJPanelWithFields() {
"State/Province",
"Country",
"Collection",
"Collection Nr.",
"Collector",
"Interpreted Date",
"Workflow Status",
Expand Down Expand Up @@ -370,6 +376,7 @@ private JScrollPane getJPanelWithFields() {
this.getPrimaryDivisionJComboBox(),
this.getCountryJComboBox(),
this.getCollectionJComboBox(),
this.getCollectionNrJTextField(),
this.getCollectorsJComboBox(),
this.getInterpretedDateTextField(),
this.getWorkflowsJComboBox(),
Expand Down Expand Up @@ -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<String> getOrderJTextField() {
if (jTextFieldOrder == null) {
jTextFieldOrder = new JComboBox<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8e8bf7f

Please sign in to comment.