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 IISHEuroSocialMovement 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 = 'VIS_EuropeanSocialMovements' def String collectionPID = 'http://hdl.handle.net/10622/2EB8E2A3-5FDB-4F16-90B1-C8163C48BE89' /** * 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 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 abstractSum="A collection of visual materials on European Social Movements in the 19th and 20th century." def LIDOCollection coll = new LIDOCollection(collectionID:collectionID,collectionPID:collectionPID, langCode:'nld', collItemLanguages:[ 'fra', 'deu', 'nld', 'eng', 'spa', 'tur' ], titles:[ new LidoTitle(langCode:'eng', value:'European Social Movements') ], abstractSummaries:[ new LidoDescription(langCode:'eng', value:abstractSum, type:'abstract') ], creationDates:['1800-2000'], accumulationDates:[], owners:[cpCompleteName], sizeItems:'142839', itemType:'IMAGE', itemFormatStm:'photographs, posters, objects, prints, banners', associatedPub:'', subjects:[], typedSubjects:[ new TypedSubjects(type:'association', dates:['1800-2000'], places:[ new LidoPlace(preferredName:'Europe') ]) ],repository:cpCompleteName, useRights:'', 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" } }