`
maxwell
  • 浏览: 64745 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

读取oracle-agile plm 的bom 并 expand

阅读更多

package com.agile.test;

/**
 * Created by IntelliJ IDEA.
 * User: 

 * Date: Aug 19, 2008
 * Time: 12:45:44 PM
 * To change this template use File | Settings | File Templates.
 */
import com.agile.px.*;
import com.agile.api.*;

import java.util.List;

public class HWPX implements ICustomAction{

    public ActionResult doAction(IAgileSession agileSession,
                                       INode node,
                                       IDataObject affectedObject) {

        try {
            IItem part = null;
            if(affectedObject!=null) {
                part = (IItem)agileSession.getObject(IItem.OBJECT_TYPE,affectedObject.getObjectId());
            }
            int size = 0;
            if(part!=null) {
                size = countBom(part);
                return new ActionResult(ActionResult.STRING, String.valueOf(size));
            }
            return new ActionResult(ActionResult.STRING, "hello world!!!");
        } catch (APIException e) {
            return new ActionResult(ActionResult.STRING, "Exception");
        }
    }
    private int countBom(IItem part) throws APIException{
        ITable bomTable = part.getTable(ItemConstants.TABLE_BOM);
        int size = 1;
        ITwoWayIterator iter = bomTable.getTableIterator();

        while(iter.hasNext()) {
            IRow subRow = (IRow)iter.next();
            IItem subPart = (IItem)subRow.getReferent();
            size = size + countBom(subPart);
        }

        return size;
    }
}

 

分享到:
评论
2 楼 liu9822 2009-11-19  
大哥--你还有agile二次开发的相关资料了啊,能不能共享点给小弟。。。。
目前公司正在准备做agile二次开发,找不到什么资料,唉,苦恼死了
1 楼 maxwell 2008-08-20  
1:注意 size 初始为1,因为这是在hasNext()里调用.
2:bom里的一个row 并不能当成一个 IItem . row 只能表示当前object 和 某个IItem 的关联关系. 要找到这个row 对应的IItem 就要用 row.getReferent() 方法。

相关推荐

Global site tag (gtag.js) - Google Analytics