I am trying to extract items from different TypeHierarchies from a single query. 3 of the attributes are from "HierarchicalRequirement" while 3 other are from "PortfolioItem".
My question is, can I mention multiple TypeHierarchies in a single query? in the find, like this:
"find" => {"_ProjectHierarchy" => projectID, "_TypeHierarchy" => ["HierarchicalRequirement","PortfolioItem"] , "ScheduleState" => "Accepted" }
Thanks!
You are correct, the LookbackAPI figures out what field belongs to what hierarchy type.
PortfolioItem has field "State" and HierarchicalRequirement has field "ScheduleState". Just to illustrate your answer for the benefit of other users here is a screenshot of results fragment from a query that specifies two types "_TypeHierarchy":{$in:["PortfolioItem","HierarchicalRequirement"]} :
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ProjectHierarchy":12352814790, "_TypeHierarchy":{$in:["PortfolioItem","HierarchicalRequirement"]},"__At":"2013-08-01T00Z"}&fields=["_TypeHierarchy","_UnformattedID","ScheduleState","State"]&hydrate=["_TypeHierarchy","ScheduleState","State"]
Related
I have created a new extension with the extension builder which includes some tables and inline relations between some tables.
For reporting I need some queries where the selection condition is based on the related records.
Here I have difficulties to get the data (except doing raw queries, which seems wrong).
attempt:
do the query in the related records and extract the field which holds the uid of the parent records.
Problem: in the query result is no field with the uid of the parent record (although it is in the database).
This is understandable as there are no methods to get/set the relation. (But it does not change if I insert these methods.)
Also in the children record there is no TCA definition of the relation field except:
'parent' => [
'config' => [
'type' => 'passthrough',
],
],
which might be the reason the field can not be displayed in the record even if inserted in the showitem list.
attempt:
doing a join from the parent record.
Here I have not found any examples how to build a join.
There are other possibilities for a query, but the plainest seems this in the parent record repository:
public function getParentsByFilter($mainCondition,$subCondition) {
$parentQuery = $this->createQuery();
$parentQuery->matching(
$parentQuery->logicalAnd(
$parentQuery->equals('parent_field',$mainCondition)
// $childQuery->equals('children_field',$subCondition)
)
);
// $parentQuery->joinTable('tx_myext_domain_model_children', ...)
$parentQuery->setOrderings(['crdate'=> QueryInterface::ORDER_DESCENDING]);
$parentQuery->getQuerySettings()->setRespectStoragePage(false);
return $parentQuery ->execute();
}
Here I don't know how to join the children table.
I expect some methods like the commented lines, but have not found anything like it.
What's about the same configuration like in the table sys_category?
I need to search for a text within a particular workspace. I need all items and fields, except comments.
I'm using php-wrapper for Podio API and Search in space function:
$attributes = array(
"query" => $query,
"ref_type" => "item", // I need just items, not tasks, statuses etc.
"search_fields" => "title"
);
$items = PodioSearchResult::space( $space_id, $attributes );
If search_fields parameter will be removed, it will search not only in titles, but in all fields. However, it will also search in comments left for each item and return that items as a result. But I need just results based on fileds values.
Of course, it is possible to list all the fields needed in search_fields. But there is a dozen of apps with a dozen of different fields each in that space. Moreover, fields could be added, edited or removed by workspace users. So it looks like a very rough and hard-coded solutiuon to list all the fields.
Is there another way to avoid comments in search results?
Podio doesn't have specific method to avoid only comments. But instead of hardcoding all the fields, you can query dynamically "Get app values" call and use the result in "search_fields".
I am not sure why I can't get the columns from my other tables via my relations. I was thinking is it because of my scope? After i had a default scope in my models, everything seems to be out of place, even if i use resetscope() at some places. Some sections I can't get to my relation columns; when that happens, I'd have to use Model::model->findbypk(n)->name.. that doesn't look pretty.
the id shows if i don't have the relations, but the name is blank when i put the relation name.
CHtml::listData(Model::model()->findAll(),'product_id','main.product_name'),
my model defaultscope is pretty basic:
return array(
'condition'=>'store_id1=:store_id OR store_id2=:store_id' ,
'params' => array(':store_id' => $store_id)
);
You can change the way you use your model like below:
Model::model()->with('main')->findAll();
I have an error "The column 'Translat2_' was specified multiple times for 'query'" when using paging for my query.
My classes hierarchy:
Politician
--PoliticianInFactions : PoliticianInFaction
--EntityTranslations : Translation
Faction
--PoliticiansInFaction : PoliticianInFaction
--EntityTranslations : Translation
Translation
--Name : String
--Language : Language
What I want: to fetch politicians ordered by its faction's name and than by its name.
My query:
var criteria = Session.CreateCriteria<Politician>("politician");
// criteria for current faction
var currentFactionCriteria = criteria
.CreateCriteria<Politician>(x => x.PoliticianInFactions, JoinType.InnerJoin)
.Add<PoliticianInFaction>(x => x.FromDate <= DateTime.Now)
.CreateCriteria<PoliticianInFaction>(x => x.Faction, JoinType.InnerJoin);
// add order by faction's name !!!
currentFactionCriteria
.CreateCriteria<Faction>(x => x.EntityTranslations, JoinType.InnerJoin)
.Add<Translation>(x => x.Language.Id == languageId)
.AddOrder<CityTranslation>(x => x.Name, Order.Asc);
// add order by politician's name !!!
criteria
.CreateCriteria<Politician>(x => x.EntityTranslations, JoinType.InnerJoin)
.Add<Translation>(x => x.Language.Id == languageId)
.AddOrder<Translation>(x => x.Name, Order.Asc);
When adding paging to this query I have an error. Without paging everything is OK. Also if I comment(remove) any block marked with (!!!) exception dissapears.
What am I doing wrong? If this is a bug of NHibernate give me some workaround please. Thank you.
Check you mapping files to see if you have mapped multiple properties to the same database column or mapped the same databases column to multiple properties.
I know that this is an ancient thread, but this issue plagued me recently.
I've discovered that the case of the property calls in your mapping matters relative to paging. I.E. if you have a property with a column called "field" and you map it to another property as well, this will not be an issue if the case of field is the same.
However, if you identify your other mapping with a column called "Field", paging will not know that this is not a distinct property and will try to query the same column twice!
I guess that you have a CASE or duplicate problem.In my issue I have the following situation:
I take the column "serie id" two times but in different ways.. I put "S" in lower and in upper.. I hope that helps..
i have posts table
id
type enum(A,Q)
title
content
and i need controllers questions_controller and answer_controller to use
please lead the right way to
1-
make 2 models (question and answer) and use 'posts' as model's table
2-
use post model in questions_controller and answer_controller
For me, it should be one table has one model
So better use
$uses = array('Post'); in your controllers.
Update:
As far I understood you want to filter the data depending from the type column. Actually your db model is wrong, because except if they are totally unrelated your answers need to belong to the question. This mean you need an extra column parent_id which will determine what is the parent node (question) and child nodes (answers).
If we have this assumption, then you can set a relation in the model like:
class Post extends AppModel {
...
var $belongsTo = array(
'Parent' => array('className' => 'Post','foreignKey' => 'parent_id', 'conditions' => 'Parent.parent_id IS NOT NULL')
);
...
}
So you automatically have Post and Post->Parent. But I think that it would be better to have 2 tables - one which holds the questions and another the answers.