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 OSAPhysicians 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 = "OSAPhysicians" def String collectionPID = "http://hdl.handle.net/10891/osa:b9e6110d-b739-451a-bc67-c13cb3b382af" 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()) oaiheader.setObjIdentifier(oaiHeaderNode.'dri:objIdentifier'.text()) 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:'Physicians for Human Rights Forensic Monitoring Reports', language:'eng'), creationProvider:this.dataProvider, languages:[ new Language(code:'eng', text:'English')] ) return eadHeader } def generateCollectionRecord = { def String description = ''' The collection contains 137 forensic reports produced by the Physicians for Human Rights (PHR) during its Forensic Assistance Project (FAP) in Bosnia and Hercegovina in 1997-1999, documenting the extent and consequences of violence, as well as the humanitarian response of the international community in the immediate aftermath of the Yugoslav wars. Complementing the work of the International Criminal Tribunal for the former Yugoslavia (ICTY) and the International Committee of the Red Cross (ICRC), which operated in the region simultaneously, PHR worked with local Bosnian forensic teams on FAP and several related projects to exhume and document mass grave sites that were not designated for investigation by other organizations, and to collect unique personal information on victims from families and match them with data collected from postmortem examinations. The Forensic Monitoring Reports summarize the findings from exhumations at over 500 sites and sub-sites across the country. The reports are of two types: Findings (1997-1998) and the follow-up Consultation Reports (1999). Each report offers a summary of events prior to exhumation and a detailed description of the exhumation process itself, a list of participants and observers (forensics, law enforcement, military, or local media), a description of the grave site and its history and, where applicable, a record of the postmortem findings. Reports often provide information on the circumstances in which individuals were killed and their alleged status (civilian or military), while the postmortem findings may reveal victims’ identities. The written account is supported with substantial visual documentation. With a few exceptions, each report contains several color photographs detailing various aspects of the exhumation process. Geographic coordinates for all grave sites and sub-sites are provided and represented on area maps by the US Department of Defense. Occasionally, hand-drawn maps or computer generated site diagrams are also available, showing field objects, the exact position of graves and orientation of bodies. ''' def List spatiaCoverages = ['Bosnia and Hercegovina'] def EadArchDesc eadArchDesc = new EadArchDesc(dateCreated:new EadDate(normal:'1997-1999', value:'1997-1999'),pid:this.collectionPID, landingPage:new EadDaoLoc(href:this.collectionPID), //dateAccumulated:new EadDate(normal:'1948-1990', value:'1948-1990'), temporalCoverages:[ '1992-1995. Exhumations took place from 1997-1999.' ], spatialCoverages:spatiaCoverages, 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:'Physicians for Human Rights Forensic Monitoring Reports', language:'eng') ], repository:this.dataProvider, physicalDescriptions:[ new EadPhysDesc(extents:[ new LanguagedValue(value:'137') ], genreforms:[ new LanguagedValue(value:'Technical reports; Reports', language:'eng') ]) ], originations:[ new EadOrigination(corpnames:[ new LanguagedValue(value:'Radio Free Europe/Radio Liberty (RFE/RL) Research Institute', language:'eng') ]) ], langmaterials:[ new Language(code:'eng', text:'English'), new Language(code:'Bosnian', text:'Bosnian') ]) ) 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 } }