Crest Infosolutions Git Repository

Commit 2e053ddb authored by Kavitha's avatar Kavitha
Browse files

Initial commit

parent 3d5c64d8
No related merge requests found
Pipeline #190 failed with stages
in 0 seconds
Showing with 1349 additions and 1 deletion
+1349 -1
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
/target/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>rmp-activiti</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
This diff is collapsed.
# AGC Brunei APS
# Alfresco Process Services SDK Project (2.X+) for integrating digital signature module from ACS into APS using service task listener.
To see how to integrate this project in your APS workflow checkout readme file under ```src/main/java/com/activiti/extension/bean``` path.
The project consists of the following Maven submodules:
* APS extensions JAR (`aps-extensions-jar`): put here your Java extensions
Running Docker will also create volumes for each storage component (contentstore, db and ElasticSearch) for making the development approach in APS consistent and reliable.
# Prerequisites
* OpenJDK 11.0.5
* Apache Maven 3.8.4
* Docker (optional)
* A valid APS license installed in your development environment `<USER_HOME>/.activiti/enterprise-license` (for development purpose)
* A valid Aspose license installed in your development environment `<USER_HOME>/.activiti/enterprise-license` (for development purpose)
* Access to the Alfresco Nexus Repositories (credentials provided by Alfresco)
* Configure your Maven servers settings.xml with credentials for these repositories:
```
<server>
<id>activiti-enterprise-releases</id>
<username>yourAlfrescoUsername</username>
<password>yourAlfrescoPassword</password>
</server>
<server>
<id>enterprise-releases</id>
<username>yourAlfrescoUsername</username>
<password>yourAlfrescoPassword</password>
</server>
<server>
<id>internal-thirdparty</id>
<username>yourAlfrescoUsername</username>
<password>yourAlfrescoPassword</password>
</server>
```
# APS Extensions JAR Module
Folder structure is based on the same APS project classpath:
* `/aps-extensions-jar/src/main/resources/activiti`: APS configuration files
* `/aps-extensions-jar/src/main/resources/apps`: contains your own APS applications extracted
* `/aps-extensions-jar/src/test/java`: put here your unit and integration tests
To run use `mvn clean install -DskipITs`
* Runs the embedded container + H2 DB
* Runs unit tests with `mvn clean test`
* Packaging of App ZIP, JAR and WAR with extensions
# SDK Packages - Runtime - Cross platform
* `com.activiti.extension.api`: put here your enterprise custom REST endpoint (authentication required)
* `com.activiti.extension.rest`: put here your internal API (with no authentication)
* `com.activiti.extension.bean`: put here your Spring beans (services and components)
*Suggested naming conventions for implementations dedicated to a specific app*
* `com.activiti.extension.*your_app*.listeners`: put here your listeners
* `com.acitivit.extension.*your_app*.service.tasks`: put here your service tasks
# SDK Packages - Embedded Test Runtime
* `org.alfresco.activiti.unit.tests`: put here your unit test (with suffix *Test.java)
# Few things to notice
* You can use all the APS services such as: UserService, GroupService, TenantService and so on...
* No parent pom
* Standard JAR, WAR packaging with also Docker container generation
* Works seamlessly with any IDE
* Test your extensions with a consistent APS architecture running with Docker volumes
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.activiti.extension</groupId>
<artifactId>agc-activiti</artifactId>
<version>1.0</version>
<name>Activiti Endpoints Extension Module for Digital Signature workflow</name>
<description>Activiti Extension Module that produces a JAR file with Java extensions such as service task delegates.</description>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Properties used in dependency declarations -->
<activiti.groupId>com.activiti</activiti.groupId>
<activiti.version>1.5.1</activiti.version>
<activiti.engine.version>5.21.0.2</activiti.engine.version>
<!-- Compile with Java 8, default is 5 -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.activiti.api/activiti-api-runtime-shared -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-app-rest</artifactId>
<version>6.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.activiti/activiti-app-logic -->
<dependency>
<groupId>com.activiti</groupId>
<artifactId>activiti-app-logic</artifactId>
<version>1.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.activiti/activiti-explorer -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-explorer</artifactId>
<version>5.14</version>
</dependency>
<dependency>
<groupId>com.activiti</groupId>
<artifactId>activiti-app-model</artifactId>
<version>1.11.0</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>com.activiti</groupId>
<artifactId>activiti-app-logic</artifactId>
<version>1.11.0</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-app-data</artifactId>
<version>6.0.0.Beta1</version>
</dependency>
<!-- Thanks for using https://jar-download.com -->
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
</dependencies>
<build>
<resources>
<!-- Filter the resource files in this project and do property substitutions -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<!-- Filter the test resource files in this project and do property substitutions -->
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<configuration>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<id>create-distribution</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Alfresco Maven Repositories -->
<repositories>
<!-- Activiti Enterprise Edition Artifacts, put username/pwd for server
in settings.xml -->
<repository>
<id>activiti-private-repository</id>
<url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-enterprise-releases</url>
</repository>
<!--repo added by Shashikanth.Chill for enterprise dependencies to work
with Spring beans -->
<repository>
<id>alfresco-artifacts-repository</id>
<name>Alfresco EE releases</name>
<url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-enterprise-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>adobe-public</id>
<url>https://repo.adobe.com/nexus/content/repositories/public/</url>
</repository>
</repositories>
</project>
\ No newline at end of file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>app</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/app/</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.activiti.extension.bean;
import com.activiti.domain.idm.EndpointConfiguration;
import com.activiti.domain.idm.User;
import com.activiti.model.editor.EndpointCheckResultRepresentation;
import com.activiti.model.editor.kickstart.TypedValueObject;
import com.activiti.service.api.EndpointService;
import com.activiti.service.api.UserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.delegate.DelegateExecution;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/**
*
* @author Kavitha
*/
@Component("dw")
public class DynamicFlowBean {
private static final ObjectMapper mapper = new ObjectMapper();
@Autowired
RepositoryService repositoryService;
@Autowired
UserService userService;
@Autowired
@Qualifier("endpointService")
EndpointService endpointService;
/**
* Read the internal/external users dynamic table data as JSON string, extract
* taskStage from each row of both tables, pick distinct, sort them and return
* in a list.
*
* @param delegateExecution
* @throws IOException
*/
public void unMarshallTaskStageDetails(DelegateExecution delegateExecution) throws IOException {
List<Integer> taskStages = new ArrayList<>();
String internalUsersJson = (String) delegateExecution.getVariable("internal_users_dy_table");
String externalUsersJson = (String) delegateExecution.getVariable("external_users_dy_table");
if (internalUsersJson != null) {
JsonNode jsonNodesArray = mapper.readTree(internalUsersJson);
// extract taskStage from each jsonNode and add it to list
jsonNodesArray.iterator().forEachRemaining(jsonNode -> {
taskStages.add(jsonNode.get("taskStage").asInt());
});
}
if (externalUsersJson != null) {
JsonNode jsonNodesArray = mapper.readTree(externalUsersJson);
// extract taskStage from each jsonNode and add it to list
jsonNodesArray.iterator().forEachRemaining(node -> {
taskStages.add(node.get("taskStage").asInt());
});
}
delegateExecution.setVariable("taskStages",
taskStages.stream().distinct().sorted().collect(Collectors.toList()));
}
/**
* Read the internal/external users dynamic table data as JSON string, extract
* user details from each row of both tables for matching taskStage, put the
* user details in a map against userId & in a JSON array.
*
* @param delegateExecution
* @param taskStage
* @throws IOException
*/
// kavitha
public void getUserDetailtaskstage(DelegateExecution delegateExecution, int taskStage) throws IOException {
Map<Long, String> internalUserDetailsMap = new HashMap<>();
Map<String, String> purposeMap = new HashMap<>();
Map<String, String> remarksMap = new HashMap<>();
List<String> listuser = new ArrayList<>();
String internalUsersJson = (String) delegateExecution.getVariable("internal_users_dy_table");
System.out.println("internalUsersJson: " + internalUsersJson);
if (internalUsersJson != null) {
JsonNode jsonNodesArray = mapper.readTree(internalUsersJson);
List<JsonNode> jsonNodes = new ArrayList<>();
jsonNodesArray.iterator().forEachRemaining(jsonNodes::add);
System.out.println("jsonNodesArray: " + jsonNodesArray);
// filter jsonNodes on matching taskStage, map filtered nodes to UserDetail, get distinct UserDetail based on email into a list.
List<String> userDetailss = jsonNodes.stream()
.filter(jsonNode -> jsonNode.get("taskStage").asInt() == taskStage).map(jsonNode -> {
System.out.println("jsonNode: " + jsonNode);
List<Integer> signsets = new ArrayList<>();
JsonNode signsetsNode = jsonNode.get("assign_to");
JsonNode purposenode = jsonNode.get("purpose");
String remarks = jsonNode.get("remarks").asText();
String purpose = purposenode.get("name").asText();
String userID = signsetsNode.get("id").asText();
remarksMap.put(userID, remarks);
purposeMap.put(userID, purpose);
listuser.add(userID);
return userID;
}).distinct().collect(Collectors.toList());
delegateExecution.setVariable("user", listuser);
delegateExecution.setVariable("purposemap", purposeMap);
delegateExecution.setVariable("remarksmap", remarksMap);
}
}
// kavitha
public void getUserDetail(DelegateExecution delegateExecution, int taskStage) throws IOException {
Map<String, String> purposeMap = new HashMap<>();
String internalUsersJson = (String) delegateExecution.getVariable("internal_users_dy_table");
if (internalUsersJson != null) {
JsonNode jsonNodesArray = mapper.readTree(internalUsersJson);
List<JsonNode> jsonNodes = new ArrayList<>();
jsonNodesArray.iterator().forEachRemaining(jsonNodes::add);
// filter jsonNodes on matching taskStage, map filtered nodes to UserDetail, get distinct UserDetail based on email into a list.
List<String> userDetails = jsonNodes.stream().map(jsonNode -> {
List<Integer> signsets = new ArrayList<>();
JsonNode signsetsNode = jsonNode.get("assign_to_2");
JsonNode purposenode = jsonNode.get("purpose_2");
String purpose = purposenode.get("name").asText();
String userID = signsetsNode.get("id").asText();
purposeMap.put(userID, purpose);
return userID;
}).distinct().collect(Collectors.toList());
System.out.println("user: "+delegateExecution.getVariable("user"));
List<String> listuser = new ArrayList<>();
if (delegateExecution.getVariable("user").toString() != null && !delegateExecution.getVariable("user").toString().isEmpty())
listuser = (List<String>) delegateExecution.getVariable("user");
System.out.println("userDetails: " + userDetails);
System.out.println("listuser: " + listuser);
listuser.addAll(userDetails);
//Collections.copy(listuser, userDetails);
System.out.println();
System.out.println("all users: " + listuser);
delegateExecution.setVariable("user", listuser);
delegateExecution.setVariable("purposemap", purposeMap);
}
}
class UserDetail {
private long id;
private String name;
private String email;
private List<Signset> signsets;
private String attachmentRef;
public UserDetail() {
}
public UserDetail(long id, String name, String email, List<Signset> signsets, String attachmentRef) {
this.id = id;
this.name = name;
this.email = email;
this.signsets = signsets;
this.attachmentRef = attachmentRef;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public List<Signset> getSignsets() {
return signsets;
}
public void setSignsets(List<Signset> signsets) {
this.signsets = signsets;
}
public String getAttachmentRef() {
return attachmentRef;
}
public void setAttachmentRef(String attachmentRef) {
this.attachmentRef = attachmentRef;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + Objects.hashCode(this.email);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final UserDetail other = (UserDetail) obj;
return this.email.equals(other.email);
}
@Override
public String toString() {
return "UserDetail: {" + "id=" + id + ", name=" + name + ", email=" + email + '}';
}
public ObjectNode mapToJsonNode() {
ObjectNode userDetailNode = mapper.createObjectNode();
userDetailNode.put("name", name);
userDetailNode.put("email", email);
ArrayNode signsetNodes = mapper.createArrayNode();
signsetNodes.addAll(signsets.stream().map(signset -> {
ObjectNode signsetNode = mapper.createObjectNode();
signsetNode.put("pageindex", signset.getPageIndex());
signsetNode.put("top", signset.getTop());
signsetNode.put("left", signset.getLeft());
signsetNode.put("fieldtype", signset.getFieldtype());
return signsetNode;
}).collect(Collectors.toList()));
userDetailNode.set("signsets", signsetNodes);
return userDetailNode;
}
}
public class Signset {
private int pageIndex;
private int top;
private int left;
private final String fieldtype = "sign";
public Signset() {
}
public Signset(int pageIndex, int top, int left) {
this.pageIndex = pageIndex;
this.top = top;
this.left = left;
}
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public int getTop() {
return top;
}
public void setTop(int top) {
this.top = top;
}
public int getLeft() {
return left;
}
public void setLeft(int left) {
this.left = left;
}
public String getFieldtype() {
return fieldtype;
}
@Override
public String toString() {
return "Signset: {" + "pageIndex=" + pageIndex + ", top=" + top + ", left=" + left + ", fieldtype="
+ fieldtype + '}';
}
}
}
To use DigitialSignatureBean in your workflows, call ds.fetchSigningUrl(...) method in service task as following: ${ds.fetchSigningUrl(execution,"ACS_endpoint_name","Webscript_URL","dynamic_table_field_id")}
/**
*
* @param delegateExecution
* @param endpointName :: ACS endpoint name configured in APS.
* @param restUrl :: Url of the ACS webscript to send signing data
* @param fieldId :: Field id of dynamic table in workflow
* @throws JsonProcessingException
* @throws IOException
*/
public void fetchSigningUrl(DelegateExecution delegateExecution, String endpointName, String restUrl, String fieldId) throws JsonProcessingException, IOException {...}
The dynamic table in your workflow corresponding to fieldId should contain columns with following ids: pageindex,top,left. All columns should be of type Number.
All columns should have values.
If not configured already, configure ACS base endpoint with proper auth details in APS under Identity Manager >> Tenants >> Endpoints. Provide the configured endpoint name
as second param to fetchSigningUrl().
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment