Class NamespaceManager
- java.lang.Object
-
- es.bsc.dataclay.util.management.AbstractManager
-
- es.bsc.dataclay.logic.namespacemgr.NamespaceManager
-
- All Implemented Interfaces:
CommonManager
public final class NamespaceManager extends AbstractManager
This class is responsible for managing namespaces (add and remove).
-
-
Field Summary
-
Fields inherited from class es.bsc.dataclay.util.management.AbstractManager
dataSource
-
-
Constructor Summary
Constructors Constructor Description NamespaceManager(SQLiteDataSource dataSource)
Instantiates a Namespace Manager that uses the Namespace DB in the provided path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashSet<ImportedInterface>
checkImportsOfClassAreNotUsedAndGet(NamespaceID namespaceID, String className)
Verify that there is an imported interface in contract with IDs provided and it is not used by any property, operation or implementation and is not the parent class of any other class.Namespace
checkNamespaceResponsibleAndGetInfo(NamespaceID namespaceID, AccountID responsible)
This operation checks whether an account is responsible for a namespacevoid
cleanCaches()
Method that cleans the caches of the manager.NamespaceManagerDB
getDbHandler()
Method used for unit testing.HashSet<ImportedInterface>
getImportedInterfaces(NamespaceID namespaceID, String className)
This operation gets information of the imported interfaces for a specific class in a specific namespaceMap<MetaClassID,Set<ImportedInterface>>
getImportedInterfacesForMetaclasses(NamespaceID namespaceID, Set<MetaClassID> metaClassIDs)
This operation gets information of the imported interfaces in the namespace specified for the given metaclassesHashSet<ImportedInterface>
getImportsOfAccount(AccountID accountID)
Get all the information of all the imports in the namespaces of the account with ID providedHashSet<ImportedInterface>
getImportsOfAccountInNamespace(AccountID accountID, NamespaceID namespaceID)
Get all the information of the imports in the given namespace of the account with ID providedNamespaceID
getNamespaceID(String namespaceName)
Returns the namespaceID of the specified namespace nameNamespace
getNamespaceInfo(NamespaceID namespaceID)
This operation retrieves the info of the given namespaceCommonMessages.Langs
getNamespaceLang(String namespaceName)
Returns the language of the specified namespace nameSet<String>
getNamespaceNamesThatImportsMetaClass(MetaClassID classID)
Get namespace names that import the metaclass with id providedMap<NamespaceID,Namespace>
getNamespacesInfo(Set<NamespaceID> namespacesIDs)
This operation retrieves the info of the given namespaceSet<String>
getNamespacesNames()
Get all names of namespacesvoid
importInterfaces(NamespaceID namespaceID, Set<ImportedInterface> newImportedInterfaces)
Register a set of new imported interfaces in the namespaceNamespaceID
newNamespace(Namespace newNamespace)
This operation creates a new namespace.void
registerImplementationsUsingImportedClass(NamespaceID namespaceID, Set<ImplementationID> implementationsIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the implementations with IDs provided as using an imported classvoid
registerOperationsUsingImportedClass(NamespaceID namespaceID, Set<OperationID> operationsIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the operations with IDs provided as using an imported classvoid
registerPropertiesUsingImportedClass(NamespaceID namespaceID, Set<PropertyID> propertiesIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the properties with IDs provided as using an imported classvoid
registerSubClassesUsingImportedClass(NamespaceID namespaceID, Set<MetaClassID> metaClassesIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the classes with IDs provided as extending from an imported classvoid
removeImportedInterfaces(NamespaceID namespaceID, Set<ImportedInterface> importedInterfaces)
Removes the imported interface in contract with IDs provided in the Namespace with ID specified.void
removeNamespace(NamespaceID namespaceID)
This operation removes the indicated namespacevoid
unregisterImplementationsFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<ImplementationID> implementationsIDs)
Unregisters the implementations with IDs provided from using any imports of the specified namespacevoid
unregisterOperationsFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<OperationID> operationsIDs)
Unregisters the operations with IDs provided from using any imports of the specified namespacevoid
unregisterSubClassesFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<MetaClassID> metaClassesIDs)
Unregisters the classes with IDs provided as using (by extension) from any imports of the specified namespace
-
-
-
Constructor Detail
-
NamespaceManager
public NamespaceManager(SQLiteDataSource dataSource)
Instantiates a Namespace Manager that uses the Namespace DB in the provided path.- Parameters:
dataSource
- Manager/service name.
-
-
Method Detail
-
newNamespace
public NamespaceID newNamespace(Namespace newNamespace)
This operation creates a new namespace.- Parameters:
newNamespace
- Namespace to create- Returns:
- namespaceID of the new namespace if the it was successfully created.
- Throws:
Exception
- if an exception occurs:
NamespaceExistsException if the namespace already exists
-
getNamespaceLang
public CommonMessages.Langs getNamespaceLang(String namespaceName)
Returns the language of the specified namespace name- Parameters:
namespaceName
- the name of the namespace- Returns:
- the language of the namespace
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
getNamespaceID
public NamespaceID getNamespaceID(String namespaceName)
Returns the namespaceID of the specified namespace name- Parameters:
namespaceName
- the name of the namespace- Returns:
- the id of the namespace
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
removeNamespace
public void removeNamespace(NamespaceID namespaceID)
This operation removes the indicated namespace- Parameters:
namespaceID
- NamespaceID of the namespace to be removed- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
getNamespacesInfo
public Map<NamespaceID,Namespace> getNamespacesInfo(Set<NamespaceID> namespacesIDs)
This operation retrieves the info of the given namespace- Parameters:
namespacesIDs
- IDs of the namespaces to be retrieved- Returns:
- the info of the namespaces
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
getNamespaceInfo
public Namespace getNamespaceInfo(NamespaceID namespaceID)
This operation retrieves the info of the given namespace- Parameters:
namespaceID
- IDs of the namespace to be retrieved- Returns:
- the info of the namespace
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
checkNamespaceResponsibleAndGetInfo
public Namespace checkNamespaceResponsibleAndGetInfo(NamespaceID namespaceID, AccountID responsible)
This operation checks whether an account is responsible for a namespace- Parameters:
responsible
- AccountID of the responsible to be checkednamespaceID
- ID of the namespace to be checked- Returns:
- true if accountID is responsible for namespaceID, false if not.
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
importInterfaces
public void importInterfaces(NamespaceID namespaceID, Set<ImportedInterface> newImportedInterfaces)
Register a set of new imported interfaces in the namespace- Parameters:
namespaceID
- ID of the namespace in which the interface is importednewImportedInterfaces
- Improted interfaces to register- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceAlreadyImportedException: If interface was already imported
-
removeImportedInterfaces
public void removeImportedInterfaces(NamespaceID namespaceID, Set<ImportedInterface> importedInterfaces)
Removes the imported interface in contract with IDs provided in the Namespace with ID specified.- Parameters:
namespaceID
- ID of the namespace containing the importimportedInterfaces
- the imported interfaces to be removed- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceNotImportedException: If interface with Name provided does not exist
-
checkImportsOfClassAreNotUsedAndGet
public HashSet<ImportedInterface> checkImportsOfClassAreNotUsedAndGet(NamespaceID namespaceID, String className)
Verify that there is an imported interface in contract with IDs provided and it is not used by any property, operation or implementation and is not the parent class of any other class.- Parameters:
namespaceID
- ID of the namespace that importsclassName
- name of the class- Returns:
- The info of the imports of the class in namespace, which are not in use
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
ImportedInterfaceInUseException: If an imported interface of the classname in namespace is in use
-
getImportedInterfaces
public HashSet<ImportedInterface> getImportedInterfaces(NamespaceID namespaceID, String className)
This operation gets information of the imported interfaces for a specific class in a specific namespace- Parameters:
namespaceID
- ID of the namespace that importsclassName
- the class to be checked- Returns:
- The information of the imported interfaces
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
getImportedInterfacesForMetaclasses
public Map<MetaClassID,Set<ImportedInterface>> getImportedInterfacesForMetaclasses(NamespaceID namespaceID, Set<MetaClassID> metaClassIDs)
This operation gets information of the imported interfaces in the namespace specified for the given metaclasses- Parameters:
namespaceID
- the id of the namespacemetaClassIDs
- the ids of the metaclasses- Returns:
- indexed table of the import information for every class
- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
ClassNotImportedException: if the class is not imported in namespace provided
-
getImportsOfAccount
public HashSet<ImportedInterface> getImportsOfAccount(AccountID accountID)
Get all the information of all the imports in the namespaces of the account with ID provided- Parameters:
accountID
- ID of the account- Returns:
- A set of import specifications of the imports in the namespaces of the account with ID provided. It can be empty.
- Throws:
Exception
- if an exception occurs.
-
getNamespaceNamesThatImportsMetaClass
public Set<String> getNamespaceNamesThatImportsMetaClass(MetaClassID classID)
Get namespace names that import the metaclass with id provided- Parameters:
classID
- ID of the class- Returns:
- Set of names of namespaces that import the metaclass with id provided
- Throws:
Exception
- if some exception occurs.
-
getNamespacesNames
public Set<String> getNamespacesNames()
Get all names of namespaces- Returns:
- set of namespaces names
-
getImportsOfAccountInNamespace
public HashSet<ImportedInterface> getImportsOfAccountInNamespace(AccountID accountID, NamespaceID namespaceID)
Get all the information of the imports in the given namespace of the account with ID provided- Parameters:
accountID
- ID of the accountnamespaceID
- ID of the namespace- Returns:
- A set of import specifications of the imports in the namespace of the account with ID provided. It can be empty.
- Throws:
Exception
- if an exception occurs.
-
registerPropertiesUsingImportedClass
public void registerPropertiesUsingImportedClass(NamespaceID namespaceID, Set<PropertyID> propertiesIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the properties with IDs provided as using an imported class- Parameters:
namespaceID
- ID of the namespace that importspropertiesIDs
- IDs of the properties using the importinterfacesInContractOfImportedClass
- the interfaces in contract of imported class- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceNotImportedException: If interface was not imported
-
registerOperationsUsingImportedClass
public void registerOperationsUsingImportedClass(NamespaceID namespaceID, Set<OperationID> operationsIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the operations with IDs provided as using an imported class- Parameters:
namespaceID
- ID of the namespace that importsoperationsIDs
- IDs of the operations using the importinterfacesInContractOfImportedClass
- the interfaces in contract of imported class- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceNotImportedException: If interface was not imported
-
registerImplementationsUsingImportedClass
public void registerImplementationsUsingImportedClass(NamespaceID namespaceID, Set<ImplementationID> implementationsIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the implementations with IDs provided as using an imported class- Parameters:
namespaceID
- ID of the namespace that importsimplementationsIDs
- IDs of the implementations using the importinterfacesInContractOfImportedClass
- the interfaces in contract of imported class- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceNotImportedException: If interface was not imported
-
registerSubClassesUsingImportedClass
public void registerSubClassesUsingImportedClass(NamespaceID namespaceID, Set<MetaClassID> metaClassesIDs, Map<ContractID,InterfaceID> interfacesInContractOfImportedClass)
Registers the classes with IDs provided as extending from an imported class- Parameters:
namespaceID
- ID of the namespace that importsmetaClassesIDs
- IDs of the classes extending the importinterfacesInContractOfImportedClass
- the interfaces in contract of imported class- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
InterfaceNotImportedException: If interface was not imported
-
unregisterOperationsFromUsingAnyImportedClassInNamespace
public void unregisterOperationsFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<OperationID> operationsIDs)
Unregisters the operations with IDs provided from using any imports of the specified namespace- Parameters:
namespaceID
- ID of the namespace that importsoperationsIDs
- IDs of the operations using the import- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
unregisterImplementationsFromUsingAnyImportedClassInNamespace
public void unregisterImplementationsFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<ImplementationID> implementationsIDs)
Unregisters the implementations with IDs provided from using any imports of the specified namespace- Parameters:
namespaceID
- ID of the namespace that importsimplementationsIDs
- IDs of the implementations using the import- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
unregisterSubClassesFromUsingAnyImportedClassInNamespace
public void unregisterSubClassesFromUsingAnyImportedClassInNamespace(NamespaceID namespaceID, Set<MetaClassID> metaClassesIDs)
Unregisters the classes with IDs provided as using (by extension) from any imports of the specified namespace- Parameters:
namespaceID
- ID of the namespace that importsmetaClassesIDs
- IDs of the classes extending the import- Throws:
Exception
- if an exception occurs:
NamespaceDoesNotExistException: if the namespace does not exist
-
getDbHandler
public NamespaceManagerDB getDbHandler()
Method used for unit testing.- Returns:
- The db handler reference of this manager.
-
cleanCaches
public void cleanCaches()
Description copied from interface:CommonManager
Method that cleans the caches of the manager. Used on testing.- Specified by:
cleanCaches
in interfaceCommonManager
- Specified by:
cleanCaches
in classAbstractManager
-
-