|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The OntologyManager is the central component as it manages the elements of the ontology. It is reponsible for loading an existing ontology from a persistent backend store on application startup, and it must initialize the QueryEngine as well as export and import handlers.
The OntologyManager implementation can be configured with the key cf.ontologymanager
in the ConsensusFoundation.properties
configuration file. It's a core component and not optional.
The implementation is loaded by the ConsensusFoundation
constructor. For successful instantiation,
the OntologyManager implementation must provide a default constructor without arguments.
QueryEngine
,
ImportHandler
,
ExportHandler
,
ConsensusFoundation
,
EvolutionManager
Method Summary | |
void |
abortTransaction(Object scope,
Object ta)
This is a "quick rollback" for the transaction if no changes have been made to the ontology. |
void |
addExportHandler(ExportHandler handler)
Registers an ExportHandler instance with the OntologyManager. |
void |
addImportHandler(ImportHandler handler)
Registers an ImportHandler instance with the OntologyManager. |
void |
addOntologyListener(OntologyListener listener)
Registers a new OntologyListener. |
Rateable |
checkInternalRateable(Rateable rateable)
Checks the given rateable object if it is a special association that is usually wrapped inside a TypeInstance, SuperSubclass or Synonym. |
void |
commitTransaction(Object scope,
Object ta)
Commits the transaction for the given scope. |
Association |
createAssociation(User creator,
String id,
String name,
Topic type)
Creates an association of the given type. |
Attribute |
createAttribute(User creator,
String id,
String name,
String value,
Topic type)
Creates an attribute of the given type. |
Topic |
createClassTopic(User creator,
String id,
String name,
Topic cls)
Creates a class topic as a subclass of the given superclass topic. |
Topic |
createInternalTopic(User creator,
String id,
String name,
Topic type)
Creates an internal topic that is not visible through the topic collections, only by id query. |
Topic |
createTopic(User creator,
String id,
String name,
Topic type)
Creates a topic of the given type. |
void |
deleteAssociation(Association assoc)
Deletes an association permanently from the ontology. |
void |
deleteAttribute(Attribute attr)
Deletes an attribute permanently from the ontology. |
void |
deleteTopic(Topic topic)
Deletes a topic permanently from the ontology. |
ExportHandler |
getExportHandler(String format)
Returns an export handler for a certain file format. |
int |
getExportHandlerCount()
Returns the number of registered export handlers. |
Iterator |
getExportHandlers()
Returns all export handlers. |
ImportHandler |
getImportHandler(String format)
Returns an import handler for a certain file format. |
int |
getImportHandlerCount()
Returns the number of registered import handlers. |
Iterator |
getImportHandlers()
Returns all import handlers. |
ImportHandler |
getMergeHandler(String format)
Returns an import handler for a certain file format that can merge ontologies in this format. |
int |
getMergeHandlerCount()
Returns the number of registered import handlers that can merge ontologies. |
Iterator |
getMergeHandlers()
Returns all import handlers that can merge ontologies. |
QueryEngine |
getQueryEngine()
Returns the QueryEngine that is part of the OntologyManager. |
void |
init(Properties config,
LoggingManager logging,
UserManager users)
This method is called by the ConsensusFoundation constructor to initialize the OntologyManager.
|
Object |
openTransaction(Object scope)
Opens a transaction for the ontology backend. |
void |
removeOntologyListener(OntologyListener listener)
Removes an OntologyListener, if it is registered with the OntologyManager (otherwise this call is ignored). |
boolean |
reorg()
If the ontology needs reorganization from time to time, the implementation can clean up the ontology when an application calls this method. |
void |
rollbackTransaction(Object scope,
Object ta)
Rolls the transaction back for the given scope. |
Methods inherited from interface de.uka.ipd.consensus.foundation.ConsensusFoundationModule |
getConsensusFoundationManager, getVersion, initCompleted, shutdown |
Method Detail |
public void init(Properties config, LoggingManager logging, UserManager users) throws Exception
This method is called by the ConsensusFoundation
constructor to initialize the OntologyManager.
An implementation can use this method to restore an existing ontology from a persistent backend or to load a new ontology from a file (and replace an existing ontology). Import and export handlers should be initialized here, too.
config
- all entries from ConsensusFoundation.properties
logging
- the successfully initialized LoggingManager instanceusers
- the the successfully initialized UserManager instance
Exception
- if any error occurs (startup of the application is aborted in this case)ConsensusFoundation.ConsensusFoundation()
public Topic createTopic(User creator, String id, String name, Topic type) throws OntologyManagerException, DynamicRightsManagerException
creator
- the user who wants to create the topicid
- the id (must not be empty) or (usually) null
for an automatically computed idname
- the topic's name (must not be empty or null
)type
- the type topic for the topic or null
for a typeless topic
OntologyManagerDuplicateIdException
- if the id parameter is not null
and is already used within the ontology
OntologyManagerException
- if the topic could not be created
DynamicRightsManagerException
- if the user is not allowed to create topics of the given typeTopic.isClassTopic()
,
DynamicRightsManager.mayCreateTopic(User, Topic)
public Topic createClassTopic(User creator, String id, String name, Topic cls) throws OntologyManagerException, DynamicRightsManagerException
Topic.setClassTopic(true) is called after creation automatically.
creator
- the user who wants to create the class topicid
- the id (must not be empty) or (usually) null
for an automatically computed idname
- the topic's name (must not be empty or null
)cls
- the superclass topic for the new class topic or null
for a root class topic
OntologyManagerDuplicateIdException
- if the id parameter is not null
and is already used within the ontology
OntologyManagerException
- if the class topic could not be created
DynamicRightsManagerException
- if the user is not allowed to create class topics of the given type
UnsupportedOperationException
- if the implementation does not support classesTopic.isClassTopic()
,
Topic.setClassTopic(boolean)
,
DynamicRightsManager.mayCreateClassTopic(User, Topic)
public Topic createInternalTopic(User creator, String id, String name, Topic type) throws OntologyManagerException
If an id is given and an internal topic already exists with that id, the existing topic is returned instead of a newly created one.
Topic.setClassTopic(true) is called after creation automatically if the implementation uses classes.
creator
- the user who wants to create the internal topicid
- the id (must not be empty), null
for an automatically computed idname
- the topic's name (must not be empty or null
)type
- the type topic for the new topic or null
for a typeless topic
OntologyManagerException
- if the topic could not be createdTopic.isClassTopic()
,
Topic.setClassTopic(boolean)
public Association createAssociation(User creator, String id, String name, Topic type) throws OntologyManagerException, DynamicRightsManagerException
creator
- the user who wants to create the associationid
- the id (must not be empty) or (usually) null
for an automatically computed idname
- the association's name (null
is treated as the empty string)type
- the type topic for the association or null
for a typeless association
OntologyManagerDuplicateIdException
- if the id parameter is not null
and is already used within the ontology
OntologyManagerException
- if the association could not be created
DynamicRightsManagerException
- if the user is not allowed to create associations of the given typeTopic.isClassTopic()
,
DynamicRightsManager.mayCreateAssociation(User, Topic)
public Attribute createAttribute(User creator, String id, String name, String value, Topic type) throws OntologyManagerException, DynamicRightsManagerException
creator
- the user who wants to create the attributeid
- the id (must not be empty) or (usually) null
for an automatically computed idname
- the attribute's name (must not be empty or null
)value
- the attribute's value (null
is treated as the empty string)type
- the type topic for the attribute or null
for a typeless attribute
OntologyManagerDuplicateIdException
- if the id parameter is not null
and is already used within the ontology
OntologyManagerException
- if the attribute could not be created
DynamicRightsManagerException
- if the user is not allowed to create attributes of the given typeAttributeable.addAttribute(User, Attribute)
,
Topic.isClassTopic()
,
DynamicRightsManager.mayCreateAttribute(User, Topic)
public Rateable checkInternalRateable(Rateable rateable)
rateable
- the rateable object to be checked if it is a special internal association
TypeInstance
,
SuperSubclass
,
Synonym
public void deleteTopic(Topic topic) throws OntologyManagerException
To delete topics in an application, use the EvolutionManager that keeps the ontology consistent and checks the user's rights. The EvolutionManager will then use this method to do the actual deleting.
topic
- the topic to be deleted
OntologyManagerException
- if the topic cannot be deleted without making the ontology inconsistentEvolutionManager
public void deleteAssociation(Association assoc) throws OntologyManagerException
To delete associations in an application, use the EvolutionManager that keeps the ontology consistent and checks the user's rights. The EvolutionManager will then use this method to do the actual deleting.
assoc
- the association to be deleted
OntologyManagerException
- if the association cannot be deleted without making the ontology inconsistentEvolutionManager
public void deleteAttribute(Attribute attr) throws OntologyManagerException
To delete attributes in an application, use the EvolutionManager that keeps the ontology consistent and checks the user's rights. The EvolutionManager will then use this method to do the actual deleting.
attr
- the attribute to be deleted
OntologyManagerException
- if the attribute cannot be deleted without making the ontology inconsistentEvolutionManager
public QueryEngine getQueryEngine()
Note that the engine might be available only after initCompleted()
has finished.
public Object openTransaction(Object scope) throws OntologyManagerException
The return value is a transaction object if this call started a new transaction or null
if another transaction is already running for this scope.
You'll have to pass the exact return value to the commit/rollback method.
Note that the implementation is not required to use the scope information if the backend does not support scoped transactions.
If the backend does not support transactions at all, you'll always get null
as the return value, which you can safely pass
to the other transaction methods.
scope
- the scope how long the transaction will probably last
null
OntologyManagerException
- if the transaction could not be openedpublic void commitTransaction(Object scope, Object ta) throws OntologyManagerException
openTransaction()
to this method.
scope
- the scope for this transactionta
- the return value from openTransaction()
OntologyManagerException
- if the transaction could not be committed successfullyopenTransaction(Object)
public void rollbackTransaction(Object scope, Object ta) throws OntologyManagerException
openTransaction()
to this method.
scope
- the scope for this transactionta
- the return value from openTransaction()
OntologyManagerException
- if the transaction could not be rolled back successfullyopenTransaction(Object)
public void abortTransaction(Object scope, Object ta)
scope
- the scope for this transactionta
- the return value from openTransaction()
openTransaction(Object)
public void addExportHandler(ExportHandler handler)
ConsensusFoundation.properties
.
For each file format, only one export handler can be registered. Registering a format again replaces the older handler.
handler
- the ExportHandler to be added to the OntologyManager's list of export handlersExportHandler
public ExportHandler getExportHandler(String format)
format
- the required file format (e.g. "xtm")
null
if no export handler exists for the required formataddExportHandler(ExportHandler)
public Iterator getExportHandlers()
addExportHandler(ExportHandler)
public int getExportHandlerCount()
addExportHandler(ExportHandler)
public void addImportHandler(ImportHandler handler)
ConsensusFoundation.properties
.
For each file format, only one import handler can be registered. Registering a format again replaces the older handler.
handler
- the ImportHandler to be added to the OntologyManager's list of import and merge handlersImportHandler
public ImportHandler getImportHandler(String format)
format
- the required file format (e.g. "xtm")
null
if no import handler exists for the required formataddImportHandler(ImportHandler)
public ImportHandler getMergeHandler(String format)
format
- the required file format (e.g. "xtm")
null
if no import handler exists that can merge ontologies in the required formataddImportHandler(ImportHandler)
public Iterator getImportHandlers()
addImportHandler(ImportHandler)
public Iterator getMergeHandlers()
addImportHandler(ImportHandler)
public int getImportHandlerCount()
addImportHandler(ImportHandler)
public int getMergeHandlerCount()
addImportHandler(ImportHandler)
public boolean reorg() throws OntologyManagerException
true
if the reorganization was started due to this call or false
if an older reorganization is still running
OntologyManagerException
- if the reorganization could not be finished successfullypublic void addOntologyListener(OntologyListener listener)
listener
- the OntologyListener to be addedpublic void removeOntologyListener(OntologyListener listener)
listener
- the OntologyListener to be removed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |