Class Knowledge
- java.lang.Object
-
- org.gcube.informationsystem.discovery.knowledge.Knowledge
-
public class Knowledge extends Object
A singleton class that manages the discovery and validation of model knowledge from variousRegistrationProviders.- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected ModelKnowledgeallKnowledgeThe aggregated knowledge from all registered models.static org.slf4j.LoggerloggerThe logger for this class.protected Map<String,ModelKnowledge>modelKnowledgesA map of model knowledge, keyed by model name.protected Map<String,RegistrationProvider>registrationProvidersA map of registration providers, keyed by model name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddiscover()Discovers and builds the knowledge base from all availableRegistrationProviders found viaServiceLoader.ModelKnowledgegetAllKnowledge()Returns the aggregated knowledge from all registered models.static KnowledgegetInstance()Returns the singleton instance of theKnowledgeclass.static KnowledgegetInstance(boolean forceRediscover)Returns the singleton instance of theKnowledgeclass, with an option to force re-discovery.ModelKnowledgegetModelKnowledge(String modelName)Returns the knowledge for a specific model by name.ModelKnowledgegetModelKnowledge(RegistrationProvider rp)Returns the knowledge for a specific model.voidvalidateModelKnowledge(String modelName)Validates the discovered knowledge for a specific model by name.voidvalidateModelKnowledge(RegistrationProvider rp)Validates the discovered knowledge for a specific model.
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
The logger for this class.
-
allKnowledge
protected ModelKnowledge allKnowledge
The aggregated knowledge from all registered models.
-
modelKnowledges
protected Map<String,ModelKnowledge> modelKnowledges
A map of model knowledge, keyed by model name.
-
registrationProviders
protected Map<String,RegistrationProvider> registrationProviders
A map of registration providers, keyed by model name.
-
-
Method Detail
-
getInstance
public static Knowledge getInstance() throws Exception
Returns the singleton instance of theKnowledgeclass.- Returns:
- The singleton instance.
- Throws:
Exception- if an error occurs during discovery.
-
getInstance
public static Knowledge getInstance(boolean forceRediscover) throws Exception
Returns the singleton instance of theKnowledgeclass, with an option to force re-discovery.- Parameters:
forceRediscover-trueto force re-discovery of all models.- Returns:
- The singleton instance.
- Throws:
Exception- if an error occurs during discovery.
-
getAllKnowledge
public ModelKnowledge getAllKnowledge()
Returns the aggregated knowledge from all registered models.- Returns:
- The
ModelKnowledgefor all models.
-
getModelKnowledge
public ModelKnowledge getModelKnowledge(RegistrationProvider rp)
Returns the knowledge for a specific model.- Parameters:
rp- TheRegistrationProviderfor the model.- Returns:
- The
ModelKnowledgefor the specified model.
-
getModelKnowledge
public ModelKnowledge getModelKnowledge(String modelName)
Returns the knowledge for a specific model by name.- Parameters:
modelName- The name of the model.- Returns:
- The
ModelKnowledgefor the specified model.
-
validateModelKnowledge
public void validateModelKnowledge(RegistrationProvider rp) throws Exception
Validates the discovered knowledge for a specific model.- Parameters:
rp- TheRegistrationProviderfor the model to validate.- Throws:
Exception- if the validation fails.
-
validateModelKnowledge
public void validateModelKnowledge(String modelName) throws Exception
Validates the discovered knowledge for a specific model by name.- Parameters:
modelName- The name of the model to validate.- Throws:
Exception- if the validation fails.
-
discover
public void discover() throws ExceptionDiscovers and builds the knowledge base from all availableRegistrationProviders found viaServiceLoader.- Throws:
Exception- if an error occurs during discovery.
-
-