Pentaho dynamic loading name of month in Pentaho User Console - console

In my dimensional table i have month field with number representation of month 1...12, but in this table i don't have name of that months (Jan, Feb, etc...). In mondrian file i use it like time dimension.
<Dimension type="TimeDimension" visible="true" highCardinality="false" name="timedimension" caption="Datetime">
<Hierarchy visible="true" hasAll="true" primaryKey="id_date">
<Table name="dim_date" schema="dbo">
</Table>
<Level name="year" visible="true" column="year4" type="String" uniqueMembers="false" levelType="TimeYears" hideMemberIf="Never" caption="year">
<Annotations>
<Annotation name="AnalyzerDateFormat">
<![CDATA[[yyyy]]]>
</Annotation>
</Annotations>
</Level>
<Level name="month" visible="true" column="month" ordinalColumn="month" type="String" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never" caption="month">
<Annotations>
<Annotation name="AnalyzerDateFormat">
<![CDATA[[yyyy].['Q'q].[M]]]>
</Annotation>
</Annotations>
</Level>
</Hierarchy>
</Dimension>
When i show this dimension in Pentaho User Console i would like to show the Name of these months instead of numbers in Anylyzer report. Is this possible without adding this names of months into my dimension table. Exists some internal function for showing of that or some property file or internal dictionary for using of that or some attribute in mondrian file? And i would like to have the names of the month depends on selected language in Pentaho User Console.

If creating a column in the dim table is not an option (although this is the recommended approach), you can do it by adding a KeyExpression element to the Level expression:
<Level name="month" visible="true" ordinalColumn="month" type="String" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never">
<KeyExpression>
<SQL dialect="generic">
CASE
WHEN month = 1 THEN 'Jan'
WHEN month = 2 THEN 'Feb'
(...)
WHEN month = 12 THEN 'Dec'
END
</SQL>
</KeyExpression>
<Annotations>
<Annotation name="AnalyzerDateFormat">
<![CDATA[[yyyy].['Q'q].[MMM]]]>
</Annotation>
</Annotations>
</Level>
Notice that I removed the column and caption attributes. Also notice the change in the value of AnalyzerDateFormat (if you want full month names you must use MMMM instead of MMM).

Related

Same space between 2 inputText boxes using JSF and CSS

I want to create a JSF form where users can write their name and surname and validate them using JSF validators. The problem is that I would like to set the same space between the 2 inputText boxes in the form, in both cases, when the typed data is correct according to the validator, and when it is not correct. So if between the 2 inputText boxes there are X pixels if the user has not typed anything, when typed name is not correct, the error showing message should be displayed between the 2 inputText boxes and the pixels between them should be also X px. I suppose this is a CSS issue, but I am unable to get it, so any help would be appreciated.
Here is my code
<h:form>
<p:panel id="panelregister">
<h:panelGrid columns="1">
<!--Name-->
<p:inputText id="name" label="name" size="32" maxlength="9"
value="#{mManagedBean.name}">
<f:validator validatorId="packagevalidators.NameValidator"/>
</p:inputText>
<p:watermark for="name" value="Name (*)" />
<p:message for="name"/>
<!--Surname-->
<p:inputText id="surname" label="surname" required="true" size="32" maxlength="9"
value="#{mManagedBean.surname}"
requiredMessage="Must enter a surname">
<f:validator validatorId="packagevalidators.SurnameValidator"/>
</p:inputText>
<p:watermark for="surname" value="Surname (*)" />
<p:message for="surname" />
<p:commandButton value="Submit" action="#{mManagedBean.save}" ajax="false" />
</h:panelGrid>
</p:panel>
</h:form>
You are using h:panelGrid which renders as HTML <table>.
p:message will be rendered as div and by default that div won't have any content so it won't take any space you provide.
One way to do this is to use a h:panelGroup around it and give pre defined height of p:message
Example:
<h:panelGroup layout="block" style="height:27px">
<p:message for="name" />
</h:panelGroup>

Customized legend for RadChart

How can i customize the text in legend. am using telerik tools. how can i change the legend text from the back end? c# or vb.net code is enough. as per the customer requirement i need to display combined text from x axis and y axis are to be displayed in the legend. following is the code am using for this.
<telerik:radchart id="radchart_teamchart" autolayout="true" charttitle-appearance-fillstyle-fillsettings-imagealign="Center"
chartimageformat="Png" charttitle-visible="true" seriesorientation="Vertical"
width="900px" defaulttype="Bubble" runat="server" skin="Vista" autotextwrap="true"
intelligentlabelsenabled="true">
<ChartTitle TextBlock-Text="My New Customer Status">
</ChartTitle>
<Series>
<telerik:ChartSeries DataYColumn="noofcustomer" Name="Order" Type="Bar" Appearance-BarWidthPercent="10">
<Appearance LabelAppearance-Visible="false">
<TextAppearance TextProperties-Font="Cambria, 8.25pt" Position-AlignedPosition="TopLeft">
</TextAppearance>
<FillStyle MainColor="DarkOrange" SecondColor="WhiteSmoke" FillType="Gradient">
</FillStyle>
<PointMark Visible="True" Border-Width="2" Border-Color="DarkKhaki" Dimensions-AutoSize="false"
Dimensions-Height="10px" Dimensions-Width="6px">
<FillStyle MainColor="Red" FillType="solid">
</FillStyle>
</PointMark>
<LineSeriesAppearance Width="6"></LineSeriesAppearance>
</Appearance>
</telerik:ChartSeries>
</Series>
<PlotArea>
<XAxis DataLabelsColumn="month" AxisLabel-Visible="true" AxisLabel-TextBlock-Text="Month"
AxisLabel-TextBlock-Appearance-TextProperties-Color="Brown">
<Appearance>
<TextAppearance TextProperties-Font="Arial, 8.25pt, style=Bold" Dimensions-Paddings="0.5px">
</TextAppearance>
<LabelAppearance RotationAngle="270">
</LabelAppearance>
</Appearance>
</XAxis>
<YAxis AxisMode="Normal" MaxItemsCount="7" AxisLabel-Visible="true" AxisLabel-TextBlock-Text="No Of Cusotmers"
AxisLabel-TextBlock-Appearance-TextProperties-Color="Brown">
<Appearance>
<TextAppearance TextProperties-Font="Arial, 8.5pt, style=Bold">
</TextAppearance>
</Appearance>
</YAxis>
</PlotArea>
<Legend Visible="true" ></Legend>
</telerik:radchart>
I do not think that's what a legend is for and thus, I do not think you can do this.
I would advise that you first go through the control documentation and explore the available properties to see whether something is useful for you:
http://www.telerik.com/help/aspnet-ajax/chart-styling-custom-appearance-properties.html
http://www.telerik.com/help/aspnet-ajax/chart-styling-elements.html
http://www.telerik.com/help/aspnet-ajax/chart-legenddisplaymode.html - note the ItemLabels option that puts the items in the legend
http://www.telerik.com/help/aspnet-ajax/chart-legend.html - there are also some options on building custom legends, so this can help
Another idea is to build a custom legend from your data source. You can see a sample approach here http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/custombarcolor/defaultcs.aspx even though the chart is the current RadHtmlChart control (RadChart is deprecated in favor of this newer chart control).

Button action called upon second click

I have 2 command buttons and one select one menu. I need to call a bean method depending on the buttons selected and the currently selected item in the menu.
<h:form id="form1">
<h:outputLabel value="menu:" />
<h:commandButton value ="en" action="#{bean.exec}" >
<f:setPropertyActionListener target="#{bean.menu}" value='en' />
</h:commandButton>
<h:commandButton value ="fr" action="#{bean.exec}" >
<f:setPropertyActionListener target="#{bean.menu}" value='fr' />
</h:commandButton>
<h:outputLabel value="id:" />
<h:selectOneMenu value="#{bean.id}">
<f:selectItems value="#{bean.idlist}" />
<f:ajax listener="#{bean.exec}" render ="form1" />
</h:selectOneMenu>
</h:form>
However, although the first button updates my properties and calls the action method, the second button gives me the following message
WARNING: FacesMessage(s) have been enqueued, but may not have been displayed
and the view doesn't get updated on the fist click. However, immediately on the second click, the properties get updated and so does the view.
How is this caused and how can I solve it?
I did see the log, however I dont understand the error: this is what it shows: form1:j_idt124: Validation Error: Value is not valid What value and where?
It's easier to identify the value if you give all input components an ID and attach a <h:message> to them as follows:
<h:outputLabel for="id" value="id:" />
<h:selectOneMenu id="id" value="#{bean.id}">
<f:selectItems value="#{bean.idlist}" />
<f:ajax listener="#{bean.exec}" render ="form1" />
</h:selectOneMenu>
<h:message for="id" />
This way you will get form1:id as label instead of form1:j_idt124. Alternatively, you can also specify the label of the input component:
<h:selectOneMenu label="id" ... />
As to the "Value is not valid" error, you will get this error when the selected value does not match any one of the available values during processing the form submit. This can in turn happen when the property behind #{bean.idlist} has incompatibly changed during processing the form submit. This can in turn happen when the bean is request scoped. Putting the bean in the view scope should fix it.
See also:
Validation Error: Value is not valid

Propel ORM Behavior for defining Parent Child relationships?

I'm using Symfony2 with PropelBundle, and lets say I have the following schema:
<table name="person">
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="name" type="VARCHAR" size="100" required="true"/>
</table>
<table name="person_parent">
<column name="person_id" type="INTEGER" primaryKey="true" required="true"/>
<column name="parent_id" type="INTEGER" primaryKey="true" required="true"/>
</table>
Consider that a person can have many "Parents", just like a parent can have many child "Persons". Both of the columns in the "person_parent" table are foreign keys to the "person" table. Unlike for relationships like Book/Author where one can set isCrossRef="true" in the schema of table "book_author" to let Propel generate methods for directly getting/setting/adding book objects from an author class or viceversa, for Parent/Child relationships it is not possible to set isCrossRef="true" and thus not possible to get/set/add Parent Person objects directly from a "Person" Object. In other words it is not possible to do:
$person = new Person();
$person->setPersonParents($personCollection);
The method "setPersonParents()" to set all the parent "Person" objects of any given person is not available. However, for cross tables that do not reference to the same table like author_book, setting isCrossRef="true" allows for the following:
$author = new Author();
$author->setBooks($bookCollection);
With that in mind, it is also not possible to directly select a Person's "Parents" in a "New Person" Form...
For friend like relationships there is the EqualNestBehavior, which allows for:
$person = new Person();
$person->setFriends($personCollection);
However, that behavior does not seem applicable to Parent/Child relationships since it does not care about hierarchy (if one tries to get the "Parents" of any given "Person", one gets all the "Childs" of that "Person" in addition to its "Parents"...). This is the behavior one would expect for "friend like" relationships, where a Friend of a Person is also that Person's Friend.
Is there a way to use the EqualNestBehavior for the Parent/Child case? or is there any other Propel behavior or method to handle this kind of relationships?
I am not sure about EqualNestBehavior but you could set up your workflow as following.
In your schema define FKs to Person table:
<table name="person">
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="name" type="VARCHAR" size="100" required="true"/>
</table>
<table name="person_parent">
<column name="person_id" type="INTEGER" primaryKey="true" required="true"/>
<column name="parent_id" type="INTEGER" primaryKey="true" required="true"/>
<foreign-key foreignTable="person" name="p1" onDelete="CASCADE" onUpdate="CASCADE">
<reference local="person_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="person" name="p2" onDelete="CASCADE" onUpdate="CASCADE">
<reference local="parent_id" foreign="id"/>
</foreign-key>
</table>
After that, when you generate models - you'll get such methods as:
$person = new Person();
$person->getPersonParentsRelatedByParentId();
$person->setPersonParentsRelatedByParentId($personCollection);
$person->getPersonParentsRelatedByPersonId();
$person->setPersonParentsRelatedByPersonId($personCollection);
Setters accept PropelCollection as argument.
You just have to think about this situation not like "get parents" or "get children", but as about related elements.

reRender a specific row of rich:dataTable

Good Morning!
Is it possible to reRender only 1 specific row of rich:dataTable?
I have a rich:dataTable and, when I do something that I´m sure only 1 row has changed, I need to reRednder only this row, not the entire table. Is it possible? How?
XHTML:
<rich:dataTable id="myTable" value="#{bean.table}" var="me">
<rich:column>
<h:outputText value="#{me.id}" />
</rich:column>
<rich:column>
<h:outputText value="#{me.valueOne}" />
</rich:column>
<rich:column>
<h:outputText value="#{me.valueTwo}" />
</rich:column>
</rich:dataTable>
<some:tag.... reRender="??????" action="bean.example" />
Java:
public void example{
// Do something that affects to the row selected
}
THANK YOU VERY MUCH.
Yes , it is possible . You have to specify the followings things:
Which columns to be rendered via the reRender attribute of the tags that can invoke MBean method
What rows to be rendered via the ajaxKeys attribute of the rich:dataTable .
The ajaxKeys attribute is bound to Set <Integer> Object which holds the row numbers to be updated.
For example , suppose you want to invoke a Mbean method using a4j:commandButton and want to render a particular row and column after the action finishes . You can use the following :
<a4j:commandButton action="#{bean.someAction}" reRender="columnID,columnID2">
<f:setPropertyActionListener value="#{idx}" target="#{bean.selectedRow}" />
</a4j:commandButton>
<rich:dataTable id="myTable" value="#{bean.table}" var="me" ajaxKeys="#{bean.rowsToUpdate}" rowKeyVar="idx">
<rich:column id="columnID">
<h:outputText value="#{me.id}" />
</rich:column>
<rich:column id="columnID2">
<h:outputText value="#{me.valueOne}" />
</rich:column>
<rich:column>
<h:outputText value="#{me.valueTwo}" />
</rich:column>
</rich:dataTable>
Inside the bean.someAction() , you add the row number that you want to update to the rowsToUpdate integer set:
HashSet<Integer> rows = new HashSet<Integer>();
rows.add(selectedRow);
setRowsToUpdate( rows );

Resources