mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #6 from lap82/DS-1252-bte
Fix for IE10, add fuuid to send all itemlookup uuid
This commit is contained in:
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.hwpf.model.Ffn;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
@@ -120,6 +121,7 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
String autori = request.getParameter("search_authors");
|
||||
String uuidSubmission = request.getParameter("suuid");
|
||||
String uuidLookup = request.getParameter("iuuid");
|
||||
String fuuidLookup = request.getParameter("fuuid");
|
||||
|
||||
if (StringUtils.isBlank(uuidSubmission))
|
||||
{
|
||||
@@ -133,16 +135,16 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
{
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
|
||||
|
||||
ItemSubmissionLookupDTO itemLookup = null;
|
||||
if (StringUtils.isNotBlank(uuidLookup))
|
||||
{
|
||||
itemLookup = submissionDTO.getLookupItem(uuidLookup);
|
||||
if (itemLookup == null)
|
||||
{
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
}
|
||||
if (fuuidLookup == null || fuuidLookup.isEmpty()) {
|
||||
if (StringUtils.isNotBlank(uuidLookup)) {
|
||||
itemLookup = submissionDTO.getLookupItem(uuidLookup);
|
||||
if (itemLookup == null) {
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if the user didn't select a collection,
|
||||
// send him/her back to "select a collection" page
|
||||
if (id < 0)
|
||||
@@ -168,15 +170,21 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ItemSubmissionLookupDTO dto = null;
|
||||
List<ItemSubmissionLookupDTO> dto = new ArrayList<ItemSubmissionLookupDTO>();
|
||||
|
||||
if (itemLookup != null)
|
||||
{
|
||||
dto = itemLookup;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dto.add(itemLookup);
|
||||
} else if (fuuidLookup != null) {
|
||||
String[] ss = fuuidLookup.split(",");
|
||||
for(String s : ss) {
|
||||
itemLookup = submissionDTO.getLookupItem(s);
|
||||
if (itemLookup == null) {
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
dto.add(itemLookup);
|
||||
}
|
||||
} else {
|
||||
SubmissionLookupPublication manualPub = new SubmissionLookupPublication(
|
||||
SubmissionLookupService.MANUAL_USER_INPUT);
|
||||
manualPub.add("title", titolo);
|
||||
@@ -198,7 +206,7 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
}
|
||||
List<Record> publications = new ArrayList<Record>();
|
||||
publications.add(manualPub);
|
||||
dto = new ItemSubmissionLookupDTO(publications);
|
||||
dto.add(new ItemSubmissionLookupDTO(publications));
|
||||
|
||||
}
|
||||
|
||||
@@ -207,14 +215,14 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
TransformationEngine transformationEngine = slService.getPhase2TransformationEngine();
|
||||
if (transformationEngine != null){
|
||||
SubmissionItemDataLoader dataLoader = (SubmissionItemDataLoader)transformationEngine.getDataLoader();
|
||||
dataLoader.setDtoList(Arrays.asList(new ItemSubmissionLookupDTO[]{dto}));
|
||||
dataLoader.setDtoList(dto);
|
||||
//dataLoader.setProviders()
|
||||
|
||||
DSpaceWorkspaceItemOutputGenerator outputGenerator = (DSpaceWorkspaceItemOutputGenerator)transformationEngine.getOutputGenerator();
|
||||
outputGenerator.setCollection(col);
|
||||
outputGenerator.setContext(context);
|
||||
outputGenerator.setFormName(inputSet.getFormName());
|
||||
outputGenerator.setDto(dto);
|
||||
outputGenerator.setDto(dto.get(0));
|
||||
|
||||
try {
|
||||
transformationEngine.transform(new TransformationSpec());
|
||||
|
@@ -68,6 +68,7 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
SubmissionLookupDTO subDTO = service.getSubmissionLookupDTO(req, suuid);
|
||||
// Check that we have a file upload request
|
||||
boolean isMultipart = ServletFileUpload.isMultipartContent(req);
|
||||
boolean isTestMultipart = false;
|
||||
if ("identifiers".equalsIgnoreCase(req.getParameter("type"))) {
|
||||
Map<String, Set<String>> identifiers = new HashMap<String, Set<String>>();
|
||||
Enumeration e = req.getParameterNames();
|
||||
@@ -166,6 +167,102 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
Map<String, Object> dto = getDetails(subDTO.getLookupItem(i_uuid),
|
||||
context);
|
||||
serializer.deepSerialize(dto, resp.getWriter());
|
||||
} else if (isTestMultipart) { //FIXME remove this in release version
|
||||
|
||||
// Create a factory for disk-based file items
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
// Create a new file upload handler
|
||||
//ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
// Parse the request
|
||||
List<FileItem> items;
|
||||
Map<String, String> valueMap = new HashMap<String, String>();
|
||||
InputStream io = null;
|
||||
|
||||
// Create a new file upload handler
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
// Parse the request
|
||||
FileItemIterator iter;
|
||||
try {
|
||||
iter = upload.getItemIterator(req);
|
||||
while (iter.hasNext()) {
|
||||
FileItemStream item = iter.next();
|
||||
String name = item.getFieldName();
|
||||
InputStream stream = item.openStream();
|
||||
if (item.isFormField()) {
|
||||
String value = Streams.asString(stream);
|
||||
valueMap.put(name, value);
|
||||
} else {
|
||||
io = stream;
|
||||
// Process the input stream
|
||||
}
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
Map<String, Set<String>> identifiers = new HashMap<String, Set<String>>();
|
||||
Set<String> aa = new HashSet<String>();
|
||||
aa.add("arXiv:1302.1497");
|
||||
aa.add("arXiv:hep-lat/0105002");
|
||||
// Set<String> aaa = new HashSet<String>();
|
||||
// aaa.add("20524090");
|
||||
identifiers.put("arxiv", aa);
|
||||
// identifiers.put("pubmed", aaa);
|
||||
|
||||
suuid = valueMap.get("s_uuid");
|
||||
subDTO = service.getSubmissionLookupDTO(req, suuid);
|
||||
|
||||
List<ItemSubmissionLookupDTO> result = new ArrayList<ItemSubmissionLookupDTO>();
|
||||
|
||||
TransformationEngine transformationEngine = service
|
||||
.getPhase1TransformationEngine();
|
||||
if (transformationEngine != null) {
|
||||
MultipleSubmissionLookupDataLoader dataLoader = (MultipleSubmissionLookupDataLoader) transformationEngine
|
||||
.getDataLoader();
|
||||
dataLoader.setIdentifiers(identifiers);
|
||||
|
||||
try {
|
||||
log.debug("BTE transformation is about to start!");
|
||||
transformationEngine.transform(new TransformationSpec());
|
||||
log.debug("BTE transformation finished!");
|
||||
|
||||
SubmissionLookupOutputGenerator outputGenerator = (SubmissionLookupOutputGenerator) transformationEngine
|
||||
.getOutputGenerator();
|
||||
result = outputGenerator.getDtoList();
|
||||
} catch (BadTransformationSpec e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (MalformedSourceException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
subDTO.setItems(result);
|
||||
|
||||
service.storeDTOs(req, suuid, subDTO);
|
||||
List<Map<String, Object>> dto = getLightResultList(result);
|
||||
if (valueMap.containsKey("skip_loader")) {
|
||||
if (valueMap.get("skip_loader").equals("true")) {
|
||||
Map<String, Object> skip = new HashMap<String, Object>();
|
||||
skip.put(
|
||||
"skip",
|
||||
Boolean.TRUE);
|
||||
skip.put(
|
||||
"uuid",
|
||||
valueMap.containsKey("s_uuid") ? suuid
|
||||
: -1);
|
||||
skip.put(
|
||||
"collectionid",
|
||||
valueMap.containsKey("collectionid") ? valueMap
|
||||
.get("collectionid") : -1);
|
||||
dto.add(skip);
|
||||
}
|
||||
}
|
||||
|
||||
JSONSerializer serializer = new JSONSerializer();
|
||||
serializer.rootName("result");
|
||||
serializer.deepSerialize(dto, resp.getWriter());
|
||||
resp.setContentType("text/plain");
|
||||
} else if (isMultipart) {
|
||||
|
||||
// Create a factory for disk-based file items
|
||||
@@ -195,7 +292,9 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
|
||||
suuid = valueMap.get("s_uuid");
|
||||
subDTO = service.getSubmissionLookupDTO(req, suuid);
|
||||
|
||||
List<ItemSubmissionLookupDTO> result = new ArrayList<ItemSubmissionLookupDTO>();
|
||||
|
||||
TransformationEngine transformationEngine = service
|
||||
@@ -217,7 +316,7 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
}
|
||||
}
|
||||
subDTO.setItems(result);
|
||||
service.storeDTOs(req, valueMap.get("s_uuid"), subDTO);
|
||||
service.storeDTOs(req, suuid, subDTO);
|
||||
List<Map<String, Object>> dto = getLightResultList(result);
|
||||
if (valueMap.containsKey("skip_loader")) {
|
||||
if (valueMap.get("skip_loader").equals("true")) {
|
||||
@@ -227,7 +326,7 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
Boolean.TRUE);
|
||||
skip.put(
|
||||
"uuid",
|
||||
valueMap.containsKey("s_uuid") ? valueMap.get("s_uuid")
|
||||
valueMap.containsKey("s_uuid") ? suuid
|
||||
: -1);
|
||||
skip.put(
|
||||
"collectionid",
|
||||
|
@@ -113,14 +113,6 @@ submissionLookupShowResult = function(info){
|
||||
j('#result-list').html(" ");
|
||||
for (var i=0;i<info.result.length;i++)
|
||||
{
|
||||
if(info.result[i].skip==true) {
|
||||
//skip details
|
||||
j('#collectionid').val(info.result[i].collectionid);
|
||||
j('#suuid').val(info.result[i].uuid);
|
||||
j('#form-submission').submit();
|
||||
return false;
|
||||
}
|
||||
|
||||
var bt = j('<button class="btn btn-info" type="button">').append(j('#jsseedetailsbuttonmessage').text());
|
||||
var par = j('<p class="sl-result">');
|
||||
var divImg = j('<div class="submission-lookup-providers">');
|
||||
@@ -194,9 +186,10 @@ submissionLookupShowDetails = function(info){
|
||||
});
|
||||
modalfooter.append(start);
|
||||
j('#loading-details').modal('show');
|
||||
}
|
||||
};
|
||||
|
||||
submissionLookupPreview = function(){
|
||||
submissionLookupFile = function(form){
|
||||
|
||||
|
||||
var suuidVal = j('#suuid').val();
|
||||
var suuid = j('<input type="hidden" name="s_uuid" value="'+suuidVal+'">');
|
||||
@@ -213,39 +206,86 @@ submissionLookupPreview = function(){
|
||||
var provider_loaderVal = j('#provider_loader').val();
|
||||
var provider_loader = j('<input type="hidden" name="provider_loader" value="'+provider_loaderVal+'">');
|
||||
|
||||
var iframe = j('<iframe name="postiframe" id="postiframe" style="display: none" />');
|
||||
|
||||
j("body").append(iframe);
|
||||
|
||||
var form = j('#form-loader');
|
||||
form.attr("action", dspaceContextPath+"/json/submissionLookup");
|
||||
form.attr("method", "post");
|
||||
form.attr("enctype", "multipart/form-data");
|
||||
form.attr("encoding", "multipart/form-data");
|
||||
form.attr("target", "postiframe");
|
||||
form.attr("file", j('#file_upload').val());
|
||||
j(form).append(suuid);
|
||||
j(form).append(collectionid);
|
||||
j(form).append(preview_loader);
|
||||
j(form).append(provider_loader);
|
||||
form.submit();
|
||||
|
||||
j("#postiframe").load(function () {
|
||||
var iframeContents = j("#postiframe")[0].contentWindow.document.body.innerHTML;
|
||||
j('#iframecontent').html(iframeContents);
|
||||
var json = j.parseJSON(j("#iframecontent").text());
|
||||
if (json == null || json.result == null || json.result.length == 0)
|
||||
{
|
||||
j('#result-list').hide();
|
||||
j('#empty-result').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
submissionLookupShowResult(json);
|
||||
}
|
||||
j('#loading-file-result').modal("hide");
|
||||
j('#tabs').find('a[href="#tabs-result"]').click();
|
||||
});
|
||||
j('#loading-file-result').modal("show");
|
||||
// Create the iframe...
|
||||
var iframe = j('<iframe name="upload_iframe" id="upload_iframe" style="display: none" />');
|
||||
// Add to document...
|
||||
j("body").append(iframe);
|
||||
window.frames['upload_iframe'].name = "upload_iframe";
|
||||
|
||||
}
|
||||
iframeId = document.getElementById("upload_iframe");
|
||||
|
||||
// Add event...
|
||||
var eventHandler = function () {
|
||||
|
||||
if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
|
||||
else iframeId.removeEventListener("load", eventHandler, false);
|
||||
|
||||
// Message from server...
|
||||
if (iframeId.contentDocument) {
|
||||
content = iframeId.contentDocument.body.innerHTML;
|
||||
} else if (iframeId.contentWindow) {
|
||||
content = iframeId.contentWindow.document.body.innerHTML;
|
||||
} else if (iframeId.document) {
|
||||
content = iframeId.document.body.innerHTML;
|
||||
}
|
||||
j('#iframecontent').html(content);
|
||||
var clickResultTab = true;
|
||||
var index = 0;
|
||||
var iindex = new Array();
|
||||
var json = j.parseJSON(j("#iframecontent").text());
|
||||
if (json == null || json.result == null || json.result.length == 0)
|
||||
{
|
||||
j('#result-list').hide();
|
||||
j('#empty-result').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < json.result.length; i++) {
|
||||
if (json.result[i].skip == true) {
|
||||
clickResultTab = false;
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
iindex[i] = json.result[i].uuid;
|
||||
}
|
||||
}
|
||||
if (clickResultTab) {
|
||||
submissionLookupShowResult(json);
|
||||
j('#loading-file-result').modal("hide");
|
||||
j('#tabs').find('a[href="#tabs-result"]').click();
|
||||
} else {
|
||||
// skip details
|
||||
j('#collectionid').val(json.result[index].collectionid);
|
||||
j('#suuid').val(json.result[index].uuid);
|
||||
j('#fuuid').val(iindex);
|
||||
j('#form-submission').submit();
|
||||
return false;
|
||||
}
|
||||
// Del the iframe...
|
||||
j('upload_iframe').empty();
|
||||
};
|
||||
|
||||
if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
|
||||
if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
|
||||
|
||||
// Set properties of form...
|
||||
form.attr("target", "upload_iframe");
|
||||
form.attr("action", dspaceContextPath+"/json/submissionLookup");
|
||||
form.attr("method", "post");
|
||||
form.attr("enctype", "multipart/form-data");
|
||||
form.attr("encoding", "multipart/form-data");
|
||||
form.attr("target", "upload_iframe");
|
||||
form.attr("file", j('#file_upload').val());
|
||||
j(form).append(suuid);
|
||||
j(form).append(collectionid);
|
||||
j(form).append(preview_loader);
|
||||
j(form).append(provider_loader);
|
||||
// Submit the form...
|
||||
form.submit();
|
||||
|
||||
j('#loading-file-result').modal("show");
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -124,6 +124,7 @@
|
||||
<form class="form-horizontal" id="form-submission" action="" method="post">
|
||||
<input type="hidden" id="suuid" name="suuid" value="<%= uuid %>"/>
|
||||
<input type="hidden" id="iuuid" name="iuuid" value=""/>
|
||||
<input type="hidden" id="fuuid" name="fuuid" value=""/>
|
||||
<input type="hidden" id="collectionid" name="collectionid" value=""/>
|
||||
|
||||
<div id="tabs-search-accordion">
|
||||
@@ -259,6 +260,9 @@
|
||||
<div id="manual-accordion"> </div>
|
||||
</div>
|
||||
</form>
|
||||
<form id="form-loader" action="" method="post">
|
||||
</form>
|
||||
<div id="iframecontent" style="display: none"></div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="tabs-result">
|
||||
@@ -297,9 +301,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="form-loader" action="" method="post">
|
||||
</form>
|
||||
<div id="iframecontent" style="display: none"></div>
|
||||
|
||||
<div id="no-collection-warn" class="modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
@@ -421,7 +423,7 @@
|
||||
submissionLookupSearch(j('.submission-lookup-search'));
|
||||
});
|
||||
j('#loadfile_go').click(function(){
|
||||
submissionLookupPreview(j('.submission-file-loader'));
|
||||
submissionLookupFile(j('#form-loader'));
|
||||
});
|
||||
j('button.exit').click(function(event){
|
||||
event.preventDefault();
|
||||
|
Reference in New Issue
Block a user