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 FESLibraryDigbib implements RunnableGroovy { def FESLibraryUtils utils = new FESLibraryUtils() 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 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, this.repositoryId, 'digbib' ,'http://library.fes.de/inhalt/digital/fes-publikation.htm','http://hdl.handle.net/11088/de-bo133:digbib') resultsQueue.put(marcCollection) def c = 0; 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, this.repositoryId, collectionDate) resultsQueue.put(marcRecord); c++; } libraryTemplate.reset() println c +" marc records enueued" this.resultsQueue.put("END") println "closedQueue" } def createCollection = { template, dateOfColl, repoId, set, collID, collPID-> template.reset() def OAIHeader oaiheader = new OAIHeader(dateOfCollection:dateOfColl, repositoryId:repoId, setSpec:set, identifier:collPID, objIdentifier:repoId+"::"+collPID) def String theAbstract = ''' Seit 1998 engagiert sich die Bibliothek der Friedrich-Ebert-Stiftung - in Ergänzung ihres konventionellen Bestandsaufbaus - auch im Bereich "Digitale Publikationen". Sie übernimmt mit der Datenbank "Digitale Bibliothek" für die Publikationen des Hauses die Funktion eines Volltext-Servers und erweitert darüber hinaus in zahlreichen Digitalisierungsprojekten das Internetangebot für Publikationen aus ihrem Sammelschwerpunkt. ''' 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:'1992', stm:'1992-2013'), accumulationDate:new DateStm(date:'2013', stm:''), isbn_020:'', issn_022:'', providerName:providerName, providerLanguage:providerLanguage, bookNo_091:'', extents:[ new LanguagedValue(value:'9596') ], physDetails:[ new LanguagedValue(value:'application/pdf') ], 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:['1992-2013'], topicSubjects_650:[], spatialCoverages_651:['DE'], personContributors:[], corporateContributors:[], creatorMeetings_111:[], titles_245:[ new MarcTitle(main:new MarcTranslatedTitle(original:'Digitale Bibliothek der Friedrich-Ebert-Stiftung')) ], editionStms_250:[], landingPage:new LandingPage(href:collPID, localID:collPID), languages_041:['deu']) 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 } }