Skip to content

Commit

Permalink
Added strategy samples
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jan 7, 2025
1 parent 169e3ac commit 31eba31
Show file tree
Hide file tree
Showing 13 changed files with 442 additions and 5 deletions.
307 changes: 307 additions & 0 deletions .palantir/revapi.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module ical4j.extensions {
requires java.base;
requires ical4j.core;
requires ical4j.vcard;

Expand Down Expand Up @@ -30,4 +29,5 @@
exports net.fortuna.ical4j.extensions.strategy.observance;
exports net.fortuna.ical4j.extensions.strategy.issue;
exports net.fortuna.ical4j.extensions.strategy.request;
exports net.fortuna.ical4j.extensions.strategy.resource;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fortuna.ical4j.data.CalendarParser;
import net.fortuna.ical4j.data.ContentHandler;
import net.fortuna.ical4j.data.ParserException;

import java.io.*;

Expand All @@ -18,12 +17,12 @@ public CalendarCSVParser(String componentName) {
}

@Override
public void parse(InputStream inputStream, ContentHandler contentHandler) throws IOException, ParserException {
public void parse(InputStream inputStream, ContentHandler contentHandler) throws IOException {
parse(new InputStreamReader(inputStream), contentHandler);
}

@Override
public void parse(Reader reader, ContentHandler contentHandler) throws IOException, ParserException {
public void parse(Reader reader, ContentHandler contentHandler) throws IOException {
try (BufferedReader in = new BufferedReader(reader)) {
contentHandler.startCalendar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public class ReportType extends ImmutableConcept {
public enum Id {

Attendance("semcal:concept:report:attendance"),
Budget("semcal:concept:report:budget"),
Diagnostic("semcal:concept:report:diagnostic"),
Expense("semcal:concept:report:expense"),
Income("semcal:concept:report:income"),
Presence("semcal:concept:report:presence"),
Report("semcal:concept:report"),
Timesheet("semcal:concept:report:timesheet"),
Expand All @@ -36,6 +38,8 @@ public URI getUri() {

public static final ReportType ATTENDANCE = new ReportType(Id.Attendance);

public static final ReportType BUDGET = new ReportType(Id.Budget);

public static final ReportType TIME_TO_RESPOND = new ReportType(Id.TimeToRespond);

public static final ReportType TIME_TO_RESOLVE = new ReportType(Id.TimeToResolve);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class ResourceType extends ImmutableConcept {

public enum Id {

Application("semcal:concept:resource:application"),
Asset("semcal:concept:resource:asset"),
Book("semcal:concept:resource:book"),
Collection("semcal:concept:resource:collection"),
ConfigurationItem("semcal:concept:resource:configuration_item"),
Expand All @@ -28,6 +30,10 @@ public URI getUri() {
}
}

public static final ResourceType APPLICATION = new ResourceType(Id.Application);

public static final ResourceType ASSET = new ResourceType(Id.Asset);

public static final ResourceType COLLECTION = new ResourceType(Id.Collection);

public static final ResourceType CONFIGURATION_ITEM = new ResourceType(Id.ConfigurationItem);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.fortuna.ical4j.extensions.strategy.entity

import net.fortuna.ical4j.vcard.VCardBuilder
import spock.lang.Specification

class ApplicationTest extends Specification {

def 'test parsing equivalence'() {
expect: 'parsed model matches strategy'
def application = new Application().withPrototype(prototype).get()
application.propertyList <=> prototype.propertyList == 0

and: 'output is valid'
!application.validate().hasErrors()

where: 'prototype loaded from samples'
prototype << new File('src/test/resources/strategy/application').listFiles().collect {
return new VCardBuilder(new FileInputStream(it)).build().entities
}.flatten()
}
}
6 changes: 6 additions & 0 deletions src/test/resources/strategy/application/notion.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN:VCARD
VERSION:4.0
FN:Notion
KIND:APPLICATION
URL:https://www.notion.com/
END:VCARD
9 changes: 9 additions & 0 deletions src/test/resources/strategy/collection/productivity.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:resource:collection
SUMMARY:Productivity on the Web
DESCRIPTION:Links and resources for different productivity methodologies and strategies.
LINK;VALUE=URI;LINKREL=related;LABEL=Intro & Overview of Pillars, Pipelines & Vaults – Notion Life OS:
https://youtu.be/d93SGaf82OM?si=KgPq9Hj37sI6xY9j
END:VJOURNAL
END:VCALENDAR
10 changes: 10 additions & 0 deletions src/test/resources/strategy/collection/recipes.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:resource:collection
SUMMARY:Recipes on the Web
DESCRIPTION:Links to various recipes
LINK;VALUE=URI;LINKREL=related;LABEL=How to make scones:
https://www.womensweeklyfood.com.au/recipe/quick-and-easy/basic-scone-22571/
CATEGORIES:Lifestyle
END:VJOURNAL
END:VCALENDAR
10 changes: 10 additions & 0 deletions src/test/resources/strategy/collection/working_with_icalendar.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:resource:collection
SUMMARY:Working with iCalendar
DESCRIPTION:Articles on working with the iCalendar specification
LINK;VALUE=URI;LINKREL=related;LABEL=iCalendar, CalDAV & Elixir:
https://blog.swmansion.com/icalendar-caldav-elixir-13be601572eb
CATEGORIES:Education and Employment
END:VJOURNAL
END:VCALENDAR
35 changes: 35 additions & 0 deletions src/test/resources/strategy/report/budget_tracker.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report
SUMMARY:Monthly Budget Tracker
DTSTART;VALUE=DATE:20250101
RRULE:FREQ=MONTHLY;INTERVAL=1
RELATED-TO;VALUE=UID;RELTYPE=CHILD:2
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report:budget
SUMMARY:Budget - Groceries
DTSTART;VALUE=DATE:20250101
RRULE:FREQ=MONTHLY;INTERVAL=1
STRUCTURED-DATA;VALUE=TEXT;FMTTYPE=application/json:{
"total": 1000,
"remaining": 1000
}
UID:2
CATEGORIES:Household
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report:budget
SUMMARY:Groceries
DTSTART;VALUE=DATE:20250101
SEQUENCE:1
RECURRENCE-ID;VALUE=DATE:20250101
RRULE:FREQ=MONTHLY;INTERVAL=1
STRUCTURED-DATA;VALUE=TEXT;FMTTYPE=application/json:{
"total": 1000,
"remaining": 735
}
UID:2
CATEGORIES:Household
END:VJOURNAL
END:VCALENDAR
18 changes: 17 additions & 1 deletion src/test/resources/strategy/report/expense_tracker.ics
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report
SUMMARY:Expense Tracker
SUMMARY:Monthly Expense Tracker
RRULE:FREQ=MONTHLY;INTERVAL=1
RELATED-TO;VALUE=UID;RELTYPE=CHILD:2
RELATED-TO;VALUE=UID;RELTYPE=CHILD:3
RELATED-TO;VALUE=UID;RELTYPE=CHILD:4
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report:expense
SUMMARY:Groceries
UID:2
CATEGORIES:Household
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report:expense
SUMMARY:Utilities
UID:3
CATEGORIES:Household
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report:expense
SUMMARY:Rent/Mortgage
UID:4
CATEGORIES:Household
END:VJOURNAL
END:VCALENDAR
14 changes: 14 additions & 0 deletions src/test/resources/strategy/report/investment_portfolio.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BEGIN:VCALENDAR
BEGIN:VJOURNAL
CONCEPT:semcal:concept:report
SUMMARY:Investment Portfolio
RRULE:FREQ=WEEKLY;INTERVAL=1
RELATED-TO;VALUE=UID;RELTYPE=CHILD:2
END:VJOURNAL
BEGIN:VJOURNAL
CONCEPT:semcal:concept:resource:asset
SUMMARY:AAPL
UID:2
CATEGORIES:Finance,Investments
END:VJOURNAL
END:VCALENDAR

0 comments on commit 31eba31

Please sign in to comment.