0
1

Hello and thanks again for your great work on Saiku.

I would like to be able to load my custom formatter using Spring injection. so the code in OlapQueryService would be replaced by :

public ICellSetFormatter getFormatter(String formatter) {
    formatter = formatter == null ? "" : formatter.toLowerCase();
    String formatterBeanId = formatters.get(formatter);
    if (formatterBeanId != null) {
        return (ICellSetFormatter) appContext.getBean(formatterBeanId);
    }
    return (ICellSetFormatter) appContext.getBean(defaultFormatterBeanId);
}

public CellDataSet execute(String queryName, String formatter) {
    ICellSetFormatter cellSetFormatter = getFormatter(formatter);
    return execute(queryName, cellSetFormatter);
}

associated with the following spring declaration :

<bean id="cellSetFormatter" class="org.saiku.olap.util.formatter.CellSetFormatter" scope="prototype"/>
<bean id="hierarchicalCellSetFormatter" class="org.saiku.olap.util.formatter.HierarchicalCellSetFormatter" scope="prototype"/>
<bean id="flattenedCellSetFormatter" class="org.saiku.olap.util.formatter.FlattenedCellSetFormatter" scope="prototype"/>
<bean id="customCellSetFormatter" class="org.custom.formatter.customCellSetFormatter" scope="prototype"/>

<util:map id="formattersMap">
    <entry key="flat" value="cellSetFormatter"/>
    <entry key="hierarchical" value="hierarchicalCellSetFormatter"/>
    <entry key="flattened" value="flattenedCellSetFormatter"/>
    <entry key="custom" value="customCellSetFormatter"/>
</util:map>

<bean id="olapQueryBean" scope="session" class="org.saiku.service.olap.OlapQueryService">
    <property name="olapDiscoverService" ref="olapDiscoverServiceBean" />
    <property name="formatters" ref="formattersMap"/>
    <property name="defaultFormatterBeanId" value="flattenedCellSetFormatter"/>
</bean>

but I must add a dependency on spring inside saiku-service because it needs the applicationContext in order to get a new instance of the bean each time a query is done. what do you think about that ? I can do a git pull request.

asked 11 Jan, 04:10

nico's gravatar image

nico
112
accept rate: 0%

edited 13 Jan, 03:58


yeh i thought about that already, and i agree we should springify the cellsetformatter

if you create a pull request i'll make sure that i'll look over it and apply it at some point (just need to find some time for the testing etc) i'd prefer not to add spring to saiku-service and either make this a SaikuProperty or define it in the context by adding this hashmap as property to a service or a helper class (or like you did in the query service itself)

couldn't we just make these formatter beans non-singletons?

-paul

link

answered 13 Jan, 10:28

pstoellberger's gravatar image

pstoellberger ♦♦
89727
accept rate: 5%

Sorry for the delay I thought I would have received notifications about answers. We could make those formatters as singletons indeed, and that would be a lot more simple, as the singleton instance would be available directly in the hashmap, but there are class fields in some of them, like ignorex in FlattenedCellSetFormatter. Another possibility is to write a CellSetFormatter factory in saiku-web, that requires moving interface ICellSetFormatter in saiku-web.

link

answered 20 Jan, 09:25

nico's gravatar image

nico
112
accept rate: 0%

true a factory sounds like the best option so far can you please log this in our issue tracker, otherwise i'll lose track of it... we can discuss the details there!

link

answered 24 Jan, 04:02

pstoellberger's gravatar image

pstoellberger ♦♦
89727
accept rate: 5%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1
×1

Asked: 11 Jan, 04:10

Seen: 171 times

Last updated: 24 Jan, 04:02

Related questions

powered by OSQA