Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement workflow approvalService #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/
*.iml
target
88 changes: 88 additions & 0 deletions components/org.wso2.carbon.identity.workflow.engine/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>default.workflow.engine</artifactId>
<groupId>org.wso2.carbon.identity.workflow.engine</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>workflow.engine</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Workflow Engine Simple</name>

<dependencies>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.configuration.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.user.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.user.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.workflow.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.ds-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.user.mgt</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.2.0</version>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add property

Copy link
Author

@IsharaSilva IsharaSilva Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses this issue from 032e778 of 2nd PR.

<extensions>true</extensions>
<configuration>
<obrRepository>NONE</obrRepository>
<instructions>
<SCM-Revision>${buildNumber}</SCM-Revision>
<Private-Package>
org.wso2.carbon.identity.workflow.engine.internal,
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.workflow.engine.internal,
org.wso2.carbon.identity.workflow.engine.*;
</Export-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${maven.findbugsplugin.version}</version>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
</configuration>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.wso2.carbon.identity.workflow.engine;

import org.wso2.carbon.identity.workflow.mgt.bean.Parameter;
import org.wso2.carbon.identity.workflow.mgt.bean.metadata.InputData;
import org.wso2.carbon.identity.workflow.mgt.bean.metadata.Item;
import org.wso2.carbon.identity.workflow.mgt.bean.metadata.MapType;
import org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData;
import org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException;
import org.wso2.carbon.identity.workflow.mgt.exception.WorkflowRuntimeException;
import org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow;
import org.wso2.carbon.identity.workflow.mgt.workflow.TemplateInitializer;
import org.wso2.carbon.identity.workflow.mgt.workflow.WorkFlowExecutor;

import java.util.List;

import static org.wso2.carbon.identity.workflow.engine.util.WorkflowEngineConstants.ParameterName.BPS_PROFILE;
import static org.wso2.carbon.identity.workflow.engine.util.WorkflowEngineConstants.ParameterName.HT_SUBJECT;

/**
* The class that extends the AbstractWorkflow class.
*/
public class DefaultApprovalWorkflow extends AbstractWorkflow {


public DefaultApprovalWorkflow(Class<? extends TemplateInitializer> templateInitializerClass,
Class<? extends WorkFlowExecutor> workFlowExecutorClass, String metaDataXML)
throws WorkflowRuntimeException {

super(templateInitializerClass, workFlowExecutorClass, metaDataXML);
}

/**
*{@inheritDoc}
*/
@Override
protected InputData getInputData(ParameterMetaData parameterMetaData) {

InputData inputData = null;
if (parameterMetaData != null && parameterMetaData.getName() != null) {
String parameterName = parameterMetaData.getName();
if (BPS_PROFILE.equals(parameterName)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove BPS profile

Copy link
Author

@IsharaSilva IsharaSilva Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed with commit 032e778 of 2nd PR.

inputData = new InputData();
MapType mapType = new MapType();
inputData.setMapType(mapType);
Item item = new Item();
item.setKey("embeded_bps");
item.setValue("embeded_bps");
mapType.setItem(new Item[]{item});
} else if (HT_SUBJECT.equals(parameterName)) {
inputData = new InputData();
MapType mapType = new MapType();
inputData.setMapType(mapType);
Item item1 = new Item();
item1.setKey("subject1");
item1.setValue("subject1");
Item item2 = new Item();
item2.setKey("subject2");
item2.setValue("subject2");
mapType.setItem(new Item[]{item1, item2});
}
}
return inputData;
}

/**
*{@inheritDoc}
*/
@Override
public void deploy(List<Parameter> parameterList) throws WorkflowException {

super.deploy(parameterList);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.wso2.carbon.identity.workflow.engine;

import org.wso2.carbon.identity.workflow.mgt.bean.Parameter;
import org.wso2.carbon.identity.workflow.mgt.bean.WorkflowAssociation;
import org.wso2.carbon.identity.workflow.mgt.dto.WorkflowRequest;

import java.util.List;

/**
* Default Workflow Event Request service interface.
*/
public interface DefaultWorkflowEventRequest {

/**
* Add who approves the relevant request.
*
* @param request workflow request object.
* @param parameterList parameterList.
*/
void addApproversOfRequests(WorkflowRequest request, List<Parameter> parameterList);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename methods.
Fix other places as well

Copy link
Author

@IsharaSilva IsharaSilva Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed these type of issues from 032e778 of 2nd PR.


/**
* Get taskId from WF_REQUEST_APPROVAL_RELATION table.
*
* @param eventId the request ID that need to be checked.
* @return task Id.
*/
String getApprovalOfRequest(String eventId);

/**
* Delete approver details using task Id.
*
* @param taskId random generated unique Id.
*/
void deleteApprovalOfRequest(String taskId);

/**
* Add current step.
*
* @param eventId the request ID that need to be checked.
* @param workflowId workflow id.
* @param currentStep current step of the flow.
*/
void createStatesOfRequest(String eventId, String workflowId, int currentStep);

/**
* Get current step from the table.
*
* @param eventId the request ID that need to be checked.
* @param workflowId workflow Id.
* @return currentStep.
*/
int getStateOfRequest(String eventId, String workflowId);

/**
*Update current step according to the eventId and workflowId.
*
* @param eventId the request ID that need to be checked.
* @param workflowId workflow Id.
*/
void updateStateOfRequest(String eventId, String workflowId);

/**
* Get related associations.
*
* @param workflowRequest request object.
* @return association list.
*/
List<WorkflowAssociation> getAssociations(WorkflowRequest workflowRequest);

/**
* Get relevant workflow id to request.
*
* @param request request object.
* @return workflow Id.
*/
String getWorkflowId(WorkflowRequest request);
}
Loading