Package org.corpus_tools.pepper.core
Class ModuleControllerImpl
- java.lang.Object
-
- org.corpus_tools.pepper.core.ModuleControllerImpl
-
- All Implemented Interfaces:
ModuleController
public class ModuleControllerImpl extends Object implements ModuleController
An object of this types contains aPepperModuleand handles as a connector between such an object and the Pepper framework.- Author:
- Florian Zipser
-
-
Field Summary
Fields Modifier and Type Field Description protected ReentrantLockbusyLockA lock determining, whether this object currently is busy with importing corpus structure or importing document structure.protected ExecutorServiceexecutorExecutor, to create and manage threads for import of corpus structure and import of document structureprotected Stringidid of this objectprotected PepperModulepepperModuleThePepperModuleobject, this controller object is observing.protected org.corpus_tools.salt.common.SCorpusGraphsCorpusGraphTheSCorpusGraphobject to be filled.
-
Constructor Summary
Constructors Constructor Description ModuleControllerImpl(String id)Creates an instance ofModuleControllerImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete(DocumentController documentController)Adds the givenDocumentControllerto the output document bus to be processed by the nextPepperModuleobjects.voiddelete(DocumentController documentController)Notifies the Pepper framework, that theSDocumentbeing contained in passedDocumentControllershall not be processed any further by following Pepper modules.protected ReentrantLockgetBusyLock()A lock determining, whether this object currently is busy with importing corpus structure or importing document structure.org.corpus_tools.salt.common.SCorpusGraphgetCorpusGraph()Returns theSCorpusGraphobject, the containedPepperImporteris mapping.protected ExecutorServicegetExecutor()Returns an executor service for this object.StringgetId()Returns the id of this object.DocumentBusgetInputDocumentBus()TheDocumentBusobject working as input for thisModuleControllerImpl.PepperJobImplgetJob()Returns thePepperJobImplobject reference of this object.DocumentBusgetOutputDocumentBus()All documents which were consumed by thePepperModulecontained in this object are set to this output bus, regarding the status, thePepperModulereturned.PepperModulegetPepperModule()Returns thePepperModuleobject, this controller object is observing.DoublegetProgress(String globalId)Returns the progress as a value between 0 and 1 of the containedPepperModuleobject concerning to theSDocumentcorresponding to the passed global identifier.Future<?>importCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)Starts the import of corpus structure via the setPepperImporterobject by callingPepperImporter.importCorpusStructure(SCorpusGraph).DocumentControllernext()Returns the nextDocumentControllerwaiting in the input document bus to be processed by the containedPepperModule.DocumentControllernext(boolean ignorePermissionForDocument){@inheritDoc ModuleController#next(boolean)}Future<?>processDocumentStructures()Starts the import of document-structure.voidsetInputDocumentBus(DocumentBus inputDocumentBus)TheDocumentBusobject working as input for thisModuleControllerImpl.voidsetJob(PepperJobImpl job)Sets thePepperJobImplobject reference of this object.voidsetJob_basic(PepperJobImpl job)Sets thePepperJobImplobject reference of this object.voidsetOutputDocumentBus(DocumentBus outputDocumentBus)All documents which were consumed by thePepperModulecontained in this object are set to this output bus, regarding the status, thePepperModulereturned.voidsetPepperModule(PepperModule newPepperModule)Sets thePepperModuleobject, this controller object is observing.voidsetPepperModule_basic(PepperModule newPepperModule)Sets thePepperModuleobject, this controller object is observing.StringtoString()Returns a String representation of this object.
-
-
-
Field Detail
-
id
protected String id
id of this object
-
pepperModule
protected PepperModule pepperModule
ThePepperModuleobject, this controller object is observing.
-
sCorpusGraph
protected volatile org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph
TheSCorpusGraphobject to be filled.
-
executor
protected ExecutorService executor
Executor, to create and manage threads for import of corpus structure and import of document structure
-
busyLock
protected ReentrantLock busyLock
A lock determining, whether this object currently is busy with importing corpus structure or importing document structure.
-
-
Constructor Detail
-
ModuleControllerImpl
public ModuleControllerImpl(String id)
Creates an instance ofModuleControllerImpl. Sets the internal id to the passed one. Note: the id is unchangeable.- Parameters:
id- identifier of this object. Id can neither be null nor empty.
-
-
Method Detail
-
getId
public String getId()
Returns the id of this object.- Specified by:
getIdin interfaceModuleController- Returns:
- the stable id
-
getPepperModule
public PepperModule getPepperModule()
Returns thePepperModuleobject, this controller object is observing.- Specified by:
getPepperModulein interfaceModuleController- Returns:
- observed object
-
setPepperModule
public void setPepperModule(PepperModule newPepperModule)
Sets thePepperModuleobject, this controller object is observing. Also sets the inverse methodPepperModule#setPepperModuleController_basic(ModuleControllerImpl)- Specified by:
setPepperModulein interfaceModuleController- Parameters:
newPepperModule- new object to observe
-
setPepperModule_basic
public void setPepperModule_basic(PepperModule newPepperModule)
Sets thePepperModuleobject, this controller object is observing.- Specified by:
setPepperModule_basicin interfaceModuleController- Parameters:
newPepperModule- new object to observe
-
getJob
public PepperJobImpl getJob()
Returns thePepperJobImplobject reference of this object.- Specified by:
getJobin interfaceModuleController- Returns:
- containing
PepperJobImplobject
-
setJob
public void setJob(PepperJobImpl job)
Sets thePepperJobImplobject reference of this object. And notifies the reverse methodPepperJobImpl, to set theModuleControllerImplobject to this.- Specified by:
setJobin interfaceModuleController- Parameters:
job- newPepperJobImplobject
-
setJob_basic
public void setJob_basic(PepperJobImpl job)
Sets thePepperJobImplobject reference of this object.- Specified by:
setJob_basicin interfaceModuleController- Parameters:
job- newPepperJobImplobject
-
getInputDocumentBus
public DocumentBus getInputDocumentBus()
TheDocumentBusobject working as input for thisModuleControllerImpl. All documents on bus will be processed and set to#outputDocumentBus- Specified by:
getInputDocumentBusin interfaceModuleController- Returns:
- bus which is input bus
-
setInputDocumentBus
public void setInputDocumentBus(DocumentBus inputDocumentBus)
TheDocumentBusobject working as input for thisModuleControllerImpl. All documents on bus will be processed and set to#outputDocumentBus- Specified by:
setInputDocumentBusin interfaceModuleController- Parameters:
inputDocumentBus- bus to be used as input bus
-
getOutputDocumentBus
public DocumentBus getOutputDocumentBus()
All documents which were consumed by thePepperModulecontained in this object are set to this output bus, regarding the status, thePepperModulereturned.- Specified by:
getOutputDocumentBusin interfaceModuleController- Returns:
- bus, which is output bus
-
setOutputDocumentBus
public void setOutputDocumentBus(DocumentBus outputDocumentBus)
All documents which were consumed by thePepperModulecontained in this object are set to this output bus, regarding the status, thePepperModulereturned.- Specified by:
setOutputDocumentBusin interfaceModuleController- Parameters:
outputDocumentBus- bus to be used as input bus
-
getCorpusGraph
public org.corpus_tools.salt.common.SCorpusGraph getCorpusGraph()
Returns theSCorpusGraphobject, the containedPepperImporteris mapping. This method will only return a non empty object, if the containedPepperModuleis anPepperImporterand ifModuleController.importCorpusStructure(SCorpusGraph)was called.- Specified by:
getCorpusGraphin interfaceModuleController- Returns:
-
getExecutor
protected ExecutorService getExecutor()
Returns an executor service for this object. Executor, to create and manage threads for import of corpus structure and import of document structure.- Returns:
-
importCorpusStructure
public Future<?> importCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)
Starts the import of corpus structure via the setPepperImporterobject by callingPepperImporter.importCorpusStructure(SCorpusGraph). The import runs in a separate thread, which is set as child of current thread. Therefore, don#t forget to call method, this method keeps the focus until, the import of the corpus structure has ended. This enables the calling object to wait until the corpus structure was imported. This method can only be invoked once per time.- Specified by:
importCorpusStructurein interfaceModuleController- Parameters:
sCorpusGraph- aSCorpusGraphobject, in which thePepperImportershall import the corpus structure.
-
processDocumentStructures
public Future<?> processDocumentStructures()
Starts the import of document-structure. When calling this method, theModuleControllerImplobject will request allDocumentControllerobject waiting in the incomingDocumentBus.
-
getBusyLock
protected ReentrantLock getBusyLock()
A lock determining, whether this object currently is busy with importing corpus structure or importing document structure.- Returns:
-
next
public DocumentController next(boolean ignorePermissionForDocument)
{@inheritDoc ModuleController#next(boolean)}- Specified by:
nextin interfaceModuleController- Parameters:
ignorePermissionForDocument- if set, a document will be returned even if the Pepper job gives no permission- Returns:
- next document controller
-
next
public DocumentController next()
Returns the nextDocumentControllerwaiting in the input document bus to be processed by the containedPepperModule.- Specified by:
nextin interfaceModuleController- Returns:
- next document controller
-
complete
public void complete(DocumentController documentController)
Adds the givenDocumentControllerto the output document bus to be processed by the nextPepperModuleobjects.- Specified by:
completein interfaceModuleController- Parameters:
documentController- to be passed to next Pepper module
-
delete
public void delete(DocumentController documentController)
Notifies the Pepper framework, that theSDocumentbeing contained in passedDocumentControllershall not be processed any further by following Pepper modules.- Specified by:
deletein interfaceModuleController
-
getProgress
public Double getProgress(String globalId)
Returns the progress as a value between 0 and 1 of the containedPepperModuleobject concerning to theSDocumentcorresponding to the passed global identifier.- Specified by:
getProgressin interfaceModuleController- Parameters:
globalId- global id forSDocument, note, that this is not theSElementId- Returns:
- progress of process
-
-