mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Merge from ekt branch
This commit is contained in:
@@ -128,48 +128,44 @@ public abstract class ConfigurableLookupProvider implements SubmissionLookupProv
|
|||||||
shortName);
|
shortName);
|
||||||
Field[] fields = bean.getClass().getDeclaredFields();
|
Field[] fields = bean.getClass().getDeclaredFields();
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
if (field.getType() == String.class) {
|
if (field.getType() == String.class) {
|
||||||
Method getter = bean.getClass().getMethod(
|
Method getter = bean.getClass().getMethod(
|
||||||
"get" + field.getName().substring(0, 1).toUpperCase()
|
"get" + field.getName().substring(0, 1).toUpperCase()
|
||||||
+ field.getName().substring(1));
|
+ field.getName().substring(1));
|
||||||
|
|
||||||
String value = (String) getter.invoke(bean);
|
String value = (String) getter.invoke(bean);
|
||||||
|
|
||||||
addMetadata(shortName, publication, field.getName(), value);
|
addMetadata(shortName, publication, field.getName(), value);
|
||||||
|
|
||||||
} else if (field.getType() == List.class) {
|
} else if (field.getType() == List.class) {
|
||||||
ParameterizedType pt = (ParameterizedType) field
|
ParameterizedType pt = (ParameterizedType) field
|
||||||
.getGenericType();
|
.getGenericType();
|
||||||
|
|
||||||
Method getter = bean.getClass().getMethod(
|
Method getter = bean.getClass().getMethod(
|
||||||
"get" + field.getName().substring(0, 1).toUpperCase()
|
"get" + field.getName().substring(0, 1).toUpperCase()
|
||||||
+ field.getName().substring(1));
|
+ field.getName().substring(1));
|
||||||
|
|
||||||
ParameterizedType stringListType = (ParameterizedType) field.getGenericType();
|
if (pt.getActualTypeArguments()[0] instanceof GenericArrayType) { // nomi
|
||||||
Class<?> stringListClass = (Class<?>) stringListType.getActualTypeArguments()[0];
|
// di
|
||||||
|
// persone
|
||||||
if (String.class.isAssignableFrom(stringListClass)) { //repeatable metadata
|
List<String[]> values = (List<String[]>) getter.invoke(bean);
|
||||||
List<String> values = (List<String>) getter.invoke(bean);
|
if (values != null) {
|
||||||
if (values != null) {
|
for (String[] nvalue : values) {
|
||||||
for (String value : values) {
|
String value = nvalue[1] + ", " + nvalue[0];
|
||||||
addMetadata(shortName, publication,
|
addMetadata(shortName, publication,
|
||||||
field.getName(), value);
|
field.getName(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else { // metadati ripetibili
|
||||||
//authors
|
List<String> values = (List<String>) getter.invoke(bean);
|
||||||
List<String[]> values = (List<String[]>) getter
|
if (values != null) {
|
||||||
.invoke(bean);
|
for (String value : values) {
|
||||||
if (values != null) {
|
addMetadata(shortName, publication,
|
||||||
for (String[] nvalue : values) {
|
field.getName(), value);
|
||||||
String value = nvalue[1] + ", " + nvalue[0];
|
}
|
||||||
addMetadata(shortName, publication,
|
}
|
||||||
field.getName(), value);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return publication;
|
return publication;
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.util.DCInput;
|
import org.dspace.app.util.DCInput;
|
||||||
import org.dspace.app.util.DCInputSet;
|
import org.dspace.app.util.DCInputSet;
|
||||||
import org.dspace.app.util.DCInputsReader;
|
import org.dspace.app.util.DCInputsReader;
|
||||||
@@ -43,6 +44,8 @@ import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
|||||||
*/
|
*/
|
||||||
public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator {
|
public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(DSpaceWorkspaceItemOutputGenerator.class);
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private String formName;
|
private String formName;
|
||||||
private List<WorkspaceItem> witems;
|
private List<WorkspaceItem> witems;
|
||||||
@@ -57,12 +60,21 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> generateOutput(RecordSet records) {
|
public List<String> generateOutput(RecordSet recordSet) {
|
||||||
|
|
||||||
|
log.info("BTE OutputGenerator started. Records to output: " + recordSet.getRecords().size());
|
||||||
|
|
||||||
|
//Printing debug message
|
||||||
|
String totalString = "";
|
||||||
|
for (Record record : recordSet.getRecords()){
|
||||||
|
totalString += SubmissionLookupUtils.getPrintableString(record)+"\n";
|
||||||
|
}
|
||||||
|
log.debug("Records to output:\n"+totalString);
|
||||||
|
|
||||||
|
|
||||||
witems = new ArrayList<WorkspaceItem>();
|
witems = new ArrayList<WorkspaceItem>();
|
||||||
|
|
||||||
Map<String, List<Record>> record_sets = new HashMap<String, List<Record>>();
|
for(Record rec : recordSet.getRecords()) {
|
||||||
for(Record rec : records) {
|
|
||||||
try {
|
try {
|
||||||
WorkspaceItem wi = WorkspaceItem.create(context, collection, true);
|
WorkspaceItem wi = WorkspaceItem.create(context, collection, true);
|
||||||
merge(formName, wi.getItem(), rec);
|
merge(formName, wi.getItem(), rec);
|
||||||
|
@@ -34,7 +34,7 @@ public class FieldMergeModifier extends AbstractModifier {
|
|||||||
rec.addValue(target_field, value);
|
rec.addValue(target_field, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rec.removeField(source_field);
|
//rec.removeField(source_field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,12 +14,14 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import gr.ekt.bte.core.DataLoader;
|
import gr.ekt.bte.core.DataLoader;
|
||||||
import gr.ekt.bte.core.DataLoadingSpec;
|
import gr.ekt.bte.core.DataLoadingSpec;
|
||||||
import gr.ekt.bte.core.Record;
|
import gr.ekt.bte.core.Record;
|
||||||
import gr.ekt.bte.core.RecordSet;
|
import gr.ekt.bte.core.RecordSet;
|
||||||
import gr.ekt.bte.core.StringValue;
|
import gr.ekt.bte.core.StringValue;
|
||||||
|
import gr.ekt.bte.core.Value;
|
||||||
import gr.ekt.bte.exceptions.MalformedSourceException;
|
import gr.ekt.bte.exceptions.MalformedSourceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +30,8 @@ import gr.ekt.bte.exceptions.MalformedSourceException;
|
|||||||
*/
|
*/
|
||||||
public class MultipleSubmissionLookupDataLoader implements DataLoader {
|
public class MultipleSubmissionLookupDataLoader implements DataLoader {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(MultipleSubmissionLookupDataLoader.class);
|
||||||
|
|
||||||
private static final String NOT_FOUND_DOI = "NOT-FOUND-DOI";
|
private static final String NOT_FOUND_DOI = "NOT-FOUND-DOI";
|
||||||
|
|
||||||
List<ConfigurableLookupProvider> providers;
|
List<ConfigurableLookupProvider> providers;
|
||||||
@@ -91,8 +95,13 @@ public class MultipleSubmissionLookupDataLoader implements DataLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//KSTA:ToDo: providers must only be the ones that support DOI search!
|
|
||||||
for (SubmissionLookupProvider provider : providers) {
|
for (SubmissionLookupProvider provider : providers) {
|
||||||
|
|
||||||
|
//Provider must support DOI
|
||||||
|
if (provider.getSupportedIdentifiers().contains(SubmissionLookupProvider.DOI)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//if (evictProviders != null
|
//if (evictProviders != null
|
||||||
// && evictProviders.contains(provider.getShortName())) {
|
// && evictProviders.contains(provider.getShortName())) {
|
||||||
// continue;
|
// continue;
|
||||||
@@ -122,6 +131,16 @@ public class MultipleSubmissionLookupDataLoader implements DataLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.info("BTE DataLoader finished. Items loaded: " + recordSet.getRecords().size());
|
||||||
|
|
||||||
|
//Printing debug message
|
||||||
|
String totalString = "";
|
||||||
|
for (Record record : recordSet.getRecords()){
|
||||||
|
totalString += SubmissionLookupUtils.getPrintableString(record)+"\n";
|
||||||
|
}
|
||||||
|
log.debug("Records loaded:\n"+totalString);
|
||||||
|
|
||||||
return recordSet;
|
return recordSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ import gr.ekt.bte.exceptions.MalformedSourceException;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ public class SubmissionItemDataLoader implements DataLoader {
|
|||||||
private List<ItemSubmissionLookupDTO> dtoList;
|
private List<ItemSubmissionLookupDTO> dtoList;
|
||||||
List<SubmissionLookupProvider> providers;
|
List<SubmissionLookupProvider> providers;
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(SubmissionItemDataLoader.class);
|
||||||
|
|
||||||
public SubmissionItemDataLoader() {
|
public SubmissionItemDataLoader() {
|
||||||
dtoList = null;
|
dtoList = null;
|
||||||
providers = null;
|
providers = null;
|
||||||
@@ -44,6 +46,15 @@ public class SubmissionItemDataLoader implements DataLoader {
|
|||||||
ret.addRecord(rec);
|
ret.addRecord(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("BTE DataLoader finished. Items loaded: " + ret.getRecords().size());
|
||||||
|
|
||||||
|
//Printing debug message
|
||||||
|
String totalString = "";
|
||||||
|
for (Record record : ret.getRecords()){
|
||||||
|
totalString += SubmissionLookupUtils.getPrintableString(record)+"\n";
|
||||||
|
}
|
||||||
|
log.debug("Records loaded:\n"+totalString);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,10 @@ public class SubmissionLookupOutputGenerator implements OutputGenerator {
|
|||||||
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(entry.getValue());
|
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(entry.getValue());
|
||||||
dtoList.add(dto);
|
dtoList.add(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Print debug messages
|
||||||
|
|
||||||
|
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ import java.util.Map;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.identifier.DOI;
|
||||||
import org.dspace.submit.util.SubmissionLookupDTO;
|
import org.dspace.submit.util.SubmissionLookupDTO;
|
||||||
|
|
||||||
import gr.ekt.bte.core.TransformationEngine;
|
import gr.ekt.bte.core.TransformationEngine;
|
||||||
@@ -92,13 +93,19 @@ public class SubmissionLookupService {
|
|||||||
return phase2TransformationEngine;
|
return phase2TransformationEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
//KSTA:ToDo: Replace with something more dynamic
|
|
||||||
public List<String> getIdentifiers() {
|
public List<String> getIdentifiers() {
|
||||||
List<String> identifiers = new ArrayList<String>();
|
|
||||||
identifiers.add("doi");
|
List<String> allSupportedIdentifiers = new ArrayList<String>();
|
||||||
identifiers.add("pubmed");
|
MultipleSubmissionLookupDataLoader dataLoader = (MultipleSubmissionLookupDataLoader)phase1TransformationEngine.getDataLoader();
|
||||||
identifiers.add("arxiv");
|
for (SubmissionLookupProvider provider : dataLoader.getProviders()){
|
||||||
return identifiers;
|
for (String identifier : provider.getSupportedIdentifiers()){
|
||||||
|
if (!allSupportedIdentifiers.contains(identifier)){
|
||||||
|
allSupportedIdentifiers.add(identifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allSupportedIdentifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<SubmissionLookupProvider>> getProvidersIdentifiersMap() {
|
public Map<String, List<SubmissionLookupProvider>> getProvidersIdentifiersMap() {
|
||||||
|
@@ -126,11 +126,29 @@ public class SubmissionLookupUtils {
|
|||||||
public static List<String> getValues(Record rec, String field) {
|
public static List<String> getValues(Record rec, String field) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
List<Value> values = rec.getValues(field);
|
List<Value> values = rec.getValues(field);
|
||||||
String value = null;
|
|
||||||
if (values != null && values.size() > 0) {
|
if (values != null && values.size() > 0) {
|
||||||
value = values.get(0).getAsString();
|
for (Value value : values){
|
||||||
result.add(value);
|
result.add( value.getAsString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPrintableString(Record record){
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
result.append("\nPublication {\n");
|
||||||
|
|
||||||
|
for (String field: record.getFields()){
|
||||||
|
result.append("--"+field + ":\n");
|
||||||
|
List<Value> values = record.getValues(field);
|
||||||
|
for (Value value : values){
|
||||||
|
result.append("\t"+value.getAsString()+"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.append("}\n");
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -208,6 +208,7 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
|||||||
if (transformationEngine != null){
|
if (transformationEngine != null){
|
||||||
SubmissionItemDataLoader dataLoader = (SubmissionItemDataLoader)transformationEngine.getDataLoader();
|
SubmissionItemDataLoader dataLoader = (SubmissionItemDataLoader)transformationEngine.getDataLoader();
|
||||||
dataLoader.setDtoList(Arrays.asList(new ItemSubmissionLookupDTO[]{dto}));
|
dataLoader.setDtoList(Arrays.asList(new ItemSubmissionLookupDTO[]{dto}));
|
||||||
|
//dataLoader.setProviders()
|
||||||
|
|
||||||
DSpaceWorkspaceItemOutputGenerator outputGenerator = (DSpaceWorkspaceItemOutputGenerator)transformationEngine.getOutputGenerator();
|
DSpaceWorkspaceItemOutputGenerator outputGenerator = (DSpaceWorkspaceItemOutputGenerator)transformationEngine.getOutputGenerator();
|
||||||
outputGenerator.setCollection(col);
|
outputGenerator.setCollection(col);
|
||||||
|
@@ -64,14 +64,14 @@ public class ItemSubmissionLookupDTO implements Serializable {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MutableRecord pub = new SubmissionLookupPublication(MERGED_PUBLICATION_PROVIDER);
|
MutableRecord pub = new SubmissionLookupPublication(MERGED_PUBLICATION_PROVIDER);
|
||||||
for (SubmissionLookupProvider prov : providers)
|
//for (SubmissionLookupProvider prov : providers)
|
||||||
{
|
//{
|
||||||
for (Record p : publications)
|
for (Record p : publications)
|
||||||
{
|
{
|
||||||
if (!SubmissionLookupService.getProviderName(p).equals(prov.getShortName()))
|
//if (!SubmissionLookupService.getProviderName(p).equals(prov.getShortName()))
|
||||||
{
|
//{
|
||||||
continue;
|
// continue;
|
||||||
}
|
//}
|
||||||
for (String field : p.getFields())
|
for (String field : p.getFields())
|
||||||
{
|
{
|
||||||
List<Value> values = p.getValues(field);
|
List<Value> values = p.getValues(field);
|
||||||
@@ -87,7 +87,7 @@ public class ItemSubmissionLookupDTO implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
return pub;
|
return pub;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,9 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
|||||||
dataLoader.setIdentifiers(identifiers);
|
dataLoader.setIdentifiers(identifiers);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
log.debug("BTE transformation is about to start!");
|
||||||
transformationEngine.transform(new TransformationSpec());
|
transformationEngine.transform(new TransformationSpec());
|
||||||
|
log.debug("BTE transformation finished!");
|
||||||
|
|
||||||
SubmissionLookupOutputGenerator outputGenerator = (SubmissionLookupOutputGenerator)transformationEngine.getOutputGenerator();
|
SubmissionLookupOutputGenerator outputGenerator = (SubmissionLookupOutputGenerator)transformationEngine.getOutputGenerator();
|
||||||
result = outputGenerator.getDtoList();
|
result = outputGenerator.getDtoList();
|
||||||
@@ -208,6 +210,7 @@ public class SubmissionLookupJSONRequest extends JSONRequest {
|
|||||||
data.put("authors",pub.getValues("authors")!=null?
|
data.put("authors",pub.getValues("authors")!=null?
|
||||||
StringUtils.join(SubmissionLookupUtils.getValues(pub, "authors").iterator(), ", "):"");
|
StringUtils.join(SubmissionLookupUtils.getValues(pub, "authors").iterator(), ", "):"");
|
||||||
data.put("issued", SubmissionLookupUtils.getFirstValue(pub, "issued"));
|
data.put("issued", SubmissionLookupUtils.getFirstValue(pub, "issued"));
|
||||||
|
|
||||||
publications.add(data);
|
publications.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user