Skip to content

Commit

Permalink
Merge branch 'master' into carnivore
Browse files Browse the repository at this point in the history
  • Loading branch information
holmbergius committed Oct 26, 2023
2 parents a051e63 + 0105883 commit f8db3e1
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/ecocean/EncounterQueryProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static String queryStringBuilder(HttpServletRequest request, StringBuffer
jdoqlVariableDeclaration += ";org.ecocean.Annotation annot46;";
}
else {
jdoqlVariableDeclaration=" VARIABLES org.ecocean.Annotation annot46;";
jdoqlVariableDeclaration=" VARIABLES org.ecocean.Annotation annot46";
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.*;
import java.util.*;

import org.apache.commons.text.StringEscapeUtils;
import org.ecocean.*;
import org.ecocean.genetics.*;
import org.ecocean.servlet.ServletUtilities;
Expand All @@ -16,6 +17,8 @@

import jxl.write.*;
import jxl.Workbook;
import jxl.WorkbookSettings;

import java.lang.Boolean;


Expand Down Expand Up @@ -43,7 +46,6 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
context=ServletUtilities.getContext(request);
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("EncounterSearchExportExcelFile.class");



Vector rEncounters = new Vector();
Expand Down Expand Up @@ -91,7 +93,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER);

//let's write out headers for the OBIS export file
WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile);
WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding( "UTF-8" );
WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile,ws);
WritableSheet sheet = workbookOBIS.createSheet("Search Results", 0);
Label label0 = new Label(0, 0, "Date Last Modified");
sheet.addCell(label0);
Expand Down Expand Up @@ -245,7 +249,7 @@ else if(CommonConfiguration.getProperty("genusSpecies0",context)!=null){
sheet.addCell(lNumberx22);
}

Label lNumberx23 = new Label(22, count, enc.getLocation());
Label lNumberx23 = new Label(22, count, StringEscapeUtils.unescapeHtml4(enc.getLocation()));
sheet.addCell(lNumberx23);

//check for available locale coordinates
Expand Down Expand Up @@ -282,15 +286,15 @@ else if(CommonConfiguration.getProperty("genusSpecies0",context)!=null){
sheet.addCell(lSex);
}
if(enc.getComments()!=null){
Label lNumberx26 = new Label(26, count, enc.getComments().replaceAll("<br>", ". ").replaceAll("\n", "").replaceAll("\r", ""));
Label lNumberx26 = new Label(26, count, StringEscapeUtils.unescapeHtml4(enc.getComments().replaceAll("<br>", ". ").replaceAll("\n", "").replaceAll("\r", "")));
sheet.addCell(lNumberx26);
}
if(enc.getSizeAsDouble()!=null){
Label lNumberx27 = new Label(27, count, enc.getSizeAsDouble().toString());
sheet.addCell(lNumberx27);
}
if (enc.getIndividual()!=null) {
Label lNumberx28 = new Label(28, count, enc.getIndividual().getDisplayName(request, myShepherd));
Label lNumberx28 = new Label(28, count, StringEscapeUtils.unescapeHtml4(enc.getIndividual().getDisplayName(request, myShepherd)));
sheet.addCell(lNumberx28);
}
if (enc.getLocationCode() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.io.*;
import java.util.*;

import org.apache.commons.text.StringEscapeUtils;
import org.ecocean.*;
import org.ecocean.media.*;
import org.ecocean.genetics.*;
Expand All @@ -13,10 +15,12 @@
import java.lang.StringBuffer;
import jxl.write.*;
import jxl.Workbook;
import jxl.WorkbookSettings;

import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;


public class EncounterSearchExportMetadataExcel extends HttpServlet {


Expand Down Expand Up @@ -132,7 +136,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr


// business logic start here
WritableWorkbook excelWorkbook = Workbook.createWorkbook(excelFile);
WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding( "UTF-8" );
WritableWorkbook excelWorkbook = Workbook.createWorkbook(excelFile,ws);
WritableSheet sheet = excelWorkbook.createSheet("Search Results", 0);

List<ExportColumn> columns = new ArrayList<ExportColumn>();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/ecocean/servlet/export/ExportColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.text.StringEscapeUtils;

public class ExportColumn {

Expand Down Expand Up @@ -63,7 +64,7 @@ public String getStringValue(Object obj) throws InvocationTargetException, Illeg
if (value == null){
return null;
}
return value.toString();
return StringEscapeUtils.unescapeHtml4(value.toString());
}

public int getMeasurementNum() {return measureNum;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import jxl.write.*;
import jxl.Workbook;
import jxl.WorkbookSettings;
import org.apache.commons.text.StringEscapeUtils;


public class OccurrenceSearchExportMetadataExcel extends HttpServlet {
Expand Down Expand Up @@ -121,7 +123,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER);

//let's write out headers for the OBIS export file
WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile);
WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding( "UTF-8" );
WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile,ws);
sheet = workbookOBIS.createSheet("Search Results", 0);

String[] colHeaders = new String[]{
Expand Down Expand Up @@ -188,7 +192,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
writeCell("taxonomies", occ.getAllSpecies()); // the getAllSpecies List<String> toStrings nicely
writeCell("individualCount", occ.getIndividualCount());
writeCell("groupBehavior", occ.getGroupBehavior());
writeCell("commments", occ.getComments());
writeCell("commments", StringEscapeUtils.unescapeHtml4(occ.getComments()));
writeCell("modified", occ.getDWCDateLastModified());
writeCell("dateTimeCreated", occ.getDateTimeCreated());
writeCell("fieldStudySite", occ.getFieldStudySite());
Expand Down
28 changes: 15 additions & 13 deletions src/main/webapp/encounters/encounter.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ $(function() {
<%
//set a default date if we cann
if(enc.getDateInMilliseconds()!=null){
if(isOwner && enc.getDateInMilliseconds()!=null){
//LocalDateTime jodaTime = new LocalDateTime(enc.getDateInMilliseconds());
Expand Down Expand Up @@ -867,10 +867,9 @@ else {


<%
if(enc.getLocation()!=null){
if(isOwner && enc.getLocation()!=null){
%>

<em><%=encprops.getProperty("locationDescription")%> <span id="displayLocation"><%=enc.getLocation()%></span></em>
<em><%=encprops.getProperty("locationDescription")%> <span id="displayLocation"><%=enc.getLocation()%></span></em>
<%
}
%>
Expand All @@ -887,11 +886,14 @@ if(enc.getLocation()!=null){
List<String> hier=LocationID.getIDForChildAndParents(enc.getLocationID(), null);
int sizeHier=hier.size();
String displayPath="";
for(int q=0;q<sizeHier;q++){
if(q==0){displayPath+=LocationID.getNameForLocationID(hier.get(q),null);}
else{displayPath+=" &rarr; "+LocationID.getNameForLocationID(hier.get(q),null);}
if(isOwner || isPublic){
for(int q=0;q<sizeHier;q++){
if(q==0){displayPath+=LocationID.getNameForLocationID(hier.get(q),null);}
else{displayPath+=" &rarr; "+LocationID.getNameForLocationID(hier.get(q),null);}
}
if (!Util.stringExists(displayPath) && Util.stringExists(enc.getLocationID())) displayPath = enc.getLocationID();
}
if (!Util.stringExists(displayPath) && Util.stringExists(enc.getLocationID())) displayPath = enc.getLocationID();
%>
<%=displayPath %>
</span>
Expand All @@ -908,7 +910,7 @@ if(CommonConfiguration.showProperty("showCountry",context)){
%>

<%
if(enc.getCountry()!=null){
if(isOwner && enc.getCountry()!=null){
%>
<span>: <span id="displayCountry"><%=enc.getCountry()%></span></span>
<%
Expand Down Expand Up @@ -2331,7 +2333,7 @@ function checkIdDisplay() {
<p class="para"><h4><%=encprops.getProperty("submitter") %></h4>
<%
if(enc.getSubmitters()!=null){
if(isOwner && enc.getSubmitters()!=null){
%>
<table id="submitters" width="100%">
<tbody>
Expand Down Expand Up @@ -2415,7 +2417,7 @@ function checkIdDisplay() {
<p class="para"><h4><%=encprops.getProperty("photographer") %></h4>
<%
if(enc.getPhotographers()!=null){
if(isOwner && enc.getPhotographers()!=null){
%>
<table id="photographers" width="100%">
Expand Down Expand Up @@ -3632,7 +3634,7 @@ else {
<%}%>
<p>
<%if(enc.getDateInMilliseconds()!=null && visible){ %>
<%if(isOwner && visible && enc.getDateInMilliseconds()!=null){ %>
<a
href="//<%=CommonConfiguration.getURLLocation(request)%>/xcalendar/calendar.jsp?scDate=<%=enc.getMonth()%>/1/<%=enc.getYear()%>">
<span id="displayDate"><%=enc.getDate()%></span>
Expand All @@ -3649,7 +3651,7 @@ else {
<br />
<em><%=encprops.getProperty("verbatimEventDate")%></em>:
<%
if(enc.getVerbatimEventDate()!=null){
if(isOwner && enc.getVerbatimEventDate()!=null){
%>
<span id="displayVerbatimDate"><%=enc.getVerbatimEventDate()%></span>
<%
Expand Down
23 changes: 23 additions & 0 deletions src/main/webapp/import.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ try{
int numWithACMID=0;
int numAllowedIA=0;
int numDetectionComplete=0;
ArrayList<MediaAsset> invalidMediaAssets=new ArrayList<MediaAsset>();
for(MediaAsset asset:allAssets){
if(asset.getAcmId()!=null)numWithACMID++;
Expand All @@ -625,6 +626,10 @@ try{
}
else if(asset.validateSourceImage()){numAllowedIA++;myShepherd.updateDBTransaction();}
if(asset.isValidImageForIA() == null || !asset.isValidImageForIA().booleanValue()){
invalidMediaAssets.add(asset);
}
if(asset.getDetectionStatus()!=null && (asset.getDetectionStatus().equals("complete")||asset.getDetectionStatus().equals("pending"))) numDetectionComplete++;
}
Expand All @@ -634,6 +639,24 @@ try{
<ul>
<li>Number with acmIDs: <%=numWithACMID %></li>
<li>Number valid for image analysis: <%=numAllowedIA %></li>

<%
if("complete".equals(itask.getStatus()) && invalidMediaAssets.size()>0){
%>
<li>Number invalid for image analysis: <%=invalidMediaAssets.size()%>
<ol>
<%
for(MediaAsset inv_asset:invalidMediaAssets){
%>
<li><a target="_blank" href="obrowse.jsp?type=MediaAsset&id=<%=inv_asset.getId() %>"><%=inv_asset.getId() %></a></li>
<%
}
%>
</ol>
</li>
<%
}
%>
<li>Number that have completed detection: <%=numDetectionComplete %></li>
</ul>
</p>
Expand Down
7 changes: 6 additions & 1 deletion src/main/webapp/occurrence.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ if (!Util.collectionIsEmptyOrNull(occ.getInformOthers())) {
int total = dateSortedEncs.length;
for (int i = 0; i < total; i++) {
Encounter enc = dateSortedEncs[i];
if(ServletUtilities.isUserAuthorizedForEncounter(enc, request, myShepherd)){
%>
<tr>
Expand Down Expand Up @@ -626,7 +627,11 @@ if (!Util.collectionIsEmptyOrNull(occ.getInformOthers())) {
<%}%>
</td>
</tr>
<%} //End of loop iterating over encounters. %>
<%
}//end if user is authorized
} //End of loop iterating over encounters. %>
</table>
<!-- Start thumbnail images -->
Expand Down

0 comments on commit f8db3e1

Please sign in to comment.