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

Restore default locationID selection to bulk import #612

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
17 changes: 11 additions & 6 deletions src/main/java/org/ecocean/LocationID.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private static void recurseToFindIDStrings(JSONObject jsonobj, ArrayList<String>
/*
* Return an HTML selector of hierarchical locationIDs with indenting
*/
public static String getHTMLSelector(boolean multiselect, String selectedID, String qualifier,
public static String getHTMLSelector(boolean multiselect, List<String> selectedIDs, String qualifier,
String htmlID, String htmlName, String htmlClass) {
String multiselector = "";

Expand All @@ -338,22 +338,27 @@ public static String getHTMLSelector(boolean multiselect, String selectedID, Str
htmlName + "\" id=\"" + htmlID + "\" class=\"" + htmlClass + "\" " + multiselector +
">\n\r<option value=\"\"></option>\n\r");

createSelectorOptions(getLocationIDStructure(qualifier), selector, 0, selectedID);
createSelectorOptions(getLocationIDStructure(qualifier), selector, 0, selectedIDs);

selector.append("</select>\n\r");
return selector.toString();
}

public static String getHTMLSelector(boolean multiselect, String selectedID, String qualifier, String htmlID, String htmlName, String htmlClass) {
ArrayList<String> locationIDs = new ArrayList<String>();
locationIDs.add(selectedID);
return getHTMLSelector(multiselect, locationIDs, qualifier, htmlID, htmlName, htmlClass);
}

private static void createSelectorOptions(JSONObject jsonobj, StringBuffer selector,
int nestingLevel, String selectedID) {
private static void createSelectorOptions(JSONObject jsonobj, StringBuffer selector, int nestingLevel, List<String> selectedIDs) {
int localNestingLevel = nestingLevel;
String selected = "";
String spacing = "";

for (int i = 0; i < localNestingLevel; i++) { spacing += "&nbsp;&nbsp;&nbsp;"; }
// see if we can add this item to the list
try {
if (selectedID != null && jsonobj.getString("id").equals(selectedID))
if (selectedIDs != null && selectedIDs.contains(jsonobj.getString("id")))
selected = " selected=\"selected\"";
selector.append("<option value=\"" + jsonobj.getString("id") + "\" " + selected + ">" +
spacing + jsonobj.getString("name") + "</option>\n\r");
Expand All @@ -365,7 +370,7 @@ private static void createSelectorOptions(JSONObject jsonobj, StringBuffer selec
int numLocs = locs.length();
for (int i = 0; i < numLocs; i++) {
JSONObject loc = locs.getJSONObject(i);
createSelectorOptions(loc, selector, localNestingLevel, selectedID);
createSelectorOptions(loc, selector, localNestingLevel, selectedIDs);
}
} catch (JSONException e) {}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/import.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ try{
}


Set<String> locationIds = new HashSet<String>();
ArrayList<String> locationIds = new ArrayList<String>();

out.println("<p><b style=\"font-size: 1.2em;\">Import Task " + itask.getId() + "</b> (" + itask.getCreated().toString().substring(0,10) + ") <a class=\"button\" href=\"imports.jsp\">back to list</a></p>");
out.println("<br>Data Import Status: <em>"+itask.getStatus()+"</em>");
Expand Down Expand Up @@ -447,7 +447,7 @@ try{
ArrayList<MediaAsset> fixACMIDAssets=new ArrayList<MediaAsset>();

JSONArray jarr=new JSONArray();
if (enc.getLocationID() != null) locationIds.add(enc.getLocationID());
if (enc.getLocationID() != null && !locationIds.contains(enc.getLocationID())) locationIds.add(enc.getLocationID());
out.println("<tr>");
out.println("<td><a title=\"" + enc.getCatalogNumber() + "\" href=\"encounters/encounter.jsp?number=" + enc.getCatalogNumber() + "\">" + enc.getCatalogNumber().substring(0,8) + "</a></td>");
out.println("<td>" + enc.getDate() + "</td>");
Expand Down Expand Up @@ -891,7 +891,7 @@ try{
%>
<div style="margin-bottom: 20px;">
<a class="button" style="margin-left: 20px;" onClick="resendToID(); return false;">Send to identification</a> matching against <b>location(s):</b>
<%=LocationID.getHTMLSelector(true, null, null, "id-locationids", "locationID", "") %>
<%=LocationID.getHTMLSelector(true, locationIds, null, "id-locationids", "locationID", "") %>
</div>

<%
Expand Down
Loading