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.archive.EadArchDesc import eu.dnetlib.hope.domains.archive.EadDaoLoc import eu.dnetlib.hope.domains.archive.EadDate import eu.dnetlib.hope.domains.archive.EadDid import eu.dnetlib.hope.domains.archive.EadHeader import eu.dnetlib.hope.domains.archive.EadOrigination import eu.dnetlib.hope.domains.archive.EadPhysDesc import eu.dnetlib.hope.domains.archive.Language import eu.dnetlib.hope.domains.archive.UnitTitle import eu.dnetlib.hope.domains.common.* class OSASovietMonitoring implements RunnableGroovy { def String templatePath = "/var/lib/hope-scripts/templates" def BlockingQueue resultsQueue, inputQueue; def OSAUtils utils = new OSAUtils() def String dataProvider = "Open Society Archives at Central European University" def String datasetName = "OSASovietMonitoring" def String collectionPID = "http://hdl.handle.net/10891/osa:ed645793-91bb-4168-9515-7a223fed242a" 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 mets=new groovy.xml.Namespace("http://www.loc.gov/METS/", 'mets') def osa=new groovy.xml.Namespace("http://greenfield.osaarchivum.org/ns/item", 'osa') def xlink = new groovy.xml.Namespace("http://www.w3.org/1999/xlink", 'xlink') @Override public void run() { def StringTemplateGroup group = new StringTemplateGroup("archiveGroup", templatePath, DefaultTemplateLexer.class); def StringTemplate archiveTemplate = group.getInstanceOf("archiveTemplate"); println "got template at path "+templatePath def parser = new XmlParser(false, true) println "got parser" def input; def EadArchDesc eadArchDesc = generateCollectionRecord() while(!((input = this.inputQueue.take()).equals("END"))){ //print "processing record " def Node xmlRoot = parser.parseText(input) def Node oaiHeaderNode = xmlRoot.'**'.header[0] def OAIHeader oaiheader = new OAIHeader() oaiheader.setDateOfCollection(oaiHeaderNode.'dri:dateOfCollection'.text()) oaiheader.setIdentifier(oaiHeaderNode.identifier.text()) def String objId = oaiHeaderNode.'dri:objIdentifier'.text() oaiheader.setObjIdentifier(objId) oaiheader.setRepositoryId(this.repositoryId) oaiheader.setSetSpec(oaiHeaderNode.setSpec.text()) def header = generateEadHeader() as EadHeader utils.fillEadArchDesc(xmlRoot, dataProvider, eadArchDesc, true) archiveTemplate.setAttribute("oaiheader", oaiheader) archiveTemplate.setAttribute("header", header) archiveTemplate.setAttribute("archdescs", [eadArchDesc]) def String res = archiveTemplate.toString() //println res resultsQueue.put(res) //println " result pushed" archiveTemplate.reset() } println "consumed input queue" this.resultsQueue.put("END") } def generateEadHeader = { def EadHeader eadHeader = new EadHeader( mainagencycode:"Hope", eadid:this.collectionPID, titleproper:new UnitTitle(title:'Video Recordings of Soviet and Russian Television Programs', language:'eng'), creationProvider:this.dataProvider, languages:[ new Language(code:'eng', text:'English'), new Language(code:'rus', text:'Russian')] ) return eadHeader } def generateCollectionRecord = { def String description = ''' The collection contains 3,874 videos produced in Russian and eight other languages by Soviet Central Television (1985-1991) and Ostankino Television (1992-1994), and recorded by RFE/RL’s Monitoring Unit and successor agencies, totaling almost 840 hours of material. The selected programs portray different aspects of life in the Soviet Union and Russian Federation in the late 1980s and early 1990s, with a focus on contemporary key social, political, and economic issues before, during and after the collapse of the Soviet Union, including independence movements, the establishment of a multi-party system in Russia, and economic reform and privatization. The Monitoring Unit was founded during the early years of Radio Liberty and continued its activities after the merger with Radio Free Europe in 1977. Its primary aim was to monitor radio and later television coverage of Soviet current affairs. The unit also prepared transcripts of news programs were included together with Soviet news agency materials and press clippings in daily bulletins produced by RFE/RL’s Research Institute. Since the monitoring activities were not systematized, programs were often not recorded in their entirety. When the unit was dissolved in 1992, Russian media monitoring was contracted out to the Moscow-based What The Papers Say (WPS) information agency. However, throughout 1993 and 1994, RFE/RL Research Institute staff continued to conduct on-demand television monitoring. ''' def List spatiaCoverages = [ 'Latvia', 'Armenia (Republic)', 'Georgia (Republic)', 'Estonia', 'Belarus', 'Lithuania', 'Moldova', 'Azerbaijan', 'Bosnia and Hercegovina', 'Yugoslavia', 'Ukraine', 'Uzbekistan', 'Turkmenistan', 'Kyrgyzstan', 'Croatia', 'Yugoslavia', 'Tajikistan' ] def String useRestrict = ''' Ownership of and financial copyrights to the reports belong to RFE/RL, Inc. Reprinted with the permission of Radio Free Europe/Radio Liberty, 1201 Connecticut Ave., N.W., Washington, DC 20036, USA. Users of RFE/RL content cannot alter the meaning, name or integrity of the content. RFE/RL reserves the right to revoke permission for use of its content at any time. The sale of RFE/RL content is strictly prohibited. ''' def EadArchDesc eadArchDesc = new EadArchDesc(dateCreated:new EadDate(normal:'1985-1994', value:'1985-1994'), //dateAccumulated:new EadDate(normal:'1948-1990', value:'1948-1990'), temporalCoverages:['1985-1994'], spatialCoverages:spatiaCoverages, landingPage:new EadDaoLoc(href:this.collectionPID), pid:this.collectionPID, europeanaType:'VIDEO', europeanaRights:'Rights reserved – free access', level:'collection', scopecontentPars:[ new LanguagedValue(language:'eng', value:description) ], accessrestrictPars:[ new LanguagedValue(value:'Rights reserved – free access') ], userrestrictPars:[ new LanguagedValue(value:useRestrict, language:'eng') ], did:new EadDid(localId:this.collectionPID, unittitles:[ new UnitTitle(title:'Video Recordings of Soviet and Russian Television Programs', language:'eng') ], repository:this.dataProvider, physicalDescriptions:[ new EadPhysDesc(extents:[ new LanguagedValue(value:'3874') ], genreforms:[ new LanguagedValue(value:'Broadcasts', language:'eng') ]) ], originations:[ new EadOrigination(corpnames:[ new LanguagedValue(value:'Radio Free Europe/Radio Liberty (RFE/RL) Research Institute', language:'eng') ]) ], langmaterials:[ new Language(code:'rus', text:'Russian'), new Language(code:'eng', text:'English'), new Language(code:'deu', text:'German'), new Language(code:'Ukranian', text:'Ukranian'), new Language(code:'pol', text:'Polish') ]) ) return eadArchDesc } @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 } }