Skip to content

Commit 091bdbb

Browse files
committed
Specimen Upload mechanism public
1 parent 567e112 commit 091bdbb

6 files changed

Lines changed: 92 additions & 166 deletions

File tree

src/org/calacademy/antweb/Login.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ public Boolean isUploadImages() {
136136
public void setIsUploadImages(boolean isUploadImages) {
137137
this.isUploadImages = isUploadImages;
138138
}
139-
139+
140+
private String uploadAs = null;
141+
public void setUploadAs(String uploadAs) {
142+
this.uploadAs = uploadAs;
143+
}
144+
public String getUploadAs() {
145+
return uploadAs;
146+
}
140147

141148
public ArrayList<SpeciesListable> getProjects() {
142149
return projects;

src/org/calacademy/antweb/curate/login/SaveLoginAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm f,
7777
login.setIsAdmin(form.isAdmin());
7878
login.setIsUploadSpecimens(form.isUploadSpecimens());
7979
login.setIsUploadImages(form.isUploadImages());
80+
login.setUploadAs(form.getUploadAs());
8081

8182
// Handle Projects Access
8283
String[] projects = form.getProjects();

src/org/calacademy/antweb/curate/login/SaveLoginForm.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ public void setChangePassword(String changePassword) {
154154
this.changePassword = changePassword;
155155
}
156156

157+
private String uploadAs;
158+
public String getUploadAs() {
159+
return uploadAs;
160+
}
161+
public void setUploadAs(String uploadAs) {
162+
this.uploadAs = uploadAs;
163+
}
164+
165+
157166
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
158167

159168
ActionErrors errors = null;

src/org/calacademy/antweb/home/LoginDb.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ private Curator instantiateCurator(ResultSet rset)
216216
login.setIsUploadSpecimens(rset.getBoolean("is_upload_specimens"));
217217
login.setIsUploadImages(rset.getBoolean("is_upload_images"));
218218

219+
login.setUploadAs(rset.getString("upload_as"));
220+
219221
if (login.getId() == 0) return null;
220222
return login;
221223
}
@@ -260,6 +262,8 @@ private Login instantiate(Login login, ResultSet rset)
260262
//curator.getGroup().setCurator(curator); // backwards, but allows code to remain unchanged.
261263
login.setIsUploadSpecimens(rset.getBoolean("is_upload_specimens"));
262264
login.setIsUploadImages(rset.getBoolean("is_upload_images"));
265+
266+
login.setUploadAs(rset.getString("upload_as"));
263267
}
264268
return login;
265269
}
@@ -493,8 +497,8 @@ public void saveLogin(Login login) throws SQLException, AntwebException {
493497
}
494498

495499
String theInsert = "insert into login" +
496-
" (id, name, first_name, last_name, email, password, group_id, is_admin, is_upload_specimens, is_upload_images)" +
497-
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
500+
" (id, name, first_name, last_name, email, password, group_id, is_admin, is_upload_specimens, is_upload_images, upload_as)" +
501+
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
498502

499503
//s_log.info("saveLogin() insert:" + theInsert);
500504

@@ -514,6 +518,7 @@ public void saveLogin(Login login) throws SQLException, AntwebException {
514518
stmt.setInt(8, isAdmin);
515519
stmt.setInt(9, uploadSpecimens);
516520
stmt.setInt(10, uploadImages);
521+
stmt.setString(11, login.getUploadAs());
517522

518523
stmt.executeUpdate();
519524
//s_log.warn("saveLogin() isAdmin:" + login.isAdmin() + " projects:" + login.getProjects());
@@ -592,7 +597,7 @@ public void updateLogin(Login login, Login accessLogin) throws SQLException {
592597
stmt.setInt(6, login.getId());
593598
} else if (isAdminUpdate && !isSelfUpdate) {
594599
String adminUpdate = "update login "
595-
+ "set name = ?, first_name = ?, last_name = ?, email = ?, group_id = ?, is_admin = ?, is_upload_specimens = ?, is_upload_images = ? "
600+
+ "set name = ?, first_name = ?, last_name = ?, email = ?, group_id = ?, is_admin = ?, is_upload_specimens = ?, is_upload_images = ?, upload_as = ? "
596601
+ "where id = ?";
597602

598603
theUpdate = adminUpdate;
@@ -606,10 +611,11 @@ public void updateLogin(Login login, Login accessLogin) throws SQLException {
606611
stmt.setInt(6, isAdmin);
607612
stmt.setInt(7, uploadSpecimens);
608613
stmt.setInt(8, uploadImages);
609-
stmt.setInt(9, login.getId());
614+
stmt.setString(9, login.getUploadAs());
615+
stmt.setInt(10, login.getId());
610616
} else if (isAdminUpdate && isSelfUpdate) {
611617
String adminSelfUpdate = "update login "
612-
+ "set name = ?, first_name = ?, last_name = ?, email = ?, password = ?, group_id = ?, is_admin = ?, is_upload_specimens = ?, is_upload_images = ? "
618+
+ "set name = ?, first_name = ?, last_name = ?, email = ?, password = ?, group_id = ?, is_admin = ?, is_upload_specimens = ?, is_upload_images = ?, upload_as = ? "
613619
+ "where id = ?";
614620

615621
theUpdate = adminSelfUpdate;
@@ -624,7 +630,8 @@ public void updateLogin(Login login, Login accessLogin) throws SQLException {
624630
stmt.setInt(7, isAdmin);
625631
stmt.setInt(8, uploadSpecimens);
626632
stmt.setInt(9, uploadImages);
627-
stmt.setInt(10, login.getId());
633+
stmt.setString(10, login.getUploadAs());
634+
stmt.setInt(11, login.getId());
628635
}
629636

630637
//A.log("updateLogin() update:" + DBUtil.getPreparedStatementString(stmt));

web/curate/curate-body.jsp

Lines changed: 53 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -132,71 +132,74 @@ Need Help? Check out the <a href="<%= domainApp %>/documentation.do" target="new
132132
}
133133
if (!takeDownUpload || LoginMgr.isAdmin(accessLogin)) { %>
134134

135-
<html:form method="POST" action="upload.do" enctype="multipart/form-data">
136-
<input type="hidden" name="ancFileDirectory" value="none" />
137-
<input type="hidden" name="action" value="specimenUpload" />
138-
<input type="hidden" name="updateAdvanced" value="no" />
139-
<input type="hidden" name="updateFieldGuide" value="none" />
140-
<input type="hidden" name="images" value="no" />
141-
<input type="hidden" name="outputFileName" value="" />
142-
<input type="hidden" name="successkey" value="null" />
143-
<input type="hidden" name="updateAdvanced" value="yes" />
144-
145135
<div class="admin_action_item">
146136
<div style="float:left;">
147137
<h2>Specimen Data</h2>
148138
</div>
149139
<div class="clear"></div>
150140
</div>
151141

152-
<div class="admin_action_item">
153-
<br><div class="action_desc"><b>Upload</b> Specimen File:<br>&nbsp;&nbsp;&nbsp;(tab-delimited .txt file)</div>
154-
<div class="action_dropdown"></div>
155-
<div class="action_browse">
156-
<html:file property="theFile" />
157-
</div>
158-
<div class="clear"></div>
142+
<!-- Universal Specimen Upload -->
143+
<!-- Antweb, TaxonWorks, or GBIF Specimen (file or Zip File) Upload -->
159144

160-
<% if (AntwebProps.isDevMode()) {
161-
if (true) { %>
162-
<div class="align_left">
163-
<select name="specimenUploadType">
164-
<option value="full" selected>Full
165-
<option value="incremental">Incremental
166-
<option value="diff">Diff
167-
<option value="augment">Augment
168-
</select><br>
169-
</div>
170-
<% } else { %>
171-
<div class="admin_action_item">
172-
<html:checkbox property="whole" value="true"/> Update entire the biota file
173-
</div>
174-
<% } %>
175-
<% } else { %>
176-
<input type="hidden" name="whole" value="true" />
177-
<% } %>
178-
179-
<% if (false && LoginMgr.isCurator(accessLogin)) { // || accessLogin.getId() == 16) { // || accessLogin.getId() == 338 %>
180-
<div class="align_left">
181-
<select name="encoding">
182-
<option value="default" selected>Default
183-
<option value="UTF-8">UTF-8
184-
<option value="MacRoman">MacRoman
185-
<option value="ISO8859_1">ISO8859_1
145+
<html:form method="POST" action="upload.do" enctype="multipart/form-data">
146+
147+
<div class="admin_action_item">
148+
<br>
149+
<div class="action_desc"><b>Upload</b> Specimen File or Zip File:<br>&nbsp;&nbsp;&nbsp;</div>
150+
<div class="action_browse">
151+
<html:file property="theFile" />
152+
</div>
153+
<div class="clear"></div>
154+
155+
<%
156+
if (LoginMgr.isAdmin(accessLogin)) { %>
157+
158+
<div class="align_left">
159+
&nbsp;&nbsp;Upload Type:
160+
<select name="action">
161+
<option value="specimenUpload" selected>Antweb
162+
<option value="taxonWorksUpload">TaxonWorks
163+
<option value="GBIFUpload">GBIF
186164
</select>
187-
</div>
188-
<% } %>
165+
</div>
189166

190-
To calculate the taxon children counts run the <a href='<%= domainApp %>/utilData.do?action=runCountCrawls' title="If taxon children counts are not calculated subsequent to the upload, it will happen nightly.">Count Crawls<img src=<%= domainApp%>/image/new1.png width=20></a>
191-
<br>If not returned an upload report, find it in the <a href='<%= domainApp %>/listSpecimenUploads.do?groupId=<%= accessGroup.getId() %>'>Specimen Upload Reports</a>.
167+
<div class="align_left">
168+
&nbsp;&nbsp;Upload as:
169+
<select name="uploadAs">
170+
<option value="<%= accessLogin.getId() %>" selected><%= accessLogin.getName() %>
192171

172+
<%
173+
String uploadAs = accessLogin.getUploadAs();
174+
if (uploadAs != null) {
175+
List<String> curatorList = new ArrayList<String>(Arrays.asList(uploadAs.split(",")));
176+
for (String curatorIdStr : curatorList) {
177+
int curatorId = Integer.parseInt((curatorIdStr.trim()));
178+
Login curator = LoginMgr.getCurator(curatorId);
179+
%>
180+
<option value="<%= curator.getId() %>"><%= curator.getName() %>
181+
<% } %>
182+
</select>
183+
</div>
193184

194-
<div class="align_right"><input border="0" type="image" src="<%= domainApp %>/image/grey_submit.png" width="77" height="23" value="Submit" <%= active %>></div>
195-
<div class="clear"></div>
196-
</div>
185+
<% } %>
186+
<% } else { %>
187+
<input type="hidden" name="action" value="specimenUpload" />
188+
<input type="hidden" name="specimenUploadLoginId" value="<%= accessLogin.getId() %>" />
189+
190+
<% } %>
197191

192+
<div class="align_right"><input border="0" type="image" src="<%= domainApp %>/image/grey_submit.png" width="77" height="23" value="Submit" <%= active %>></div>
193+
<div class="clear">
194+
To calculate the taxon children counts run the <a href='<%= domainApp %>/utilData.do?action=runCountCrawls' title="If taxon children counts are not calculated subsequent to the upload, it will happen nightly.">Count Crawls<img src=<%= domainApp%>/image/new1.png width=20></a>
195+
<br>If not returned an upload report, find it in the <a href='<%= domainApp %>/listSpecimenUploads.do?groupId=<%= accessGroup.getId() %>'>Specimen Upload Reports</a>. <br><br>
196+
</div>
197+
</div>
198198
</html:form>
199199

200+
<!-- End Specimen file or Zip File Upload -->
201+
202+
200203
<!-- Reload Specimen Data -->
201204

202205
<div class="admin_action_module">
@@ -343,115 +346,6 @@ To calculate the taxon children counts run the <a href='<%= domainApp %>/utilDat
343346
</div>
344347
</html:form>
345348

346-
347-
<!-- TaxonWorks Specimen Zip File Upload -->
348-
<% if (AntwebProps.isDevMode() || GroupMgr.isCAS(accessGroup)) { %>
349-
<html:form method="POST" action="upload.do" enctype="multipart/form-data">
350-
<input type="hidden" name="action" value="taxonWorksUpload" />
351-
352-
<div class="admin_action_item">
353-
<div class="action_desc"><b>Upload</b> TaxonWorks Specimen Zip File:<br>&nbsp;&nbsp;&nbsp;(w/ tab-delimited .tsv file)</div>
354-
<div class="action_browse">
355-
<html:file property="theFile" />
356-
</div>
357-
<div class="clear"></div>
358-
359-
<input type="hidden" name="whole" value="true" />
360-
361-
<div class="align_right"><input border="0" type="image" src="<%= domainApp %>/image/grey_submit.png" width="77" height="23" value="Submit" <%= active %>></div>
362-
<div class="clear"></div>
363-
</div>
364-
</html:form>
365-
366-
<!-- End TaxonWorks Specimen Zip File Upload -->
367-
<% } %>
368-
369-
370-
<!-- GBIF Specimen Zip File Upload -->
371-
<% if (GroupMgr.isCAS(accessGroup) || LoginMgr.isMingnaUtep(accessLogin)) { %>
372-
<!-- GBIF Specimen file or Zip File Upload -->
373-
374-
<html:form method="POST" action="upload.do" enctype="multipart/form-data">
375-
<input type="hidden" name="action" value="GBIFUpload" />
376-
377-
<div class="admin_action_item">
378-
<div class="action_desc"><b>Upload</b> GBIF Specimen File or Zip File:<br>&nbsp;&nbsp;&nbsp;</div>
379-
<div class="action_browse">
380-
<html:file property="theFile" />
381-
</div>
382-
<div class="clear"></div>
383-
384-
<input type="hidden" name="whole" value="true" />
385-
386-
<div class="align_right"><input border="0" type="image" src="<%= domainApp %>/image/grey_submit.png" width="77" height="23" value="Submit" <%= active %>></div>
387-
<div class="clear"></div>
388-
</div>
389-
</html:form>
390-
391-
<!-- End GBIF Specimen file or Zip File Upload -->
392-
<% } %>
393-
394-
<div class="admin_action_item">
395-
<br><b><small>Testing: For Admin only:</small></b>
396-
</div>
397-
398-
399-
<!-- Universal Specimen Upload -->
400-
<% if (AntwebProps.isDevMode() || LoginMgr.isAdmin(accessLogin)) { %>
401-
<!-- Antweb, TaxonWorks, or GBIF Specimen (file or Zip File) Upload -->
402-
403-
<html:form method="POST" action="upload.do" enctype="multipart/form-data">
404-
405-
<div class="admin_action_item">
406-
<div class="action_desc"><b>Upload</b> Specimen File or Zip File:<br>&nbsp;&nbsp;&nbsp;</div>
407-
<div class="action_browse">
408-
<html:file property="theFile" />
409-
</div>
410-
<div class="clear"></div>
411-
412-
<% if (LoginMgr.isAdmin(accessLogin)) { %>
413-
414-
<div class="align_left">
415-
&nbsp;&nbsp;Upload Type:
416-
<select name="action">
417-
<option value="specimenUpload" selected>Antweb
418-
<option value="taxonWorksUpload">TaxonWorks
419-
<option value="GBIFUpload">GBIF
420-
</select>
421-
</div>
422-
423-
<div class="align_left">
424-
&nbsp;&nbsp;Upload as:
425-
<select name="uploadAs">
426-
<option value="<%= accessLogin.getId() %>" selected><%= accessLogin.getName() %>
427-
<option value="23">Michele
428-
<option value="9716">Mingna
429-
</select>
430-
</div>
431-
432-
<% } else { %>
433-
<input type="hidden" name="specimenUploadLoginId" value="<%= accessLogin.getId() %>" />
434-
435-
<!-- How do we know what upload file options a user has? Do we discern by file type or specify?
436-
i.e. Minga is always GBIF?
437-
-->
438-
439-
<% } %>
440-
441-
442-
443-
<div class="align_right"><input border="0" type="image" src="<%= domainApp %>/image/grey_submit.png" width="77" height="23" value="Submit" <%= active %>></div>
444-
<div class="clear"></div>
445-
</div>
446-
</html:form>
447-
448-
<!-- End GBIF Specimen file or Zip File Upload -->
449-
<% } %>
450-
451-
452-
453-
454-
455349
<% } %> <!-- takeDownUpload -->
456350
<% } %> <!-- accessLogin.isUploadSpecimens() -->
457351

web/curate/viewLogin-body.jsp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
boolean isSelf = (accessLogin.getId() == thisLogin.getId());
4141
ArrayList<Group> groups = (ArrayList) request.getSession().getAttribute("antwebGroups");
4242
43+
A.log("viewLogin-body.jsp uploadAs:" + thisLogin.getUploadAs());
4344
%>
4445

4546
<div class=admin_left>
@@ -194,6 +195,13 @@ NOTE: These will not be modified unless "Changed Password" button is selected.
194195
<input type="checkbox" name="isUploadImages" <%= (thisLogin.isUploadImages() == true)?"checked":"" %> <%= (accessLogin.isAdmin()) ? "" : " disabled" %>>
195196
</h3>
196197

198+
<% if (LoginMgr.isAdmin(accessLogin)) { %>
199+
<br>
200+
<H3>Upload As (comma separated list of curator IDs):
201+
<input type="text" name="uploadAs" <%= (LoginMgr.isAdmin(accessLogin)) ? "" : " disabled" %> value="<%= thisLogin.getUploadAs() %>">
202+
</h3>
203+
<% } %>
204+
197205
<input type="hidden" name="id" value="<%= thisLogin.getId() %>">
198206
<logic:present parameter="isNewLogin">
199207
<input type="hidden" name="newLogin" value="true">

0 commit comments

Comments
 (0)