Skip to content

Commit

Permalink
Brings mail capabilities with thymeleaf and code mirror.
Browse files Browse the repository at this point in the history
Store forms and mail templates as files to easily store in git.
  • Loading branch information
chDame committed Aug 1, 2022
1 parent d81a942 commit e138322
Show file tree
Hide file tree
Showing 35 changed files with 2,210 additions and 493 deletions.
Binary file modified h2/db.mv.db
Binary file not shown.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@
<artifactId>camunda-operate-client-java</artifactId>
<version>1.1.0</version>
</dependency>

<!-- gmail, drive, thymeleaf & feel -->
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-google-ws-java</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.7</version>
</dependency>

<!-- h2 runtime -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,86 @@
package org.example.camunda.process.solution;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonInclude(Include.NON_NULL)
public class ProcessVariables {

private String texte;
private Long number;
private String date;

public String getTexte() {
return texte;
}

public ProcessVariables setTexte(String texte) {
this.texte = texte;
return this;
}

public Long getNumber() {
return number;
}

public ProcessVariables setNumber(Long number) {
this.number = number;
return this;
}

public String getDate() {
return date;
}

public ProcessVariables setDate(String date) {
this.date = date;
return this;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(
this,
new MultilineRecursiveToStringStyle() {
public ToStringStyle withShortPrefixes() {
this.setUseShortClassName(true);
this.setUseIdentityHashCode(false);
return this;
}
private String intialMessage;
private String assignee1;
private String assignee2;
private List<Map<String, String>> comments;
private Map<String, Object> file;
private String date;

public String getIntialMessage() {
return intialMessage;
}

public void setIntialMessage(String intialMessage) {
this.intialMessage = intialMessage;
}

public String getAssignee1() {
return assignee1;
}

public ProcessVariables setAssignee1(String assignee1) {
this.assignee1 = assignee1;
return this;
}

public String getAssignee2() {
return assignee2;
}

public ProcessVariables setAssignee2(String assignee2) {
this.assignee2 = assignee2;
return this;
}

public List<Map<String, String>> getComments() {
return comments;
}

public ProcessVariables setComments(List<Map<String, String>> comments) {
this.comments = comments;
return this;
}

public Map<String, Object> getFile() {
return file;
}

public ProcessVariables setFile(Map<String, Object> file) {
this.file = file;
return this;
}

public String getDate() {
return date;
}

public ProcessVariables setDate(String date) {
this.date = date;
return this;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, new MultilineRecursiveToStringStyle() {
public ToStringStyle withShortPrefixes() {
this.setUseShortClassName(true);
this.setUseIdentityHashCode(false);
return this;
}
}.withShortPrefixes());
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.example.camunda.process.solution.facade;

import com.fasterxml.jackson.databind.JsonNode;
import io.camunda.tasklist.exception.TaskListException;
import io.camunda.tasklist.util.JsonUtils;
import java.io.IOException;
import org.example.camunda.process.solution.model.Form;

import org.example.camunda.process.solution.facade.dto.Form;
import org.example.camunda.process.solution.service.FormService;
import org.example.camunda.process.solution.service.TaskListService;
import org.slf4j.Logger;
Expand All @@ -17,6 +15,11 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.JsonNode;

import io.camunda.tasklist.exception.TaskListException;
import io.camunda.tasklist.util.JsonUtils;

@RestController
@RequestMapping("/forms")
@CrossOrigin(origins = "*")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package org.example.camunda.process.solution.facade;

import java.util.Collections;
import java.io.IOException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.example.camunda.process.solution.model.Form;

import org.example.camunda.process.solution.facade.dto.Form;
import org.example.camunda.process.solution.service.FormService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.camunda.tasklist.exception.TaskListException;

@RestController
@RequestMapping("/edition/forms")
@CrossOrigin(origins = "*")
Expand All @@ -29,34 +32,31 @@ public class FormsEditionController extends AbstractController {
@Autowired private FormService formService;

@PostMapping
public ResponseEntity<Form> save(@RequestBody Form form) {
if (form.getId() == null) {
form = formService.create(form);
} else {
form = formService.update(form);
}
public ResponseEntity<Form> save(@RequestBody Form form) throws IOException {
formService.saveForm(form);
return new ResponseEntity<>(form, HttpStatus.CREATED);
}

@GetMapping("/{formKey}")
@ResponseBody
public Form getForm(@PathVariable String formKey)
throws TaskListException, IOException {
return formService.findByName(formKey);
}

@DeleteMapping("/{formKey}")
public void deleteForm(@PathVariable String formKey)
throws TaskListException, IOException {
formService.deleteByName(formKey);
}


@GetMapping(value = "/names")
@ResponseBody
public List<String> formNames() {
return formService.findNames();
}

@GetMapping
@ResponseBody
public List<Form> list(@RequestParam(required = false) String name) {
if (StringUtils.isNotBlank(name)) {
Form form = formService.findByName(name);
if (form == null) {
return Collections.emptyList();
}
return Collections.singletonList(form);
}
return formService.findAll();
}

@Override
public Logger getLogger() {
return logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.example.camunda.process.solution.facade;

import java.io.IOException;
import java.util.List;

import org.example.camunda.process.solution.facade.dto.Form;
import org.example.camunda.process.solution.facade.dto.MailTemplate;
import org.example.camunda.process.solution.service.MailTemplateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.camunda.tasklist.exception.TaskListException;

@RestController
@RequestMapping("/edition/mails")
@CrossOrigin(origins = "*")
public class MailEditionController extends AbstractController {

private final Logger logger = LoggerFactory.getLogger(MailEditionController.class);

@Autowired private MailTemplateService mailTemplateService;

@PostMapping
public ResponseEntity<MailTemplate> save(@RequestBody MailTemplate mailTemplate) throws IOException {
mailTemplateService.saveMail(mailTemplate);
return new ResponseEntity<>(mailTemplate, HttpStatus.CREATED);
}

@GetMapping("/{templateName}")
@ResponseBody
public MailTemplate getMailTemplate(@PathVariable String templateName)
throws TaskListException, IOException {
return mailTemplateService.findByName(templateName);
}

@DeleteMapping("/{templateName}")
public void deleteForm(@PathVariable String templateName)
throws TaskListException, IOException {
mailTemplateService.deleteByName(templateName);
}


@GetMapping(value = "/names")
@ResponseBody
public List<String> formNames() {
return mailTemplateService.findNames();
}

@Override
public Logger getLogger() {
return logger;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
package org.example.camunda.process.solution.facade;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.example.camunda.process.solution.facade.dto.FormJsListValue;
import org.example.camunda.process.solution.model.User;
import org.example.camunda.process.solution.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.camunda.tasklist.exception.TaskListException;

@RestController
@RequestMapping("/simul")
@CrossOrigin(origins = "*")
public class SimulationController {

@GetMapping("/checklist")
public List<FormJsListValue> getChecklist() {
return List.of(new FormJsListValue("1", "choice 1"), new FormJsListValue("2", "choice 2"));
}
@Autowired
private UserService userService;

@GetMapping("/users")
public List<FormJsListValue> users() throws TaskListException, IOException {

List<User> users = userService.all();
List<FormJsListValue> result = new ArrayList<>();
for (User u : users) {
result.add(new FormJsListValue(u.getUsername(), u.getFirstname() + " " + u.getLastname()));
}
return result;
}

@GetMapping("/checklist")
public List<FormJsListValue> getChecklist() {
return List.of(new FormJsListValue("1", "choice 1"), new FormJsListValue("2", "choice 2"));
}
}
Loading

0 comments on commit e138322

Please sign in to comment.