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.* import eu.dnetlib.hope.domains.visual.* class IISHNDAudio 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 = 'NonDigitalAudiovisualMaterial' def String collectionPID = 'NonDigitalAudiovisualMaterial' /** * 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 IISHLido iishLido = new IISHLido(resultsQueue:resultsQueue, inputQueue:inputQueue, isDigital:false, euroType:'AUDIO') def int numberOfRecords = iishLido.enqueueResults(template, collectionPID) template.reset() 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() 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%22Music+and+sound%22' def String abstractSum=''' The IISH Library holds about one million records. Next to scholarly journals and monographs in the field of social history, the original publications of the social movements, e.g. periodicals, posters and leaflets, as well as audio-visual recordings are abundantly present. All these materials are available for research and can be retrieved through different types of searches in the IISH catalogue. The scope of the library collections extends considerably beyond the boundaries of social history. This is thanks to the inclusion of specialized libraries and subject-based collections of books, leaflets, pamphlets, and periodicals. ''' def OAIHeader collOaiheader = new OAIHeader(repositoryId:repositoryId, identifier:collectionID, objIdentifier:repositoryId+"::"+collectionID) def LIDOCollection coll = new LIDOCollection(collectionID:collectionID,collectionPID:collectionPID, langCode:'eng', collItemLanguages:[ 'eng', 'dut', 'fra', 'ger', 'spa', 'rus', 'ara', 'tur', 'ita', 'por' ], titles:[ new LidoTitle(langCode:'eng', value:'Audio material on Social History from IISH Library, 1500-2013') ], abstractSummaries:[ new LidoDescription(langCode:'eng', value:abstractSum, type:'abstract') ], creationDates:['1900-2013'], accumulationDates:['1900-2013'], owners:[cpCompleteName], sizeItems:'4202', itemType:'audio, music', itemFormatStm:'', associatedPub:'', subjects:[], typedSubjects:[ new TypedSubjects(type:'association', dates:['1900-2013'], places:[]) ],repository:cpCompleteName, useRights:'', accessRights:'Rights reserved - Free access', europeanaType:'AUDIO', 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" } }