Class PentahoMetadataDomainRepository
- java.lang.Object
-
- org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository
-
- All Implemented Interfaces:
org.pentaho.metadata.repository.IMetadataDomainRepository
,IAclAwarePentahoMetadataDomainRepositoryImporter
,IDataSourceAwareMetadataDomainRepository
,IModelAnnotationsAwareMetadataDomainRepositoryImporter
,IPentahoMetadataDomainRepositoryExporter
,IPentahoMetadataDomainRepositoryImporter
- Direct Known Subclasses:
CachingPentahoMetadataDomainRepository
,PentahoMondrianDomainRepository
,SecurityAwarePentahoMetadataDomainRepository
public class PentahoMetadataDomainRepository extends Object implements org.pentaho.metadata.repository.IMetadataDomainRepository, IModelAnnotationsAwareMetadataDomainRepositoryImporter, IAclAwarePentahoMetadataDomainRepositoryImporter, IPentahoMetadataDomainRepositoryExporter, IDataSourceAwareMetadataDomainRepository
Handles the storage and retrieval of Pentaho Metada Domain objects in a repository. It does this by using a pre-defined system location (defined byPentahoMetadataDomainRepositoryInfo
) as the storage location for the Domain files and associated locale files. Since Domain IDs are the unique identifier for Pentaho Metadata domains and may contain any character (including repository folder separator character(s) like '/', aUUID
will be created to store each file. The metadata for the file will be used to store the information (such as the Domain ID).- Author:
- David M. Kincade
-
-
Field Summary
-
Fields inherited from interface org.pentaho.metadata.repository.IMetadataDomainRepository
ACCESS_TYPE_ADMIN, ACCESS_TYPE_DELETE, ACCESS_TYPE_READ, ACCESS_TYPE_SCHEMA_ADMIN, ACCESS_TYPE_UPDATE, ACCESS_TYPE_WRITE
-
Fields inherited from interface org.pentaho.platform.plugin.services.metadata.IModelAnnotationsAwareMetadataDomainRepositoryImporter
ANNOTATIONS_FILE_ID_POSTFIX, PROPERTY_NAME_ANNOTATIONS
-
-
Constructor Summary
Constructors Modifier Constructor Description PentahoMetadataDomainRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository)
Creates an instance of this class providing theIUnifiedRepository
repository backend.protected
PentahoMetadataDomainRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository, org.pentaho.platform.repository2.unified.RepositoryUtils repositoryUtils, org.pentaho.metadata.util.XmiParser xmiParser, org.pentaho.metadata.util.LocalizationUtil localizationUtil)
Helper constructor used for setting other objects in this class
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDataSourceType(Map<String,Serializable> fileMetadata, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Adds datasource property to map based on serialized data converted to Domain object.void
addLocalizationFile(String domainId, String locale, InputStream inputStream, boolean overwrite)
void
addLocalizationFile(String domainId, String locale, Properties properties)
Adds a set of properties as a locale properties file for the specified Domain IDvoid
createOrUpdateAnnotationsXml(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile, org.pentaho.platform.api.repository2.unified.RepositoryFile annotationsFile, String annotationsXml)
protected org.pentaho.platform.api.repository2.unified.RepositoryFile
createUniqueFile(String filename, String domainId, String locale, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Creates a new repository file (with the supplied data) and applies the proper metadata to this file.protected org.pentaho.platform.api.repository2.unified.RepositoryFile
createUniqueFile(String domainId, String locale, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Creates a new repository file (with the supplied data) and applies the proper metadata to this file.protected String
endsWithXmi(String value)
void
flushDomains()
flush the domains from memoryString
generateRowLevelSecurityConstraint(org.pentaho.metadata.model.LogicalModel model)
org.pentaho.platform.api.repository2.unified.RepositoryFileAcl
getAclFor(String domainId)
protected org.pentaho.platform.api.repository2.unified.IAclNodeHelper
getAclHelper()
org.pentaho.platform.api.repository2.unified.RepositoryFile
getAnnotationsXmlFile(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile)
Set<String>
getDataSourceWizardDomainIds()
Return a list of all the domain ids in the repository of the data source type Metadata.org.pentaho.metadata.model.Domain
getDomain(String domainId)
retrieve a domain from the repo.Map<String,InputStream>
getDomainFilesData(String domainId)
protected String
getDomainIdFromXmi(StringBuilder sb)
Set<String>
getDomainIds()
return a list of all the domain ids in the repository.Map<String,Serializable>
getFileMetadataHelper(Serializable serializableId)
Only migrate if certain properties don't exist and other conditions.protected org.pentaho.metadata.util.LocalizationUtil
getLocalizationUtil()
protected org.apache.commons.logging.Log
getLogger()
protected org.pentaho.platform.api.repository2.unified.RepositoryFile
getMetadataDir()
Set<String>
getMetadataDomainIds()
Return a list of all the domain ids in the repository of the data source type Metadata.protected org.pentaho.platform.api.repository2.unified.RepositoryFile
getMetadataRepositoryFile(String domainId)
Accesses the metadata mapping (with 1 retry) to find the metadata file for the specified domainIdprotected org.pentaho.platform.api.repository2.unified.IUnifiedRepository
getRepository()
protected org.pentaho.platform.repository2.unified.RepositoryUtils
getRepositoryUtils()
protected org.pentaho.metadata.util.XmiParser
getXmiParser()
boolean
hasAccess(int accessType, org.pentaho.metadata.model.concept.IConcept aclHolder)
The aclHolder cannot be null unless the access type requested is ACCESS_TYPE_SCHEMA_ADMIN.boolean
hasAccessFor(String domainId)
protected boolean
isDomainIdXmiEqualsOrNotPresent(String domainId, String domainIdXmi)
String
loadAnnotationsXml(String domainId)
protected void
loadLocaleStrings(String domainId, org.pentaho.metadata.model.Domain domain)
protected Properties
loadProperties(org.pentaho.platform.api.repository2.unified.RepositoryFile bundle)
protected String
noXmi(String value)
void
reloadDomains()
reload domains from diskvoid
removeDomain(String domainId)
remove a domain from disk and memory.void
removeModel(String domainId, String modelId)
remove a model from a domain which is stored either on a disk or memory.protected String
replaceDomainId(StringBuilder sb, String domainId)
protected String
resolveAnnotationsFilePath(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile)
void
setAclFor(String domainId, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl)
protected void
setLocalizationUtil(org.pentaho.metadata.util.LocalizationUtil localizationUtil)
protected void
setRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository)
protected void
setRepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils repositoryUtils)
protected void
setXmiParser(org.pentaho.metadata.util.XmiParser xmiParser)
void
storeAnnotationsXml(String domainId, String annotationsXml)
void
storeDomain(InputStream inputStream, String domainId, boolean overwrite)
Stores a domain to the repository directly as an Input Streamvoid
storeDomain(InputStream inputStream, String domainId, boolean overwrite, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl)
void
storeDomain(org.pentaho.metadata.model.Domain domain, boolean overwrite)
Store a domain to the repository.protected String
toString(org.pentaho.platform.api.repository2.unified.RepositoryFile file)
org.pentaho.platform.api.repository2.unified.RepositoryFile
updateFile(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
-
-
-
Constructor Detail
-
PentahoMetadataDomainRepository
public PentahoMetadataDomainRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository)
Creates an instance of this class providing theIUnifiedRepository
repository backend.- Parameters:
repository
- theIUnifiedRepository
in which data will be stored / retrieved
-
PentahoMetadataDomainRepository
protected PentahoMetadataDomainRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository, org.pentaho.platform.repository2.unified.RepositoryUtils repositoryUtils, org.pentaho.metadata.util.XmiParser xmiParser, org.pentaho.metadata.util.LocalizationUtil localizationUtil)
Helper constructor used for setting other objects in this class- Parameters:
repository
- theIUnifiedRepository
in which data will be stored / retrievedrepositoryUtils
- utility class for working inside the repository (NOTE:null
is acceptable and will create a default instance)xmiParser
- the parser class for serializing / de-serializing Domain objects (NOTE:null
is acceptable and will create a default instance)localizationUtil
- the object used to add locale bundles into a Pentaho Metadata Domain object (NOTE:null
is acceptable and will create a default instance)
-
-
Method Detail
-
storeDomain
public void storeDomain(org.pentaho.metadata.model.Domain domain, boolean overwrite) throws org.pentaho.metadata.repository.DomainIdNullException, org.pentaho.metadata.repository.DomainAlreadyExistsException, org.pentaho.metadata.repository.DomainStorageException
Store a domain to the repository. The domain should persist between JVM restarts.- Specified by:
storeDomain
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
- Parameters:
domain
- domain object to storeoverwrite
- if true, overwrite existing domain- Throws:
org.pentaho.metadata.repository.DomainIdNullException
- if domain id is null or emptyorg.pentaho.metadata.repository.DomainAlreadyExistsException
- if a domain with the same Domain ID already exists in the repository andoverwrite == false
org.pentaho.metadata.repository.DomainStorageException
- if there is a problem storing the domain
-
replaceDomainId
protected String replaceDomainId(StringBuilder sb, String domainId)
-
getDomainIdFromXmi
protected String getDomainIdFromXmi(StringBuilder sb)
-
isDomainIdXmiEqualsOrNotPresent
protected boolean isDomainIdXmiEqualsOrNotPresent(String domainId, String domainIdXmi)
-
storeDomain
public void storeDomain(InputStream inputStream, String domainId, boolean overwrite) throws org.pentaho.metadata.repository.DomainIdNullException, org.pentaho.metadata.repository.DomainAlreadyExistsException, org.pentaho.metadata.repository.DomainStorageException
Stores a domain to the repository directly as an Input Stream- Specified by:
storeDomain
in interfaceIPentahoMetadataDomainRepositoryImporter
- Parameters:
inputStream
-domainId
-overwrite
-- Throws:
org.pentaho.metadata.repository.DomainIdNullException
org.pentaho.metadata.repository.DomainAlreadyExistsException
org.pentaho.metadata.repository.DomainStorageException
-
storeDomain
public void storeDomain(InputStream inputStream, String domainId, boolean overwrite, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl) throws org.pentaho.metadata.repository.DomainIdNullException, org.pentaho.metadata.repository.DomainAlreadyExistsException, org.pentaho.metadata.repository.DomainStorageException
- Specified by:
storeDomain
in interfaceIAclAwarePentahoMetadataDomainRepositoryImporter
- Throws:
org.pentaho.metadata.repository.DomainIdNullException
org.pentaho.metadata.repository.DomainAlreadyExistsException
org.pentaho.metadata.repository.DomainStorageException
-
getAclHelper
protected org.pentaho.platform.api.repository2.unified.IAclNodeHelper getAclHelper()
-
setAclFor
public void setAclFor(String domainId, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl)
- Specified by:
setAclFor
in interfaceIAclAwarePentahoMetadataDomainRepositoryImporter
-
getAclFor
public org.pentaho.platform.api.repository2.unified.RepositoryFileAcl getAclFor(String domainId)
- Specified by:
getAclFor
in interfaceIAclAwarePentahoMetadataDomainRepositoryImporter
-
hasAccessFor
public boolean hasAccessFor(String domainId)
- Specified by:
hasAccessFor
in interfaceIAclAwarePentahoMetadataDomainRepositoryImporter
-
getDomainFilesData
public Map<String,InputStream> getDomainFilesData(String domainId)
- Specified by:
getDomainFilesData
in interfaceIPentahoMetadataDomainRepositoryExporter
-
getDomain
public org.pentaho.metadata.model.Domain getDomain(String domainId)
retrieve a domain from the repo. This does lazy loading of the repo, so it calls reloadDomains() if not already loaded.- Specified by:
getDomain
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
- Parameters:
domainId
- domain to get from the repository- Returns:
- domain object
-
getDomainIds
public Set<String> getDomainIds()
return a list of all the domain ids in the repository. triggers a call to reloadDomains if necessary.- Specified by:
getDomainIds
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
- Returns:
- the domain Ids.
-
getMetadataDomainIds
public Set<String> getMetadataDomainIds()
Return a list of all the domain ids in the repository of the data source type Metadata. SeegetDomainIds()
for similar functionality.- Specified by:
getMetadataDomainIds
in interfaceIDataSourceAwareMetadataDomainRepository
- Returns:
- the metadata domain Ids.
-
getDataSourceWizardDomainIds
public Set<String> getDataSourceWizardDomainIds()
Return a list of all the domain ids in the repository of the data source type Metadata. SeegetDomainIds()
for similar functionality.- Specified by:
getDataSourceWizardDomainIds
in interfaceIDataSourceAwareMetadataDomainRepository
- Returns:
- the data source wizard domain Ids.
-
removeDomain
public void removeDomain(String domainId)
remove a domain from disk and memory.- Specified by:
removeDomain
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
- Specified by:
removeDomain
in interfaceIPentahoMetadataDomainRepositoryImporter
- Parameters:
domainId
-
-
removeModel
public void removeModel(String domainId, String modelId) throws org.pentaho.metadata.repository.DomainIdNullException, org.pentaho.metadata.repository.DomainStorageException
remove a model from a domain which is stored either on a disk or memory.- Specified by:
removeModel
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
- Parameters:
domainId
-modelId
-- Throws:
org.pentaho.metadata.repository.DomainIdNullException
org.pentaho.metadata.repository.DomainStorageException
-
reloadDomains
public void reloadDomains()
reload domains from disk- Specified by:
reloadDomains
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
-
getFileMetadataHelper
public Map<String,Serializable> getFileMetadataHelper(Serializable serializableId)
Only migrate if certain properties don't exist and other conditions. Else return file metadata.- Parameters:
serializableId
-- Returns:
-
flushDomains
public void flushDomains()
flush the domains from memory- Specified by:
flushDomains
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
-
generateRowLevelSecurityConstraint
public String generateRowLevelSecurityConstraint(org.pentaho.metadata.model.LogicalModel model)
- Specified by:
generateRowLevelSecurityConstraint
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
-
hasAccess
public boolean hasAccess(int accessType, org.pentaho.metadata.model.concept.IConcept aclHolder)
The aclHolder cannot be null unless the access type requested is ACCESS_TYPE_SCHEMA_ADMIN.- Specified by:
hasAccess
in interfaceorg.pentaho.metadata.repository.IMetadataDomainRepository
-
addLocalizationFile
public void addLocalizationFile(String domainId, String locale, Properties properties) throws org.pentaho.metadata.repository.DomainStorageException
Adds a set of properties as a locale properties file for the specified Domain ID- Parameters:
domainId
- the domain ID for which this properties file will be addedlocale
- the locale for which this properties file will be addedproperties
- the properties to be added- Throws:
org.pentaho.metadata.repository.DomainStorageException
-
addLocalizationFile
public void addLocalizationFile(String domainId, String locale, InputStream inputStream, boolean overwrite) throws org.pentaho.metadata.repository.DomainStorageException
- Specified by:
addLocalizationFile
in interfaceIPentahoMetadataDomainRepositoryImporter
- Throws:
org.pentaho.metadata.repository.DomainStorageException
-
getMetadataDir
protected org.pentaho.platform.api.repository2.unified.RepositoryFile getMetadataDir()
-
loadLocaleStrings
protected void loadLocaleStrings(String domainId, org.pentaho.metadata.model.Domain domain)
-
loadProperties
protected Properties loadProperties(org.pentaho.platform.api.repository2.unified.RepositoryFile bundle)
-
addDataSourceType
protected void addDataSourceType(Map<String,Serializable> fileMetadata, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Adds datasource property to map based on serialized data converted to Domain object.- Parameters:
fileMetadata
-data
-
-
createUniqueFile
protected org.pentaho.platform.api.repository2.unified.RepositoryFile createUniqueFile(String domainId, String locale, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Creates a new repository file (with the supplied data) and applies the proper metadata to this file.- Parameters:
domainId
- the Domain id associated with this filelocale
- the locale associated with this file (or null for a domain file)data
- the data to put in the file- Returns:
- the repository file created
-
createUniqueFile
protected org.pentaho.platform.api.repository2.unified.RepositoryFile createUniqueFile(String filename, String domainId, String locale, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
Creates a new repository file (with the supplied data) and applies the proper metadata to this file.- Parameters:
filename
- filename for new filedomainId
- the Domain id associated with this filelocale
- the locale associated with this file (or null for a domain file)data
- the data to put in the file- Returns:
- the repository file created
-
updateFile
public org.pentaho.platform.api.repository2.unified.RepositoryFile updateFile(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile, org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData data)
-
getRepository
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository getRepository()
-
getXmiParser
protected org.pentaho.metadata.util.XmiParser getXmiParser()
-
getRepositoryUtils
protected org.pentaho.platform.repository2.unified.RepositoryUtils getRepositoryUtils()
-
getLocalizationUtil
protected org.pentaho.metadata.util.LocalizationUtil getLocalizationUtil()
-
setRepository
protected void setRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository)
-
setXmiParser
protected void setXmiParser(org.pentaho.metadata.util.XmiParser xmiParser)
-
setRepositoryUtils
protected void setRepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils repositoryUtils)
-
setLocalizationUtil
protected void setLocalizationUtil(org.pentaho.metadata.util.LocalizationUtil localizationUtil)
-
toString
protected String toString(org.pentaho.platform.api.repository2.unified.RepositoryFile file)
-
getMetadataRepositoryFile
protected org.pentaho.platform.api.repository2.unified.RepositoryFile getMetadataRepositoryFile(String domainId)
Accesses the metadata mapping (with 1 retry) to find the metadata file for the specified domainId
-
loadAnnotationsXml
public String loadAnnotationsXml(String domainId)
- Specified by:
loadAnnotationsXml
in interfaceIModelAnnotationsAwareMetadataDomainRepositoryImporter
-
storeAnnotationsXml
public void storeAnnotationsXml(String domainId, String annotationsXml)
- Specified by:
storeAnnotationsXml
in interfaceIModelAnnotationsAwareMetadataDomainRepositoryImporter
-
getAnnotationsXmlFile
public org.pentaho.platform.api.repository2.unified.RepositoryFile getAnnotationsXmlFile(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile)
-
createOrUpdateAnnotationsXml
public void createOrUpdateAnnotationsXml(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile, org.pentaho.platform.api.repository2.unified.RepositoryFile annotationsFile, String annotationsXml)
-
resolveAnnotationsFilePath
protected String resolveAnnotationsFilePath(org.pentaho.platform.api.repository2.unified.RepositoryFile domainFile)
-
getLogger
protected org.apache.commons.logging.Log getLogger()
-
-