Added Event Property type

This commit is contained in:
Luca Frosini 2024-06-24 14:20:09 +02:00
parent 0cce2b156c
commit 2d9c91f226
2 changed files with 160 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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);
}