From 2d9c91f226313778182609ca5db8917a55e3b8eb Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 24 Jun 2024 14:20:09 +0200 Subject: [PATCH] Added Event Property type --- .../model/impl/properties/EventImpl.java | 93 +++++++++++++++++++ .../model/reference/properties/Event.java | 67 +++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 src/main/java/org/gcube/informationsystem/model/impl/properties/EventImpl.java create mode 100644 src/main/java/org/gcube/informationsystem/model/reference/properties/Event.java diff --git a/src/main/java/org/gcube/informationsystem/model/impl/properties/EventImpl.java b/src/main/java/org/gcube/informationsystem/model/impl/properties/EventImpl.java new file mode 100644 index 0000000..9ae5c09 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/model/impl/properties/EventImpl.java @@ -0,0 +1,93 @@ +/** + * + */ +package org.gcube.informationsystem.model.impl.properties; + +import java.util.Date; + +import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName; +import org.gcube.informationsystem.model.reference.properties.Event; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +@JsonTypeName(value=Event.NAME) +public final class EventImpl extends PropertyImpl implements Event { + + /** + * Generated Serial Version UID + */ + private static final long serialVersionUID = 5102553511155113169L; + + protected String what; + protected Date when; + protected String who; + protected String where; + protected String why; + protected String how; + + public EventImpl() { + super(); + } + + @Override + public String getWhat() { + return what; + } + + @Override + public void setWhat(String what) { + this.what = what; + } + + @Override + public Date getWhen() { + return when; + } + + @Override + public void setWhen(Date when) { + this.when = when; + } + + @Override + public String getWho() { + return who; + } + + @Override + public void setWho(String who) { + this.who = who; + } + + @Override + public String getWhere() { + return where; + } + + @Override + public void setWhere(String where) { + this.where = where; + } + + @Override + public String getWhy() { + return why; + } + + @Override + public void setWhy(String why) { + this.why = why; + } + + @Override + public String getHow() { + return how; + } + + @Override + public void setHow(String how) { + this.how = how; + } + +} diff --git a/src/main/java/org/gcube/informationsystem/model/reference/properties/Event.java b/src/main/java/org/gcube/informationsystem/model/reference/properties/Event.java new file mode 100644 index 0000000..0cb3bfd --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/model/reference/properties/Event.java @@ -0,0 +1,67 @@ +/** + * + */ +package org.gcube.informationsystem.model.reference.properties; + +import java.util.Date; + +import org.gcube.com.fasterxml.jackson.annotation.JsonFormat; +import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.gcube.informationsystem.base.reference.Element; +import org.gcube.informationsystem.model.impl.properties.EventImpl; +import org.gcube.informationsystem.types.annotations.Final; +import org.gcube.informationsystem.types.annotations.ISProperty; +import org.gcube.informationsystem.types.reference.Change; +import org.gcube.informationsystem.types.reference.TypeMetadata; +import org.gcube.informationsystem.utils.Version; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +@JsonDeserialize(as=EventImpl.class) +@TypeMetadata(name = Event.NAME, description = "This type provides information regarding an event using the Five Ws (checklist) https://en.wikipedia.org/wiki/Five_Ws", version = Version.MINIMAL_VERSION_STRING) +@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION) +@Final +public interface Event extends Property { + + public static final String NAME = "Event"; // Event.class.getSimpleName(); + + public static final String WHAT_PROPERTY = "what"; + public static final String WHEN_PROPERTY = "when"; + public static final String WHO_PROPERTY = "who"; + public static final String WHERE_PROPERTY = "where"; + public static final String WHY_PROPERTY = "why"; + public static final String HOW_PROPERTY = "how"; + + @ISProperty(name = WHAT_PROPERTY, description = "WHAT happened.", readonly = true, mandatory = true, nullable = false) + public String getWhat(); + + public void setWhat(String what); + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Element.DATETIME_PATTERN) + @ISProperty(name = WHEN_PROPERTY, description = "WHEN the event occured. It is represented in the format " + Element.DATETIME_PATTERN + ".", readonly = true, mandatory = true, nullable = false) + public Date getWhen(); + + public void setWhen(Date when); + + @ISProperty(name = WHO_PROPERTY, description = "WHO triggered the event.", readonly = true, mandatory = false, nullable = false) + public String getWho(); + + public void setWho(String who); + + @ISProperty(name = WHERE_PROPERTY, description = "The location (can be virtual) WHERE the event occurred.", readonly = true, mandatory = false, nullable = false) + public String getWhere(); + + public void setWhere(String where); + + @ISProperty(name = WHY_PROPERTY, description = "The reason WHY the event occurred.", readonly = true, mandatory = false, nullable = false) + public String getWhy(); + + public void setWhy(String why); + + @ISProperty(name = HOW_PROPERTY, description = "How the event occurred.", readonly = true, mandatory = false, nullable = false) + public String getHow(); + + public void setHow(String how); + +} \ No newline at end of file