Commit 548f9a5f authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

Improve location of content InputStream

parent 584204ef
...@@ -40,13 +40,11 @@ public abstract class AbstractTemplateExcelSheetBundlesSource implements Bundles ...@@ -40,13 +40,11 @@ public abstract class AbstractTemplateExcelSheetBundlesSource implements Bundles
ImmutableSet.Builder<Metadatum> metadataBuilder = new ImmutableSet.Builder<>(); ImmutableSet.Builder<Metadatum> metadataBuilder = new ImmutableSet.Builder<>();
doGetBundles(row, metadataBuilder); doGetBundles(row, metadataBuilder);
//TODO logic to download document, based on dc.identifier.urn, dc.identifier.doi and dc.identifier.url
InputStream content = null;
Set<Metadatum> metadata = metadataBuilder.build(); Set<Metadatum> metadata = metadataBuilder.build();
InputStream content = ContentResolver.resolveContentInputStream(metadata);
Bundle bundle = new SimpleBundle(content, metadata); Bundle bundle = new SimpleBundle(content, metadata);
bundles.add(bundle); bundles.add(bundle);
//Bundle bundle = new SimpleBundle(content, metadata );
} }
} }
return bundles; return bundles;
...@@ -76,6 +74,17 @@ public abstract class AbstractTemplateExcelSheetBundlesSource implements Bundles ...@@ -76,6 +74,17 @@ public abstract class AbstractTemplateExcelSheetBundlesSource implements Bundles
} }
} }
protected void extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder(String key, Cell cell, ImmutableSet.Builder<Metadatum> metadataBuilder) {
if (null != cell) {
String rawValue = cell.toString();
if ( isNotBlank(rawValue) ) {
String sanitizedValue = rawValue.replaceAll("\\s+","");
Metadatum metadatum = new SimpleMetadatum(key, sanitizedValue);
metadataBuilder.add(metadatum);
}
}
}
protected void extractMetadataFromCellAndAddToMetadataSetBuilder(String key, Cell cell, String delimiterRegex, ImmutableSet.Builder<Metadatum> metadataBuilder) { protected void extractMetadataFromCellAndAddToMetadataSetBuilder(String key, Cell cell, String delimiterRegex, ImmutableSet.Builder<Metadatum> metadataBuilder) {
if (null != cell) { if (null != cell) {
String rawValues = cell.toString(); String rawValues = cell.toString();
......
...@@ -33,8 +33,8 @@ public class CollectionSheetBundlesSource extends AbstractTemplateExcelSheetBund ...@@ -33,8 +33,8 @@ public class CollectionSheetBundlesSource extends AbstractTemplateExcelSheetBund
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(13), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(13), metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(14), "@@", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(14), "@@", metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(15), "; ", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(15), "; ", metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(16), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(16), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(17), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(17), metadataBuilder );
extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(18), metadataBuilder ); extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(18), metadataBuilder );
extractControlledVocabularyFromCell( "dc.type.document", row.getCell(19), metadataBuilder ); extractControlledVocabularyFromCell( "dc.type.document", row.getCell(19), metadataBuilder );
extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(20), "true", null, metadataBuilder ); extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(20), "true", null, metadataBuilder );
...@@ -43,7 +43,7 @@ public class CollectionSheetBundlesSource extends AbstractTemplateExcelSheetBund ...@@ -43,7 +43,7 @@ public class CollectionSheetBundlesSource extends AbstractTemplateExcelSheetBund
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(23), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(23), metadataBuilder );
extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(24), metadataBuilder ); extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(24), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(25), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(25), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(26), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(26), metadataBuilder );
} }
@Override @Override
......
...@@ -44,7 +44,7 @@ public class ContentResolver { ...@@ -44,7 +44,7 @@ public class ContentResolver {
if (null != content) break; if (null != content) break;
} }
else if ( metadatum.getKey().equals("dc.identifier.doi") ) { else if ( metadatum.getKey().equals("dc.identifier.doi") ) {
String url = "http://dx.doi.org/" + metadatum.getValue(); // http://dx.doi.org/10.1140/epjc/s10052-014-3060-7 String url = metadatum.getValue(); // http://dx.doi.org/10.1140/epjc/s10052-014-3060-7
content = resolveLink(url); content = resolveLink(url);
if (null != content) break; if (null != content) break;
content = null; content = null;
......
...@@ -35,8 +35,8 @@ public class InCollectionSheetBundlesSource extends AbstractTemplateExcelSheetBu ...@@ -35,8 +35,8 @@ public class InCollectionSheetBundlesSource extends AbstractTemplateExcelSheetBu
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(15), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(15), metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(16), "@@", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(16), "@@", metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(17), "; ", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(17), "; ", metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(18), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(18), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(19), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(19), metadataBuilder );
extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(20), metadataBuilder ); extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(20), metadataBuilder );
extractControlledVocabularyFromCell( "dc.type.document", row.getCell(21), metadataBuilder ); extractControlledVocabularyFromCell( "dc.type.document", row.getCell(21), metadataBuilder );
extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(22), "true", null, metadataBuilder ); extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(22), "true", null, metadataBuilder );
...@@ -45,7 +45,7 @@ public class InCollectionSheetBundlesSource extends AbstractTemplateExcelSheetBu ...@@ -45,7 +45,7 @@ public class InCollectionSheetBundlesSource extends AbstractTemplateExcelSheetBu
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(25), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(25), metadataBuilder );
extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(26), metadataBuilder ); extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(26), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(27), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(27), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(28), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(28), metadataBuilder );
} }
@Override @Override
......
...@@ -32,8 +32,8 @@ public class JournalArticleSheetBundlesSource extends AbstractTemplateExcelSheet ...@@ -32,8 +32,8 @@ public class JournalArticleSheetBundlesSource extends AbstractTemplateExcelSheet
extractMetadatumFromCellAndAddToMetadataSetBuilder( "dc.source.pageinfo", row.getCell(10), metadataBuilder ); extractMetadatumFromCellAndAddToMetadataSetBuilder( "dc.source.pageinfo", row.getCell(10), metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(11), "@@", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(11), "@@", metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(12), "; ", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(12), "; ", metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(13), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(13), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(14), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(14), metadataBuilder );
extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(15), metadataBuilder ); extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(15), metadataBuilder );
extractControlledVocabularyFromCell( "dc.type.document", row.getCell(16), metadataBuilder ); extractControlledVocabularyFromCell( "dc.type.document", row.getCell(16), metadataBuilder );
extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(17), "true", null, metadataBuilder ); extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder( "ssoar.wgl.collection", row.getCell(17), "true", null, metadataBuilder );
...@@ -42,7 +42,7 @@ public class JournalArticleSheetBundlesSource extends AbstractTemplateExcelSheet ...@@ -42,7 +42,7 @@ public class JournalArticleSheetBundlesSource extends AbstractTemplateExcelSheet
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(20), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "ssoar.contributor.institution", row.getCell(20), metadataBuilder );
extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(21), metadataBuilder ); extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(21), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(22), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(22), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(23), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(23), metadataBuilder );
} }
@Override @Override
......
...@@ -37,8 +37,8 @@ public class MonographSheetBundlesSource extends AbstractTemplateExcelSheetBundl ...@@ -37,8 +37,8 @@ public class MonographSheetBundlesSource extends AbstractTemplateExcelSheetBundl
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(13), metadataBuilder ); extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.publisher.city", row.getCell(13), metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(14), "@@", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.description.abstract", row.getCell(14), "@@", metadataBuilder );
extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(15), "; ", metadataBuilder ); extractMetadataFromCellAndAddToMetadataSetBuilder( "dc.subject.other", row.getCell(15), "; ", metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(16), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.urn", row.getCell(16), metadataBuilder );
extractMetadatumFromCellAndSanitizeAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(17), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.doi", row.getCell(17), metadataBuilder );
extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(18), metadataBuilder ); extractControlledVocabularyFromCell( "dc.rights.licence", row.getCell(18), metadataBuilder );
extractControlledVocabularyFromCell( "dc.type.document", row.getCell(19), metadataBuilder ); extractControlledVocabularyFromCell( "dc.type.document", row.getCell(19), metadataBuilder );
extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder("ssoar.wgl.collection", row.getCell(20), "true", null, metadataBuilder); extractBinaryMetadatumFromCellAndAddToMetadatumSetBuilder("ssoar.wgl.collection", row.getCell(20), "true", null, metadataBuilder);
...@@ -48,7 +48,7 @@ public class MonographSheetBundlesSource extends AbstractTemplateExcelSheetBundl ...@@ -48,7 +48,7 @@ public class MonographSheetBundlesSource extends AbstractTemplateExcelSheetBundl
extractControlledVocabularyFromCell( "dc.description.review", row.getCell(24), metadataBuilder ); extractControlledVocabularyFromCell( "dc.description.review", row.getCell(24), metadataBuilder );
extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(25), metadataBuilder ); extractControlledVocabularyFromCell( "dc.description.pubstatus", row.getCell(25), metadataBuilder );
extractMetadatumFromCellAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(26), metadataBuilder ); extractMetadatumFromCellAndAddToMetadataSetBuilder( "internal.embargo.liftdate", row.getCell(26), metadataBuilder );
extractMetadatumFromCellAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(27), metadataBuilder ); extractMetadatumFromCellAndRemoveAllWhitespaceAndAddToMetadataSetBuilder( "dc.identifier.url", row.getCell(27), metadataBuilder );
} }
@Override @Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment