From c4ea97b5ef779ef2baf83b2ea4a8b36374804f54 Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Sat, 11 Nov 2023 19:44:33 +1100 Subject: [PATCH] Added skeleton workflow templates --- .../ical4j/template/workflow/Approval.java | 23 ++++++++++ .../org/ical4j/template/workflow/Request.java | 29 ++++++++++++ .../org/ical4j/template/workflow/Roster.java | 20 +++++++++ .../ical4j/template/workflow/Workspace.java | 45 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 src/main/java/org/ical4j/template/workflow/Approval.java create mode 100644 src/main/java/org/ical4j/template/workflow/Request.java create mode 100644 src/main/java/org/ical4j/template/workflow/Roster.java create mode 100644 src/main/java/org/ical4j/template/workflow/Workspace.java diff --git a/src/main/java/org/ical4j/template/workflow/Approval.java b/src/main/java/org/ical4j/template/workflow/Approval.java new file mode 100644 index 0000000..2281a91 --- /dev/null +++ b/src/main/java/org/ical4j/template/workflow/Approval.java @@ -0,0 +1,23 @@ +package org.ical4j.template.workflow; + +import net.fortuna.ical4j.model.component.VToDo; +import org.ical4j.template.AbstractTemplate; + +/** + * Captures an approval step as part of a workflow. + */ +public class Approval extends AbstractTemplate { + + public Approval() { + super(VToDo.class); + } + + public Approval(Class typeClass) { + super(typeClass); + } + + @Override + public VToDo apply(VToDo vToDo) { + return vToDo; + } +} diff --git a/src/main/java/org/ical4j/template/workflow/Request.java b/src/main/java/org/ical4j/template/workflow/Request.java new file mode 100644 index 0000000..c559c09 --- /dev/null +++ b/src/main/java/org/ical4j/template/workflow/Request.java @@ -0,0 +1,29 @@ +package org.ical4j.template.workflow; + +import net.fortuna.ical4j.extensions.concept.RequestType; +import net.fortuna.ical4j.model.component.VToDo; +import org.ical4j.template.AbstractTemplate; + +public class Request extends AbstractTemplate { + + private RequestType requestType; + + public Request() { + super(VToDo.class); + } + + public Request(Class typeClass) { + super(typeClass); + } + + public Request type(String summary, RequestType requestType) { + this.requestType = requestType; + return this; + } + + @Override + public VToDo apply(VToDo vToDo) { + vToDo.replace(requestType); + return vToDo; + } +} diff --git a/src/main/java/org/ical4j/template/workflow/Roster.java b/src/main/java/org/ical4j/template/workflow/Roster.java new file mode 100644 index 0000000..738332f --- /dev/null +++ b/src/main/java/org/ical4j/template/workflow/Roster.java @@ -0,0 +1,20 @@ +package org.ical4j.template.workflow; + +import net.fortuna.ical4j.model.component.VAvailability; +import org.ical4j.template.AbstractTemplate; + +public class Roster extends AbstractTemplate { + + public Roster() { + super(VAvailability.class); + } + + public Roster(Class typeClass) { + super(typeClass); + } + + @Override + public VAvailability apply(VAvailability vAvailability) { + return vAvailability; + } +} diff --git a/src/main/java/org/ical4j/template/workflow/Workspace.java b/src/main/java/org/ical4j/template/workflow/Workspace.java new file mode 100644 index 0000000..3ec55e3 --- /dev/null +++ b/src/main/java/org/ical4j/template/workflow/Workspace.java @@ -0,0 +1,45 @@ +package org.ical4j.template.workflow; + +import net.fortuna.ical4j.vcard.VCard; +import net.fortuna.ical4j.vcard.property.Fn; +import net.fortuna.ical4j.vcard.property.Member; +import org.ical4j.template.AbstractTemplate; + +import java.util.ArrayList; +import java.util.List; + +/** + * A workspace represents a collaborative space for one or more members. A member can be an individual or + * a group. + */ +public class Workspace extends AbstractTemplate { + + private String title; + + private List members = new ArrayList<>(); + + public Workspace() { + super(VCard.class); + } + + public Workspace(Class typeClass) { + super(typeClass); + } + + public Workspace title(String title) { + this.title = title; + return this; + } + + public Workspace member(VCard member) { + members.add(member); + return this; + } + + @Override + public VCard apply(VCard vCard) { + vCard.replace(new Fn(title)); + members.forEach(m -> vCard.add(new Member(m))); + return vCard; + } +}