Skip to content

Commit

Permalink
Add (untested) reader capability for sex
Browse files Browse the repository at this point in the history
  • Loading branch information
GenieTim committed Aug 16, 2020
1 parent f953f0a commit 955d502
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 66 deletions.
9 changes: 2 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
## v1.11.1
* [[`876635ba6c`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/876635ba6c)] - Remove copy button from specimen list (Tim Bernhard)
* [[`8c9f651849`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/8c9f651849)] - Pseudo-disable paste previous action (Tim Bernhard)
* [[`41fc96d9dc`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/41fc96d9dc)] - Slighly improve stability of file chooser (Tim Bernhard)
* [[`41fc96d9dc`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/41fc96d9dc)] - Slightly improve stability of file chooser (Tim Bernhard)
* [[`f460b2882b`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/f460b2882b)] - Add rudimentary custom shortcut functionality (Tim Bernhard)
* [[`9ebb3ca864`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/9ebb3ca864)] - Add more mnemonics as shortcuts in specimen edit view (Tim Bernhard)
* [[`8a88a6c778`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/8a88a6c778)] - Get the next/prev arrows working as intended (Tim Bernhard)
* [[`c51ca5c5a2`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/c51ca5c5a2)] - Partially auto-complete iso date from dateNOS where applicable (risky) (Tim Bernhard)
* [[`c51ca5c5a2`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/c51ca5c5a2)] - Partially auto-complete ISO date from dateNOS where applicable (risky) (Tim Bernhard)
* [[`58712f33b2`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/58712f33b2)] - Explicitly load english location names from OpenStreetMap (Tim Bernhard)
* [[`be05ddb58c`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/be05ddb58c)] - Update dependencies (Tim Bernhard)
* [[`46311021e9`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/46311021e9)] - Refactor Georeference dialog to Miglayout including a little map (Tim Bernhard)
* [[`efaaa1d9cb`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/efaaa1d9cb)] - Fix typo in README (Tim Bernhard)
* [[`22a788ccdb`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/22a788ccdb)] - Fix (hopefully) GitHub Action to extract changelog automatically (Tim Bernhard)
* [[`fc9ac60b22`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/fc9ac60b22)] - Increment version number for pre-realeases (Tim Bernhard)
* [[`45a15449c9`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/45a15449c9)] - Update changelog to publish Version v1.11.0 (Tim Bernhard)


## v1.11.0
* [[`b3b7c7de6a`](https://github.com/BernhardWebstudio/DataShot_DesktopApp/commit/056a3a0dc9)] - Change travis to GitHub actions (Tim Bernhard)
Expand Down
2 changes: 2 additions & 0 deletions bin/publish-current.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ git commit -am "Update changelog to publish Version v$MVN_VERSION"

git tag -a "v$MVN_VERSION" -m "Version $MVN_VERSION" #\n\nChanges:\n$GIT_HISTORY"
git push --follow-tags

echo "Remember to run ./prepare-{major|minor|patch}.sh to increment the version"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.harvard.mcz</groupId>
<artifactId>DataShot</artifactId>
<version>1.11.1</version>
<version>1.12.0-SNAPSHOT</version>
<!-- Remember to edit src/main/java/edu/harvard/mcz/imagecapture/ImageCaptureApp.java -->
<name>datashot</name>
<description>MCZ DataShot Collection Imaging Application</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import edu.harvard.mcz.imagecapture.lifecycle.SpecimenLifeCycle;
import edu.harvard.mcz.imagecapture.ui.ButtonEditor;
import edu.harvard.mcz.imagecapture.ui.ButtonRenderer;
import edu.harvard.mcz.imagecapture.ui.CopyRowButtonEditor;
import edu.harvard.mcz.imagecapture.ui.tablemodel.SpecimenListTableModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class UnitTrayLabelParser implements TaxonNameReturner, DrawerNameReturne
private String drawerNumber;
private String collection; // collection from which the material came
private String identifiedBy;
private String sex;
private boolean parsedFromJSON;

/**
Expand Down Expand Up @@ -81,6 +82,7 @@ protected boolean parseFromJSON(String json) {
infraspecificEpithet = label.getInfraspecificEpithet();
infraspecificRank = label.getInfraspecificRank();
drawerNumber = label.getDrawerNumber();
sex = label.getSex();
parsedFromJSON = true;
}
return result;
Expand Down Expand Up @@ -493,6 +495,24 @@ public void setIdentifiedBy(String identifiedBy) {
this.identifiedBy = identifiedBy;
}

/**
* Get the gender (male, female, worker)
*
* @return the gender of the object
*/
public String getSex() {
return sex;
}

/**
* Set the gender of the entity
*
* @param sex
*/
public void setSex(String sex) {
this.sex = sex;
}

/**
* Was this Parse done from JSON.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,7 @@ public static boolean printList(List<UnitTrayLabel> taxa) throws PrintFailedExce
// in two columns, filling left column first, then right
if (cellCounter == 12) {
// add a page of 12 cells in columns of two.
for (int x = 0; x < 6; x++) {
if (cells.get(x) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x));
table.addCell(cells_barcode.get(x));
}
if (cells.get(x + 6) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x + 6));
table.addCell(cells_barcode.get(x + 6));
}
}
addPageWithColCells(table, cells, cells_barcode);
// Reset to begin next page
cellCounter = 0;
document.add(table);
Expand All @@ -259,26 +240,7 @@ public static boolean printList(List<UnitTrayLabel> taxa) throws PrintFailedExce
counter++;
} // end while results has next (for all taxa requested)
// get any remaining cells in pairs
for (int x = 0; x < 6; x++) {
if (cells.get(x) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x));
table.addCell(cells_barcode.get(x));
}
if (cells.get(x + 6) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x + 6));
table.addCell(cells_barcode.get(x + 6));
}
}
addPageWithColCells(table, cells, cells_barcode);
// add any remaining cells
document.add(table);
try {
Expand Down Expand Up @@ -324,6 +286,29 @@ public static boolean printList(List<UnitTrayLabel> taxa) throws PrintFailedExce
return result;
}

private static void addPageWithColCells(PdfPTable table, ArrayList<PdfPCell> cells, ArrayList<PdfPCell> cells_barcode) {
for (int x = 0; x < 6; x++) {
if (cells.get(x) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x));
table.addCell(cells_barcode.get(x));
}
if (cells.get(x + 6) == null) {
PdfPCell c = new PdfPCell();
c.setBorder(0);
table.addCell(c);
table.addCell(c);
} else {
table.addCell(cells.get(x + 6));
table.addCell(cells_barcode.get(x + 6));
}
}
}

public static void main(String[] args) {
try {
UnitTrayLabelLifeCycle uls = new UnitTrayLabelLifeCycle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class UnitTrayLabel
private String collection; // collection from which the material came
private Integer ordinal; // order in which to print
private String identifiedBy;
private String sex;

public UnitTrayLabel() {
this.printed = 0;
Expand All @@ -72,6 +73,7 @@ public UnitTrayLabel() {
this.authorship = "";
this.unNamedForm = "";
this.collection = "";
this.sex = "";
this.ordinal = 1;
this.dateCreated = new Date();
this.dateLastUpdated = new Date();
Expand Down Expand Up @@ -324,6 +326,9 @@ public static UnitTrayLabel createFromJSONString(String jsonEncodedLabel) {
if (key.equals("id")) {
result.setIdentifiedBy(value);
}
if (key.equals("x")) {
result.setSex(value);
}
}
}
log.debug(result.toJSONString());
Expand Down Expand Up @@ -624,6 +629,14 @@ public void setDateLastUpdated(Date dateLastUpdated) {
this.dateLastUpdated = dateLastUpdated;
}

public String getSex() {
return sex;
}

public void setSex(String sex) {
this.sex = sex;
}

@Override
public String getCollection() {
return collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@ public interface TaxonNameReturner {
*/
String getIdentifiedBy();

/**
* @return the sex (male, female, worker)
*/
String getSex();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import edu.harvard.mcz.imagecapture.*;
import edu.harvard.mcz.imagecapture.data.MetadataRetriever;
import edu.harvard.mcz.imagecapture.entity.ICImage;
import edu.harvard.mcz.imagecapture.entity.Specimen;
import edu.harvard.mcz.imagecapture.entity.UnitTrayLabel;
import edu.harvard.mcz.imagecapture.entity.*;
import edu.harvard.mcz.imagecapture.entity.fixed.WorkFlowStatus;
import edu.harvard.mcz.imagecapture.exceptions.OCRReadException;
import edu.harvard.mcz.imagecapture.exceptions.SaveFailedException;
Expand Down Expand Up @@ -411,6 +409,17 @@ protected static void createDatabaseRecordForSpecimen(File containedFile, ScanCo
s.setFamily(parser.getFamily());
s.setSubfamily(parser.getSubfamily());
s.setTribe(parser.getTribe());
// set sex
String sex = parser.getSex();
if (sex.equalsIgnoreCase("worker")) {
s.setSex("female");
SpecimenPart worker = new SpecimenPart();
SpecimenPartAttribute workerCaste = new SpecimenPartAttribute(worker, "caste", "worker", "", "", "", new Date());
worker.getAttributeCollection().add(workerCaste);
s.getSpecimenParts().add(worker);
} else {
s.setSex(sex);
}
} else {
// We failed over to OCR, try lookup in DB.
s.setFamily(""); // make sure there's a a non-null value in family.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2237,8 +2237,9 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
}

private void updateJButtonPaste() {
if (jButtonPaste != null){
jButtonPaste.setEnabled(!(this.previousSpecimen == null && ImageCaptureApp.lastEditedSpecimenCache == null));}
if (jButtonPaste != null) {
jButtonPaste.setEnabled(!(this.previousSpecimen == null && ImageCaptureApp.lastEditedSpecimenCache == null));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.List;

Expand All @@ -32,7 +31,7 @@
public class SpecimenListTableModel extends AbstractTableModel {

public static final int COL_ID = 0;
// public static final int COL_COPY = 1;
// public static final int COL_COPY = 1;
public static final int COL_BARCODE = 2 - 1;
public static final int COL_WORKFLOW = 3 - 1;
public static final int COL_FAMILY = 4 - 1;
Expand Down Expand Up @@ -204,7 +203,7 @@ public String getColumnName(int columnIndex) {
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
boolean result = false;
if (columnIndex == COL_ID){ //|| columnIndex == COL_COPY) {
if (columnIndex == COL_ID) { //|| columnIndex == COL_COPY) {
result = true;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package edu.harvard.mcz.imagecapture.utility;

import edu.harvard.mcz.imagecapture.ImageCaptureApp;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;

// TODO: refactor into https://github.com/westnordost/osmapi-overpass
// and load ISO 3166-1 & -2 instead
Expand Down

0 comments on commit 955d502

Please sign in to comment.