グローバル関数の作成

グローバル関数は、ビジネス・ロジックをWebサービスでラップして、他の場所で簡単に使用できるようにするために使用されます。

OCMCreateRepositoryCollectionFunction

OCMCreateRepositoryCollectionService Webサービスへのアクセスに使用されるOCMリポジトリ・コレクションの作成グローバル機能を作成するには:

  1. 左側のナビゲーション・メニューから「共通設定」「グローバル機能」の順に選択します。
  2. 「グローバル関数」ページで、「グローバル関数の追加」アイコンをクリックします。
  3. 「Create Global Function (グローバル機能の作成)」ページで、次のフィールドに入力します。

    1. 「ファンクション名」フィールドで、ファンクションの名前をOCMCreateRepositoryCollectionFunctionとして指定します。
    2. 「戻り値」ドロップダウン・メニューから「文字列」を選択します。
    3. 「説明」フィールドに、「指定したOCMRepositoryId内に新しいOCMCollectionNameを作成し、新しく作成されたコレクションIDを返します。」というテキストを入力します。
    4. 「パラメータ」セクションで、「パラメータの追加」アイコンをクリックし、次のフィールドを追加します。
      名前 タイプ
      OCMRepositoryId String
      OCMCollectionName String
    5. 「スクリプトの編集」フィールドに、次のスクリプトを貼り付けます。
      println("Create OCM Collection " + OCMCollectionName + " within the Asset Repository Id: " + OCMRepositoryId);
      def params = [:]
      params.name = OCMCollectionName
      def OCMCollection = [:]
      try {
        def OCMCreateRepositoryCollectionService = adf.webServices.OCMCreateRepositoryCollectionService
        OCMCreateRepositoryCollectionService.requestHTTPHeaders = ['X-Requested-With': 'XMLHttpRequest']
        OCMCollection = OCMCreateRepositoryCollectionService.POST(OCMRepositoryId, params)
        println("OCM Collection Created: " + OCMCollection)
        return OCMCollection.id
      } catch (Exception e) {
        println("OCM Create Respository(" + OCMRepositoryId + ") Collection(" + OCMCollectionName + ") Error: " + e)
      }
    6. 「保存して閉じる」をクリックします。

OCMGetDocumentsByFolderIdFunction

OCMGetDocumentsByFolderIdService Webサービスへのアクセスに使用する新しい「グローバル機能の作成」ページで「フォルダID別OCMドキュメントの取得」グローバル機能を作成するには、次のフィールドに入力します。

ノート:

このグローバル機能は、Oracle Sales and Serviceビジネス・オブジェクトに解決オプションがあり、OCM文書統合で構成されている場合にのみ必要です。ドキュメント統合の詳細は、ドキュメント・コラボレーションによるOracle Sales and Serviceビジネス・オブジェクトの拡張方法について学習を参照してください。


  1. 「ファンクション名」フィールドで、ファンクションの名前をOCMGetDocumentsByFolderIdFunctionとして指定します。
  2. 「戻り値」ドロップダウン・メニューから「リスト」を選択します。
  3. 「説明」フィールドに、「指定したOCMFolderIdに基づいてOCMドキュメントIDのリストを返します(これには子フォルダも含まれます)。」というテキストを入力します。
  4. 「パラメータ」セクションで、「パラメータの追加」アイコンをクリックします。

    「名前」フィールドで、OCMFolderIdという名前を指定し、「タイプ」ドロップダウン・メニューから「文字列」を選択します。

  5. 「スクリプトの編集」フィールドに、次のスクリプトを貼り付けます。
    def response = [:]
    def items = []
    try {
      response = adf.webServices.OCMGetDocumentsByFolderIdService.GET(OCMFolderId)
      for(item in response.items){
        items.add(item["id"])
      }
      println("OCM Get Documents By Folder Id " + OCMFolderId + " Result(" + items.size() + "): " + items)
      return items
    } catch (Exception e) {
      println("Get OCM Documents By Folder Id Error: " + e)
    }
    
  6. 「保存して閉じる」をクリックします。

OCMCopyDocumentsToRepositoryCollectionFunction

OCMBulkOperationsService Webサービスへのアクセスに使用する新しい「グローバル機能の作成」ページでOCMリポジトリ・コレクションへのドキュメントのコピー・グローバル機能を作成するには、次のフィールドに入力します。

ノート:

このグローバル機能は、Oracle Sales and Serviceビジネス・オブジェクトに解決オプションがあり、OCM文書統合で構成されている場合にのみ必要です。ドキュメント統合の詳細は、ドキュメント・コラボレーションによるOracle Sales and Serviceビジネス・オブジェクトの拡張方法について学習を参照してください。


  1. 「ファンクション名」フィールドで、ファンクションの名前をOCMCopyDocumentsToRepositoryCollectionFunctionとして指定します。
  2. 「戻り値」ドロップダウン・メニューから「ブール」を選択します。
  3. 「説明」フィールドに、「Copies the OCM specified list of OCMDocumentIds into the specified OCMCollectionId within the specified OCMRepositoryId.」というテキストを入力します。
  4. 「パラメータ」セクションで、「パラメータの追加」アイコンをクリックし、次のフィールドを追加します。
    名前 タイプ
    OCMRepositoryId String
    OCMCollectionId String
    OCMDocumentIds リスト
  5. 「スクリプトの編集」フィールドに、次のスクリプトを貼り付けます。
    // Create the structure required for the list of documents that will be used in the payload below
    def documents = []
    for(OCMDocumentId in OCMDocumentIds) {
      def document = 
      [
        externalId: OCMDocumentId,
        // NOTE: The type value must match the name of the Asset Type that you created during the installation
        type: "Service-Request-Asset",
        collections:
        [
          data: [OCMCollectionId]
        ]
      ]
      
      documents.add(document)
    }
    
    // Create the payload required to make the addToRepository bulk operation call
    def payload =
    [
      operations:
      [
        addToRepository:
        [
          connectorId: "Documents",
          repositoryId: OCMRepositoryId,
          externalItems: documents
        ]
      ]
    ]
    
    try {
      def OCMBulkOperationsService = adf.webServices.OCMBulkOperationsService  
      OCMBulkOperationsService.requestHTTPHeaders = ['X-Requested-With': 'XMLHttpRequest']
      OCMBulkOperationsService.POST(payload)
      println("OCM Documents Copied To Repository: " + OCMRepositoryId + "(" + OCMCollectionId + "): (" + OCMDocumentIds + ")")
      return true
    } catch (Exception e) {
      println("Copy OCM Documents To Repository Error: " + e)
      return false 
    }

    ノート:

    前述のスクリプトの「タイプ」の値は、以前に作成したアセット・タイプの名前と一致する必要があります。
  6. 「保存して閉じる」をクリックします。

OCMIsRepositoryCollectionSharedAsContributorFunction

OCMRepositoryCollectionPermissionsService Webサービスへのアクセスに使用する新しい「グローバル機能の作成」ページでOCM Is Repository Collection Shared As Contributorグローバル機能を作成するには、次のフィールドに入力します。



  1. 「ファンクション名」フィールドで、ファンクションの名前をOCMIsRepositoryCollectionSharedAsContributorFunctionとして指定します。
  2. 「戻り値」ドロップダウン・メニューから「ブール」を選択します。
  3. 「説明」フィールドに、「指定したOCMUserNameが指定したOCMRespositoryId内の指定されたOCMCollectionIdに少なくともContributorロールで共有されている場合、trueを返す」というテキストを入力します。
  4. 「パラメータ」セクションで、「パラメータの追加」アイコンをクリックし、次のフィールドを追加します。
    名前 タイプ
    OCMRepositoryId String
    OCMCollectionId String
    OCMUserName String
  5. 「スクリプトの編集」フィールドに、次のスクリプトを貼り付けます。
    def response = [:]
    try {
      response = adf.webServices.OCMRepositoryCollectionPermissionsService.GET(OCMRepositoryId, OCMCollectionId)
      def responseItems = [:]
      responseItems = response.items
      for (item in responseItems) {
        // Ignore case as these could be different between the two security systems even though it is the same user
        if ((item['id'] as String).toLowerCase() == OCMUserName.toLowerCase()) {
          // If found make sure the user also has at least the contributor role
          if (item['roleName'] == 'contributor' || item['roleName'] == 'manager') {
            println("OCM User(" + OCMUserName + ") was found with enough role permissions to the repository collection: " + OCMRepositoryId + "(" + OCMCollectionId + ")")
            return true
          } else {
            println("OCM User(" + OCMUserName + ") was found but without enough role permissions to the repository collection: " + OCMRepositoryId + "(" + OCMCollectionId + ")")
            return false
          }
        }
      }
      println("OCM User(" + OCMUserName + ") does not have permissions to the repository: " + OCMRepositoryId)
      return false
    } catch (Exception e) {
      println("OCM Is Repository Collection Shared As Contributor Error: " + e)
      return false
    }
  6. 「保存して閉じる」をクリックします。

OCMShareCollectionFunction

OCMPermissionOperationsService Webサービスへのアクセスに使用する新しい「グローバル機能の作成」ページでOCM共有収集グローバル機能を作成するには、次のフィールドに入力します。



  1. 「ファンクション名」フィールドで、ファンクションの名前をOCMShareCollectionFunctionとして指定します。
  2. 「戻り値」ドロップダウン・メニューから「ブール」を選択します。
  3. 「説明」フィールドに、テキスト「Shares the specified OCMCollectionId in OCM with the OCMUserName and OCMRole specified」を入力します。
  4. 「パラメータ」セクションで、「パラメータの追加」アイコンをクリックし、次のフィールドを追加します。
    名前 タイプ
    OCMCollectionId String
    OCMUserName String
    OCMRole String
  5. 「スクリプトの編集」フィールドに、次のスクリプトを貼り付けます。
    // Create the payload required to make the permissions operation call
    def payload =
    [
      operations:
      [
        share:
        [
          resource:
          [
            id :OCMCollectionId,
            type :"collection",
          ],
          roles:
          [[
            name :OCMRole,
            users:
            [[
              name :OCMUserName,
              type :"user",
            ]],
          ]],
        ],
      ]
    ]
    
    def response = [:]
    try {
      def OCMPermissionOperationsService = adf.webServices.OCMPermissionOperationsService
      OCMPermissionOperationsService.requestHTTPHeaders = ['X-Requested-With': 'XMLHttpRequest', 'content-type': 'application/json']
      response = OCMPermissionOperationsService.POST(payload)
      
      // Check the response to make sure we do not have a failure
      def hasFailedRoles = response?.operations?.share?.failedRoles
      if (hasFailedRoles == null) {
        println("OCM Collection Shared: " + OCMCollectionId + "(" + OCMUserName + ":" + OCMRole + ")")
        return true
      } else {
        println("Share OCM Collection Failed: " + response)
        return false
      }
    } catch (Exception e) {
      println("Share OCM Collection Error: " + e)
      return false 
    }
    
  6. 「保存して閉じる」をクリックします。