Commit 85c7252c authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

WIP: Make BundlesSource entity Bibtex-ready

parent 9cd07fda
......@@ -11,6 +11,8 @@ import java.util.Map;
import javax.inject.Inject;
import org.gesis.dda.persist.PersistableHelper;
import org.gesis.dda.publishing.domain.impl.BibtexBundlesStreamSource;
import org.gesis.dda.publishing.domain.impl.BibtexDto;
import org.gesis.dda.publishing.domain.impl.ExcelSpreadsheetBundlesSetSource;
import org.gesis.dda.publishing.domain.impl.KmhopbssDto;
import org.gesis.dda.publishing.domain.impl.KnownMetadataPrefixesOaiPmhBundlesStreamSource;
......@@ -124,6 +126,12 @@ public class BundlesStreamSourceFactory {
String xsltContent = dto.getXsltFile().getContent();
result = new XmlXsltBundlesStreamSource(xmlContent, xsltContent, bseId);
}
else if (BundlesSourceType.BIBTEX_SOURCE == bundlesSourceType) {
BibtexDto dto = PersistableHelper.instantiate(data, BibtexDto.class);
String bibtexContent = dto.getBibtexFile().getContent();
result = new BibtexBundlesStreamSource(bibtexContent, bseId);
}
return result;
}
......
package org.gesis.dda.publishing.domain.impl;
public class BibtexDto {
private FileDto bibtexFile;
public BibtexDto(FileDto bibtexFile) {
this.bibtexFile = bibtexFile;
}
public FileDto getBibtexFile() {
return bibtexFile;
}
}
\ No newline at end of file
......@@ -4,5 +4,5 @@ package org.gesis.dda.wizard.domain.enumeration;
* The BundlesSourceType enumeration.
*/
public enum BundlesSourceType {
OAI_PMH, EXCEL_SPREADSHEET, XML_FILE, UNAPI, XSLT_OAI_PMH, XML_XSLT_SOURCE
OAI_PMH, EXCEL_SPREADSHEET, XML_FILE, UNAPI, XSLT_OAI_PMH, XML_XSLT_SOURCE, BIBTEX_SOURCE
}
......@@ -20,6 +20,7 @@ import org.gesis.dda.feeder.FeedingContext;
import org.gesis.dda.feeder.impl.FeedingContextFactory;
import org.gesis.dda.feeder.impl.OaiPmhNextFeedingTimeStrategy;
import org.gesis.dda.persist.PersistableHelper;
import org.gesis.dda.publishing.domain.impl.BibtexDto;
import org.gesis.dda.publishing.domain.impl.FileDto;
import org.gesis.dda.publishing.domain.impl.KmhopbssDto;
import org.gesis.dda.publishing.domain.impl.UnapiBssConfigDto;
......@@ -450,5 +451,45 @@ public class FeederServiceIntTest {
}
@Test
public void feedBibtexSource() throws IOException {
BundlesSource underTest = new BundlesSource();
underTest = bundlesSourceRepository.save(underTest);
long bseId = underTest.getId();
String reference = "bibtex-bundlessource-" + bseId;
underTest.setType(BundlesSourceType.BIBTEX_SOURCE);
String bibtexString = IOUtils.toString(
getClass().
getResourceAsStream("/bibtex/citavi-ssoar-convention-bibtex-export.bib"), StandardCharsets.UTF_8);
log.info("bibtexString=\n{}", bibtexString);
FileDto bibtexFileDto = new FileDto("bibtex.bib", bibtexString);
BibtexDto dto = new BibtexDto(bibtexFileDto);
underTest.setReference(reference);
underTest.setData( PersistableHelper.getData(dto) );
underTest.setBundlesSourceState(BundlesSourceState.UNPROCESSED);
underTest = bundlesSourceRepository.save(underTest);
FeedingContext feedingContext = feedingContextFactory.getFeedingContext(underTest);
feederService.feed(feedingContext);
List<BundlesSource> databaseBundlesSources = bundlesSourceRepository.findAll();
databaseBundlesSources.stream().map(Object::toString).forEach(log::info);
List<Bundle> databaseBundles = bundleRepository.findAll();
databaseBundles.stream().map(Object::toString).forEach(log::info);
underTest = bundlesSourceRepository.findByReference(reference);
feedingContext = feedingContextFactory.getFeedingContext(underTest);
}
}
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