Class OlapResourceImporter

java.lang.Object
fr.becpg.repo.olap.OlapResourceImporter

public class OlapResourceImporter extends Object
Imports the OLAP queries, dashboards and applications beCPG ships as classpath resources.

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

    Fields
    Modifier and Type
    Field
    Description
    private org.alfresco.service.cmr.repository.ContentService
     
    private static final String
    Bundle holding the display label of every shipped resource, keyed by technical id.
    private static final String
     
    private static final org.apache.commons.logging.Log
     
    private org.alfresco.service.cmr.repository.MimetypeService
     
    private org.alfresco.service.cmr.repository.NodeService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static ResourceBundle
    bundleFor(Locale locale)
    Loads the label bundle of a locale, or null when no module on the classpath ships one.
    private org.alfresco.service.cmr.repository.NodeRef
    createNode(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String olapQueryId, String fileName)
     
    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)
     
    void
    importResources(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String pattern)
    Imports every classpath resource matching the pattern into the folder.
    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.
    private String
    label(String olapQueryId, Locale locale)
     
    private String
    label(ResourceBundle bundle, String olapQueryId)
     
    void
    setContentService(org.alfresco.service.cmr.repository.ContentService contentService)
    Setter for the field contentService.
    void
    setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
    Setter for the field mimetypeService.
    void
    setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
    Setter for the field nodeService.
    private static String
     
    private org.alfresco.service.cmr.repository.MLText
    titles(String olapQueryId)
    Builds the multilingual title of a resource from every translation the bundle actually carries.
    private void
    writeContent(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.springframework.core.io.Resource resource, String fileName)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      private static final org.apache.commons.logging.Log logger
    • LABEL_BUNDLE

      private static final String LABEL_BUNDLE
      Bundle holding the display label of every shipped resource, keyed by technical id.
      See Also:
    • LABEL_KEY_PREFIX

      private static final String 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 - a NodeService object
    • setContentService

      public void setContentService(org.alfresco.service.cmr.repository.ContentService contentService)

      Setter for the field contentService.

      Parameters:
      contentService - a ContentService object
    • setMimetypeService

      public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)

      Setter for the field mimetypeService.

      Parameters:
      mimetypeService - a MimetypeService object
    • 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 resources
      pattern - an Ant-style classpath pattern, such as classpath*: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

      private org.alfresco.service.cmr.repository.NodeRef createNode(org.alfresco.service.cmr.repository.NodeRef folderNodeRef, String olapQueryId, String fileName)
    • 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

      private org.alfresco.service.cmr.repository.MLText titles(String olapQueryId)
      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

      private String label(String olapQueryId, Locale locale)
    • label

      private String label(ResourceBundle bundle, String olapQueryId)
    • bundleFor

      private static ResourceBundle bundleFor(Locale locale)
      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

      private static String stripExtension(String fileName)