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.LandingPage import eu.dnetlib.hope.domains.common.OAIHeader import eu.dnetlib.hope.domains.visual.LIDOCollection import eu.dnetlib.hope.domains.visual.LidoDescription import eu.dnetlib.hope.domains.visual.LidoPlace import eu.dnetlib.hope.domains.visual.LidoTitle import eu.dnetlib.hope.domains.visual.TypedSubjects class IISHAHP implements RunnableGroovy { def String cpCompleteName = "International Institute of Social History" def BlockingQueue resultsQueue, inputQueue def String templatePath = "/var/lib/hope-scripts/templates" def String repositoryId def String collectionID = 'geheugen3' def String collectionPID = 'http://hdl.handle.net/10622/A51E3BCD-2FD7-4342-A2E4-2994BEB9312F' /** * Driver namespace for elements in the OAI header. */ def dri = new groovy.xml.Namespace("http://www.driver-repository.eu/namespace/dri", 'dri') @Override public void run() { try{ def StringTemplateGroup group = new StringTemplateGroup("visualGroup", templatePath, DefaultTemplateLexer.class); def StringTemplate template = group.getInstanceOf("visualTemplate"); def coll = generateCollectionRecord(template) def OAIHeader oaiHeader = new OAIHeader(dateOfCollection:'', repositoryId:repositoryId, identifier:collectionID, objIdentifier:repositoryId+'::'+collectionID) def String collXML = coll.getXML(template, oaiHeader, cpCompleteName, coll) this.resultsQueue.put(collXML) template.reset() def iishLido = new IISHLido(resultsQueue:resultsQueue, inputQueue:inputQueue) iishLido.enqueueResults(template, coll.getCollectionPID()) this.resultsQueue.put("END") println "closedQueue" }catch(Exception e){ this.resultsQueue.put("FAIL") println "closedQueue after exception in groovy execution"+e throw new RuntimeException(e) } } def generateCollectionRecord = { template -> def String lPageURL = collectionPID def String providerName = cpCompleteName def String abstractSum="""As founder, owner, director and often sole photographer of the Algemeen Hollands Fotopersbureau (General Dutch Photo Press Agency), Ben van Meerendonk documented changes as they occurred in the Netherlands in the 1950s and 1960s. "After many years of oblivion, his photography has since been rediscovered and has recently again gained wide popularity. "Almost 1900 photographs offer a good overview of Van Meerendonk's specialties: reportages on Dutch celebrities at home, international stars visiting the Netherlands, everyday occurrences on the streets of Amsterdam, and sports photography. "The pictures originate from the 75,000 negatives in the Ben van Meerendonk/Algemeen Hollands Fotopersbureau collection.""" def LIDOCollection coll = new LIDOCollection(collectionID:collectionID, collectionPID:collectionPID, langCode:'nld', collItemLanguages:['nld'], titles:[ new LidoTitle(langCode:'dut', value:'Algemeen Hollands Fotopersbureau, 1945-1969'), new LidoTitle(langCode:'eng', value:'General Dutch Press Photograph Agency, 1945-1969') ], abstractSummaries:[ new LidoDescription(langCode:'eng', value:abstractSum, type:'abstract') ], creationDates:['1945-1969'], accumulationDates:[], owners:[providerName], sizeItems:'1869', itemType:'IMAGE', itemFormatStm:'photographs', associatedPub:'', subjects:[], typedSubjects:[ new TypedSubjects(type:'association', dates:['1945-1969'], places:[ new LidoPlace(preferredName:'NL') ]) ],repository:providerName, useRights:"Copyright International Institute of Social History", accessRights:'Rights reserved - Free access', europeanaType:'IMAGE', europeanaRights:'Rights reserved - Free access', landingPage:new LandingPage(href:lPageURL, localID:lPageURL)) return coll } @Override public void setRepositoryId(String repoId) { repositoryId = repoId; } @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") println "closedQueue" } }