import java.util.concurrent.BlockingQueue import org.antlr.stringtemplate.StringTemplate import org.antlr.stringtemplate.StringTemplateGroup import org.antlr.stringtemplate.language.DefaultTemplateLexer import eu.dnetlib.enabling.manager.msro.hope.groovy.RunnableGroovy import eu.dnetlib.hope.domains.common.* import eu.dnetlib.hope.domains.library.* import eu.dnetlib.miscutils.datetime.DateUtils class FESLibraryBIZGAG implements RunnableGroovy { def String templatePath = "/var/lib/hope-scripts/templates" def BlockingQueue resultsQueue, inputQueue; def String repositoryId def String providerName = "Bibliothek der Friedrich-Ebert-Stiftung" def String providerLanguage = "deu" def oai_hope = new groovy.xml.Namespace("http://library.fes.de/xsd/hope/ http://library.fes.de/xsd/hope/hope.xsd", 'oai_hope') @Override public void run() { def FESLibraryUtils utils = new FESLibraryUtils(isDigital:false) def StringTemplateGroup group = new StringTemplateGroup("libraryGroup", templatePath, DefaultTemplateLexer.class); def StringTemplate libraryTemplate = group.getInstanceOf("libraryTemplate"); def parser = new XmlParser(false, true) def input def String collectionDate = DateUtils.now_ISO8601() def String marcCollection = createCollection(libraryTemplate, collectionDate, 'bizga', 'http://library.fes.de/cgi-bin/populo/bizga.pl','http://hdl.handle.net/11088/de-bo133:bizga') resultsQueue.put(marcCollection) def c = 1; while(!((input = this.inputQueue.take()).equals("END"))){ // println "processing record" def Node xmlRoot = parser.parseText(input) def Node theRecord = xmlRoot.'**'.'metadata'.'oai_hope:record'[0] def String marcRecord = utils.transformRecord(theRecord, libraryTemplate, repositoryId, collectionDate) resultsQueue.put(marcRecord); c++; Thread.sleep(20) } libraryTemplate.reset() println c +" marc records enueued" this.resultsQueue.put("END") println "closedQueue" } def createCollection = { template, dateOfColl, set, collID, collPID-> template.reset() def OAIHeader oaiheader = new OAIHeader(dateOfCollection:dateOfColl, repositoryId:repositoryId, setSpec:set, identifier:collPID, objIdentifier:this.repositoryId+"::"+collPID, nonDigitalCollection:true) def String theAbstract = ''' Die seit dem Jahr 1976 erscheinende Bibliographie zur Geschichte der deutschen Arbeiterbewegung ist die herausragende Publikation der FES-Bibliothek. Zur Aufgabe einer wissenschaftlichen Spezialbibliothek gehört die Dokumentation und Veröffentlichung der Literatur ihres Sammelschwerpunkts. Traditionell sind dies bibliographische Verzeichnisse einzelner Themenkomplexe, Verzeichnisse von Sonderbeständen, wertvollen Sammlungen oder Verzeichnisse von sogenannter "Grauer Literatur", die nicht in der Nationalbibliographie verzeichnet wird. ''' def MarcRecord marcCollection = new MarcRecord(pid:collPID,localID:collID, descriptionLevel:'collection', europeanaType:'TEXT',language:'deu', accessRights:'General Public (Open Access)', useRights:'Copyright Bibliothek der Friedrich-Ebert-Stiftung', europeanaRights:'http://www.europeana.eu/rights/rr-f/', leader:'', aggregator:"HOPE - Heritage of the people's Europe", creationDate:new DateStm(date:'1976', stm:'1976-2013'), accumulationDate:new DateStm(date:'2013', stm:''), isbn_020:'', issn_022:'', providerName:providerName, providerLanguage:providerLanguage, bookNo_091:'', extents:[ new LanguagedValue(value:'55776') ], physDetails:[], dimensions:[],materialDesignations:[ new LanguagedValue(value:'Text') ], accruals:[], toc:'', theabstracts:[ new LanguagedValue(value:theAbstract, language:'deu') ], genre:'', keywords:[], creatorPersons_100:[], creatorCorps_110:[providerName], contributorMeetings_711:[], personSubjects_600:[], corporateSubjects_610:[], temporalCoverages_648:['1940-2012'], topicSubjects_650:['workers movements'], spatialCoverages_651:['DE'], personContributors:[], corporateContributors:[], creatorMeetings_111:[], titles_245:[ new MarcTitle(language:'deu', translationLanguage:'eng', main:new MarcTranslatedTitle(original:'Bibliographie zur Geschichte der deutschen Arbeiterbewegung', translation:'Bibliography of the History of the German labor movement')) ], editionStms_250:[], landingPage:new LandingPage(href:collPID, localID:collPID), languages_041:['deu'], owner:providerName, repositories:[providerName]) template.setAttribute("oaiheader", oaiheader) template.setAttribute("marc", marcCollection) return template.toString(); } @Override public void setResultsQueue(BlockingQueue queue) { this.resultsQueue = queue } @Override public void setInputQueue(BlockingQueue queue) { this.inputQueue = queue } @Override public void closeResultQueue() { this.resultsQueue.put("END") } @Override public void setRepositoryId(String repoId) { this.repositoryId = repoId } }