业务对象——WTPart
1.根据编号查询部件master
String number="传入编号";
QuerySpec qs=new QuerySpec(WTPartMaster.class);
SearchCondition sc=new SearchCondition(WTPartMaster,"number",SearchCondition.EQUAL,number);
qs.appendWhere(sc);
QueryResult qr=PersistenceHelper.service.find(qs);
WTPartMaster master=null;
while(qr.hasMoreElements()){
master = (WTPartMaster )qr.nextElement();
}
return master;
2.根据master查询WTPart
ConfigSpec cs=ConfigHelper.service.getDefaultConfigSpecFor(WTPart.class);
QueryResult qr=ConfigHelper.service.filteredIterationsof(master,cs);
WTPart part=null;
while(qr.hasMoreElements()){
part=(WTPart)qr.nextElement();
}
return part;
3.根据名称和视图查询WTPart,查询到的是当前视图下部件的集合;
String name="部件的名称";
String view="部件的视图"; //例如:Design;
QuerySpec qs=new QuerySpec(WTPart.class);
SearchCondition sc=new SearchCondition(WTPart.class,WTPart.NAME,SearchCondition.EQUAL,name);
qs.appendWhere(sc);
View view=ViewHelper.service.getView("Design");
SearchCondition sc2=new SearchCondition(WTPart.class,WTPart.VIEW_NAME,SearchCondition.EQUAL,view.getName);
qs.appendWhere(sc2);
QueryResult qr=PersistenceHelper.service.find(qs);
ArrayList<WTPart> parts=new ArrayList<>();
WTPart part=null;
While(qr.hasMoreElements()){
part=qr.nextElement();
parts.add(part);
}
return parts;