Presenting `sap-cap-sdm-plugin`: Effortless Integration Between CAP (Node.js) and DMS
2023-10-3 04:57:14 Author: blogs.sap.com(查看原文) 阅读量:5 收藏

Hello SAP Community!

I’m happy to introduce you to the sap-cap-sdm-plugin, a plugin designed to streamline the integration between CAP (Node.js) and DMS (Document Management Service).

This idea came when I stumbled upon Daniel’s blog post about cds.plugins. In his example, Daniel creates a custom annotation that appends an emoji to the end of the text for properties that are annotated with it. Although simplistic, his example gave me some ideas.

Before developing sap-cap-sdm-plugin, I conceived the sap-cloud-cmis-client library, aiming to streamline the integration between CAP/cloud-sdk projects and DMS on Cloud Foundry. Although useful, it fell short of providing a truly effortless experience for developers, which prompted me to explore this relatively new possibility.

The main goal was clear: Provide a tool where developers could integrate their CAP projects with SAP DMS by just annotating their entities using @Sdm.Entity and @Sdm.Field, while the plugin would handles the technical details in the background.

After addressing numerous questions, reviewing extensive documentation, and investing some hours, sap-cap-sdm-plugin came into existence.

How to Use

Here’s a step-by-step guide:

1. Install the Plugin:

npm i sap-cap-sdm-plugin

2. Configure the Plugin:

Add it to the `cds.requires` section of your package.json.

"cds": {
    "requires": {
        "sap-cap-sdm-plugin": {
            "impl": "sap-cap-sdm-plugin",
            "settings": {
                "destination": "<YOUR_SDM_DESTINATION_NAME>",
                "repositoryId": "<YOUR_REPOSITORY_ID>" // Optional. Remove if you have only one repository.
            }
        }
    }
}

You have to specify the destination related to the DMS service. If you have multiple repositories, you can optionally specify the repositoryId you want to use.

Since it’s CAP, you can also set specific configurations for different profiles.

"cds": {
    "requires": {
        "sap-cap-sdm-plugin": {
            "impl": "sap-cap-sdm-plugin",
            "[development]": { // development profile
              "settings": {
                  "destination": "<YOUR_SDM_DESTINATION_NAME>",
                  "repositoryId": "123"
              }
            },
            "[production]": { // production profile
              "settings": {
                  "destination": "<YOUR_SDM_DESTINATION_NAME>",
                  "repositoryId": "456"
              }
            }
        }
    }
}

3. Create an Entity:

Create an entity that should be “linked” to the DMS, using the right annotations.

service SampleService {
    @cds.persistence.skip
    @Sdm.Entity
    entity Files {
        key id       : String      @Sdm.Field      : { type : 'property', path : 'cmis:objectId' };
        name         : String      @Sdm.Field      : { type : 'property', path : 'cmis:name' };
        content      : LargeBinary @Core.MediaType : contentType  @Core.ContentDisposition.Filename : name;
        contentType  : String      @Core.IsMediaType
                                   @Sdm.Field      : { type : 'property', path : 'cmis:contentStreamMimeType' };
        createdBy    : String      @Sdm.Field      : { type : 'property', path : 'cmis:createdBy' };
        creationDate : Date        @Sdm.Field      : { type : 'property', path : 'cmis:creationDate' };
    }
}

With this setup, you can perform basic CRUD operations directly on DMS, using this OData Entity as a “proxy”.

For additional functionalities, you may refer to examples provided in the example folder.

Limitations to Consider

While sap-cap-sdm-plugin is efficient for a majority of scenarios, it has its limitations, like not supporting versioned repositories, thumbnail generation, among others. I’m on it and looking forward to enhancing its capabilities. Your feedback is invaluable, so don’t hesitate to share your thoughts or seek assistance on GitHub.

Hope you like it 🙂

Vinícius Barrionuevo


文章来源: https://blogs.sap.com/2023/10/02/presenting-sap-cap-sdm-plugin-effortless-integration-between-cap-node.js-and-dms/
如有侵权请联系:admin#unsafe.sh