5

sap-cap-sdm-plugin

 7 months ago
source link: https://community.sap.com/t5/application-development-blog-posts/presenting-sap-cap-sdm-plugin-effortless-integration-between-cap-node-js/ba-p/290789
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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 this 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.Property` 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
    @Former Member.Entity
    entity Files {
        key id       : String      @Former Member.Field      : { type : 'property', path : 'cmis:objectId' };
        name         : String      @Former Member.Field      : { type : 'property', path : 'cmis:name' };
        content      : LargeBinary @Core.MediaType : contentType  @Core.ContentDisposition.Filename : name;
        contentType  : String      @Core.IsMediaType
                                   @Former Member.Field      : { type : 'property', path : 'cmis:contentStreamMimeType' };
        createdBy    : String      @Former Member.Field      : { type : 'property', path : 'cmis:createdBy' };
        creationDate : Date        @Former Member.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! 🙂


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK