Pepper  3.6.0
A highly extensible plattform for conversion and manipulationoflinguisticdata.
org.corpus_tools.pepper.core.PepperJobImpl Class Reference

This class represents a single, but entire conversion process in Pepper, containing the entire workflow like import, manipulation and export. More...

Inherits org.corpus_tools.pepper.common.PepperJob.

Public Member Functions

 PepperJobImpl (String jobId)
 Initializes a PepperJobImpl and sets its unique identifier. More...
 
SaltProject getSaltProject ()
 Returns the SaltProject which is converted by this job.
Returns
SaltProject

 
void setSaltProject (SaltProject saltProject)
 Sets the SaltProject which is converted by this job. More...
 
PepperConfiguration getConfiguration ()
 returns the properties to customize the behavior of conversion for this single job. More...
 
void setConfiguration (PepperConfiguration conf)
 Sets the properties to customize the behavior of conversion for this single job. More...
 
ModuleResolver getModuleResolver ()
 Returns a reference to the OSGi module resolver, to find modules matching to the step description. More...
 
void setModuleResolver (ModuleResolver moduleResolver)
 Sets a reference to the OSGi module resolver, to find modules matching to the step description. More...
 
List< StepgetManipulationSteps ()
 Returns the list of all steps belonging to the manipulation phase. More...
 
List< StepgetImportSteps ()
 Returns the list of all steps belonging to the import phase. More...
 
List< StepgetExportSteps ()
 Returns the list of all steps belonging to the export phase. More...
 
List< StepgetAllSteps ()
 Returns a of all steps belonging no matter, to which phase they belong. More...
 
synchronized void addStepDesc (StepDesc stepDesc)
 Overrides method PepperJob#addStepDesc(StepDesc), but calls it via super and than calls addStep(Step). More...
 
synchronized Step addStep (StepDesc stepDesc)
 Creates a new Step object containing all values of the passed StepDesc object and adds it to the workflow covered by this PepperJobImpl. More...
 
synchronized void addStep (Step step)
 Adds the passed Step object to the workflow covered by this PepperJobImpl object and tries to resolve the described PepperModule. More...
 
List< DocumentControllergetDocumentControllers ()
 Returns a list of all DocumentControllerImpl objects corresponding to each SDocument belonging to this job. More...
 
String getStatusReport ()
 {@inheritDoc PepperJob::getStatusReport()}
 
Long getProcessingTime ()
 Returns the amount of time the job already took. More...
 
void convert ()
 Starts the conversion of this job. More...
 
void convertFrom ()
 Imports a SaltProject from any format.For conversion a process can be modeled, similar to convert() with the difference, that no PepperExporter could be defined. The imported Salt model can be accessed via getSaltProject().
 
void convertTo ()
 Exports the SaltProject into any format.For conversion, a normal process could be created, except the use of an importer. Here the do-nothing importer is used, and it is expected, that the getSaltProject() is already 'filled'.
 
void cancelConversion ()
 Cancels the current conversion. More...
 
boolean isCancellationRequested ()
 Get if someone requested to cancel this job. More...
 
MEMORY_POLICY getMemPolicy ()
 Returns the set memory policy. More...
 
int getMaxNumberOfDocuments ()
 Returns the maximal number of SDocument objects which could be processed at the same time. More...
 
int getNumOfActiveDocuments ()
 Returns the current number of SDocument objects which could be processed at the same time. More...
 
Set< DocumentControllergetActiveDocuments ()
 Returns a set of all currently active documents.
 
boolean getPermissionForProcessDoument (DocumentController controller)
 Returns true, if a SDocument or more precisely spoken a SDocumentGraph could be woken up or imported. More...
 
void releaseDocument (DocumentController controller)
 Releases a document and reduces the internal counter for the number of currently processed documents (getNumOfActiveDocuments()).
 
URI save (URI uri)
 {@inheritDoc PepperJob::save(URI)}
 
void clear ()
 {@inheritDoc PepperJob::clear()}
 
void load (URI uri)
 {@inheritDoc PepperJob::load(URI)}
 
String toString ()
 Returns a textual representation of this Pepper job. More...
 
- Public Member Functions inherited from org.corpus_tools.pepper.common.PepperJob
String getId ()
 Returns the unique identifier for this job. More...
 
void setBaseDir (URI baseDir)
 Sets the base directory for this ModuleController. More...
 
URI getBaseDir ()
 Returns the base directory for this ModuleController. More...
 
JOB_STATUS getStatus ()
 Returns the current status of this job. More...
 
List< StepDescgetStepDescs ()
 Returns a list of all step descriptions. More...
 
StepDesc createStepDesc ()
 Creates a StepDesc object an returns it, without adding the created StepDesc object to this PepperJob object. More...
 

Protected Member Functions

List< DocumentBusgetDocumentBuses ()
 
synchronized void wire ()
 Wires all Step objects being contained by this object to be ready for start(). More...
 
synchronized void importCorpusStructures ()
 Imports corpus structures of all registered ImportCorpusStructureTest steps. More...
 
List< Identifier > unifyProposedImportOrders (SCorpusGraph sCorpusGraph)
 Returns a list of Identifiers corresponding to the SDocument objects contained in the passed SCorpusGraph object. More...
 
synchronized Collection< Pair< Step, Collection< String > > > checkReadyToStart ()
 Checks for each PepperModule in all steps, if it is ready to start, via calling PepperModule#isReadyToStart(). More...
 
void setMemPolicy (MEMORY_POLICY memPolicy)
 Sets the memory policy. More...
 
void setMaxNumerOfDocuments (int maxNumOfDocuments)
 

Protected Attributes

SaltProject saltProject = null
 The SaltProject which is converted by this job.
 
ModuleResolver moduleResolver = null
 A reference to the OSGi module resolver, to find modules matching to the step description.
 
List< DocumentBusdocumentBuses = null
 A list of all buses between the ModuleControllerImpl objects.
 
List< DocumentBusinitialDocumentBuses = null
 all documentBusses which are connected with PepperImporter modules
 
boolean isWired = false
 Determines, if steps are already wired. More...
 
volatile boolean isImportedCorpusStructure = false
 flag to determine, if corpus structure has already been imported
 
List< DocumentControllerdocumentControllers = null
 A list of all DocumentControllerImpl objects corresponding to each SDocument belonging to this job.
 
boolean isReadyToStart = false
 Determines if checkReadyToStart() was already called.
 
volatile ReentrantLock inProgress = new ReentrantLock()
 Specifies if this job currently runs a conversion. More...
 
volatile MEMORY_POLICY memPolicy = MEMORY_POLICY.MODERATE
 
- Protected Attributes inherited from org.corpus_tools.pepper.common.PepperJob
String id = null
 Identifier of this job. More...
 
JOB_STATUS status = JOB_STATUS.NOT_STARTED
 status of job
 
Vector< StepDescstepDescs = null
 list of all step descriptions
 

Detailed Description

This class represents a single, but entire conversion process in Pepper, containing the entire workflow like import, manipulation and export.


This object contains a list of single steps. Each of such steps represent one task in processing by a specific module. Such a step is represented by the Step class. To get the list of all steps, see getSteps(). Note: Do not use this list to add a further step. Use addStep(PepperModule) instead.

Order of tasks to be done for start of processing

If you do not follow this order in calling, and for instance call task 3 fist, than task 1 and task 2 will be done automatically.

Author
Florian Zipser

Constructor & Destructor Documentation

◆ PepperJobImpl()

org.corpus_tools.pepper.core.PepperJobImpl.PepperJobImpl ( String  jobId)

Initializes a PepperJobImpl and sets its unique identifier.

Parameters
jobIdunique identifier for this job. The id is not changeable

Member Function Documentation

◆ addStep() [1/2]

synchronized void org.corpus_tools.pepper.core.PepperJobImpl.addStep ( Step  step)

Adds the passed Step object to the workflow covered by this PepperJobImpl object and tries to resolve the described PepperModule.

Prerequisite

Parameters
stepStep object to be added to internal list

◆ addStep() [2/2]

synchronized Step org.corpus_tools.pepper.core.PepperJobImpl.addStep ( StepDesc  stepDesc)

Creates a new Step object containing all values of the passed StepDesc object and adds it to the workflow covered by this PepperJobImpl.

Further tries to resolve the described PepperModule.

Parameters
stepDescStepDesc object to be added to internal list
Returns
the created Step object

◆ addStepDesc()

synchronized void org.corpus_tools.pepper.core.PepperJobImpl.addStepDesc ( StepDesc  stepDesc)

Overrides method PepperJob#addStepDesc(StepDesc), but calls it via super and than calls addStep(Step).


{@inheritDoc PepperJob::addStepDesc(StepDesc)}

Reimplemented from org.corpus_tools.pepper.common.PepperJob.

◆ cancelConversion()

void org.corpus_tools.pepper.core.PepperJobImpl.cancelConversion ( )

Cancels the current conversion.

This might not stop immediately, but might finish the running document controller jobs first.

Reimplemented from org.corpus_tools.pepper.common.PepperJob.

◆ checkReadyToStart()

synchronized Collection<Pair<Step, Collection<String> > > org.corpus_tools.pepper.core.PepperJobImpl.checkReadyToStart ( )
protected

Checks for each PepperModule in all steps, if it is ready to start, via calling PepperModule#isReadyToStart().

Returns
a list of steps whose modules are not ready to start

◆ convert()

void org.corpus_tools.pepper.core.PepperJobImpl.convert ( )

Starts the conversion of this job.

Reimplemented from org.corpus_tools.pepper.common.PepperJob.

◆ getAllSteps()

List<Step> org.corpus_tools.pepper.core.PepperJobImpl.getAllSteps ( )

Returns a of all steps belonging no matter, to which phase they belong.


This computation could be expensive, when working more than once with the list, make a local copy and don't call this method twice.

Returns
list of Step objects.

◆ getConfiguration()

PepperConfiguration org.corpus_tools.pepper.core.PepperJobImpl.getConfiguration ( )

returns the properties to customize the behavior of conversion for this single job.

Returns
given customization properties

◆ getDocumentControllers()

List<DocumentController> org.corpus_tools.pepper.core.PepperJobImpl.getDocumentControllers ( )

Returns a list of all DocumentControllerImpl objects corresponding to each SDocument belonging to this job.

Returns
a list of all DocumentControllerImpls

◆ getExportSteps()

List<Step> org.corpus_tools.pepper.core.PepperJobImpl.getExportSteps ( )

Returns the list of all steps belonging to the export phase.

Returns
list of Step objects.

◆ getImportSteps()

List<Step> org.corpus_tools.pepper.core.PepperJobImpl.getImportSteps ( )

Returns the list of all steps belonging to the import phase.

Returns
list of Step objects.

◆ getManipulationSteps()

List<Step> org.corpus_tools.pepper.core.PepperJobImpl.getManipulationSteps ( )

Returns the list of all steps belonging to the manipulation phase.

Returns
list of Step objects.

◆ getMaxNumberOfDocuments()

int org.corpus_tools.pepper.core.PepperJobImpl.getMaxNumberOfDocuments ( )

Returns the maximal number of SDocument objects which could be processed at the same time.

Returns
number of documents

◆ getMemPolicy()

MEMORY_POLICY org.corpus_tools.pepper.core.PepperJobImpl.getMemPolicy ( )

Returns the set memory policy.

Returns

◆ getModuleResolver()

ModuleResolver org.corpus_tools.pepper.core.PepperJobImpl.getModuleResolver ( )

Returns a reference to the OSGi module resolver, to find modules matching to the step description.

Returns
reference to resolver to resolve PepperModule objects

◆ getNumOfActiveDocuments()

int org.corpus_tools.pepper.core.PepperJobImpl.getNumOfActiveDocuments ( )

Returns the current number of SDocument objects which could be processed at the same time.

Returns
number of documents

◆ getPermissionForProcessDoument()

boolean org.corpus_tools.pepper.core.PepperJobImpl.getPermissionForProcessDoument ( DocumentController  controller)

Returns true, if a SDocument or more precisely spoken a SDocumentGraph could be woken up or imported.

This is the case, as long as:
getNumOfActiveDocuments() < getMaxNumberOfDocuments().
Must be synchronized,

Returns
true, when #getCurrNumberOfDocuments()} < false otherwise

◆ getProcessingTime()

Long org.corpus_tools.pepper.core.PepperJobImpl.getProcessingTime ( )

Returns the amount of time the job already took.

Returns
time in milli seconds

◆ importCorpusStructures()

synchronized void org.corpus_tools.pepper.core.PepperJobImpl.importCorpusStructures ( )
protected

Imports corpus structures of all registered ImportCorpusStructureTest steps.

After calling PepperImporter#importCorpusStructure(SCorpusGraph) , all following modules will be asked, if they want to influence the order of importing documents. If this is the case, an order is created and put to all PepperImporter objects.
This method produces as much as SCorpusGraph objects as Step given in import step list getImportSteps(). The position of SCorpusGraph corresponding to PepperImporter (importing that graph) in SaltProject#getCorpusGraphs() is equivalent to position of Step in list getImportSteps().

◆ isCancellationRequested()

boolean org.corpus_tools.pepper.core.PepperJobImpl.isCancellationRequested ( )

Get if someone requested to cancel this job.

Returns
True if cancellation was requested.

◆ setConfiguration()

void org.corpus_tools.pepper.core.PepperJobImpl.setConfiguration ( PepperConfiguration  conf)

Sets the properties to customize the behavior of conversion for this single job.

Parameters
conffor customization

◆ setMemPolicy()

void org.corpus_tools.pepper.core.PepperJobImpl.setMemPolicy ( MEMORY_POLICY  memPolicy)
protected

Sets the memory policy.

Don't change the memory policy, when job was started.

Parameters
memPolicy

◆ setModuleResolver()

void org.corpus_tools.pepper.core.PepperJobImpl.setModuleResolver ( ModuleResolver  moduleResolver)

Sets a reference to the OSGi module resolver, to find modules matching to the step description.

Parameters
moduleResolverreference to resolver to resolve PepperModule objects

◆ setSaltProject()

void org.corpus_tools.pepper.core.PepperJobImpl.setSaltProject ( SaltProject  saltProject)

Sets the SaltProject which is converted by this job.

Parameters
saltProjectnew SaltProject

◆ toString()

String org.corpus_tools.pepper.core.PepperJobImpl.toString ( )

Returns a textual representation of this Pepper job.

Note: This representation could not be used for serialization/deserialization purposes.

Returns
textual representation

Reimplemented from org.corpus_tools.pepper.common.PepperJob.

◆ unifyProposedImportOrders()

List<Identifier> org.corpus_tools.pepper.core.PepperJobImpl.unifyProposedImportOrders ( SCorpusGraph  sCorpusGraph)
protected

Returns a list of Identifiers corresponding to the SDocument objects contained in the passed SCorpusGraph object.

If all registered modules, do not make a proposal, the natural one (the one given by the order of SDocuments in SCorpusGraph) is taken. Note: Currently, this method does not a real unification, if more than one proposals are given, the first one is taken.

Parameters
sCorpusGraphthe SCorpusGraph for which the list has to be unified
Returns
unified list

◆ wire()

synchronized void org.corpus_tools.pepper.core.PepperJobImpl.wire ( )
protected

Wires all Step objects being contained by this object to be ready for start().

Which means, that:

  1. each step of getImportSteps() is wired via a initial document bus with the framework (no wiring, but listening on ID_INTITIAL)
  2. each step of getManipulationSteps() is wired with following step in list with a DocumentBus.
  3. each step of getExportSteps() is wired via a terminal document bus with the framework (no wiring, but listening on ID_TERMINAL)

Member Data Documentation

◆ inProgress

volatile ReentrantLock org.corpus_tools.pepper.core.PepperJobImpl.inProgress = new ReentrantLock()
protected

Specifies if this job currently runs a conversion.

If this is the case, some other operations, like adding Steps cannot be done simultaneously.

◆ isWired

boolean org.corpus_tools.pepper.core.PepperJobImpl.isWired = false
protected

Determines, if steps are already wired.

This is necessary for start().