From 3cb6805185c876194d00e607ec530eb74d3dd30f Mon Sep 17 00:00:00 2001
From: Zihlu Wang
+ * Categories, is used to specify categories or subtypes of the calendar component. The categories are useful in
+ * searching for a calendar component of a particular type and category.
+ * Referenced from RFC-5545 - 3.8.1.2. Categories
+ * Classification, An access classification is only one component of the general security system within a calendar
+ * application. It provides a method of capturing the scope of the access the calendar owner intends for information
+ * within an individual calendar entry.
+ * Referenced from RFC-5545 - 3.8.1.3. Classification
+ * Comment, is used to specify a comment to the calendar user.
+ * Referenced from RFC-5545 - 3.8.1.4. Comment
+ * Description is used in the {@link WebCalendarEvent} and to-do to capture lengthy extual descriptions associated with
+ * the activity.
+ *
+ * Description is used in the Journal calendar component to capture one or more textual journal entries.
+ *
+ * Description is used in the Alarm calendar component to capture the display text for a DISPLAY category of
+ * alarm, and to capture the body text for an EMAIL category of alarm.
+ * Referenced from RFC-5545 - 3.8.1.5. Description
+ * Location, Specific venues such as conference or meeting rooms may be explicitly specified using this property.
+ *
+ * Note Referenced from RFC-5545 - 3.8.1.7. Location
+ * Percent Complete, is a positive integer between 0 and 100. A value of "0" indicates the to-do has not yet been
+ * started. A value of "100" indicates that the to-do has been completed. Integer values in between indicate the
+ * percent partially complete.
+ * Referenced from RFC-5545 - 3.8.1.8. Percent Complete
+ * Priority, is specified as an integer in the range 0 to 9. A value of 0 specifies an undefined priority. A value
+ * of 1 is the highest priority. A value of 2 is the second-highest priority. Subsequent numbers specify a
+ * decreasing ordinal priority. A value of 9 is the lowest priority.
+ *
+ * Summary, is used to capture a short, one-line summary about the activity or journal entry.
+ *
+ // * Example:
+ // * CATEGORIES:APPOINTMENT,EDUCATION
+ * CATEGORIES:MEETING
+ *
+ * CLASS:protected
+ *
+ *
+ * COMMENT:The meeting really needs to include both ourselves
+ * and the customer. We can't hold this meeting without them.
+ * As a matter of fact\, the venue for the meeting ought to be at
+ * their site. - - John
+ *
+ *
+ *
+ * DESCRIPTION:Meeting to provide technical review for "Phoenix"
+ * design.\nHappy Face Conference Room. Phoenix design team
+ * MUST attend this meeting.\nRSVP to team leader.
+ *
+ *
+ *
+ * This location has not implement the URI of the location.
+ * LOCATION:Conference Room - F123\, Bldg. 002
+ * LOCATION;ALTREP="http://xyzcorp.com/conf-rooms/f123.vcf":
+ * Conference Room - F123\, Bldg. 002
+ *
+ * PERCENT-COMPLETE:39
+ *
+ *
+ *
+ */
+ protected Integer priority;
+
+
+
+ /**
+ * PRIORITY:1
+ * PRIORITY:2
+ * SUMMARY:Department Party
+ */
+ protected String summary;
+
+
+
+ // /**
+ // * Completed defines the date and time that a to-do was actually completed.
+ // *
+ // * COMPLETED:19960401T150000Z
+ // *
DTEND:19960401T150000Z+ *
DTEND;VALUE=DATE:19980704+ */ + protected LocalDateTime end; + + + + /** + * Start defines the start date and time for the event. + * + * Example: + *
DTSTART:19980118T073000Z+ *
DTSTART;VALUE=DATE:19980118+ */ + protected LocalDateTime start; + + + + /** + * Duration may be used to specify a duration of the event, instead of an explicit end DATE-TIME. + * + * Example: + *
DURATION:PT100000S+ */ + protected Duration duration; + + + + /** + * URL may be used in a calendar component to convey a location where a more dynamic rendition of the calendar + * information associated with the calendar component can be found. + * + * Example: + *
URL:http://example.com/pub/calendars/jsmith/mytime.ics+ */ + protected String url; + + protected String uid; + + protected String domainName; + + protected String timezone; + + + + // + // Constructors + // + protected WebCalendarNode() { + this.categories = new ArrayList<>(); + } + + public WebCalendarNode setDomainName(String domainName) { + this.domainName = domainName; + return this; + } + + // + // Protected methods + // + protected String resolveCategories() { + var builder = new StringBuilder(); + if (categories != null && !categories.isEmpty()) { + categories.forEach(item -> builder.append(item).append(",")); + return builder.substring(0, builder.length() - 1); + } + return builder.toString(); + } + + // + // Abstract methods + // + public abstract String resolve(); + +} + diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java new file mode 100644 index 0000000..94a5588 --- /dev/null +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 CodeCraftersCN. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.org.codecrafters.webcal.config; + +/** + * WebCalClassification + * + * @author Zihlu Wang + */ +public enum Classification { + + PUBLIC("PUBLIC"), + + PRIVATE("PRIVATE"), + + CONFIDENTIAL("CONFIDENTIAL"), + ; + + private final String classification; + + Classification(String classification) { + this.classification = classification; + } + + public String getClassification() { + return classification; + } +} diff --git a/webcal/src/test/java/cn/org/codecrafters/webcal/test/TestWebCalendar.java b/webcal/src/test/java/cn/org/codecrafters/webcal/test/TestWebCalendar.java new file mode 100644 index 0000000..c9224b6 --- /dev/null +++ b/webcal/src/test/java/cn/org/codecrafters/webcal/test/TestWebCalendar.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 CodeCraftersCN. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.org.codecrafters.webcal.test; + +import cn.org.codecrafters.webcal.WebCalendar; +import cn.org.codecrafters.webcal.WebCalendarEvent; +import cn.org.codecrafters.webcal.config.Classification; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; +import java.util.UUID; + +/** + * TestWebCalendar + * + * @author Zihlu Wang + */ +@Slf4j +public class TestWebCalendar { + + @Test + void testWebCalendar() { + var calendar = new WebCalendar(); + calendar.setCompanyName("Code Crafters") + .setDomainName("codecrafters.org.cn") + .setName("Code Crafters SPECIAL EVENT") + .setProductName("Code Crafters SPECIAL EVENT"); + + calendar.addEvent(new WebCalendarEvent() + .setClassification(Classification.PUBLIC) + .setStart(LocalDateTime.of(2023, 8, 6, 0, 0, 0)) + .setEnd(LocalDateTime.of(2023, 8, 6, 8, 0, 0)) + .setLocation("湖南省长沙市天心区碧云路60号") + .setUid(UUID.randomUUID().toString()) + .setTimezone("Asia/Hong_Kong")); + + System.out.println(calendar.resolve()); + } + +}