Extending ApprovalModule
Magnet Max provides ad-hoc approval features so users can create approval on-the-fly with the data fields they want. If a developer wants to make this approval available to the 3rd party system whenever an approval is created/updated/deleted, the developer can add custom logic on these events.
In order to add custom logic on approval driven events, the developer will need to do the following:
Create a new Maven project for your custom logic and generate a jar library as the result. In the pom.xml file for the new maven project, add the following dependency for the required Max server module (use 3.0.5 or later version).
<dependencies>
<dependency>
<groupId>com.magnet.mms</groupId>
<artifactId>mms-approval-sdk</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.magnet.mms</groupId>
<artifactId>mms-sdk-base</artifactId>
<version>3.0.5</version>
</dependency>
...
</dependencies>
<repositories>
<repository>
<id>Magnet MAX repo</id>
<name>Magnet MAX</name>
<url>http://repo.magnet.com:8081/artifactory/libs-release-local/</url>
</repository>
...
</repositories>
Add a new java class to extend the ApprovalNotificationModule class for adding new business logic into the approval life cycle. The following example shows a CustomApprovalModule class that implements ApprovalNotificationModule.
package com.yourcompany.approvalext;
import com.magnet.server.approval.guice.ApprovalNotificationModule;
import com.magnet.server.approval.dao.model.enums.ApprovalStatus;
import com.magnet.server.approval.rest.model.Approval;
import com.magnet.server.sdk.annotations.AutoloadModule;
@AutoloadModule
public class CustomApprovalModule extends ApprovalNotificationModule {
@Override
public void approvalCreated(final Approval approval) {
// The method will be call back when approval is created
}
@Override
public void approvalUpdated(final Approval approval) {
// The method will be call back when approval is updated
}
@Override
public void approvalDeleted(final Approval approval) {
// The method will be call back when approval is deleted
}
@Override
public void repliedToApproval(final Approval approval, final ApprovalStatus status) {
// The method will be call back when approval is replied
}
}
Compile your new Maven project to generate the jar file,and copy the jar file into the Max server libraries directory: max-server/server/sharedlibs. Then restart the Max server to load and initialize the approval extension module.