0

API を使用して Windchill で部品とドキュメント間のリンクを作成する方法。次のコードを試しました。

WTPartDescribeLink wl=WTPartDescribeLink.newWTPartDescribeLink(part1, Doc1);
PersistenceHelper.manager.save(wl);

しかし、それは機能していません.:(:(

4

2 に答える 2

0

WTDocumentWTPartオブジェクトの両方をチェックアウトし、作業コピーを取得する必要があります。その後、合格する必要があります。

以下は、WTPartDescribeLink

import wt.doc.WTDocument;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.folder.Folder;
import wt.part.WTPart;
import wt.part.WTPartDescribeLink;
import wt.pds.StatementSpec;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.wip.CheckoutLink;
import wt.vc.wip.WorkInProgressHelper;

public class PartDesc {

    public static void main(String args[]) throws WTException, WTPropertyVetoException
    {
        WTPart part=null;
        WTDocument doc=null;
        String number="0000000025";
        String docnumber="0000000027";
        QuerySpec qspec=new QuerySpec(WTPart.class);
        qspec.appendWhere(new SearchCondition(WTPart.class,WTPart.NUMBER,SearchCondition.LIKE,number),new int[]{0,1});
        QueryResult qr=PersistenceHelper.manager.find((StatementSpec)qspec);
        while(qr.hasMoreElements())
        {
            part=(WTPart) qr.nextElement();
        }
        System.out.println("Part found");

        QuerySpec qspec1=new QuerySpec(WTDocument.class);
        qspec1.appendWhere(new SearchCondition(WTDocument.class,WTDocument.NUMBER,SearchCondition.LIKE,docnumber),new int[]{0,1});
        QueryResult qr1=PersistenceHelper.manager.find((StatementSpec)qspec1);
        while(qr1.hasMoreElements())
        {
            doc=(WTDocument) qr1.nextElement();
        }
        System.out.println("Document found");

          //Checkout and getting Working copy of object
        Folder checkoutFolder = WorkInProgressHelper.service.getCheckoutFolder();
        CheckoutLink col = WorkInProgressHelper.service.checkout(doc,checkoutFolder,"");
        doc = (WTDocument)col.getWorkingCopy();


        Folder checkoutFolder1 = WorkInProgressHelper.service.getCheckoutFolder();
        CheckoutLink col1 = WorkInProgressHelper.service.checkout(part,checkoutFolder,"");
        part = (WTPart)col1.getWorkingCopy();

        //Creating Link between part and doc
        WTPartDescribeLink link=WTPartDescribeLink.newWTPartDescribeLink(part, doc);
        PersistenceHelper.manager.save(link);
        System.out.println("link created ");

        doc = (WTDocument)WorkInProgressHelper.service.checkin(doc,"");
        part = (WTPart)WorkInProgressHelper.service.checkin(part,"");
    }

}
于 2013-06-22T07:18:40.987 に答える