Im using a nested XML and parsing it using 'hasMany'.. I would appreciate if someone could tell me how to read the value of the node '<type>'. I can easily read the attributes 'id' & 'val' of '' using mapping but i want to also read the node value eg. 257411 in
<type id="3" val="0">257411
I would appreciate if anyone could provide a suitable 'mapping'
XML data:
<?xml version="1.0" encoding="ISO-8859-1"?>
<basics id="744" name="social">
<number>302221</number>
<types>
<type id="3" val="0">257411</type>
<type id="2" val="1081337">28213</type>
<type id="1" val="263258">8645</type>
<type id="5" val="0">3664</type>
<type id="4" val="0">2246</type>
<type id="9" val="0">1124</type>
<type id="10" val="0">918</type>
</types>
</basics>
model Basic
Ext.define("ap3.model.Basic",{
extend: "Ext.data.Model",
config: {
fields: [
{name: 'id', mapping: '#id'},
{name: 'name', mapping: '#name'},
{name: 'number', mapping: 'number'}
],
associations: [
{
type: 'hasMany',
model: 'apv3.model.Type',
associationKey: 'types'
}]
}
});
model Type
Ext.define("ap3.model.Type",{
extend: "Ext.data.Model",
config: {
fields: [
{name: 'id', mapping: '#id'},
{name: 'val', mapping: '#val'},
{name: 'type', mapping: 'type'}
],
proxy: {
type: 'memory',
reader: {
type: 'xml',
record: 'type'
}
}
}
});
"mapping" accepts a function too:
{name: 'id', mapping: '#id'},
{name: 'name', mapping: '#name'},
{name: 'number', mapping: function (node) {
return (node.firstChild ? node.firstChild.nodeValue : null);
}}
Don't know if that counts as an answer, but having spent a lot of time on the same issue I'd say this is a bug in the framework :(
A couple of relevant links:
https://stackoverflow.com/a/11549596/454266
http://www.sencha.com/forum/showthread.php?209025-Nested-XML-reader-problem&p=838952&viewfull=1#post838952
Luckily nested JSON works fine. My advice is to switch to it or to handle loading of the lower-level models manually (e.g. writing your own method doing the job of hasMany association by creating a store / reader and feeding this.raw.types to it).
Related
In a declarative pipeline, I have this job call :
build job: 'myJob', parameters: [
string(name: 'PARAM1', value: 'value1'),
string(name: 'PARAM2', value: 'value2'),
], wait: true
I would like Intellij recognizes this syntax with a GDSL file. Currently, I have in my GDSL file :
method(name: 'build', type: 'Object', namedParams: [
parameter(name: 'job', type: 'java.lang.String'),
parameter(name: 'parameters', type: 'java.util.List'),
parameter(name: 'propagate', type: 'boolean'),
parameter(name: 'quietPeriod', type: 'java.lang.Integer'),
parameter(name: 'wait', type: 'java.lang.Boolean')])
But defining a java.util.List type for parameter is incorrect : IntelliJ do not expect to have string() as parameter.
Any idea ?
I need to describe REST (json) api with OpenAPI (Swagger) syntax. I have stuck at the point when I need to describe nested request body. Please suggest how to make it, lets use as example the next nested request body:
{
"pauses" : [
{"name" : "PAUSING_AUTO"},
{"name" : "NO_PAUSE_CRITERIA","Min" : 15},
{"name" : "PREVENTED_PAUSE","Min" : 5},
{"name" : "REVERT_TO_RUN"},
{"name" : "RUNNING"}
]
}
The following description would do:
pauses:
type: "array"
items:
type: "object"
required:
- name
properties:
name:
type: "string"
Min:
type: "integer"
I've been able to create a grid and basic filtering to narrow down iterations etc. Ideally I would like to run this via html/confluence so ideally I need to have the filtering set so that I can filter on parent as well as project. Testing this in the Rally dashboard, the way I have it still only working within project I'm sitting in. How do I make my filtering work so that where I'm at project wise in Rally doesn't matter or if I use my api key.
Thanks!
Mark
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['userstory'],
autoLoad: true,
enableHierarchy: true,
filters: [{property: 'Iteration.Name',
operator : '=',
value : 'March'},
{property: 'Project.Parent.Name',
operator : '=',
value : 'Synergy'},
{property: 'Project.Name',
operator : '=',
value : 'Condor'}
]
}).then({
success: function(store) {
Ext.create('Ext.Container', {
items: [{
xtype: 'rallytreegrid',
columnCfgs: [
'DisplayColor',
'Name',
'ScheduleState',
'Blocked',
'TaskEstimateTotal',
'TaskRemainingTotal',
'Owner',
'Notes'
],
store: store
}],
renderTo: Ext.getBody()
});
}
});
You just need to pass a context to your store:
https://help.rallydev.com/apps/2.0/doc/#!/guide/data_stores-section-scoping
All projects:
{ project: null, workspace: '/workspace/12345'}
Specific project:
{ project: '/project/12345', projectScopeDown: false, projectScopeUp: false }
Project hierarchy:
{ project: '/project/12345', projectScopeDown: true, projectScopeUp: false }
Or if you are trying to get data from multiple projects not in a tree you can always create a filter in the store on Project like you're doing above. Note that you'll need to make sure all those projects are actually in scope based on your context to get any results.
I'm just getting started try to code scripts for Rally that can be utilized for a confluence wiki. I've gotten the basic TreeStoreBuilder to work with my number of fields, but I need to constrain it to an iteration (ideally latest) as well as hard code project/subproject as that I'm expecting would need to be constrained as I want to have multiple charts from different projects on 1 wiki page. The code that I have so far is below..
Thanks!
Mark
enter code here
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['userstory'],
autoLoad: true,
enableHierarchy: true
}).then({
success: function(store) {
Ext.create('Ext.Container', {
items: [{
xtype: 'rallytreegrid',
columnCfgs: [
'DisplayColor',
'Name',
'ScheduleState',
'Blocked',
'TaskEstimateTotal',
'TaskRemainingTotal',
'Owner',
'Notes'
],
store: store
}],
renderTo: Ext.getBody()
});
}
});
You can check out filtering here: https://help.rallydev.com/apps/2.0/doc/#!/guide/data_stores-section-filtering
And project scoping here:
https://help.rallydev.com/apps/2.0/doc/#!/guide/data_stores-section-scoping
Finally after struggling with extjs tree panel, tree store and building custom reader to read and convert pentaho data for 2 weeks I have managed to load pentaho data into treepanel of extjs.
Now my Tree panel is loading same data infinitely.
Treepanel looks as follows :
Part of my json data looks as follows :
{
{name: 'US', candidateCount: 3, children: []},
{name: 'India', candidateCount: 922, children: [
{name: 'Goa', candidateCount:124, children: []},
{name: 'Maharashtra', candidateCount: 43, children: [
{name: 'Pune', candidateCount: 3},
{name: 'Mumbai', candidateCount: 33},
{name: 'Kolhapur', candidateCount: 4},
{name: 'XXX', candidateCount: 3},
]}
]},
{name: 'UK', candidateCount: 1, children: []},
}
As you can see in image above, after expanding India node it has again loaded data of country level (i.e. country names US, uk, India, UK). Actually I want to show state level data like data of Maharashtra, Goa. Instead of that treepanel is again loading same data again.
How to avoid this kind of behavior? I have already set leaf property of US, uk and India nodes to false.
I tried setting Expanded property to true but then treepanel keeps loading same nodes again and again and my browser tab just gets hanged.
Please let me know how to avoid this? I want tree panel to load data only once.
EDIT - Solution to this problem
I solved this problem by adding listener on append event of store and then setting leaf value to true for the nodes which I wanted to be leaf.
I had the same problem with my treepanel and JSON data. My treeStore looks something like this:
proxy: {
type: 'ajax',
url: 'urlJson',
reader: {
type: 'json',
root: 'instanceList',
successProperty: 'success'
}
},
root:{
text: 'Root',
expanded: true
}
And the JSON
{
"instanceList": [
{
"text": "Parent 1",
"instanceList": [
{
"class": "testing",
"id": 3,
"leaf": true,
"text": "Child 1"
}
]
},
{
"text": "Parent 2",
"instanceList": [
{
"class": "testing",
"id": 2,
"leaf": true,
"text": "Child 2"
},
{
"class": "testing",
"id": 1,
"leaf": true,
"text": "Child 3"
}
]
}
],
"instanceTotal": 1,
"success": true
}
I changed "children" for "instanceList" and my treepanel stopped doing that infinitely loop, so I guess If you change "name" for "children" ?
Setting data item to:
{
...
leaf: true
}
will stop it.
Loading trees can be tricking. Try setting loaded: true on those nodes. Before you start clicking around, is the tree properly loaded?
Make sure all parents that do not have any children have "leaf" set to "true" OR
have an empty "children" node.
AND all children nodes have "leaf" set to "true" (as already mentioned by Asken)
it seems to me that any child becomes a root to its dependents . So the root property and the children property MUST have the same NAME. I am very happy I found this tread. It saved my life I was about to shoot myself because of endless reloading the tree
As Edd said, if you set in proxy custom rootProperty:'instanceList', you have to change all "children" in json to that property, ie 'instanceList'. It was my solution.