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.DateStm import eu.dnetlib.hope.domains.library.MarcRecord import eu.dnetlib.hope.domains.library.MarcTitle import eu.dnetlib.hope.domains.library.MarcTranslatedTitle class OSAHungarianPropagandaLib implements RunnableGroovy { def String templatePath = "/var/lib/hope-scripts/templates" def BlockingQueue resultsQueue, inputQueue; def OSALibraryUtils utils = new OSALibraryUtils() def String euroType = 'IMAGE' def String dataProvider = "Open Society Archives at Central European University" def String datasetName = "OSAHungarianPropaganda" def String collectionPID = "http://hdl.handle.net/10891/osa:74d6d644-8818-4cf7-b24c-6781cd0bcf80" def String dataProviderLanguage = 'hun' def String repositoryId; /** * Namespaces */ def dri = new groovy.xml.Namespace("http://www.driver-repository.eu/namespace/dri", 'dri') def foxml= new groovy.xml.Namespace("info:fedora/fedora-system:def/foxml#", 'foxml') def marc=new groovy.xml.Namespace("http://www.loc.gov/MARC21/slim", 'marc') def osa=new groovy.xml.Namespace("http://greenfield.osaarchivum.org/ns/item", 'osa') def rdf = new groovy.xml.Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", 'rdf') @Override public void run() { def StringTemplateGroup group = new StringTemplateGroup("libraryGroup", templatePath, DefaultTemplateLexer.class); def StringTemplate libraryTemplate = group.getInstanceOf("libraryTemplate"); println "got template at path "+templatePath def parser = new XmlParser(false, true) println "got parser" def input; def OAIHeader collectionHeader = new OAIHeader(repositoryId:this.repositoryId, identifier:this.collectionPID, objIdentifier:this.repositoryId+'::'+this.collectionPID) def MarcRecord collectionRecord = generateCollectionRecord() libraryTemplate.setAttribute("oaiheader", collectionHeader) libraryTemplate.setAttribute("marc", collectionRecord) resultsQueue.put(libraryTemplate.toString()) libraryTemplate.reset() while(!((input = this.inputQueue.take()).equals("END"))){ //print "processing record " def Node xmlRoot = parser.parseText(input) def Node oaiHeaderNode = xmlRoot.'**'.header[0] def String dateOfColl = oaiHeaderNode.'dri:dateOfCollection'.text() def Node theRecordRoot =xmlRoot.'**'.'foxml:digitalObject'[0] def String res = utils.transformRecord(theRecordRoot, libraryTemplate, this.repositoryId, dateOfColl, this.dataProvider, this.dataProviderLanguage, this.collectionPID) if(res) //println res resultsQueue.put(res.replace("&", "&")) //println " result pushed" libraryTemplate.reset() } println "consumed input queue" this.resultsQueue.put("END") } def generateCollectionRecord = { def String theAbstract = ''' The collection comprises 178 filmstrips of an explicit propaganda or ideological nature, produced by Magyar Diafilmgyártó Vállalat (Hungarian Filmstrip Production Company) between 1948 and 1989, and whose temporal coverage spans the decades 1917 to 1989. The items contained in the collection were compiled on a thematic basis from Ferenc Bíró’s extensive filmstrip collection. In Hungary, large-scale production of filmstrips began in the 1950s. The relatively cheap technology was recognized as an effective tool for the dissemination of popular science, adult educational material as well as political mass propaganda. While today filmstrips are exclusively produced for children and for home use, filmstrips in the past covered a wide range of topics, and were projected in community halls, schools or even in the army. The propaganda filmstrips address a wide range of topics including revolutions around the world, five-year plans, the collectivization of agriculture in the 1950s, and the achievements of Soviet space research, while later filmstrips from the Kádár era focus instead on popular education, sports, and Hungarian cultural and folk traditions. In the 1970s, mandatory deposit copies were placed in public collections, such as the National Széchényi Library and the Budapest Metropolitan Ervin Szabó Library. However, the largest filmstrip holding in Hungary is a private one: Ferenc Bíró’s collection includes close to 4,000 films as well as various types of projectors and ephemera. The Virtual Filmstrip Museum, a webpage built with the support of OSA Archivum, is based on Bíró’s collection. ''' def MarcRecord marcCollection = new MarcRecord(descriptionLevel:'collection', localID:this.collectionPID, pid:this.collectionPID, landingPage:new LandingPage(localID: this.collectionPID, href:this.collectionPID), europeanaType:this.euroType, language:'English; Hungarian', accessRights:'', useRights:'', europeanaRights:'Rights Reserved - Free Access', leader:'', aggregator:"HOPE - Heritage of the people's Europe", creationDate:new DateStm(date:'1948-1989', stm:'1948-1989'), accumulationDate:new DateStm(date:'', stm:''), isbn_020:'', issn_022:'', providerName:this.dataProvider, providerLanguage:'English; Hungarian', bookNo_091:'', extents:[ new LanguagedValue(value:'178') ], physDetails:[], dimensions:[],materialDesignations:[ new LanguagedValue(value:'Propaganda', language:'eng') ], accruals:[], toc:'', theabstracts:[ new LanguagedValue(language:'eng', value:theAbstract) ], genre:'', keywords:[], creatorPersons_100:['Ferenc Bíró'], creatorCorps_110:[], contributorMeetings_711:[], personSubjects_600:[], corporateSubjects_610:[], temporalCoverages_648:['1917-1989'], topicSubjects_650:[], spatialCoverages_651:['Hungary'], personContributors:[], corporateContributors:[], creatorMeetings_111:[], titles_245:[ new MarcTitle(main:new MarcTranslatedTitle(original:'Hungarian Propaganda Filmstrip'), language:'eng') ], editionStms_250:[], repositories:[this.dataProvider], languages_041:['Hungarian']) return marcCollection; } @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 } }