Skip to main content
1-Visitor
January 10, 2011
Question

Team Query

  • January 10, 2011
  • 3 replies
  • 1630 views
I need code to query all Teams whose context name is either "Site" or
"emhartglass".

I've have been using:

wt.query.QuerySpec qs = new
wt.query.QuerySpec(wt.team.TeamTemplate.class);
wt.fc.QueryResult qr = wt.fc.PersistenceServerHelper.manager.query(qs);
//Query all team templates

I now need to limit the teams returned in the QueryResult to only those
teams whose context name is either "Site" or "emhartglass".

Any thoughts on this?

I'd tried the following

wt.query.QuerySpec qs = new
wt.query.QuerySpec(wt.team.TeamTemplate.class);
qs.appendWhere(new SearchCondition(wt.team.TeamTemplate.class,
wt.team.TeamTemplate.CONTAINER_NAME, SearchCondition.EQUAL, "Site"));
wt.fc.QueryResult qr =
wt.fc.PersistenceServerHelper.manager.query(qs); //Query all team
templates

the error i get is



David Graham
CAx/PDM Administrator


Emhart Glass Manufacturing Inc.
123 Great Pond Drive | PO Box 220 | Windsor, CT 06095-0220 | USA
Telephone +1 (860) 298 7377 | Telefax +1 (860) 298 7397
Mobile +1 (203) 376-3144 |

3 replies

1-Visitor
January 10, 2011
I have not tried the code below and dont have an IDE handy but why not search for wt.org.WTUsers with context like site?
I could be totally wrong:

wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.org.WTUser.class);
qs.appendWhere(new SearchCondition(wt.org.WTUser.class, wt.org.WTUser.context/*(i forget the exact name can let you know later if it doesnt work)*/, SearchCondtional.EQUAL, "Site"), 0);
wt.query.StatmentSpec spec = (wt.query.StatementSpec) qs;
wt.fc.QueryResult qr = wt.fc.PersistenceHelper.manager.find(spec);

this was typed in an email may have syntax errors please check. May be of help.
1-Visitor
January 10, 2011

Not sure if you got this resolved but the code i sent you before after i read your post doesnt fit what you need.

Now you may have time to find a faster simplier solution but this is quick and works but may not be for you. Just an idea.

It should return every team template in your system and then you can do an if statment off the string to get what your looking for.

publicc static void teamTemp(){
wt.team.TeamTemplate temp = null;
try{
QuerySpec qs = new QuerySpec (wt.team.TeamTemplate.class);
qs.appendWhere (new SearchCondition (wt.team.TeamTemplate.class, wt.team.TeamTemplate.NAME,SearchCondition.NOT_LIKE, " "), 0);
StatementSpec spec = (StatementSpec)qs;
QueryResult qr = PersistenceHelper.manager.find(spec);
while(qr.hasMoreElements()){
temp = (wt.team.TeamTemplate)qr.nextElement();
String name = temp.getContainerName();
}
}catch(WTException e){e.printStackTrace();}
}

1-Visitor
January 10, 2011
TeamHelper.service.findTeamTemplates(WTContainerRef) to get templates from a
specific context.

In your case (2 contexts), just call it twice.


- Nicolas Weydert -