WS-AppServer 对象修改值返回客户端
在java方法里对WS-Appserver对象进行字段值修改后,数据库默认进行相应的持久化修改,但在某种场合下,需要对返回值进行修改单不影响DB,此时必须将对象进行TRANSIENT
public static BusObjectIterator<com.davidwsappserverpackage.dashboard> getDashboardByNames(String Names)
{
String queryText = "select * from dashboard where location in( "+Names+" )";
QueryObject query = new QueryObject(queryText);
query.setResultClass(dashboard.class);
BusObjectIterator<dashboard> dboards=query.getObjects();
List<dashboard> list=new ArrayList();
while(dboards.hasMoreElements())
{
dashboard d = dboards.nextElement();
/*
//方法一
d.makeTransient();
if(d.getLocation().equals("福建"))
{
d.setAcount(40);
}
list.add(d);
*/
方法二:
dashboard db = (dashboard)BusObject.sys_createBusObject(dashboard.class, new BusObjectConfig(d, dashboard.class, BusObjectConfig.TRANSIENT_OBJECT));
if(db.getLocation().equals("福建"))
{
db.setAcount(40);
}
list.add(db);
}
return new BusObjectArray(list);
}
// 重新对 Cordys 封装好 对象里面的值进行操作
public static BusObjectIterator<com.dashboard.MIndunction> getMIndunction(String createDateStart, String createDateEnd)
{
String sql="select instance_status as STATUS, count(instance_status) as acount from comac_hr.employee_induction MIndunction where MIndunction.CREATE_TIME > to_date('"+createDateStart+"','yyyy-mm-dd') and MIndunction.CREATE_TIME < to_date('"+createDateEnd+"','yyyy-mm-dd') group by instance_status ";
QueryObject query=new QueryObject (sql);
query.setResultClass(MIndunction.class);
BusObjectIterator<MIndunction> MIS=query.getObjects();
List<MIndunction> list=new ArrayList();
//对返回对象理解值的 操作
while(MIS.hasMoreElements())
{
MIndunction mindunction =(MIndunction)MIS.nextElement();
mindunction.makeTransient();
//test
if(mindunction.getSTATUS().equals("0"))
{
mindunction.setSTATUS("草稿");
}
if(mindunction.getSTATUS().equals("1"))
{
mindunction.setSTATUS("进行中");
}
if(mindunction.getSTATUS().equals("2"))
{
mindunction.setSTATUS("已完成");
}
list.add(mindunction);
}
return new BusObjectArray(list) ;
} 从一个A类型BusObjectIterator结果构造B类型的BusObjectIterator集合返回结果
BusObjectIterator<A> aIterator = ...
List<B> bList = new ArrayList<B>();
while(aIterator.hasMoreElements()){
A a = aIterator.nextElement();
B b = new B();
b.set...= a.get...
bList.add(b);
}
return new BusObjectArray<B>(bList);
class BusObjectArray implements BusObjectIterator
支持如下集合类型:
public BusObjectArray(Vector objects)
public BusObjectArray(Hashtable objects)
public BusObjectArray(Collection collection)