Class DocumentControllerImpl

  • All Implemented Interfaces:
    DocumentController

    public class DocumentControllerImpl
    extends Object
    implements DocumentController
    Stores the global status of a SDocument. And a list of tuples for all Modules and their current status. Can send SDocumentGraphs contained in given SDocument to sleep and wake them.
    Author:
    Florian Zipser
    • Field Detail

      • isStarted

        protected volatile boolean isStarted
        Determines, if this object is already 'started', which means if #updateStatus(String, DOCUMENT_STATUS) has been called.
      • numberOfProcessingModules

        protected volatile int numberOfProcessingModules
        Stores the number of PepperModule, currently processing this DocumentControllerImpl. Number is determined by method #updateStatus(String, DOCUMENT_STATUS)
      • currentModuleController

        protected volatile ModuleController currentModuleController
        stores the currently active document controller
    • Constructor Detail

      • DocumentControllerImpl

        public DocumentControllerImpl​(org.corpus_tools.salt.common.SDocument document)
        Initializes an object of this class. The default value of DOCUMENT_STATUS will be set to DOCUMENT_STATUS.NOT_STARTED.
        Parameters:
        document - SDocument object which is controlled by this object
    • Method Detail

      • getDocument

        public org.corpus_tools.salt.common.SDocument getDocument()
        Returns the SDocument object, to which this object belongs to.
        Specified by:
        getDocument in interface DocumentController
        Returns:
        document id
      • setDocument

        public void setDocument​(org.corpus_tools.salt.common.SDocument sDocument)
        Sets the SDocument object, to which this object belongs to. Computes the globalId ( see: DocumentController.getGlobalId()). Adds the global id as processing instruction to the SDocument object.
        Specified by:
        setDocument in interface DocumentController
        Parameters:
        sDocument - SDocument object to which this object belongs to
      • getDocumentId

        public org.corpus_tools.salt.graph.Identifier getDocumentId()
        Returns the Identifier of the SDocument object, to which this object belongs to.
        Specified by:
        getDocumentId in interface DocumentController
        Returns:
        document id
      • getGlobalId

        public String getGlobalId()
        Returns a global unique (inside one Salt project) id for the contained SDocument object. This identifier is computed by mthe number of the SCorpusGraph in list, this SDocument object is contained in and the Identifier of the SDocument. Imagine the number of the SCorpusGraph is 1 and the Identifier.getId() is /corpus1/document1, than the returned global id is /1/corpus1/document1.
        Specified by:
        getGlobalId in interface DocumentController
        Returns:
        a global unique (inside one Salt project) id for the contained SDocument object
      • setCallGC

        public void setCallGC​(boolean callGC)
        Sets whether the garbage collector should be called after sending a SDocument object to sleep.
        Parameters:
        callGC -
      • setLocation

        public void setLocation​(org.eclipse.emf.common.util.URI location)
        Sets location, where to store SDocumentGraph when #sleep() was called or load when DocumentController.awake() was called.
        Specified by:
        setLocation in interface DocumentController
        Parameters:
        location - location as URI
      • isAsleep

        public boolean isAsleep()
        Returns if the SDocumentGraph of contained SDocument is send to sleep or awake.
        Specified by:
        isAsleep in interface DocumentController
        Returns:
        true, if SDocumentGraph is asleep, false otherwise.
      • sleep

        protected void sleep()
        Sends the contained SDocument to sleep, which means, it will be stored to local disk and removed from main memory, by calling SDocument#saveSDocumentGraph(org.eclipse.emf.common.util.URI). The counterpart to this method is awake(). Both methods are synchronized.
      • sendToSleep

        public void sendToSleep()
        Notifies the DocumentControllerImpl object, that the contained SDocument or more precisely the SDocumentGraph object could be send to sleep. If no PepperModule is currently processing it, the SDocumentGraph is send to sleep. This means, the SDocumentGraph will be stored to local disk and removed from main memory, by calling SDocument#saveSDocumentGraph(org.eclipse.emf.common.util.URI). The counterpart to this method is DocumentController.awake(). Both methods are synchronized.
        Specified by:
        sendToSleep in interface DocumentController
      • awake

        public void awake()
        Wakes up the contained SDocument, which means, it the SDocumentGraph of the SDocument will be load to main memory again by calling SDocument#loadSDocumentGraph(). The counterpart to this method is #sleep(). Both methods are synchronized.
        Specified by:
        awake in interface DocumentController
      • toString

        public String toString()
        Returns a textual representation of this object. Note: This representation could not be used for serialization/deserialization purposes.
        Overrides:
        toString in class Object
        Returns:
        textual representation
      • getProcessingTime

        public Long getProcessingTime()
        Returns the processing time of the contained SDocument object, needed by all registered PepperModule, which have already started the process.
        Specified by:
        getProcessingTime in interface DocumentController
      • getStatusReport

        public String getStatusReport()
        Returns a formated string containing a report of the progress status of the contained document.
        Returns:
        a report of the progress status
      • getSize_nodes

        public int getSize_nodes()
        Stores the number of SNodes a document contains, when it ws send to sleep.
        Specified by:
        getSize_nodes in interface DocumentController
        Returns:
        number of SNode of the contained document
      • getSize_relations

        public int getSize_relations()
        Stores the number of SRelations a document contains, when it ws send to sleep.
        Specified by:
        getSize_relations in interface DocumentController
        Returns:
        number of SRelation of the contained document