mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
Added SubmissionLookupOutputGenerator
This commit is contained in:

committed by
kstamatis

parent
c13b245263
commit
de3aa60b44
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import gr.ekt.bte.core.DataOutputSpec;
|
||||
import gr.ekt.bte.core.OutputGenerator;
|
||||
import gr.ekt.bte.core.Record;
|
||||
import gr.ekt.bte.core.RecordSet;
|
||||
import gr.ekt.bte.core.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||
|
||||
|
||||
/**
|
||||
* @author Panagiotis Koutsourakis
|
||||
*/
|
||||
public class SubmissionLookupOutputGenerator implements OutputGenerator {
|
||||
private List<ItemSubmissionLookupDTO> dtoList;
|
||||
private static final String DOI_FIELD = "doi";
|
||||
private static final String NOT_FOUND_DOI = "NOT-FOUND-DOI";
|
||||
|
||||
public SubmissionLookupOutputGenerator() {
|
||||
dtoList = new ArrayList<ItemSubmissionLookupDTO>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateOutput(RecordSet records) {
|
||||
Map<String, List<Record>> record_sets = new HashMap<String, List<Record>>();
|
||||
for(Record rec : records) {
|
||||
String current_doi = NOT_FOUND_DOI;
|
||||
List<Value> values = rec.getValues(DOI_FIELD);
|
||||
if (values != null && values.size() > 0) {
|
||||
current_doi = values.get(0).getAsString();
|
||||
}
|
||||
|
||||
if(record_sets.keySet().contains(current_doi)) {
|
||||
record_sets.get(current_doi).add(rec);
|
||||
}
|
||||
else {
|
||||
ArrayList<Record> publication = new ArrayList<Record>();
|
||||
publication.add(rec);
|
||||
record_sets.put(current_doi, publication);
|
||||
}
|
||||
}
|
||||
for(Map.Entry<String, List<Record>> entry : record_sets.entrySet()) {
|
||||
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(entry.getValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateOutput(RecordSet records, DataOutputSpec spec) {
|
||||
return generateOutput(records);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the items
|
||||
*/
|
||||
public List<ItemSubmissionLookupDTO> getDtoList() {
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param items the items to set
|
||||
*/
|
||||
public void setDtoList(List<ItemSubmissionLookupDTO> items) {
|
||||
this.dtoList = items;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user