Mondrian | Parent Child Hierarchy is not working properly - parent-child

I have created a dimension with parent-child hierarchy as follows -
<Dimension type="StandardDimension" visible="true" foreignKey="ContextID"
highCardinality="false" name="Learning Context">
<Hierarchy name="Learning Context Level" allMemberName="All Contexts"
hasAll="true" primaryKey="ID">
<Table name="LearningContext">
</Table>
<Level name="ID" visible="true" column="ID" type="Numeric"
uniqueMembers="true" levelType="Regular" hideMemberIf="Never"
parentColumn="ParentID">
</Level>
</Hierarchy>
</Dimension>
The problem is, when i want to get the children of a child, then i have to put it's parents as well in the mdx query.
For example -: I have a row with id 5, whose children i want to see.
Now my mdx query is..
select
Descendants([Learning Context.Learning Context Level].&[5],
[Learning Context.Learning Context Level].[ID], SELF_AND_AFTER) on 0
from
StudentActivity
which says :
Mondrian Error:MDX object '[Learning Context.Learning Context Level].&[5]' not
found in cube 'StudentActivity'
But when i execute following query... it works fine.
select
Descendants([Learning Context.Learning Context Level].&[1].&[2].&[3].&[5],
[Learning Context.Learning Context Level].[ID], SELF_AND_AFTER) on 0
from
StudentActivity
I do not want to use all the parents of a child to get its children.
Please help me out.

If you use a parent-child hierarchie, you have to prepare and use a closure-table

Related

XPath and CSS in Oxygen XML Author: How to create a dynamic parameter in oxy_xpath

I am creating an Oxygen framework to display XML data in Oxygen XML Author's author mode. This is part of the XML I have with two nodes <ab> in it:
<TEI>
<text>
<body>
<div n="A">
<ab xml:id="n_d2e23" type="person">
<seg type="name">
<persName>
<surname>Aarberg</surname>,
<forename>Peter von</forename>
</persName>
<roleName>König</roleName>
(<date from="ca. 1300" to="vor 1372">ca. 1300–vor 1372</date>)
</seg>
<seg type="affiliations">
<list>
<item>
<affiliation role="CEO" hkg:orgKey="#n_123_456">Best CEO they ever had</affiliation>
</item>
</list>
</seg>
</ab>
<ab xml:id="n_123_456" source="SW_EB" type="organization">
<seg type="name">
<orgName>Altenburger Hofdruckerei</orgName>
</seg>
</ab>
</div>
</body>
</text>
</TEI>
The first <ab> node has an attribute hkg:orgKey="#n_123_456" which is referring to the second <ab> node's attribute xml:id="n_123_456". I use the following CSS to display the value of <orgName> of the second <ab> node in the visual representation of the first <ab> node in Oxygen XML Author:
affiliation:after {
content: " role: " oxy_textfield(
edit, "#role")
" Organization ID: " oxy_textfield(
edit, "#hkg:orgKey")
"Organization name: " oxy_xpath(
"/TEI/text/body/div/ab[#xml:id='n_123_456']/seg[#type='name']/orgName/text()"
)
" " oxy_url("gfx/link_register.png");
link: attr("hkg:orgKey")
}
This works fine and the value of <orgName> of the 2nd <ab> node, in fact "Altenburger Hofdruckerei", is displayed within the first <ab> node - as long as I use the concrete value hkg:orgKey="#n_123_456". But now I need to create the line
/TEI/text/body/div/ab[#xml:id='n_123_456']/seg[#type='name']/orgName/text()
dynamically which means: Instead of the specific value xml:id=n_123_456 it should use whatever the value of the attribute #hkg:orgKey of the node <ab> of the 1st element <ab> is. I tried this:
/TEI/text/body/div/ab[#xml:id=#hkg:orgKey]/seg[#type='name']/orgName/text()
but it doesn't work. I also tried other variations like ab[#xml:id='#hkg:orgKey'] or ab[#xml:id=attr('hkg:orgKey')] and many more but none of them gave me the expected result.
Maybe it is a syntax problem. I really hope there will be a solution to this and I would be very thankful for assistance. Any help is appreciated.
I tried to send as much code as needed but of course shortened some parts not relevant in this context. If something is missing (or too much) please let me know.
Thanks in advance.
I will assume you have already declared in the CSS a mapping for the "hkg" prefix like:
#namespace hkg "someNamespace";
I would replace:
link: attr("hkg:orgKey")
with:
link: attr(hkg|orgKey);
because in CSS you refer to namespaced elements with "prefix|elementName" instead of "prefix:elementName".
As for the main question, this line:
oxy_xpath("/TEI/text/body/div/ab[#xml:id='n_123_456']/seg[#type='name']/orgName/text()")
with:
oxy_xpath(oxy_concat("/TEI/text/body/div/ab[#xml:id='", oxy_substring(attr(hkg|orgKey), 1), "']/seg[#type='name']/orgName/text()"))
I'm using oxy_concat to step outside of the string literal, evaluate the attribute value and use its value in the larger XPath expression. I used "oxy_substring" to remove the "#" from the attribute reference.

Webdriver.io how to select and element that changes based on the number of like elements on the page

I want a way to select the udp-address-input field inside of this named-source-add div. The problem I'm having is udp-address-input-<+id> element has a different number based on how many named sources have been added. There is always only 1 udp-address-input-<+id> inside of the named-source-add div so I was wondering if I can limit my search inside that div?
<div id="named-source-add" class="named-div">
<input type="text" class="table-cell" data-bind="textInput: address, attr:
{id: 'udp-address-input-'+id, readonly: readonly, required: role() ==
'destination'}" id="udp-address-input-18">
</div>
I used xpath, only looking for inputs with ids starting with udp-address-input inside of the named-source-add div.
//div[#id='named-source-add']//input[contains(#id,'udp-address-input')]
And I had to add slashes to get this to work with my javascript webdriverio pageobject like this:
udpMulticastAddr:{ get() { return '//div[#id=\'named-source-add\']//input[contains(#id,\'udp-address-input\')]';}},

How to iterate over node var in Primefaces tree to set icons in CSS class from DB

I am using PF v. 5.3.5 and JSF v. 2.2.8.
<p:tree value="#{userFiltersBean.objectsTreeModel}" var="node" hideRootNode="true" styleClass="filtersTree">
<p:treeNode icon="">
My CSS class is below:
.ui-treenode-icon{
background: url("#{node.leafIcon}") no-repeat top !important;
}
I see the same icon in each treeNode that it is not desired. This icon is for the final treeNode in the tree.
However, I want to iterate trough them that each treeNode has his own icon.
NOTE The size of tree is different on each environment and it is created dynamically.
How can I do this, please?
Please, see current PF version here.
The desired Icefaces version is here.
Thanks in advance.
In the Api-Documentation (http://www.primefaces.org/showcase/ui/data/tree/basic.xhtml -> Documentation Tab) it says you could do it like this:
<p: tree value="#{bean.root}" var="doc">
<p:treeNode type="mp3" icon="ui-icon ui-icon-video">
<h:outputText value="#{doc.name}" />
</p:treeNode>
<p:treeNode type="document" icon="ui-icon ui-icon-image-document">
<h:outputText value="#{doc.name}" />
</p:treeNode>
</p:Tree>
So in the backing Bean you have to give the Node a name, which will be the p:treeNode type. So as far as I understand
TreeNode mp3 = new TreeNode("mp3", "some music");
would do the linking for
<p:treeNode type="mp3" ... />
Let me know if it helped.
Cheers
kyhu :)
SOLVED without css
I solved by inserting a h:graphicImage inside treeNode without facet. it now as I needed and how it was done in the previous version.
<p:tree value="#{userFiltersBean.objectsTreeModel}" var="node" hideRootNode="true" styleClass="filtersTree"
selectionMode="checkbox">
<p:treeNode>
<h:graphicImage value="#{node.leafIcon}" />
<h:outputText value="#{node.text}" />
</p:treeNode>
</p:tree>
Having different values for each element with one CSS class is not possible. You would have to create a class for each icon, like so:
my-treenode-icon-1 {
background: url("/resources/img/treenode/icon-1.jpg") no-repeat top !important;
}
my-treenode-icon-2 {
background: url("/resources/img/treenode/icon-2.jpg") no-repeat top !important;
}
and then in iteration use icon name instead of path (if you have a path in database you can slice last part of it and take only the image name which will be class name).
<p:tree value="#{userFiltersBean.objectsTreeModel}" var="node" hideRootNode="true" styleClass="filtersTree">
<p:treeNode icon="my-treenode-#{node.iconName}">

Dynamically generated id in tomahwak dataList (JSF 1.2)

I cannot figure out how to generate dynamically id for elements in <t:dataList> which is inside <t:dataTable>. Code looks more or less like this :
<t:dataTable value="#{SomeBean.foo}" var="item">
<h:column rendered="true">
<div id="divpvmu">
<t:dataList value="#{item.templates}" var="template" rowCountVar="templateIndex">
<div id="saveBtn">
</div>
</t:dataList>
</div>
</h:column>
Obiously this code generate some number of divs with the same id="saveBtn"
. I would like to have distinct id for every generated div. I was trying to do this by this change :
<div id="saveBtn_#{templateIndex}">
, however then I'm getting an exception
javax.servlet.jsp.JspException: java.io.IOException: Example.jsp(50,31) JBWEB004178: #{..} is not allowed in template text
Is there any way to generate distinct id's for such a construction ? I'm using JSF 1.2.
There is the <t:div> tag. It allows you to use EL expression in id attribute.
So something like this should do the job:
<t:div id="saveBtn_#{templateIndex}" forceId="true">
JSF should also automatically generate id for you:
<t:dataList id="myList" value="#{item.templates}" var="template">
<t:div id="saveBtn">
</t:div>
</t:dataList>
This tag in t:dataTable, t:dataList and so on will generate id like:
myList:0:saveBtn for first element,
myList:1:saveBtn for second element, and so on.

attribute on selectonemenu jsf

I have a little trouble with tag h:selectOneMenu, I just want to add some background image to option, such as avatar of user.
Follow styling options in h:selectOneMenu - by balusC
I had tried to render options with its own style css.
<h:selectOneMenu id="dropListUser"
value="#{myController.myUserObject.userid}">
<f:attribute name="avatar" value="#{true}"></f:attribute>
<f:attribute name="key" value="somthing"></f:attribute>
<f:attribute name="height" value="32"></f:attribute>
<f:attribute name="width" value="32"></f:attribute>
<f:selectItems value="#{myController.listOfUsers}" var="item" itemLabel="#{item.username}" itemValue="#{item.userid}"/>
</h:selectOneMenu>
It work great with height, width and key, but with avatar(or any attribute contains value with #{} expression) server bean could not get it.
Try to printout all key name:
Iterator itr = component.getAttributes().keySet().iterator();
while(itr.hasNext()){
System.out.println(itr.next().toString());
}
there is no key with name avatar :
--------------------------------
height
javax.faces.component.VIEW_LOCATION_KEY
com.sun.faces.facelets.MARK_ID
key
width
width: 32 height: 32 style null?: true
--------------------------------
ps: by the way,Is there any one know how to create custom taglib that extends h:selectOneMenu :-?
ps2: In the fact, If I could get myController.listOfUsers
in <f:selectItems value="#{myController.listOfUsers}" var="item" itemLabel="#{item.username}" itemValue="#{item.userid}"/> in my custom render bean, it could be better
Woof, I don't know why or how, but when try print out all of key names from component.getAttributes() also component.getAttributes().containsKey("avatar") return that avatar is not exist, BUT I really can get avatar value, my trouble was solved ^^" just remove code that check the key exist or not

Resources