Class PepperJobImpl


  • public class PepperJobImpl
    extends PepperJob
    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
    • Field Detail

      • saltProject

        protected org.corpus_tools.salt.common.SaltProject saltProject
        The SaltProject which is converted by this job.
      • moduleResolver

        protected ModuleResolver moduleResolver
        A reference to the OSGi module resolver, to find modules matching to the step description
      • isWired

        protected boolean isWired
        Determines, if steps are already wired. This is necessary for #start().
      • isImportedCorpusStructure

        protected volatile boolean isImportedCorpusStructure
        flag to determine, if corpus structure has already been imported
      • isReadyToStart

        protected boolean isReadyToStart
        Determines if checkReadyToStart() was already called
      • inProgress

        protected volatile ReentrantLock inProgress
        Specifies if this job currently runs a conversion. If this is the case, some other operations, like adding Steps cannot be done simultaneously.
    • Constructor Detail

      • PepperJobImpl

        public PepperJobImpl​(String jobId)
        Initializes a PepperJobImpl and sets its unique identifier.
        Parameters:
        jobId - unique identifier for this job. The id is not changeable
    • Method Detail

      • getSaltProject

        public org.corpus_tools.salt.common.SaltProject getSaltProject()
        Returns the SaltProject which is converted by this job.
        Specified by:
        getSaltProject in class PepperJob
        Returns:
        SaltProject
      • setSaltProject

        public void setSaltProject​(org.corpus_tools.salt.common.SaltProject saltProject)
        Sets the SaltProject which is converted by this job.
        Parameters:
        saltProject - new SaltProject
      • getConfiguration

        public PepperConfiguration getConfiguration()
        returns the properties to customize the behavior of conversion for this single job.
        Returns:
        given customization properties
      • setConfiguration

        public void setConfiguration​(PepperConfiguration conf)
        Sets the properties to customize the behavior of conversion for this single job
        Parameters:
        conf - for customization
      • getModuleResolver

        public ModuleResolver 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
      • setModuleResolver

        public void setModuleResolver​(ModuleResolver moduleResolver)
        Sets a reference to the OSGi module resolver, to find modules matching to the step description.
        Parameters:
        moduleResolver - reference to resolver to resolve PepperModule objects
      • getManipulationSteps

        public List<Step> getManipulationSteps()
        Returns the list of all steps belonging to the manipulation phase.
        Returns:
        list of Step objects.
      • getImportSteps

        public List<Step> getImportSteps()
        Returns the list of all steps belonging to the import phase.
        Returns:
        list of Step objects.
      • getExportSteps

        public List<Step> getExportSteps()
        Returns the list of all steps belonging to the export phase.
        Returns:
        list of Step objects.
      • getAllSteps

        public List<Step> 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.
      • addStep

        public 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. Further tries to resolve the described PepperModule.
        Parameters:
        stepDesc - StepDesc object to be added to internal list
        Returns:
        the created Step object
      • wire

        protected void wire()
        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)
      • importCorpusStructures

        protected void importCorpusStructures()
        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().
      • unifyProposedImportOrders

        protected List<org.corpus_tools.salt.graph.Identifier> unifyProposedImportOrders​(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)
        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:
        sCorpusGraph - the SCorpusGraph for which the list has to be unified
        Returns:
        unified list
      • getStatusReport

        public String getStatusReport()
        {@inheritDoc PepperJob#getStatusReport()}
        Specified by:
        getStatusReport in class PepperJob
        Returns:
        a report of the progress status
      • getProcessingTime

        public Long getProcessingTime()
        Returns the amount of time the job already took.
        Returns:
        time in milli seconds
      • convertTo

        public 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 PepperJob.getSaltProject() is already 'filled'.
        Specified by:
        convertTo in class PepperJob
      • cancelConversion

        public void cancelConversion()
        Description copied from class: PepperJob
        Cancels the current conversion. This might not stop immediately, but might finish the running document controller jobs first.
        Specified by:
        cancelConversion in class PepperJob
      • isCancellationRequested

        public boolean isCancellationRequested()
        Get if someone requested to cancel this job.
        Returns:
        True if cancellation was requested.
      • getMemPolicy

        public MEMORY_POLICY getMemPolicy()
        Returns the set memory policy.
        Returns:
      • setMemPolicy

        protected void setMemPolicy​(MEMORY_POLICY memPolicy)
        Sets the memory policy. Don't change the memory policy, when job was started.
        Parameters:
        memPolicy -
      • setMaxNumerOfDocuments

        protected void setMaxNumerOfDocuments​(int maxNumOfDocuments)
      • getMaxNumberOfDocuments

        public int getMaxNumberOfDocuments()
        Returns the maximal number of SDocument objects which could be processed at the same time
        Returns:
        number of documents
      • getNumOfActiveDocuments

        public int getNumOfActiveDocuments()
        Returns the current number of SDocument objects which could be processed at the same time
        Returns:
        number of documents
      • getActiveDocuments

        public Set<DocumentController> getActiveDocuments()
        Returns a set of all currently active documents.
      • getPermissionForProcessDoument

        public boolean 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()} < {@link #getMaxNumberOfDocuments(), false otherwise
      • save

        public org.eclipse.emf.common.util.URI save​(org.eclipse.emf.common.util.URI uri)
        {@inheritDoc PepperJob#save(URI)}
        Specified by:
        save in class PepperJob
        Parameters:
        uri - The location where to store this job.
        Returns:
        Returns the URI where the Pepper job was stored, normally this is the passed uri, but if the passed uri is a folder, than a file having the job-if (PepperJob.getId()).
      • clear

        public void clear()
        {@inheritDoc PepperJob#clear()}
        Specified by:
        clear in class PepperJob
      • load

        public void load​(org.eclipse.emf.common.util.URI uri)
        {@inheritDoc PepperJob#load(URI)}
        Specified by:
        load in class PepperJob
        Parameters:
        uri - path of file to load.
      • toString

        public String toString()
        Returns a textual representation of this Pepper job. Note: This representation could not be used for serialization/deserialization purposes.
        Overrides:
        toString in class PepperJob
        Returns:
        textual representation