Mondrian: Slicer axis ignored in query against a VirtualCube - mondrian

I created a VirtualCube, combining two other Cubes in my schema.
However, it seems that the slicer axis on queries made against this VirtualCube is being ignored.
This query returns the expected results:
SELECT
NON EMPTY {
[Measures].[FOB],
[Measures].[CIF]
} ON 0,
NON EMPTY [Date].[Year].Members ON 1
FROM [exports_and_imports]
This one returns the same results as the previous one, which is incorrect:
SELECT
NON EMPTY {
[Measures].[FOB],
[Measures].[CIF]
} ON 0,
NON EMPTY [Date].[Year].members ON 1
FROM [exports_and_imports]
WHERE (
[Geography].[Washington]
)
However, a slicer applied to the Date dimension does work:
SELECT
NON EMPTY {
[Measures].[FOB],
[Measures].[CIF]
} ON 0
FROM [exports_and_imports]
WHERE (
[Date].[Year].&[2005]:date.year.&[2014]
)
Edited version of my schema:
<Schema name="datachile">
<Dimension name="Date" type="TimeDimension">...</Dimension>
<Dimension name="Geography">...</Dimension>
<Dimension name="Country">...</Dimension>
<Dimension name=“HS”>...</Dimension>
<Cube name="exports">
<DimensionUsage name="Date" source="Date" foreignKey="date_id" />
<DimensionUsage name="Destination Country" source="Country" foreignKey="country_dest_id" />
<DimensionUsage name="Export Geography" source="Geography" foreignKey="exporter_comuna_id" />
<DimensionUsage name="Export HS" source="HS" foreignKey="hs_level3" />
<Measure name="FOB US" column="fob_us" aggregator="sum" />
</Cube>
<Cube name="imports">
<DimensionUsage name="Date" source="Date" foreignKey="date_id" />
<DimensionUsage name="Origin Country" source="Country" foreignKey="country_origin_id" />
<DimensionUsage name="Import Geography" source="Geography" foreignKey="importer_comuna_id" />
<DimensionUsage name="Import HS" source="HS" foreignKey="hs_6digits" />
<Measure name="CIF US" column="cif_us" aggregator="sum" />
</Cube>
<VirtualCube name="exports_and_imports">
<CubeUsages>
<CubeUsage cubeName="exports" ignoreUnrelatedDimensions="true" />
<CubeUsage cubeName="imports" ignoreUnrelatedDimensions="true" />
</CubeUsages>
<VirtualCubeDimension name="Date" />
<VirtualCubeDimension name="Geography" />
<VirtualCubeDimension name="HS" />
<VirtualCubeMeasure cubeName="exports" name="[Measures].[FOB US]" />
<VirtualCubeMeasure cubeName="imports" name="[Measures].[CIF US]" />
<CalculatedMember name="FOB" dimension="Measures">
<Formula>ValidMeasure([Measures].[FOB US])</Formula>
</CalculatedMember>
<CalculatedMember name="CIF" dimension="Measures">
<Formula>ValidMeasure([Measures].[CIF US])</Formula>
</CalculatedMember>
</VirtualCube>
</Schema>

There's no such thing as a dimension called "Geography" in any of your cubes. There's one called "Import Geography" and another one called "Export Geography". Your virtual cube is trying to use the Geography dimension, which neither cube has, but as the hierarchy is defined with hasAll="true", then the dimension defaults to the allMember in both cubes.
You need to define both Export and Import geography dimensions in your virtual cube and your slicer has to be
Union( [Import Geography].[Washington] * [Export Geography].[All], [Import Geography].[All] * [Export Geography].[Washington] )
(if what you're after is something like "show me total value in OR out of Washington).

Related

admin-on-rest: Access row's column data within a Datagrid component

I have a List view where I want to render a ReferenceField field based on the value of the current row being rendered in the table that the Datagrid component creates.
How can I access the current row's data? (the values of the columns of the current row).
I tried record.processed but I get an error saying that the record object doesn't exist (processed is a column in the record that I want to check in order to format the field). I also tried resource.processed, this.props.processed, and this.props.record.processed with no success.
The piece of code that shows what I'm trying to do is the following:
<List title="Sales Inquiries" filter={{ request_type: 'sales' }} {...props}>
<Datagrid>
<TextField source="id" />
<TextField source="firstname" label="First Name" />
<TextField source="lastname" label="Last Name" />
<TextField source="company" />
<TextField source="email" />
<DateField source="timestamp" label="Received" />
{record.processed ?
<ReferenceField label="Processed By" source="processedBy_id" reference="Users">
<TextField source="username" />
</ReferenceField>
: <span>Nobody</span> }
<ShowButton />
</Datagrid>
</List>
EDIT
Did as suggested by #kunal pareek Applied a HOC to the ReferenceField field that modifies it in order to show the proper content as follows:
const CustomField = (props) => (
<span>
{props.record.processed ?
<ReferenceField label="Processed By" source="processedBy_id" reference="Users">
<TextField source="username" />
</ReferenceField>
: <span>Nobody</span> }
</span>
);
the record is not really available at the location you want as a variable. It is passed to the component as a prop.
So you can do this.
<List title="Sales Inquiries" filter={{ request_type: 'sales' }} {...props}>
<Datagrid>
<TextField source="id" />
<TextField source="firstname" label="First Name" />
<TextField source="lastname" label="Last Name" />
<TextField source="company" />
<TextField source="email" />
<DateField source="timestamp" label="Received" />
<CustomField />
<ShowButton />
</Datagrid>
</List>
const CustomField = (props) => (
{props.record.processed ?
<ReferenceField label="Processed By" source="processedBy_id" reference="Users">
<TextField source="username" />
</ReferenceField>
: <span>Nobody</span> }
)
Above is just a simple example. I have taken your code straight and reformatted it, so it might not work straightaway. But I have been using this method to change the values of my components in several places.
You can also use HOCs. You can find examples here
https://marmelab.com/admin-on-rest/Theming.html
The dependent-input addon can help you with that.

How to use single inheritance in propel schema

I need to make a 'Event' class and propel schema with Columns:
id
employee_id
date_start
date_end
type
How to implement the simple inheritance based on the type column.
All classes should extend the abstract Event class.
Initial sub-class:
JoinEvent
can anyone write a schema for it?
I have written schema but not sure whether it is correct or not.
<table name="event" phpName="Event">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="employee_id" type="integer" required="true" />
<column name="date_start" type="date" required="true" />
<column name="date_end" type="date" required="false" />
<column name="type" type="integer" inheritance="single">
<inheritance key="1" class="JoinEvent" extends="Event"/>
</column>
<foreign-key foreignTable="employee" name="FI_event_employee">
<reference local="employee_id" foreign="id" />
</foreign-key>
</table>
Please help me.

ZKUI sorting by 'id' and not column

I am a zkui newbie and I have a Listmodel with live data. There is a sorting attribute that is set on the view which should sort the data by the column clicked but actually sorts by the id- sort="auto".
I found it at this site
Here is some sample code extracted from the site:
<columns menupopup="auto">
<column label="Author" sort="auto" />
<column label="Title" sort="auto" />
<column label="Publisher" sort="auto" />
<column label="Hardcover" />
</columns>
<rows>
<row>
<label value="Philip Hensher" />
<label value="The Northern Clemency" />
<label value="Knopf (October 30, 2008)" />
<label value="608 pages" />
</row>
<rows>
I researched a solution but I only found similar unanswered questions like the one here
I wonder if the issue might be the fact that I'm working with live data.
Please tell me what to do to ensure that the data is sorted according to the clicked column.
I am using grails to develop the application and this is my list.gsp:
<z:grid id="grid"
emptyMessage="${message(code:'emptyMessage',default:'No Record')}">
<z:columns sizable="true">
<z:column
label="${message(code: 'app.name.label', default: 'Name')}" sort="auto" />
<z:column
label="${message(code: 'app.status.label', default: 'Status')}" sort="auto"/>
In your list.gsp, try specifying the object attribute to be used in the sorting, like sort="auto(app.id)", sort="auto(app.name)" or whatever.

EXT.net - Grid Panel via Entity with DropDowns, Dates, Pin Editing and Deletion

Title sounds like a real mouthful, so let me try to explain this. I'm very strong with grinding out Web Forms and this is my second crack at using a framework and MVC (don't ask about the first one). Start with a table like this:
Title: Milestones
Id int - Auto, PK
Project_Id int - FK, Many Milestones to One Project, Provided static for now
Number int
Name varchar(50)
Status_Id int - FK One Status to One Milestone
PlannedDate date
LatestEstimate date
MilestoneType_ID int - FK One Type to One Milestone
These all sit on an SQL server, are pulled in by an Entity and then are pulled in by an ObjectDataSource, like this:
<asp:ObjectDataSource runat="server" ID="MilestonesObjectSource" SelectMethod="GetByProject"
DeleteMethod="DeleteMilestone" TypeName="TCProjectManagement.Models.MilestonesAddition">
<SelectParameters>
<asp:Parameter DefaultValue="6" Name="ProjectID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Type="Int32" Name="Id" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Type="Int32" Name="Id" />
<asp:Parameter Type="Int32" Name="Number" />
<asp:Parameter Type="String" Name="Name" />
<asp:Parameter Type="Int32" Name="Status_Id" />
<asp:Parameter Type="DateTime" Name="PlannedDate" />
<asp:Parameter Type="DateTime" Name="LatestEstimate" />
<asp:Parameter Type="Int32" Name="MilestoneType_ID" />
</UpdateParameters>
</asp:ObjectDataSource>
Sofar so good. Data pull seems to work out okay. I've got a couple more Object Sources that deal exclusively with the Foriegn Keys, so I'll skip those since they seem to be working.
The problems I have are attempting to stitch together many examples that don't seem to go together well. My objectives, in no paticular order:
1) Pin Editing: Click a button to edit, click it again to confirm. Rather do this than have somebody infer to double click for a change. Sofar, this sorta works.
2) Drop Downs for Foriegn Keys: While not in edit mode, should display the "Name" field of the FK. While in edit it should be a Drop Down for options (there's only three). This stays blank dispite what I do.
3) Deletion: Press a button to blow away a row. I put the button there but it's a copy of the JS for editing. What do I need to use to have it be deletion?
4) Dates: This doesn't work at all. One of the weird parts is that from the SQL server's type of Date, it gets changed to DateTime in the Entity and stays that way throughout. However, I cannot get the desired control of ext:DateField to cooperate with the provided data since it displays a time and completely blanks out when editing.. I know I'm doing something wrong here.
5) Saving Changes: Not quite sure I set it up right (or at all).
Provisions of Javascript:
<script type="text/javascript">
var pinEditors = function (btn, pressed) {
var columnConfig = btn.column,
column = columnConfig.column;
if (pressed) {
column.pinOverComponent();
column.showComponent(columnConfig.record, true);
} else {
column.unpinOverComponent();
column.hideComponent(true);
}
};
var pinDeleters = function (btn, pressed) { };
</script>
And ASP Code:
<ext:GridPanel ID="MilestonesGridPanel" runat="server" Title="Milestones" Width="1000px"
Height="300px">
<Store>
<ext:Store ID="MilestonesGridStore" runat="server" DataSourceID="MilestonesObjectSource">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" Type="Int" />
<ext:ModelField Name="Number" Type="Int" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="Status_Id" Type="Int" />
<ext:ModelField Name="PlannedDate" />
<ext:ModelField Name="LatestEstimate" />
<ext:ModelField Name="MilestoneType_ID" Type="Int" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="IdColumn" runat="server" DataIndex="Id" Text="DBID" Visible="false" />
<ext:ComponentColumn ID="NumberColumn" runat="server" DataIndex="Number" OverOnly="true"
Pin="true" Flex="1" Text="Number" Editor="true">
<Component>
<ext:NumberField ID="NumberColumnNumberField" runat="server" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="NameColumn" runat="server" DataIndex="Name" OverOnly="true"
Pin="true" Flex="1" Text="Name" Editor="true">
<Component>
<ext:TextField ID="NameColumnTextField" runat="server" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="StatusColumn" runat="server" DataIndex="Status_Id" OverOnly="true"
Pin="true" Flex="1" Text="Status" Editor="true">
<Component>
<ext:ComboBox ID="StatusColumnDropDownBox" runat="server" QueryMode="Local" Editable="false"
StoreID="MilestoneStatusStore" DisplayField="Name" ValueField="ID" EmptyText="Empty" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="PlannedDateColumn" runat="server" DataIndex="PlannedDate"
OverOnly="true" Pin="true" Flex="1" Text="Planned Date" Editor="true">
<Renderer Format="Date" FormatArgs="'m/d/y'" />
<Component>
<ext:DateField ID="PlannedDateColumnTextField" runat="server" Format="MM/dd/yyyy"
EmptyText="Empty" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="LatestEstimateColumn" runat="server" DataIndex="LatestEstimate"
OverOnly="true" Pin="true" Flex="1" Text="Latest ETA" Editor="true">
<Renderer Format="Date" FormatArgs="'m/d/y'" />
<Component>
<ext:DateField ID="LatestEstimateColumnTextField" runat="server" Format="MM/dd/yyyy"
EmptyText="Empty" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="MilestoneTypeColumn" runat="server" DataIndex="MilestoneType_ID"
OverOnly="true" Pin="true" Flex="1" Text="Milestone Type" Editor="true">
<Component>
<ext:ComboBox ID="MilestoneTypeColumnComboBox" runat="server" QueryMode="Local" Editable="false"
StoreID="MilestoneTypesStore" DisplayField="Name" ValueField="ID" EmptyText="Empty" />
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="EditColumn" runat="server" Width="30" PinAllColumns="false"
AutoWidthComponent="false" OverOnly="true" Text="Edit" Sortable="False">
<Component>
<ext:Button ID="EditButton" runat="server" ToolTip="Pin Editors" Icon="Pencil" AllowDepress="true"
EnableToggle="true" Width="25">
<Listeners>
<Toggle Fn="pinEditors" />
</Listeners>
</ext:Button>
</Component>
</ext:ComponentColumn>
<ext:ComponentColumn ID="DeleteColumn" runat="server" Width="30" PinAllColumns="false"
AutoWidthComponent="false" OverOnly="true" Text="Delete" Sortable="False">
<Component>
<ext:Button ID="DeleteButton" runat="server" ToolTip="Delete Milestone" Icon="Delete"
AllowDepress="true" EnableToggle="false" Width="25">
<Listeners>
<Click Handler="#{MilestonesGridStore}.remove(this.parentMenu.dataRecord)" />
</Listeners>
</ext:Button>
</Component>
</ext:ComponentColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single">
<Listeners>
<Select Handler="#{DeleteMilestoneGridButton}.enable();" />
<Deselect Handler="if (!#{MilestonesGridPanel}.selModel.hasSelection()) {
#{DeleteMilestoneGridButton}.disable();
}" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
<Buttons>
<ext:Button ID="AddtoMilestoneGridButton" runat="server" Text="Insert" Icon="Add">
<Listeners>
<Click Handler="#{MilestonesGridStore}.insert(0, {}); #{MilestonesGridPanel}.editingPlugin.startEditByPosition({row:0, column:0});" />
</Listeners>
</ext:Button>
<ext:Button ID="DeleteMilestoneGridButton" runat="server" Text="Delete" Icon="Delete"
Disabled="true">
<Listeners>
<Click Handler="#{MilestonesGridPanel}.deleteSelected();
if (!#{MilestonesGridPanel}.hasSelection()) {
#{DeleteMilestoneGridButton}.disable();
}" />
</Listeners>
</ext:Button>
<ext:Button ID="RefreshMilestonesGridButton" runat="server" Text="RefresH" Icon="Reload">
<Listeners>
<Click Handler="#{MilestonesGridStore}.load();" />
</Listeners>
</ext:Button>
<ext:Button ID="SaveMilestoneGridButton" runat="server" Text="Save" Icon="Disk">
<Listeners>
<Click Handler="#{MilestonesGridStore}.sync();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:GridPanel>

How do I find a list of subclasses for a propel model with concrete inheritance

I'm building a mini-cms for my local charity (yes, I know I could use a floss project, but they want custom coded)
My propel schema currently looks as such:-
<?xml version="1.0" encoding="UTF-8"?>
<database name="sja" defaultIdMethod="native">
<table name="section">
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
<column name="title" type="VARCHAR" required="true" />
<column name="slug" type="VARCHAR" required="true" />
</table>
<table name="page">
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
<column name="title" type="VARCHAR" required="true" />
<column name="section_id" type="INTEGER" required="true" />
<foreign-key foreignTable="section">
<reference local="section_id" foreign="id" />
</foreign-key>
</table>
<table name="static_page">
<behavior name="concrete_inheritance">
<parameter name="extends" value="page" />
</behavior>
<column name="content" type="LONGVARCHAR" required="true" />
</table>
<table name="home_page">
<behavior name="concrete_inheritance">
<parameter name="extends" value="page" />
</behavior>
<column name="standfirst_title" type="VARCHAR" />
<column name="standfirst_image" type="VARCHAR" />
<column name="standfirst_content" type="VARCHAR" />
</table>
</database>
I want to be able to get a list that would include "home_page" and "static_page" - without having to create this manually whenever I add a new page type.
Is there an easy way to get a list like this, or do I have to write some magic stuff with Reflection Classes, etc?
After a poke in the right direction from #propel on freenode - I've come up with this for a base concept - haven't tested it yet though
function getSubClasses()
{
$map = $this->getDatabaseMap();
$children = array();
foreach ($map->getRelations() AS $relation)
{
$behaviours = $relation->getRightTable()->getBehaviours();
if (issset($behaviours['concrete_inheritance']['extends']) AND $behaviours['concrete_inheritance']['extends'] == $this->getDatabaseMap()->getClassName())
{
$children[] = $relation->getRightTable()->getClassName();
}
}
return $children;
}

Resources