Skip to content

Commit

Permalink
Added skeleton workflow templates
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Nov 11, 2023
1 parent b49aee6 commit c4ea97b
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/org/ical4j/template/workflow/Approval.java
Original file line number Diff line number Diff line change
@@ -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<VToDo> {

public Approval() {
super(VToDo.class);
}

public Approval(Class<VToDo> typeClass) {
super(typeClass);
}

@Override
public VToDo apply(VToDo vToDo) {
return vToDo;
}
}
29 changes: 29 additions & 0 deletions src/main/java/org/ical4j/template/workflow/Request.java
Original file line number Diff line number Diff line change
@@ -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<VToDo> {

private RequestType requestType;

public Request() {
super(VToDo.class);
}

public Request(Class<VToDo> 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;
}
}
20 changes: 20 additions & 0 deletions src/main/java/org/ical4j/template/workflow/Roster.java
Original file line number Diff line number Diff line change
@@ -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<VAvailability> {

public Roster() {
super(VAvailability.class);
}

public Roster(Class<VAvailability> typeClass) {
super(typeClass);
}

@Override
public VAvailability apply(VAvailability vAvailability) {
return vAvailability;
}
}
45 changes: 45 additions & 0 deletions src/main/java/org/ical4j/template/workflow/Workspace.java
Original file line number Diff line number Diff line change
@@ -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<VCard> {

private String title;

private List<VCard> members = new ArrayList<>();

public Workspace() {
super(VCard.class);
}

public Workspace(Class<VCard> 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;
}
}

0 comments on commit c4ea97b

Please sign in to comment.