Skip to content

Commit

Permalink
Merge pull request #201 from wkspower/feat/email-to-case-v2
Browse files Browse the repository at this point in the history
Feat/email to case v2
  • Loading branch information
francav authored Apr 11, 2024
2 parents 3c4a0d0 + 159b040 commit 06186d7
Show file tree
Hide file tree
Showing 151 changed files with 3,600 additions and 3,236 deletions.
10 changes: 10 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ OPA_URL=http://opa:8181/v1/data/wks/authz/allow
## CASE REST API
WKS_CASE_API_URL=http://case-engine-rest-api:8081

## C7 EXTERNAL TASKS
DISABLE_BACKOFF_STRATEGY=false

## MINIO
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD='#minio00#'

#Kafka
KAFKA_URL=kafka:9093
KAFKA_TOPIC_CASE_CREATE=case-create
KAFKA_TOPIC_CASE_EMAIL_OUTBOUND=case-email-outbound
KAFKA_TOPIC_CREATE_HUMAN_TASK=human-task-create

## Novu
Expand All @@ -44,6 +48,12 @@ WEBSOCKET_ENABLED=false
WEBSOCKET_URL=ws://localhost:8484
WEBSOCKET_LOG_LEVEL=info

## EMAIL-SENDER
EMAIL_SENDER_LOG_LEVEL=info
MAIL_TO_CASE_JWT_TOKEN_CLIENT_ID=wks-email-to-case
MAIL_TO_CASE_JWT_TOKEN_CLIENT_SECRET=replaceme
MAIL_TO_CASE_JWT_TOKEN_GRANT_TYPE=client_credentials

## Camunda 7
CAMUNDA_BASE_URL=http://camunda:8080/engine-rest
CAMUNDA_USERNAME=demo
Expand Down
19 changes: 1 addition & 18 deletions .github/workflows/delploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: yarn --cwd case-portal install

- name: Build for case-portal
run: REACT_APP_KEYCLOAK_URL=${{ env.KEYCLOAK_URL }} REACT_APP_API_URL=${{ env.WKS_API_URL }} REACT_APP_EMAIL_URL=${{ env.WKS_EMAIL_API_URL }} REACT_APP_STORAGE_URL=${{ env.WKS_STORAGE_API_URL }} yarn --cwd case-portal build
run: REACT_APP_KEYCLOAK_URL=${{ env.KEYCLOAK_URL }} REACT_APP_API_URL=${{ env.WKS_API_URL }} REACT_APP_STORAGE_URL=${{ env.WKS_STORAGE_API_URL }} yarn --cwd case-portal build

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -106,15 +106,6 @@ jobs:
push: true
tags: "${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/demo-data-loader:${{ env.BUILD_VERSION }}"

- name: Build and push Docker image email-to-case
uses: docker/build-push-action@v2
with:
context: ./email-to-case
platforms: linux/amd64,linux/arm64
file: email-to-case/Dockerfile
push: true
tags: "${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case:${{ env.BUILD_VERSION }}"

- name: Build and push Docker image for case-portal
uses: docker/build-push-action@v2
with:
Expand Down Expand Up @@ -171,10 +162,6 @@ jobs:
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/c7-external-tasks=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/c7-external-tasks:${{ env.BUILD_VERSION }}
cd ../../
cd email-to-case/local
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case:${{ env.BUILD_VERSION }}
cd ../../
cd case-portal-client/local
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/case-portal=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/case-portal:${{ env.BUILD_VERSION }}
cd ../../
Expand Down Expand Up @@ -203,10 +190,6 @@ jobs:
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/c7-external-tasks=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/c7-external-tasks:${{ env.BUILD_VERSION }}
cd ../../
cd email-to-case/staging
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case:${{ env.BUILD_VERSION }}
cd ../../
cd case-portal-client/staging
kustomize edit set image ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/case-portal=${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/case-portal:${{ env.BUILD_VERSION }}
cd ../../
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ env:
REPOSITORY_OWNER: wkspower
KEYCLOAK_URL: http://localhost:8082
WKS_API_URL: http://localhost:8081
WKS_EMAIL_API_URL: http://localhost:8083
WKS_STORAGE_API_URL: http://localhost:8085
WEBSOCKET_ENABLED: false
WEBSOCKET_URL: ws://localhost:8484
Expand Down Expand Up @@ -64,7 +63,6 @@ jobs:
run: |
export REACT_APP_KEYCLOAK_URL="${{ env.KEYCLOAK_URL }}"
export REACT_APP_API_URL="${{ env.WKS_API_URL }}"
export REACT_APP_EMAIL_URL="${{ env.WKS_EMAIL_API_URL }}"
export REACT_APP_STORAGE_URL="${{ env.WKS_STORAGE_API_URL }}"
export REACT_APP_WEBSOCKETS_ENABLED="${{ env.WEBSOCKET_ENABLED }}"
export REACT_APP_WEBSOCKETS_URL="${{ env.WEBSOCKET_URL }}"
Expand Down Expand Up @@ -125,15 +123,6 @@ jobs:
push: true
tags: "${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/demo-data-loader:${{ steps.extract_tag.outputs.tag }}"

- name: Build and push Docker image email-to-case
uses: docker/build-push-action@v2
with:
context: ./apps/java/services/email-to-case
platforms: linux/amd64,linux/arm64
file: apps/java/services/email-to-case/Dockerfile
push: true
tags: "${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/email-to-case:${{ steps.extract_tag.outputs.tag }}"

- name: Build and push Docker image for case-portal
uses: docker/build-push-action@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ ProcessInstance startProcess(final String processDefinitionKey, final Optional<S

ProcessVariable[] findVariables(String processInstanceId);

void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> variables);
void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> messageCorrelateKeys);

}
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public ProcessVariable[] findVariables(String processInstanceId) {
}

@Override
public void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> variables) {
getEngineClient().sendMessage(processMesage, variables, getBpmEngine());
public void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> correlateKeys) {
getEngineClient().sendMessage(processMesage, correlateKeys, getBpmEngine());
}

public class DefaultC7BpmEngine extends BpmEngine {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public ProcessVariable[] findVariables(String processInstanceId) {
}

@Override
public void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> variables) {
getEngineClient().sendMessage(processMesage, variables, getBpmEngine());
public void sendMessage(ProcessMessage processMesage, Optional<List<ProcessVariable>> correlateKeys) {
getEngineClient().sendMessage(processMesage, correlateKeys, getBpmEngine());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ActivityInstance[] findActivityInstances(final String processInstanceId, final B

ProcessVariable[] findVariables(final String processInstanceId, final BpmEngine bpmEngine);

void sendMessage(final ProcessMessage processMesage, final Optional<List<ProcessVariable>> variables,
void sendMessage(final ProcessMessage processMesage, final Optional<List<ProcessVariable>> correlateKeys,
final BpmEngine bpmEngine);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package com.wks.bpm.engine.model.spi;

import java.util.List;
import java.util.Optional;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -33,11 +34,7 @@
@ToString
public class ProcessMessage {

private String tenantId;

private String messageName;
private String businessKey;

private List<ProcessVariable> processVariables;
private String messageCode;
private Optional<List<ProcessVariable>> processVariables;

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class ProcessVariable {

private String name;
private String value;
private Object value;
private String type;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import java.util.UUID;

import org.camunda.community.rest.client.api.DeploymentApi;
import org.camunda.community.rest.client.api.MessageApi;
import org.camunda.community.rest.client.api.ProcessDefinitionApi;
import org.camunda.community.rest.client.api.ProcessInstanceApi;
import org.camunda.community.rest.client.api.TaskApi;
import org.camunda.community.rest.client.api.VariableInstanceApi;
import org.camunda.community.rest.client.dto.ActivityInstanceDto;
import org.camunda.community.rest.client.dto.CompleteTaskDto;
import org.camunda.community.rest.client.dto.CorrelationMessageDto;
import org.camunda.community.rest.client.dto.ProcessInstanceWithVariablesDto;
import org.camunda.community.rest.client.dto.StartProcessInstanceDto;
import org.camunda.community.rest.client.dto.TaskDto;
Expand Down Expand Up @@ -79,6 +81,9 @@ public class C7EngineClient implements BpmEngineClient {
@Autowired
private VariableInstanceApi variableInstanceApi;

@Autowired
private MessageApi messageApi;

@Autowired
private SecurityContextTenantHolder tenantHolder;

Expand Down Expand Up @@ -388,9 +393,24 @@ public ProcessVariable[] findVariables(final String processInstanceId, final Bpm
}

@Override
public void sendMessage(final ProcessMessage processMessage, final Optional<List<ProcessVariable>> variables,
public void sendMessage(final ProcessMessage processMessage, final Optional<List<ProcessVariable>> correlateKeys,
final BpmEngine bpmEngine) {
throw new UnsupportedOperationException();
try {
CorrelationMessageDto messageDto = new CorrelationMessageDto().messageName(processMessage.getMessageCode());

if (correlateKeys.isPresent()) {
messageDto.correlationKeys(c7VariablesMapper.toEngineFormat(correlateKeys.get()));
}
if (processMessage.getProcessVariables().isPresent()) {
messageDto
.processVariables(c7VariablesMapper.toEngineFormat(processMessage.getProcessVariables().get()));
}

messageApi.deliverMessage(messageDto);
} catch (ApiException e) {
log.error("Error sending message to camunda", e);
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Map<String, String> toEngineFormat(final List<ProcessVariable> caseAttrib
Map<String, String> processVariablesMap = new LinkedHashMap<>();

caseAttributes.forEach(caseAttribute -> {
processVariablesMap.put(caseAttribute.getName(), caseAttribute.getValue());
processVariablesMap.put(caseAttribute.getName(), String.valueOf(caseAttribute.getValue()));
});

return processVariablesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ public abstract class ApiGateway {

@Value("${wks-case-api.process-definition.url}")
protected String processDefinitionUrl;

@Value("${wks-case-api.case-email.url}")
protected String caseEmailUrl;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* WKS Platform - Open-Source Project
*
* This file is part of the WKS Platform, an open-source project developed by WKS Power.
*
* WKS Platform is licensed under the MIT License.
*
* © 2021 WKS Power. All rights reserved.
*
* For licensing information, see the LICENSE file in the root directory of the project.
*/
package com.wks.api.client.gateway.impl;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import com.wks.api.client.gateway.ApiGateway;
import com.wks.api.dto.CaseEmailDto;

/**
* @author victor.franca
*
*/
@Component
public class CaseEmailApiGateway extends ApiGateway {

public CaseEmailDto save(final String caseEmail) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

HttpEntity<String> entity = new HttpEntity<>(caseEmail, headers);
return restTemplate.postForEntity(baseUrl + caseEmailUrl + "/save", entity, CaseEmailDto.class).getBody();

}

public void mergePatch(final String caseEmailId, final String patch) {

HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/merge-patch+json");

HttpEntity<String> entity = new HttpEntity<>(patch, headers);

restTemplate.patchForObject(baseUrl + caseEmailUrl + "/" + caseEmailId, entity, String.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import com.wks.api.client.gateway.ApiGateway;
import com.wks.api.dto.CaseInstanceDto;

/**
* @author victor.franca
Expand All @@ -25,6 +27,24 @@
@Component
public class CaseInstanceApiGateway extends ApiGateway {

public CaseInstanceDto get(final String businessKey) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

HttpEntity<String> entity = new HttpEntity<>(headers);
return restTemplate
.exchange(baseUrl + caseInstanceUrl + "/" + businessKey, HttpMethod.GET, entity, CaseInstanceDto.class)
.getBody();
}

public CaseInstanceDto start(final CaseInstanceDto caseInstance) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

HttpEntity<CaseInstanceDto> entity = new HttpEntity<>(caseInstance, headers);
return restTemplate.postForEntity(baseUrl + caseInstanceUrl, entity, CaseInstanceDto.class).getBody();
}

public void save(final String caseInstance) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
Expand All @@ -22,6 +23,7 @@
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CaseAttributeDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
Expand All @@ -24,6 +25,7 @@
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CaseCommentDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
Expand All @@ -22,6 +23,7 @@
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CaseDocumentDto {
Expand Down
Loading

0 comments on commit 06186d7

Please sign in to comment.