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.LidoTitle import eu.dnetlib.hope.domains.visual.TypedSubjects class IISHNDNonEuroSocialMovement 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 = 'VISNonEuropeanSocialMovements' def String collectionPID = 'VISNonEuropeanSocialMovements' /** * 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, nonDigitalCollection:true) def String collXML = coll.getXML(template, oaiHeader, cpCompleteName, coll) this.resultsQueue.put(collXML) template.reset() def IISHLido iishLido = new IISHLido(resultsQueue:resultsQueue, inputQueue:inputQueue, isDigital:false) 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 = 'http://search.socialhistory.org/Search/Results?lookfor=&type=AllFields&filter[]=format%3A%22Visual+documents%22' def String abstractSum="A collection of visual materials on international and worldwide social movements in the 19th and 20th century" def LIDOCollection coll = new LIDOCollection(collectionID:collectionID,collectionPID:collectionPID, langCode:'nld', collItemLanguages:[ 'eng', 'dut', 'fra', 'ger', 'spa', 'rus', 'ara', 'tur', 'ita', 'por' ], titles:[ new LidoTitle(langCode:'eng', value:'International and worldwide social movements 1800-2013') ], abstractSummaries:[ new LidoDescription(langCode:'eng', value:abstractSum, type:'abstract') ], creationDates:['1800-2013'], accumulationDates:['1800-2013'], owners:[cpCompleteName], sizeItems:'142839', itemType:'IMAGE', itemFormatStm:'photo, poster, drawing, print', associatedPub:'', subjects:[], typedSubjects:[ new TypedSubjects(type:'association', dates:['1800-2013'], places:[]) ],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" } }