Package org.corpus_tools.pepper.modules
Interface PepperModule
-
- All Known Subinterfaces:
PepperExporter,PepperImporter,PepperManipulator
- All Known Implementing Classes:
DoNothingExporter,DoNothingImporter,DoNothingManipulator,DOTExporter,DOTManipulator,PepperExporterImpl,PepperImporterImpl,PepperManipulatorImpl,PepperModuleImpl,SaltValidator,SaltXMLExporter,SaltXMLImporter,TextExporter,TextImporter
public interface PepperModuleTODO make some docu- Author:
- Florian Zipser
-
-
Field Summary
Fields Modifier and Type Field Description static StringENDING_ALL_FILESAll kinds of file endingsstatic StringENDING_FOLDERA string specifying a value for a folder as ending.static StringENDING_LEAF_FOLDERA string specifying a value for a leaf folder as ending.static StringENDING_TABEnding for an tab file.static StringENDING_TXTEnding for an txt file.static StringENDING_XMLEnding for an xml file.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description PepperMappercreatePepperMapper(org.corpus_tools.salt.graph.Identifier sElementId)OVERRIDE THIS METHOD FOR CUSTOMIZED MAPPING.voiddone(PepperMapperController controller)This method is called by aPepperMapperControllerobject to notify thePepperModuleobject, that the mapping is done.voiddone(org.corpus_tools.salt.graph.Identifier identifier, DOCUMENT_STATUS result)This method is called by aPepperMapperControllerobject to notify thePepperModuleobject, that the mapping for this object is done.voidend()This method is called by the pepper framework at the end of a conversion process.org.osgi.service.component.ComponentContextgetComponentContext()Returns theComponentContextof the OSGi environment the bundle was started in.org.corpus_tools.salt.common.SCorpusGraphgetCorpusGraph()Returns theSCorpusGraphobject which is filled, manipulated or exported by the current module.StringgetDesc()Returns a short description of this module.PepperModuleDescgetFingerprint()Returns aPepperModuleDescobject, which is a kind of a fingerprint of thisPepperModule.ModuleControllergetModuleController()Returns the container and controller object for the current module.MODULE_TYPEgetModuleType()Returns the type of this module.StringgetName()Returns the name of this module.DoublegetProgress()This method is invoked by the Pepper framework, to get the current total progress of allSDocumentobjects being processed by this module.DoublegetProgress(String globalId)This method is invoked by the Pepper framework, to get the current progress concerning theSDocumentobject corresponding to the givenIdentifierin percent.PepperModulePropertiesgetProperties()Returns aPepperModulePropertiesobject containing properties to customize the behavior of thisPepperModule.org.eclipse.emf.common.util.URIgetResources()Returns the path of the folder which might contain resources for a Pepper module.org.corpus_tools.salt.common.SaltProjectgetSaltProject()Returns theSaltProjectobject, which is filled, manipulated or exported by the current module.SelfTestDescgetSelfTestDesc()This method is called by the Pepper framework to run an integration test for module.Collection<String>getStartProblems()IfisReadyToStart()has returned false, this method returns a list of reasons why this module is not ready to start.org.eclipse.emf.common.util.URIgetSupplierContact()Returns a uri where to find more information about this module and where to find some contact information to contact the supplier.org.eclipse.emf.common.util.URIgetSupplierHomepage()Sets theURIto the homepage describing the functionality of the module.StringgetSymbolicName()Returns the symbolic name of this OSGi bundle.org.eclipse.emf.common.util.URIgetTemproraries()Deprecated.StringgetVersion()Returns the version of this module.booleanisMultithreaded()Returns whether thisPepperModuleis able to run multithreaded.booleanisReadyToStart()This method is called by the pepper framework after initializing this object and directly before start processing.List<org.corpus_tools.salt.graph.Identifier>proposeImportOrder(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)This method could be overridden, to make a proposal for the import order ofSDocumentobjects.voidsetCorpusGraph(org.corpus_tools.salt.common.SCorpusGraph value)Sets theSCorpusGraphobject which is filled, manipulated or exported by the current module.voidsetDesc(String desc)Sets a short description of this module.voidsetIsMultithreaded(boolean isMultithreaded)Sets whether thisPepperModuleis able to run multithreaded.voidsetPepperModuleController(ModuleController value)Sets the container and controller object for the current module.voidsetPepperModuleController_basic(ModuleController value)Sets the container and controller object for the current module.voidsetProperties(PepperModuleProperties properties)Sets thePepperModulePropertiesobject containing properties to customize the behavior of thisPepperModule.voidsetResources(org.eclipse.emf.common.util.URI value)Sets the resource folder used bygetResources().voidsetSaltProject(org.corpus_tools.salt.common.SaltProject value)Sets theSaltProjectobject, which is filled, manipulated or exported by the current module.voidsetSupplierContact(org.eclipse.emf.common.util.URI eMail)Sets a uri where to find more information about this module and where to find some contact information to contact the supplier.voidsetSupplierHomepage(org.eclipse.emf.common.util.URI hp)Returns theURIto the homepage describing the functionality of the module.voidsetSymbolicName(String value)Sets the symbolic name of this OSGi bundle.voidsetTemproraries(org.eclipse.emf.common.util.URI value)Deprecated.voidsetVersion(String value)Sets the version of this module.voidstart()Starts the conversion process.voidstart(org.corpus_tools.salt.graph.Identifier sElementId)This method is called by the methodstart().
-
-
-
Field Detail
-
ENDING_FOLDER
static final String ENDING_FOLDER
A string specifying a value for a folder as ending. This is useful for#setTypeOfResource(URI), to determine, that even a folder can be mapped to a resource.Can be used by importers to be put in collection#getDocumentEndings()or#getCorpusEndings()- See Also:
- Constant Field Values
-
ENDING_LEAF_FOLDER
static final String ENDING_LEAF_FOLDER
A string specifying a value for a leaf folder as ending. This is useful for#setTypeOfResource(URI), to determine, that even a leaf folder can be mapped to a resource. Can be used by importers to be put in collection#getDocumentEndings()or#getCorpusEndings()- See Also:
- Constant Field Values
-
ENDING_XML
static final String ENDING_XML
Ending for an xml file. Can be used by importers to be put in collection#getDocumentEndings()or#getCorpusEndings()- See Also:
- Constant Field Values
-
ENDING_TXT
static final String ENDING_TXT
Ending for an txt file. Can be used by importers to be put in collection#getDocumentEndings()or#getCorpusEndings()- See Also:
- Constant Field Values
-
ENDING_TAB
static final String ENDING_TAB
Ending for an tab file. Can be used by importers to be put in collection#getDocumentEndings()or#getCorpusEndings()- See Also:
- Constant Field Values
-
ENDING_ALL_FILES
static final String ENDING_ALL_FILES
All kinds of file endings- See Also:
- Constant Field Values
-
-
Method Detail
-
getFingerprint
PepperModuleDesc getFingerprint()
Returns aPepperModuleDescobject, which is a kind of a fingerprint of thisPepperModule. This fingerprint for instance contains information like the name, the version of this module or information about the supplier.- Returns:
- fingerprint to this module
-
getModuleType
MODULE_TYPE getModuleType()
Returns the type of this module.- Returns:
- type of module
-
getComponentContext
org.osgi.service.component.ComponentContext getComponentContext()
Returns theComponentContextof the OSGi environment the bundle was started in.- Returns:
-
getName
String getName()
Returns the name of this module. In most cases, the name somehow describes the task of the module.- Returns:
- the value of the 'Name' attribute.
-
getVersion
String getVersion()
Returns the version of this module.- Returns:
- the value of the 'Version' attribute.
-
setVersion
void setVersion(String value)
Sets the version of this module. The version normally is set internally, this method only exists for dependency injection, by the modules project itself. But this method is never called by the pepper framework.- Parameters:
value- the new value of the 'Version' attribute.
-
getDesc
String getDesc()
Returns a short description of this module. Please support some information, for the user, of what task this module does.- Returns:
- a short description of the task of this module
-
setDesc
void setDesc(String desc)
Sets a short description of this module. Please support some information, for the user, of what task this module does.- Parameters:
desc- a short description of the task of this module
-
getSupplierContact
org.eclipse.emf.common.util.URI getSupplierContact()
Returns a uri where to find more information about this module and where to find some contact information to contact the supplier.- Returns:
- contact address like eMail address or homepage address
-
setSupplierContact
void setSupplierContact(org.eclipse.emf.common.util.URI eMail)
Sets a uri where to find more information about this module and where to find some contact information to contact the supplier.- Parameters:
uri- contact address like eMail address or homepage address
-
getSupplierHomepage
org.eclipse.emf.common.util.URI getSupplierHomepage()
Sets theURIto the homepage describing the functionality of the module.- Returns:
URIto the homepage
-
setSupplierHomepage
void setSupplierHomepage(org.eclipse.emf.common.util.URI hp)
Returns theURIto the homepage describing the functionality of the module.- Parameters:
hp-URIto the homepage
-
getProperties
PepperModuleProperties getProperties()
Returns aPepperModulePropertiesobject containing properties to customize the behavior of thisPepperModule.- Returns:
-
setProperties
void setProperties(PepperModuleProperties properties)
Sets thePepperModulePropertiesobject containing properties to customize the behavior of thisPepperModule. Please make sure, that this method is called in constructor of your module. If not, a generalPepperModulePropertiesobject is created by the pepper framework and will be initialized. This means, when calling this method later, all properties for customizing the module will be overridden.- Parameters:
properties-
-
getModuleController
ModuleController getModuleController()
Returns the container and controller object for the current module. TheModuleControllerobject is a kind of communicator between aPepperModuleand the pepper framework.- Returns:
- the value of the 'Pepper Module Controller' container reference.
-
setPepperModuleController
void setPepperModuleController(ModuleController value)
Sets the container and controller object for the current module. TheModuleControllerobject is a kind of communicator between aPepperModuleand the pepper framework. Also calls the inverse methodModuleController.setPepperModule_basic(PepperModule). Note, this method only should be called by pepper framework.- Parameters:
value- the new value of the 'Pepper Module Controller' container reference.
-
setPepperModuleController_basic
void setPepperModuleController_basic(ModuleController value)
Sets the container and controller object for the current module. TheModuleControllerobject is a kind of communicator between aPepperModuleand the pepper framework. Note, this method only should be called by pepper framework.- Parameters:
value- the new value of the 'Pepper Module Controller' container reference.
-
getSaltProject
org.corpus_tools.salt.common.SaltProject getSaltProject()
Returns theSaltProjectobject, which is filled, manipulated or exported by the current module.- Returns:
- the value of the 'Salt Project' attribute.
-
setSaltProject
void setSaltProject(org.corpus_tools.salt.common.SaltProject value)
Sets theSaltProjectobject, which is filled, manipulated or exported by the current module. Note: This method only should be called by the pepper framework.- Parameters:
value- the new value of the 'Salt Project' attribute.
-
getCorpusGraph
org.corpus_tools.salt.common.SCorpusGraph getCorpusGraph()
Returns theSCorpusGraphobject which is filled, manipulated or exported by the current module. TheSCorpusGraphobject is contained in the salt projectgetSaltProject().- Returns:
- the value of the 'SCorpus Graph' attribute.
-
setCorpusGraph
void setCorpusGraph(org.corpus_tools.salt.common.SCorpusGraph value)
Sets theSCorpusGraphobject which is filled, manipulated or exported by the current module. TheSCorpusGraphobject is contained in the salt projectgetSaltProject(). Note: This method only should be called by the pepper framework.- Parameters:
value- the new value of the 'SCorpus Graph' attribute.
-
getResources
org.eclipse.emf.common.util.URI getResources()
Returns the path of the folder which might contain resources for a Pepper module. This is the folder, which is delivered as part of the modules zip. Usually a Pepper module is a zip file containing a jar file and a folder having the same name as the jar file. In default configuration all files of folder "./src/main/resources" are copied to the resource folder.- Returns:
- path to resources
-
setResources
void setResources(org.eclipse.emf.common.util.URI value)
Sets the resource folder used bygetResources(). This method should only be invoked by the Pepper framework. The documentation ofgetResources()for more details.- Parameters:
value- path to resource folder
-
getTemproraries
@Deprecated org.eclipse.emf.common.util.URI getTemproraries()
Deprecated.TODO make docu
-
setTemproraries
@Deprecated void setTemproraries(org.eclipse.emf.common.util.URI value)
Deprecated.TODO make docu
-
getSymbolicName
String getSymbolicName()
Returns the symbolic name of this OSGi bundle.- Returns:
- the value of the 'Symbolic Name' attribute.
-
setSymbolicName
void setSymbolicName(String value)
Sets the symbolic name of this OSGi bundle. This value is set automatically inside the activate method, which is implemented inPepperModuleImplclass. If you want to manipulate that method. make sure to set the symbolic name and make sure, that it is set to the bundles symbolic name.- Parameters:
value- the new value of the 'Symbolic Name' attribute.
-
getStartProblems
Collection<String> getStartProblems()
IfisReadyToStart()has returned false, this method returns a list of reasons why this module is not ready to start.- Returns:
- a list describing the reasons, or an empty list if there were no problems
-
isReadyToStart
boolean isReadyToStart() throws PepperModuleNotReadyExceptionThis method is called by the pepper framework after initializing this object and directly before start processing. Initializing means setting propertiesPepperModuleProperties, setting temporary files, resources etc. . returns false or throws an exception in case ofPepperModuleinstance is not ready for any reason
This method is also called, when Pepper is in self-test mode, to check if module is correctly instantiated.
The default implementation checks:- if a path to resource folder is given
- if the
MODULE_TYPEis not null - if the name is not null
getStartProblems().- Returns:
- false,
PepperModuleinstance is not ready for any reason, true, else. - Throws:
PepperModuleNotReadyException
-
setIsMultithreaded
void setIsMultithreaded(boolean isMultithreaded)
Sets whether thisPepperModuleis able to run multithreaded. This method only should be called by the module itself.- Parameters:
isThreaded- true, if module can run in multithread mode.
-
isMultithreaded
boolean isMultithreaded()
Returns whether thisPepperModuleis able to run multithreaded. The behavior only should be set by the module itself via callingsetIsMultithreaded(boolean).- Returns:
- true, if module can run in multithread mode.
-
start
void start() throws PepperModuleExceptionStarts the conversion process. This method is the main method of a pepper module. If this method is not overridden, it will callstart(Identifier)for eachSDocumentandSCorpusobject being contained in the setSCorpusGraph. This is done in a multithreaded way by default. Note: When your module should not run in multithreaded mode, callsetIsMultithreaded(boolean).- Throws:
PepperModuleException
-
start
void start(org.corpus_tools.salt.graph.Identifier sElementId) throws PepperModuleExceptionThis method is called by the methodstart(). This is the only call in Pepper. You do not need to override this method, in case of you are happy with the default behavior. In default, this method invokes a multithreaded process, which createsPepperMapperobjects for each givenIdentifierobject, to process the correspondingSDocumentorSCorpusobject. ThePepperMapperobjects are not created by the method itself, the creation is delegated tocreatePepperMapper(Identifier), which has to be overridden. Default initializations are done there (for more details, please take a look into the doc of that method). Further this method links the createdPepperMapperobject to aPepperMapperControllerobject and makes sure, that the process runs in a by Pepper controlled manner.
Note: When your module should not run in multithreaded mode, callsetIsMultithreaded(boolean).
Note: In case of you override this method, please make sure to also override the following methods:#getProgress(Identifier)
- Throws:
PepperModuleException
-
createPepperMapper
PepperMapper createPepperMapper(org.corpus_tools.salt.graph.Identifier sElementId)
OVERRIDE THIS METHOD FOR CUSTOMIZED MAPPING. This method creates a customizedPepperMapperobject and returns it. You can here do some additional initialisations. Thinks like setting theIdentifierof theSDocumentorSCorpusobject and theURIresource is done by the framework (or more in detail in methodstart()). The parametersElementId, if aPepperMapperobject should be created in case of the object to map is either anSDocumentobject or anSCorpusobject of the mapper should be initialized differently.
Note: Override this method.- Parameters:
sElementId-Identifierof theSCorpusorSDocumentto be processed.- Returns:
PepperMapperobject to do the mapping task for object connected to givenIdentifier
-
proposeImportOrder
List<org.corpus_tools.salt.graph.Identifier> proposeImportOrder(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)
This method could be overridden, to make a proposal for the import order ofSDocumentobjects. Overriding this method is useful, in case of the order matters in the specific mapping of thisPepperModule. In this case a influencing the import order can decrease the processing time. If you do not want to influence the order, just return an empty list, or don't override this method.
In case you want to override this method, you can return a value for each passedSCorpusGraph.
OVERRIDE THIS METHOD FOR CUSTOMIZED MAPPING.- Parameters:
sCorpusGraph- theSCorpusGraphobject for which the order could be proposed- Returns:
- a list determining the import order of
SDocumentobjects
-
getProgress
Double getProgress(String globalId)
This method is invoked by the Pepper framework, to get the current progress concerning theSDocumentobject corresponding to the givenIdentifierin percent. A valid value return must be between 0 and 1.
Note: In case, you have overridden the methodstart(Identifier)orstart(), please also override this method, because it accesses an internal list of all mappers, which initialized instart(Identifier).- Parameters:
globalID- identifier of the requestedSDocumentobject, note, that this is not theIdentifier.
-
getProgress
Double getProgress()
This method is invoked by the Pepper framework, to get the current total progress of allSDocumentobjects being processed by this module. A valid value return must be between 0 and 1. This method can be overridden by a derivedPepperModuleclass. If this method is not overridden, it will return null.- Returns:
- the progress of all documents processed by this module
-
end
void end() throws PepperModuleException
This method is called by the pepper framework at the end of a conversion process. Means after all objects (SDocumentandSCorpusobjects) have been processed. This method can be used to do some clean up (e.g. to close streams etc.).- Throws:
PepperModuleException
-
done
void done(PepperMapperController controller)
This method is called by aPepperMapperControllerobject to notify thePepperModuleobject, that the mapping is done.- Parameters:
controller- The object which is done with its job
-
done
void done(org.corpus_tools.salt.graph.Identifier identifier, DOCUMENT_STATUS result)This method is called by aPepperMapperControllerobject to notify thePepperModuleobject, that the mapping for this object is done.- Parameters:
identifier-result-
-
getSelfTestDesc
SelfTestDesc getSelfTestDesc()
This method is called by the Pepper framework to run an integration test for module. When the method returns null, it means that no integration test is supported. Otherwise, theSelfTestDescobject needs to provide an input corpus path and an output corpus path. When this module is:- an importer:
SelfTestDesc.getInputCorpusPath()should contain the format to be imported.SelfTestDesc.getExpectedCorpusPath()should contain the expected salt project (for control). - a manipulator:
SelfTestDesc.getInputCorpusPath()should contain a salt project which is the module's input.SelfTestDesc.getExpectedCorpusPath()should contain the expected salt project (for control). - an exporter:
SelfTestDesc.getInputCorpusPath()should contain a salt project which is the module's input.SelfTestDesc.getExpectedCorpusPath()should contain the expected corpus in output format.
return new IntegrationTestDesc(inputPath, outputPath);
When this module is an importer or a manipulator the methodSelfTestDesc.compare(SaltProject, SaltProject)is called to compare output salt project with expected salt project. When the module is an exporter the methodSelfTestDesc.compare(URI, URI)is called to compare the created output folder with an expected one. By default this method checks whether the file structure and each file is equal.- Returns:
- test description
- an importer:
-
-