2016-04-13 16 views
0

Microsoft TFSを管理するソフトウェア用のプラグインを開発しています。各プラグイン操作(チェックアウト、ラベル作成、チェックインなど)は個別に実行する必要があります。私のチェックアウト操作では、ワークスペースが作成され、そのワークスペースがダウンロードされた後、ワークスペースのマッピングは削除されますが、そのファイルはビルドまたは変更されたままになります。TFS Java SDK作成PendingChange []オブジェクト

ファイルが変更されたら、それらをチェックインする必要があります。すでにワークスペースを削除してから、新しいファイルを作成する必要があります。

作業領域内のファイルからPendingChange []オブジェクトを作成する際に問題があります。誰かがこれがどのように行われるかについてのサンプルを与えることができますか?

この

は、私はそれが助け場合、私のワークスペースを作成するために使用しているコードです:

public Workspace createWorkspace(String pWorkspaceName, String pLocalPath, String pServerPath) 
{ 
WorkingFolder[] foldersToMap = null; 
if (pServerPath != null && pLocalPath != null) 
    { 
     final List<WorkingFolder> folderList = new ArrayList<WorkingFolder>(); 
     folderList.add(new WorkingFolder(pServerPath, LocalPath.canonicalize(pLocalPath), WorkingFolderType.MAP, RecursionType.FULL)); 
     foldersToMap = folderList.toArray(EMPTY_WORKING_FOLDER_ARRAY); 
    } 
    else if (pServerPath == null || pServerPath.isEmpty()) 
    { 
     //throw 
    } 
    else if (pLocalPath == null || pLocalPath.isEmpty()) 
    { 
     //throw 
    } 

Workspace w = 
    mVersionControlClient.createWorkspace(foldersToMap, pWorkspaceName, VersionControlConstants.AUTHENTICATED_USER, VersionControlConstants.AUTHENTICATED_USER, null /*Comment*/, 
             WorkspaceLocation.SERVER, WorkspaceOptions.NONE); 

return w; 
} 

Microsoftのドキュメントは、Java SDKに大きなではないので、任意のヘルプは大歓迎です。

P.S.私の質問に何か問題がある場合、または明確にしたい場合は、コメントを残して、downvoteの前に私に知らせてください、私はそれを修正するでしょう。

答えて

0
Workspace ws = vcc.getWorkspace(workspaceName, ownerName); 
PendingSet pendings = ws.getPendingChanges(); 
for (PendingChange pending : pendings.getPendingChanges()) { 
    ItemType type = pending.getItemType(); 
    /*Don't download if it is a Folder*/ 
    if (type.getWebServiceObject().getName() 
      .equals("Folder")) 
     continue; 
    ChangeType change = pending.getChangeType(); 
    Item item = vcc.getItem(pending.getServerItem()); 
    String itemName = StringUtils.getItemName(item.getServerItem()); 

    /*My business rule: can't download if isn't in Lock with owner*/ 
    if (!change.toString().contains("(512): Lock")) { 
     returns.add(new Return("ERROR", "The object " 
+ item.getServerItem() 
+ " isn't in Lock with " + owner 
+ ".")); 
      continue; 
    } 
    String destinationFile = destinationPath + "\\" + itemName; 
    item.downloadFile(vcc, destinationFile); 

} 

希望します。

関連する問題