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 OSAHerdervary 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 = "OSAHerdervary" def String collectionPID = "http://hdl.handle.net/10891/osa:693f36ae-56a5-4564-89ee-0bc7b20eb414" 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) 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:'United Nations Special Committee Documents on the Problem of Hungary in 1956', language:'eng'), creationProvider:this.dataProvider, languages:[ new Language(code:'eng', text:'English')] ) return eadHeader } def generateCollectionRecord = { def String description = ''' The UN Special Committee Documents on the Problem of Hungary in 1956 collection contains 3,523 digitized items selected from OSA's physical holdings concerning discussions on the 1956 Hungarian Revolution, its aftermath and repercussions in the United Nations (UN) General Assembly and Special Committee on the Problem of Hungary (active 1957-1958). Known informally as the Héderváry Collection after its donor, Claire de Héderváry, a Belgian-Hungarian UN employee who advised the Committee and promoted its work, the collection contains UN memoranda and correspondence, press releases and reviews, and related internal documents from the period 1956 to 1962. On January 10, 1957, the UN General Assembly adopted Resolution 1132/XI to establish a Special Committee of five member states (Australia, Denmark, Ceylon, Tunisia and Uruguay), to investigate and submit a comprehensive report on the 1956 Hungarian revolution. The Report of the Special Committee on the Problem of Hungary drew from transcripts of witness hearings, emigré organizations’ opinions, media coverage, and correspondence between the UN and Hungarian government, and concluded that 1956 was an “instinctive national uprising” suppressed by an act of Soviet external military aggression. Resolution 1133/XI was passed on September 14, 1957 to enforce the Report’s recommendations, including the continued monitoring of developments in Hungary. Following the secret trial and execution of Imre Nagy and colleagues on June 16, 1958, the Committee issued a statement of protest, and a second, supplementary report on post-revolutionary retaliations, human rights violations, and political trials, approved by Resolution 1312/XIII on December 13, 1958. Thereafter, the Committee ceased to function, and the UN’s Special Representative, Sir Leslie Munroe, and his adviser, Claire de Héderváry, contributed to keeping the Hungarian question on the UN’s agenda, where it remained until 1962. According to the UN’s records retention schedule, Special Committee documentation, drafts, audio recordings, background material and even duplicate copies of documents should have been destroyed after three years. A considerable portion of these records were retrieved by de Héderváry and later deposited at the Hoover Institution, Stanford University. In 1998, de Héderváry donated the collection to the Hungarian National Széchényi Library's Manuscript Department, where it is currently housed and open to the public. ''' def List spatiaCoverages = ['Hungary'] def EadArchDesc eadArchDesc = new EadArchDesc(dateCreated:new EadDate(normal:'1956-1962', value:'1956-1962'), //dateAccumulated:new EadDate(normal:'1948-1990', value:'1948-1990'), temporalCoverages:['1956-1962'], spatialCoverages:spatiaCoverages, landingPage:new EadDaoLoc(href:this.collectionPID), pid:this.collectionPID, europeanaType:'TEXT', europeanaRights:'Rights reserved – free access', level:'collection', scopecontentPars:[ new LanguagedValue(language:'eng', value:description) ], accessrestrictPars:[ new LanguagedValue(value:'Rights reserved – free access') ], did:new EadDid(localId:this.collectionPID, unittitles:[ new UnitTitle(title:'United Nations Special Committee Documents on the Problem of Hungary in 1956', language:'eng') ], repository:this.dataProvider, physicalDescriptions:[ new EadPhysDesc(extents:[ new LanguagedValue(value:'3523') ], genreforms:[ new LanguagedValue(value:'Attachments, Bulletins, Drafts (Documents), Fliers, Interviews, Letters, Maps (Documents), Memorandum, Minutes (Administrative records), Newsletters, Poems, Postcards, Press releases, Press reviews, Reports, Resolutions, Statistics, Telegraph, Testimonies, Transcripts', language:'eng') ]) ], originations:[ new EadOrigination(persnames:[ new LanguagedValue(value:'Claire de Héderváry', language:'eng') ]) ], langmaterials:[ new Language(code:'eng', text:'English'), new Language(code:'fra', text:'French'), new Language(code:'esp', text:'Spanish'), new Language(code:'hun', text:'Hungarian'), new Language(code:'deu', text:'German'), new Language(code:'Chinese', text:'Chinese'), new Language(code:'ita', text:'Italian') ]) ) 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 } }