Class OlapResourceImporter
Each resource is named by its technical id (portfolio-volumes-and-margins.saiku), which
becomes bcpg:olapQueryId and is the only identity anything downstream relies on:
dashboards reference it, the Share dashlet stores it as a user preference, and the Saiku
repository resolves its paths on it. What the user reads lives apart, in the
beCPG/olap/olapQueries bundles: the repository locale supplies cm:name, and every
translation found supplies one value of the cm:title MLText.
Nothing here is keyed on a label, so a query can be renamed, translated, or shipped in a new language without breaking a reference.
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.alfresco.service.cmr.repository.ContentServiceprivate static final StringBundle holding the display label of every shipped resource, keyed by technical id.private static final Stringprivate static final org.apache.commons.logging.Logprivate org.alfresco.service.cmr.repository.MimetypeServiceprivate org.alfresco.service.cmr.repository.NodeService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ResourceBundleLoads the label bundle of a locale, or null when no module on the classpath ships one.private org.alfresco.service.cmr.repository.NodeRefcreateNode(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String olapQueryId, String fileName) private voidimportResource(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, org.springframework.core.io.Resource resource, Map<String, org.alfresco.service.cmr.repository.NodeRef> existing) voidimportResources(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String pattern) Imports every classpath resource matching the pattern into the folder.indexByOlapQueryId(org.alfresco.service.cmr.repository.NodeRef folderNodeRef) Indexes the resources already present in the folder by their technical id.private Stringprivate Stringlabel(ResourceBundle bundle, String olapQueryId) voidsetContentService(org.alfresco.service.cmr.repository.ContentService contentService) Setter for the fieldcontentService.voidsetMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService) Setter for the fieldmimetypeService.voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) Setter for the fieldnodeService.private static StringstripExtension(String fileName) private org.alfresco.service.cmr.repository.MLTextBuilds the multilingual title of a resource from every translation the bundle actually carries.private voidwriteContent(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.springframework.core.io.Resource resource, String fileName)
-
Field Details
-
logger
private static final org.apache.commons.logging.Log logger -
LABEL_BUNDLE
Bundle holding the display label of every shipped resource, keyed by technical id.- See Also:
-
LABEL_KEY_PREFIX
- See Also:
-
nodeService
private org.alfresco.service.cmr.repository.NodeService nodeService -
contentService
private org.alfresco.service.cmr.repository.ContentService contentService -
mimetypeService
private org.alfresco.service.cmr.repository.MimetypeService mimetypeService
-
-
Constructor Details
-
OlapResourceImporter
public OlapResourceImporter()
-
-
Method Details
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) Setter for the field
nodeService.- Parameters:
nodeService- aNodeServiceobject
-
setContentService
public void setContentService(org.alfresco.service.cmr.repository.ContentService contentService) Setter for the field
contentService.- Parameters:
contentService- aContentServiceobject
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService) Setter for the field
mimetypeService.- Parameters:
mimetypeService- aMimetypeServiceobject
-
importResources
public void importResources(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String pattern) Imports every classpath resource matching the pattern into the folder.Existing nodes are matched on
bcpg:olapQueryId, never on their name, so the import stays correct after a user or an administrator has renamed a query.- Parameters:
folderNodeRef- the folder receiving the resourcespattern- an Ant-style classpath pattern, such asclasspath*:beCPG/olap/fr/*.saiku
-
importResource
private void importResource(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, org.springframework.core.io.Resource resource, Map<String, org.alfresco.service.cmr.repository.NodeRef> existing) throws IOException- Throws:
IOException
-
createNode
-
writeContent
private void writeContent(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.springframework.core.io.Resource resource, String fileName) throws IOException - Throws:
IOException
-
indexByOlapQueryId
private Map<String,org.alfresco.service.cmr.repository.NodeRef> indexByOlapQueryId(org.alfresco.service.cmr.repository.NodeRef folderNodeRef) Indexes the resources already present in the folder by their technical id.- Parameters:
folderNodeRef- the folder to read- Returns:
- the nodes carrying
bcpg:olapQueryId, keyed by that id
-
titles
Builds the multilingual title of a resource from every translation the bundle actually carries. A locale whose bundle is missing is skipped rather than filled with the fallback, which would leave the reader an English label announced as a translation.- Parameters:
olapQueryId- the technical id of the resource- Returns:
- the title, one value per translated locale
-
label
-
label
-
bundleFor
Loads the label bundle of a locale, or null when no module on the classpath ships one.- Parameters:
locale- the locale to load- Returns:
- the bundle, or null
-
stripExtension
-