Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Noticeable Scar field to observation Attribute #983

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ export default function ObservationAttributeFilter({ onChange, data }) {
term="terms"
filterKey="Sex"
/>


<FormGroupText
label="FILTER_NOTICEABLE_SCARRING"
noDesc={true}
onChange={onChange}
term="match"
field="noticeableScar"
filterId={"noticeableScar"}
filterKey= {"Noticeable Scarring"}
/>


<FormGroupMultiSelect
isMulti={true}
label="FILTER_LIFE_STAGE"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"FILTER_OBSERVATION_ATTRIBUTE": "Observation Attribute",
"FILTER_OBSERVATION_ATTRIBUTE_DESC": "Use the fields below to filter your search based on observed attributes",
"FILTER_SEX": "Sex",
"FILTER_NOTICEABLE_SCARRING": "Noticeable Scarring",
"FILTER_LIVING_STATUS": "Living Status",
"FILTER_LIFE_STAGE": "Life Stage",
"FILTER_GENUS_AND_SPECIES": "Genus and Species",
Expand Down
47 changes: 41 additions & 6 deletions src/main/java/org/ecocean/Encounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void setSampleTakenForDiet(Boolean sampleTakenForDiet) {

// string descriptor of the most obvious scar (if any) as reported by the original submitter
// we also use keywords to be more specific
public String distinguishingScar = "None";
public String noticeableScar = "None";
// describes how this encounter was matched to an existing shark - by eye, by pattern recognition algorithm etc.

// SPOTS
Expand Down Expand Up @@ -1159,13 +1159,13 @@ public void setLocationCode(String newLoc) {
}

// @return the String holding specific location data used for searching
public String getDistinguishingScar() {
return distinguishingScar;
public String getNoticeableScar() {
return noticeableScar;
}

// Sets the String holding scarring information for the encounter
public void setDistinguishingScar(String scar) {
distinguishingScar = scar;
public void setNoticeableScar(String scar) {
this.noticeableScar = scar;
}

// Sets the String documenting how the size of this animal was approximated.
Expand Down Expand Up @@ -4059,7 +4059,11 @@ public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd
jgen.writeStringField("occurrenceRemarks", this.getOccurrenceRemarks());
jgen.writeStringField("otherCatalogNumbers", this.getOtherCatalogNumbers());
jgen.writeBooleanField("publiclyReadable", this.isPubliclyReadable());


String scarring = this.getNoticeableScar();
if (scarring != null) { // Only add the field if scarring is not null
jgen.writeStringField("noticeableScarring", scarring);
}
String featuredAssetId = null;
List<MediaAsset> mas = this.getMedia();
jgen.writeNumberField("numberAnnotations", this.numNonTrivialAnnotations());
Expand Down Expand Up @@ -4705,4 +4709,35 @@ public void sendCreationEmails(Shepherd myShepherd, String langCode) {
}
}

// public void opensearchIndexDeep()
// throws IOException {
// final String encId = this.getId();
// final Encounter origEnc = this;
// ExecutorService executor = Executors.newFixedThreadPool(4);
// Runnable rn = new Runnable() {
// public void run() {
// Shepherd bgShepherd = new Shepherd("context0");
// bgShepherd.setAction("Encounter.opensearchIndexDeep_" + encId);
// bgShepherd.beginDBTransaction();
// try {
// Encounter enc = bgShepherd.getEncounter(encId);
// if (enc == null) {
// // we use origEnc if we can (especially necessary on initial creation of Encounter)
// if (origEnc != null) origEnc.opensearchIndex();
// bgShepherd.rollbackAndClose();
// executor.shutdown();
// return;
// }
// enc.opensearchIndex();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// bgShepherd.rollbackAndClose();
// }
// executor.shutdown();
// }
// };

// executor.execute(rn);
// }
}
2 changes: 1 addition & 1 deletion src/main/java/org/ecocean/servlet/EncounterForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ else if (formValues.get("location") != null) {
enc.setPatterningCode(pc);
}
if (formValues.get("scars") != null) {
enc.setDistinguishingScar(formValues.get("scars").toString());
enc.setNoticeableScar(formValues.get("scars").toString());
}
int sizePeriod = 0;
if ((formValues.get("measureUnits") != null) &&
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/ecocean/servlet/EncounterSetScarring.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
String oldScar = "None";

try {
oldScar = changeMe.getDistinguishingScar();
changeMe.setDistinguishingScar(scar);
oldScar = changeMe.getNoticeableScar();
changeMe.setNoticeableScar(scar);
changeMe.addComments("<p><em>" + request.getRemoteUser() + " on " +
(new java.util.Date()).toString() +
"</em><br>Changed noticeable scarring from " + oldScar + " to " + scar +
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/ecocean/servlet/importer/WebImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ public Encounter loadEncounter(Row row, ArrayList<Annotation> annotations) {
}
Double depth = getDouble(row, "Encounter.depth");
if (depth != null) enc.setDepth(depth);
String scar = getIntAsString(row, "Encounter.distinguishingScar");
if (scar != null) enc.setDistinguishingScar(scar);
String scar = getIntAsString(row, "Encounter.noticeableScar");
if (scar != null) enc.setNoticeableScar(scar);
// SAMPLES
TissueSample sample = null;
String tissueSampleID = getStringOrInt(row, "TissueSample.sampleID");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/bundles/en/searchResults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ analysis = Analysis
export = Export
occurrenceID = Occurrence ID
sightingID = Sighting ID
NoticeableScarring = Noticeable Scarring
created = Created
editDate = Edit Date

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/org/ecocean/batch/BatchParser.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ column.encounter.releaseDate=Release Date
column.encounter.size=Size (m)
column.encounter.sizeGuess=Size Guess (m)
column.encounter.patterningCode=Pigmentation
column.encounter.distinguishingScar=Distinguishing Scars
column.encounter.noticeableScar=Noticeable Scars
column.encounter.otherCatalogNumbers=Other Catalog Numbers
column.encounter.occurrenceID=Occurrence ID
column.encounter.occurrenceRemarks=Occurrence Remarks
Expand Down Expand Up @@ -156,7 +156,7 @@ format.encounter.releaseDate=date
format.encounter.size=double
format.encounter.sizeGuess=string
format.encounter.patterningCode=string
format.encounter.distinguishingScar=string
format.encounter.noticeableScar=string
format.encounter.otherCatalogNumbers=string
format.encounter.occurrenceID=string
format.encounter.occurrenceRemarks=string
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/encounters/encounter.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -4244,7 +4244,7 @@ if(enc.getSex()!=null){sex=enc.getSex();}

<%
String recordedScarring="";
if(enc.getDistinguishingScar()!=null){recordedScarring=enc.getDistinguishingScar();}
if(enc.getNoticeableScar()!=null){recordedScarring=enc.getNoticeableScar();}
%>
<span id="displayScarring"><%=recordedScarring%></span>
<%
Expand Down Expand Up @@ -4293,7 +4293,7 @@ if(enc.getDistinguishingScar()!=null){recordedScarring=enc.getDistinguishingScar

<div class="form-group row">
<div class="col-sm-5">
<textarea name="scars" class="form-control" id="scarInput"><%=enc.getDistinguishingScar()%></textarea>
<textarea name="scars" class="form-control" id="scarInput"><%=enc.getNoticeableScar()%></textarea>
</div>
<div class="col-sm-3">
<input name="Add" type="submit" id="addScar" value="<%=encprops.getProperty("resetScarring")%>" class="btn btn-sm"/>
Expand Down