ドキュメントのリストを管理する方法

ドキュメントのリストは、同じ名前(属性「名前」)を持ついくつかのドキュメントによって表されます。単一ドキュメントの場合と同じメソッドを使用して、リストに要素を追加/削除することが可能です。


 

ドキュメントのリストを入手する

ドキュメントのリストを myDocList とした場合、結果をインデックス値の昇順でソートするためには、次のリクエストを使用します。

リクエストURL:

メソッド パス+クエリ
GET /API/bpm/caseDocument?p=0&c=10&f=name=myDocList&o=index ASC

レスポンス・ペイロード:

[
  { 
    "id":"1", 
    "creationDate":"2014-10-09 16:39:52.472", 
    "author":"1", 
    "index":"0", 
    "contentMimetype":"text/plain", 
    "caseId":"1", 
    "contentStorageId":"1", 
    "isInternal":"true", 
    "description":"", 
    "name":"myDocList", 
    "fileName":"test1.txt", 
    "submittedBy":"1", 
    "url":"documentDownload?fileName=test1.txt&contentStorageId=1", 
    "version":"1" 
  }, {
    "id":"2", 
    "creationDate":"2014-10-09 16:39:52.473", 
    "author":"1", 
    "index":"1", 
    "contentMimetype":"text/plain", 
    "caseId":"1", 
    "contentStorageId":"2", 
    "isInternal":"true", 
    "description":"", 
    "name":"myDocList", 
    "fileName":"test2.txt", 
    "submittedBy":"1", 
    "url":"documentDownload?fileName=test2.txt&contentStorageId=2", 
    "version":"1" 
  }, {
    "id":"3", 
    "creationDate":"2014-10-09 16:39:52.473", 
    "author":"1", 
    "index":"2", 
    "contentMimetype":"text/plain", 
    "caseId":"1", 
    "contentStorageId":"3", 
    "isInternal":"true", 
    "description":"", 
    "name":"myDocList", 
    "fileName":"test3.txt", 
    "submittedBy":"1", 
    "url":"documentDownload?fileName=test3.txt&contentStorageId=3",
    "version":"1"
  }
]

 

新しいドキュメントを追加する

リスト myDocList のリストの末尾に新しいドキュメントを追加するには、リクエストのペイロード内に「index」属性を指定せずに POST 呼び出しを行います。

メソッド パス+クエリ
POST /API/bpm/caseDocument

リクエストのペイロード:

{ 
  "caseId" : "1", 
  "file" : "doc.jpg", 
  "name" : "myDocList", 
  "description" : "this is an element of the list" 
}

レスポンスのペイロード

{
  "id":"4", 
  "creationDate":"2014-10-09 16:45:36.658", 
  "author":"1", 
  "index":"3", 
  "contentMimetype":"application/octet-stream", 
  "caseId":"1", 
  "contentStorageId":"4", 
  "isInternal":"true", 
  "description":"this is a simple doc", 
  "name":"myDocList", 
  "fileName":"doc.jpg", 
  "submittedBy":"1", 
  "url":"documentDownload?fileName=doc.jpg&contentStorageId=4", 
  "version":"1" 
}

注意:この新しいドキュメントは「 index=3 」を持ちます。あなたが今、最初の GET リクエストを再実行した場合は、リストの最後の要素として新たなドキュメントを持つ4つのドキュメントを含むリストを取得します。

index を指定してリストに新しいドキュメントを追加する

リスト myDocList に新しいドキュメントを「index=1」で追加するには、リクエストのペイロード内に「index」属性を指定して POST 呼び出しを行います。

メソッド パス+クエリ
POST /API/bpm/caseDocument

リクエストのペイロード

{ 
  "caseId" : "1", 
  "file" : "doc.jpg", 
  "name" : "myDocList", 
  "description" : "this is an element of the list at index 1", 
  "index" : "1"
}

レスポンスのペイロード

{
  "id":"5", 
  "creationDate":"2014-10-09 16:45:36.658", 
  "author":"1", 
  "index":"1", 
  "contentMimetype":"application/octet-stream", 
  "caseId":"1", 
  "contentStorageId":"4", 
  "isInternal":"true", 
  "description":"this is a simple doc", 
  "name":"myDocList", 
  "fileName":"doc.jpg", 
  "submittedBy":"1", 
  "url":"documentDownload?fileName=doc.jpg&contentStorageId=4", 
  "version":"1" 
}

注意:この新しいドキュメントは「 index=1 」を持ちます。

あなたは今、サンプル1のリクエスト(ドキュメントのリストを入手する)を再実行した場合、新しく追加されたドキュメントの index によって myDocList 内のドキュメントの index が再計算されていることがわかります。

このように、ドキュメントリストのドキュメントID( index のこと)を知ることで、単一ドキュメントの場合と同様に、更新(PUT)と削除(DELETE)を行うことが可能です。