diff --git a/docs/CUSTOM_CDEVENTS.md b/docs/CUSTOM_CDEVENTS.md
new file mode 100644
index 0000000..e842a30
--- /dev/null
+++ b/docs/CUSTOM_CDEVENTS.md
@@ -0,0 +1,77 @@
+# Custom CDEvents
+If a tool wants to emit events that are not supported by the CDEvents specification,
+they can do so via [custom events](https://github.com/cdevents/spec/tree/main/custom).
+
+Custom events follow the CDEvents format and can be defined via the
+`CustomTypeEvent` class, available since v0.4.
+
+Let's consider the following scenario: a tool called "MyRegistry" has a concept of "Quota"
+which can be "exceeded" by users of the system. We want to use events to notify when that
+happens, but CDEvents does not define any quota related subject.
+
+## Steps involved to create a custom CDEvent
+
+### Add SDK dependency to your project
+
+```xml
+
+ dev.cdevents
+ cdevents-sdk-java
+ ${cdevents.version}
+
+```
+### Create a Custom CDEvent
+In this example, we will create a custom event for our tool utilizing the new `CustomTypeEvent`
+
+```java
+public class QuotaExceededCustomEvent {
+
+ public static void main(String[] args) {
+
+ CustomTypeEvent cdEvent = new CustomTypeEvent();
+ // Set the event type in the format dev.cdeventsx.-..
+ cdEvent.setType("dev.cdeventsx.myregistry-quota.exceeded.0.1.0");
+
+ // Set the required context fields
+ cdEvent.setSource(URI.create("http://myregistry/region/staging"));
+ cdEvent.setSubjectId("quotaRule123");
+
+ // Set the subject type in the format -
+ cdEvent.setSubjectType("myregistry-quota");
+
+ // Define a map with the content properties
+ Map contentQuota = new HashMap<>();
+ contentQuota.put("user", "heavy_user");
+ contentQuota.put("limit", "50Tb");
+ contentQuota.put("current", 90);
+ contentQuota.put("threshold", 85);
+ contentQuota.put("level", "WARNING");
+
+ // Set the required subject content
+ cdEvent.setSubjectContentProperty(contentQuota);
+
+ // If we host a schema for the overall custom CDEvent, we can add it
+ // to the event so that the receiver may validate custom fields like
+ // the event type and subject content
+ cdEvent.setContextSchemaUri(URI.create("https://myregistry.dev/schemas/cdevents/quota-exceeded/0_1_0"));
+
+ // Create event as JSON to print
+ String eventJson = CDEvents.cdEventAsJson(cdEvent);
+ System.out.println(eventJson);
+
+ // Create event as CloudEvent, this validates event against official spec/custom/schema.json
+ CloudEvent ceEvent = CDEvents.cdEventAsCloudEvent(cdEvent);
+ // This ceEvent can be sent using HTTP Protocol Binding
+ // Refer : https://cloudevents.github.io/sdk-java/http-basic.html
+ }
+}
+
+```
+The resulting CDEvents JSON will look like:
+
+````json
+{"context":{"version":"0.4.1","id":"587b646c-5dd5-4347-aa70-7a624a05120c","source":"http://myregistry/region/staging","type":"dev.cdeventsx.myregistry-quota.exceeded.0.1.0","timestamp":"2024-07-16T16:00:28Z","schemaUri":"https://myregistry.dev/schemas/cdevents/quota-exceeded/0_1_0","links":[]},"subject":{"id":"quotaRule123","type":"myregistry-quota","content":{"current":90,"level":"WARNING","limit":"50Tb","threshold":85,"user":"heavy_user"}},"customData":{},"customDataContentType":"application/json"}
+
+````
+
+The test code is available at [QuotaExceededCustomEvent.java](../sdk/src/test/java/dev/cdevents/QuotaExceededCustomEvent.java)
\ No newline at end of file
diff --git a/generator/pom.xml b/generator/pom.xml
index 151546c..d2794f5 100644
--- a/generator/pom.xml
+++ b/generator/pom.xml
@@ -109,6 +109,19 @@
dev.cdevents.models.links
+
+
+ generate-custom-event-from-schema
+ generate-sources
+
+ generate
+
+
+
+ ${parent.project.dir}/spec/custom/schema.json
+
+ dev.cdevents.models.custom
+
generate-artifact-deleted-from-schema
diff --git a/generator/src/main/java/dev/cdevents/generator/CDEventsGenerator.java b/generator/src/main/java/dev/cdevents/generator/CDEventsGenerator.java
index 3829ea9..c370fdd 100644
--- a/generator/src/main/java/dev/cdevents/generator/CDEventsGenerator.java
+++ b/generator/src/main/java/dev/cdevents/generator/CDEventsGenerator.java
@@ -13,6 +13,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -53,16 +54,16 @@ public static void main(String[] args) {
String sdkBaseDir = args[1];
String parentBaseDir = args[2];
String targetPackageDir = sdkBaseDir + File.separator + "src/main/java/dev/cdevents/events";
+
+ //Create Mustache factory and compile event-template.mustache template
+ MustacheFactory mf = new DefaultMustacheFactory();
+ Mustache mustache = mf.compile(generatorBaseDir + File.separator + EVENT_TEMPLATE_MUSTACHE);
+
File folder = new File(parentBaseDir + File.separator + "spec" + File.separator + "schemas");
if (folder.isDirectory()) {
File[] files = folder.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
if (files != null) {
- //Create Mustache factory and compile event-template.mustache template
- MustacheFactory mf = new DefaultMustacheFactory();
- Mustache mustache = mf.compile(generatorBaseDir + File.separator + EVENT_TEMPLATE_MUSTACHE);
-
//Generate a class file for each Json schema file using a mustache template
-
for (File file : files) {
SchemaData schemaData = buildCDEventDataFromJsonSchema(file);
generateClassFileFromSchemaData(mustache, schemaData, targetPackageDir);
@@ -73,10 +74,15 @@ public static void main(String[] args) {
} else {
log.error("No schema directory found in the specified directory {}", folder.getAbsolutePath());
}
+ // Generate a class file for CustomTypeEvent using a mustache template
+ File customSchema = new File(parentBaseDir + File.separator + "spec" + File.separator + "custom" + File.separator + "schema.json");
+ SchemaData schemaData = buildCDEventDataFromJsonSchema(customSchema);
+ generateClassFileFromSchemaData(mustache, schemaData, targetPackageDir);
}
private static void generateClassFileFromSchemaData(Mustache mustache, SchemaData schemaData, String targetPackageDir) {
- String classFileName = StringUtils.join(new String[]{schemaData.getCapitalizedSubject(), schemaData.getCapitalizedPredicate(), "CDEvent", ".java"});
+ String classFileName = schemaData.isCustomEvent() ? "CustomTypeEvent.java"
+ : StringUtils.join(schemaData.getCapitalizedSubject(), schemaData.getCapitalizedPredicate(), "CDEvent", ".java");
File classFile = new File(targetPackageDir, classFileName);
try {
FileWriter fileWriter = new FileWriter(classFile);
@@ -92,14 +98,21 @@ private static void generateClassFileFromSchemaData(Mustache mustache, SchemaDat
private static SchemaData buildCDEventDataFromJsonSchema(File file) {
SchemaData schemaData = new SchemaData();
-
log.info("Processing event JsonSchema file: {}", file.getAbsolutePath());
try {
JsonNode rootNode = objectMapper.readTree(file);
JsonNode contextNode = rootNode.get("properties").get("context").get("properties");
JsonNode subjectNode = rootNode.get("properties").get("subject").get("properties");
String schemaURL = rootNode.get("$id").asText();
+ boolean isCustomEvent = schemaURL.endsWith("schema/custom");
+ schemaData.setSchemaURL(schemaURL);
+ schemaData.setBaseURI(schemaURL.substring(0, schemaURL.lastIndexOf("/") + 1));
+ schemaData.setSchemaFileName(file.getName());
+ schemaData.setCustomEvent(isCustomEvent);
+ if (isCustomEvent) {
+ return schemaData;
+ }
String subjectType = subjectNode.get("type").get("enum").get(0).asText();
String eventType = contextNode.get("type").get("enum").get(0).asText();
log.info("eventType: {} subjectType: {}", eventType, subjectType);
@@ -109,16 +122,12 @@ private static SchemaData buildCDEventDataFromJsonSchema(File file) {
String capitalizedSubject = StringUtils.capitalize(subject);
String capitalizedPredicate = StringUtils.capitalize(predicate);
String version = type[VERSION_INDEX];
-
String upperCaseSubject = getUpperCaseSubjectType(subjectType);
- //set the Schema JsonNode required values to schemaData
- schemaData.setSchemaURL(schemaURL);
- schemaData.setBaseURI(schemaURL.substring(0, schemaURL.lastIndexOf("/") + 1));
+
schemaData.setSubject(subject);
schemaData.setPredicate(predicate);
schemaData.setCapitalizedSubject(capitalizedSubject);
schemaData.setCapitalizedPredicate(capitalizedPredicate);
- schemaData.setSchemaFileName(file.getName());
schemaData.setUpperCaseSubject(upperCaseSubject);
schemaData.setVersion(version);
diff --git a/generator/src/main/java/dev/cdevents/generator/SchemaData.java b/generator/src/main/java/dev/cdevents/generator/SchemaData.java
index bc3d877..4dbc77d 100644
--- a/generator/src/main/java/dev/cdevents/generator/SchemaData.java
+++ b/generator/src/main/java/dev/cdevents/generator/SchemaData.java
@@ -22,6 +22,8 @@ public class SchemaData {
private List contentObjectFields;
private List contentObjects;
+ private boolean isCustomEvent;
+
/**
* Default constructor.
*/
@@ -198,6 +200,22 @@ public void setContentObjects(List contentObjects) {
this.contentObjects = contentObjects;
}
+ /**
+ *
+ * @return true if Custom event
+ */
+ public boolean isCustomEvent() {
+ return isCustomEvent;
+ }
+
+ /**
+ *
+ * @param customEvent
+ */
+ public void setCustomEvent(boolean customEvent) {
+ isCustomEvent = customEvent;
+ }
+
public static class ContentField {
private String fieldName;
private String capitalizedFieldName;
diff --git a/generator/src/main/resources/template/event-template.mustache b/generator/src/main/resources/template/event-template.mustache
index 6e8c9b7..1ba09b1 100644
--- a/generator/src/main/resources/template/event-template.mustache
+++ b/generator/src/main/resources/template/event-template.mustache
@@ -23,22 +23,40 @@ package dev.cdevents.events;
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
+{{^isCustomEvent}}
import dev.cdevents.models.{{subject}}.{{predicate}}.*;
-
+{{/isCustomEvent}}
+{{#isCustomEvent}}
+import dev.cdevents.models.custom.*;
+import java.util.Map;
+{{/isCustomEvent}}
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
+{{^isCustomEvent}}
public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{capitalizedSubject}}{{predicate}} implements CDEvent {
+{{/isCustomEvent}}
+{{#isCustomEvent}}
+public class CustomTypeEvent extends Schema implements CDEvent {
+{{/isCustomEvent}}
+{{^isCustomEvent}}
/**
* Constructor to init CDEvent and set the Subject for {@link {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent}.
*/
public {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent() {
+{{/isCustomEvent}}
+{{#isCustomEvent}}
+ /**
+ * Constructor to init CustomTypeEvent.
+ */
+
+ public CustomTypeEvent() {
+{{/isCustomEvent}}
initCDEvent();
}
@@ -58,10 +76,12 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
context.setTimestamp(new Date());
context.setVersion(CDEventConstants.CDEVENTS_SPEC_VERSION);
getSubject().setContent(new Content());
- {{#getContentObjects}}
+{{^isCustomEvent}}
+ {{#getContentObjects}}
getSubject().getContent().set{{capitalizedObjectName}}(new {{capitalizedObjectName}}());
- {{/getContentObjects}}
+ {{/getContentObjects}}
getSubject().setType(Subject.Type.{{upperCaseSubject}});
+{{/isCustomEvent}}
}
/**
@@ -80,7 +100,12 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
@Override
public String currentCDEventType() {
+ {{^isCustomEvent}}
return getContext().getType().value();
+ {{/isCustomEvent}}
+ {{#isCustomEvent}}
+ return getContext().getType();
+ {{/isCustomEvent}}
}
@@ -112,6 +137,15 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
return "{{schemaFileName}}";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -127,8 +161,8 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -136,7 +170,7 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
@@ -159,6 +193,34 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
getSubject().setSource(subjectSource.toString());
}
+{{#isCustomEvent}}
+ /**
+ * @param type
+ * Sets the {@link Context} type value,
+ * must be in the format dev.cdeventsx.-..
+ */
+
+ public void setType(String type) {
+ getContext().setType(type);
+ }
+
+ /**
+ * @param subjectType
+ * sets the subject type, must be in the format -
+ */
+ public void setSubjectType(String subjectType) {
+ getSubject().setType(subjectType);
+ }
+
+ /**
+ * @param contentProperty
+ * sets the subject content custom properties
+ */
+ public void setSubjectContentProperty(Map contentProperty) {
+ contentProperty.forEach((key, value) -> getSubject().getContent().setAdditionalProperty(key, value));
+ }
+{{/isCustomEvent}}
+{{^isCustomEvent}}
//getContentFields starts
{{#getContentFields}}
@@ -181,5 +243,6 @@ public class {{capitalizedSubject}}{{capitalizedPredicate}}CDEvent extends {{cap
getSubject().getContent().get{{capitalizedObjectName}}().set{{capitalizedFieldName}}({{fieldName}});
}
{{/getContentObjectFields}}
+{{/isCustomEvent}}
}
diff --git a/preprocessor/src/main/java/dev/cdevents/PreprocessSchemas.java b/preprocessor/src/main/java/dev/cdevents/PreprocessSchemas.java
index d4e69a0..aaba8e0 100644
--- a/preprocessor/src/main/java/dev/cdevents/PreprocessSchemas.java
+++ b/preprocessor/src/main/java/dev/cdevents/PreprocessSchemas.java
@@ -2,12 +2,21 @@
import dev.cdevents.process.ProcessSchemas;
import dev.cdevents.process.ProcessSchemasImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
/**
* Adapts incoming schemas to a format that jsonschema2pojo.
*/
public final class PreprocessSchemas {
+ private static Logger log = LoggerFactory.getLogger(PreprocessSchemas.class);
private PreprocessSchemas() {
}
/**
@@ -16,11 +25,44 @@ private PreprocessSchemas() {
*/
public static void main(String[] args) {
if (args == null || args.length != 1) {
- System.err.println("Usage: PreprocessSchemas ");
+ log.error("Usage: PreprocessSchemas ");
throw new IllegalArgumentException("spec schemas directory path argument not passed to PreprocessSchemas");
}
String specSchemasDir = args[0];
ProcessSchemas processSchemas = new ProcessSchemasImpl();
processSchemas.updateSchemas(specSchemasDir);
+ processSchemas.updateSchemas(specSchemasDir + "/../custom/schema.json");
+
+ // copy links to the spec/custom folder for jsonschema2pojo to generate classes
+ String targetDir = specSchemasDir + "/../custom/links/";
+ createTargetDir(targetDir);
+ try {
+ Files.walk(Paths.get(specSchemasDir + "/links/"))
+ .filter(Files::isRegularFile)
+ .filter(path -> path.toString().endsWith(".json"))
+ .forEach(path -> {
+ try {
+ log.info("copying {} to targetDir {} ", path, targetDir);
+ Files.copy(path, Paths.get(targetDir + path.getFileName()), StandardCopyOption.REPLACE_EXISTING);
+ } catch (IOException e) {
+ log.error("Exception occurred while copying links to custom directory {}", e.getMessage());
+ throw new IllegalStateException("Exception occurred while copying links to custom directory", e);
+ }
+ });
+ } catch (IOException e) {
+ log.error("Exception occurred while processing links directory {}", e.getMessage());
+ throw new IllegalStateException("Exception occurred while processing links directory", e);
+ }
+ }
+
+ private static void createTargetDir(String targetDir) {
+ try {
+ Files.createDirectory(Paths.get(targetDir));
+ } catch (FileAlreadyExistsException e) {
+ log.info("Ignore if the targetDir {} is already created ", targetDir);
+ } catch (IOException e) {
+ log.error("Exception occurred while creating {} directory", targetDir);
+ throw new IllegalStateException("Exception occurred while processing links directory", e);
+ }
}
}
diff --git a/sdk/pom.xml b/sdk/pom.xml
index 11030bc..d8f93a7 100644
--- a/sdk/pom.xml
+++ b/sdk/pom.xml
@@ -121,6 +121,21 @@
+
+ copy-custom-resources
+ generate-resources
+
+ copy-resources
+
+
+ ${project.build.directory}/schemas/dev/cdevents/custom
+
+
+ ../spec/custom
+
+
+
+
diff --git a/sdk/src/main/java/dev/cdevents/CDEvents.java b/sdk/src/main/java/dev/cdevents/CDEvents.java
index d0acb10..87c929c 100644
--- a/sdk/src/main/java/dev/cdevents/CDEvents.java
+++ b/sdk/src/main/java/dev/cdevents/CDEvents.java
@@ -13,6 +13,10 @@
import com.networknt.schema.ValidationMessage;
import dev.cdevents.config.CustomObjectMapper;
import dev.cdevents.constants.CDEventConstants;
+import static dev.cdevents.constants.CDEventConstants.CUSTOM_EVENT_PREFIX;
+import static dev.cdevents.constants.CDEventConstants.CUSTOM_SCHEMA_CLASSPATH;
+import static dev.cdevents.constants.CDEventConstants.EVENT_PREFIX;
+import dev.cdevents.events.CustomTypeEvent;
import dev.cdevents.exception.CDEventsException;
import dev.cdevents.models.CDEvent;
import io.cloudevents.CloudEvent;
@@ -63,18 +67,8 @@ public static CloudEvent cdEventAsCloudEvent(CDEvent cdEvent) {
log.error("CDEvent validation failed against schema URL - {}", cdEvent.schemaURL());
throw new CDEventsException("CDEvent validation failed against schema URL - " + cdEvent.schemaURL());
}
- String cdEventJson = cdEventAsJson(cdEvent);
- log.info("CDEvent with type {} as json - {}", cdEvent.currentCDEventType(), cdEventJson);
try {
- CloudEvent ceToSend = new CloudEventBuilder()
- .withId(UUID.randomUUID().toString())
- .withSource(new URI(cdEvent.eventSource()))
- .withType(cdEvent.currentCDEventType())
- .withDataContentType("application/json")
- .withData(cdEventJson.getBytes(StandardCharsets.UTF_8))
- .withTime(OffsetDateTime.now())
- .build();
- return ceToSend;
+ return buildCloudEvent(cdEvent);
} catch (URISyntaxException e) {
throw new CDEventsException("Exception occurred while building CloudEvent from CDEvent ", e);
}
@@ -86,28 +80,26 @@ public static CloudEvent cdEventAsCloudEvent(CDEvent cdEvent) {
* @return valid cdEvent
*/
public static boolean validateCDEvent(CDEvent cdEvent) {
- Set errors = getJsonSchemaValidationMessages(cdEvent);
-
- if (!errors.isEmpty()) {
- log.error("CDEvent validation failed with errors {}", errors);
- return false;
+ if (cdEvent.currentCDEventType().startsWith(EVENT_PREFIX)) {
+ return validateWithOfficialSchema(cdEvent);
+ } else {
+ return validateWithOfficialCustomSchema(cdEvent);
}
- return true;
}
/**
* Creates cdEvent from cdEventJson string and validates against schema.
- * @param cdEventJson
- * @return CDEvent, needs type casting to specific CDEvent class
+ * @param cdEventJson json string of any CDEvent type
+ * @return CDEvent needs type casting to specific CDEvent class
*/
public static CDEvent cdEventFromJson(String cdEventJson) {
- if (!validateCDEventJson(cdEventJson)) {
- throw new CDEventsException("CDEvent Json validation failed against schema");
- }
String eventType = getUnVersionedEventTypeFromJson(cdEventJson);
CDEventConstants.CDEventTypes cdEventType = getCDEventTypeEnum(eventType);
try {
- CDEvent cdEvent = (CDEvent) new ObjectMapper().readValue(cdEventJson, cdEventType.getEventClass());
+ CDEvent cdEvent = new ObjectMapper().readValue(cdEventJson, cdEventType.getEventClass());
+ if (!validateCDEvent(cdEvent)) {
+ throw new CDEventsException("CDEvent Json validation failed against schema");
+ }
return cdEvent;
} catch (JsonProcessingException e) {
log.error("Exception occurred while creating CDEvent from json {}", cdEventJson);
@@ -116,35 +108,57 @@ public static CDEvent cdEventFromJson(String cdEventJson) {
}
/**
- * Validates the cdEventJson against the Schema URL.
- * @param cdEventJson
- * @return true, If cdEventJson is valid
+ * Validates the CDEvent against the official spec/schemas/.
+ * @param cdEvent
+ * @return true if valid cdEvent
*/
- public static boolean validateCDEventJson(String cdEventJson) {
- String eventType = getUnVersionedEventTypeFromJson(cdEventJson);
- CDEventConstants.CDEventTypes cdEventType = getCDEventTypeEnum(eventType);
- try {
- CDEvent cdEvent = (CDEvent) new ObjectMapper().readValue(cdEventJson, cdEventType.getEventClass());
- Set errors = getJsonSchemaValidationMessages(cdEvent);
-
- if (!errors.isEmpty()) {
- log.error("CDEvent Json validation failed against schema URL {}", cdEvent.schemaURL());
- log.error("CDEvent Json validation failed with errors {}", errors);
- return false;
- }
- } catch (JsonProcessingException e) {
- throw new CDEventsException("Exception occurred while validating CDEvent json with schema file ", e);
+ private static boolean validateWithOfficialSchema(CDEvent cdEvent) {
+ Map schemaMap = new HashMap<>();
+ schemaMap.put(cdEvent.schemaURL(), SCHEMA_CLASSPATH + cdEvent.schemaFileName());
+ schemaMap.put(cdEvent.baseURI() + "links/embeddedlinksarray", SCHEMA_CLASSPATH + "links/embeddedlinksarray.json");
+ Set errors = getJsonSchemaValidationMessages(cdEvent, schemaMap);
+ if (!errors.isEmpty()) {
+ log.error("CDEvent validation failed with errors {}", errors);
+ return false;
}
return true;
}
- private static Set getJsonSchemaValidationMessages(CDEvent cdEvent) {
+ /**
+ * Validates the custom CDEvent against the official spec/custom/schema.json.
+ * @param customCDEvent
+ * @return true if valid cdEvent
+ */
+ private static boolean validateWithOfficialCustomSchema(CDEvent customCDEvent) {
Map schemaMap = new HashMap<>();
- schemaMap.put(cdEvent.schemaURL(), SCHEMA_CLASSPATH + cdEvent.schemaFileName());
- schemaMap.put(cdEvent.baseURI() + "links/embeddedlinksarray", SCHEMA_CLASSPATH + "links/embeddedlinksarray.json");
+ schemaMap.put(customCDEvent.schemaURL(), CUSTOM_SCHEMA_CLASSPATH + "schema.json");
+ schemaMap.put(customCDEvent.baseURI() + "links/embeddedlinksarray", SCHEMA_CLASSPATH + "links/embeddedlinksarray.json");
+ log.info("Validate custom CDEvent against official spec/custom/schema.json");
+ Set errors = getJsonSchemaValidationMessages(customCDEvent, schemaMap);
+ if (!errors.isEmpty()) {
+ log.error("Custom CDEvent validation failed against official spec/custom/schema.json, with errors {}", errors);
+ return false;
+ }
+ return true;
+ }
+
+ private static CloudEvent buildCloudEvent(CDEvent cdEvent) throws URISyntaxException {
+ String cdEventJson = cdEventAsJson(cdEvent);
+ log.debug("CDEvent with type {} as json - {}", cdEvent.currentCDEventType(), cdEventJson);
+ return new CloudEventBuilder()
+ .withId(UUID.randomUUID().toString())
+ .withSource(new URI(cdEvent.eventSource()))
+ .withType(cdEvent.currentCDEventType())
+ .withDataContentType("application/json")
+ .withData(cdEventJson.getBytes(StandardCharsets.UTF_8))
+ .withTime(OffsetDateTime.now())
+ .build();
+ }
+
+ private static Set getJsonSchemaValidationMessages(CDEvent cdEvent, Map schemaMap) {
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012, builder ->
- // This creates a mapping from $id which starts with https://cdevents.dev/0.4.0/schema to the retrieval URI classpath:schema/
- builder.schemaMappers(schemaMappers -> schemaMappers.mappings(schemaMap))
+ // This creates a mapping from $id which starts with https://cdevents.dev/0.4.0/schema to the retrieval URI classpath:schema/
+ builder.schemaMappers(schemaMappers -> schemaMappers.mappings(schemaMap))
);
SchemaValidatorsConfig config = new SchemaValidatorsConfig();
config.setPathType(PathType.JSON_POINTER);
@@ -167,7 +181,6 @@ private static CDEventConstants.CDEventTypes getCDEventTypeEnum(String eventType
}
private static String getUnVersionedEventTypeFromJson(String cdEventJson) {
- String unVersionedEventType = "";
try {
JsonNode rootNode = objectMapper.readTree(cdEventJson);
if (rootNode.get("context") != null && rootNode.get("context").get("type") != null) {
@@ -176,17 +189,17 @@ private static String getUnVersionedEventTypeFromJson(String cdEventJson) {
String[] type = versionedEventType.split("\\.");
String subject = type[CDEventConstants.EVENT_SUBJECT_INDEX];
String predicate = type[CDEventConstants.EVENT_PREDICATE_INDEX];
- unVersionedEventType = CDEventConstants.EVENT_PREFIX + subject + "." + predicate + ".";
+ return CDEventConstants.EVENT_PREFIX + subject + "." + predicate + ".";
+ } else if (versionedEventType.startsWith(CUSTOM_EVENT_PREFIX)) {
+ return CUSTOM_EVENT_PREFIX;
} else {
throw new CDEventsException("Invalid CDEvent type found in CDEvent Json " + versionedEventType);
}
} else {
throw new CDEventsException("Unable to find context and type in CDEvent Json");
}
- return unVersionedEventType;
} catch (JsonProcessingException e) {
throw new CDEventsException("Exception occurred while reading CDEvent Json for eventType ", e);
}
-
}
}
diff --git a/sdk/src/main/java/dev/cdevents/constants/CDEventConstants.java b/sdk/src/main/java/dev/cdevents/constants/CDEventConstants.java
index 4a1ec6a..3936cf8 100644
--- a/sdk/src/main/java/dev/cdevents/constants/CDEventConstants.java
+++ b/sdk/src/main/java/dev/cdevents/constants/CDEventConstants.java
@@ -1,6 +1,7 @@
package dev.cdevents.constants;
import dev.cdevents.events.*;
+import dev.cdevents.models.CDEvent;
import java.io.File;
@@ -24,6 +25,11 @@ private CDEventConstants() {
*/
public static final String SCHEMA_CLASSPATH = "classpath:dev/cdevents/spec/schemas/";
+ /**
+ * Custom Schema classpath location.
+ */
+ public static final String CUSTOM_SCHEMA_CLASSPATH = "classpath:dev/cdevents/custom/";
+
/**
* Event link schemas location.
*/
@@ -38,6 +44,11 @@ private CDEventConstants() {
* CDEvent type prefix.
*/
public static final String EVENT_PREFIX = "dev.cdevents.";
+
+ /**
+ * Custom Event type prefix.
+ */
+ public static final String CUSTOM_EVENT_PREFIX = "dev.cdeventsx.";
/**
* CDEvent type subject index.
*/
@@ -293,16 +304,21 @@ public enum CDEventTypes {
/**
* Ticket updated event.
*/
- TicketUpdatedEvent("dev.cdevents.ticket.updated.", TicketUpdatedCDEvent.class);
+ TicketUpdatedEvent("dev.cdevents.ticket.updated.", TicketUpdatedCDEvent.class),
+
+ /**
+ * Custom event prefix.
+ */
+ CustomEvent(CUSTOM_EVENT_PREFIX, CustomTypeEvent.class);
/**
* Continuous delivery event type.
*/
private String eventType;
- private Class eventClass;
+ private Class extends CDEvent> eventClass;
- CDEventTypes(final String event, final Class eventClass) {
+ CDEventTypes(final String event, final Class extends CDEvent> eventClass) {
this.eventType = event;
this.eventClass = eventClass;
}
@@ -324,14 +340,14 @@ public void setEventType(final String event) {
/**
* @return class name of the event type
*/
- public Class getEventClass() {
- return eventClass;
+ public Class extends CDEvent> getEventClass() {
+ return this.eventClass;
}
/**
* @param eventClass class name to set
*/
- public void setEventClass(Class eventClass) {
+ public void setEventClass(Class extends CDEvent> eventClass) {
this.eventClass = eventClass;
}
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ArtifactDeletedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ArtifactDeletedCDEvent.java
index 32e6ce6..7ec24da 100644
--- a/sdk/src/main/java/dev/cdevents/events/ArtifactDeletedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ArtifactDeletedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.artifact.deleted.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ArtifactDeletedCDEvent extends Artifactdeleted implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "artifactdeleted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ArtifactDownloadedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ArtifactDownloadedCDEvent.java
index e3b3762..9e46c4b 100644
--- a/sdk/src/main/java/dev/cdevents/events/ArtifactDownloadedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ArtifactDownloadedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.artifact.downloaded.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ArtifactDownloadedCDEvent extends Artifactdownloaded implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "artifactdownloaded.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ArtifactPackagedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ArtifactPackagedCDEvent.java
index c80d552..72c0e51 100644
--- a/sdk/src/main/java/dev/cdevents/events/ArtifactPackagedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ArtifactPackagedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.artifact.packaged.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ArtifactPackagedCDEvent extends Artifactpackaged implements CDEvent {
@@ -111,6 +109,15 @@ public String schemaFileName() {
return "artifactpackaged.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -126,8 +133,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -135,7 +142,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ArtifactPublishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ArtifactPublishedCDEvent.java
index 617010b..3b3b9a4 100644
--- a/sdk/src/main/java/dev/cdevents/events/ArtifactPublishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ArtifactPublishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.artifact.published.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ArtifactPublishedCDEvent extends Artifactpublished implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "artifactpublished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ArtifactSignedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ArtifactSignedCDEvent.java
index 63ca9b4..0250282 100644
--- a/sdk/src/main/java/dev/cdevents/events/ArtifactSignedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ArtifactSignedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.artifact.signed.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ArtifactSignedCDEvent extends Artifactsigned implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "artifactsigned.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/BranchCreatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/BranchCreatedCDEvent.java
index ffdc0c1..9f9d1b8 100644
--- a/sdk/src/main/java/dev/cdevents/events/BranchCreatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/BranchCreatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.branch.created.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class BranchCreatedCDEvent extends Branchcreated implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "branchcreated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/BranchDeletedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/BranchDeletedCDEvent.java
index 1374e1e..7652ba5 100644
--- a/sdk/src/main/java/dev/cdevents/events/BranchDeletedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/BranchDeletedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.branch.deleted.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class BranchDeletedCDEvent extends Branchdeleted implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "branchdeleted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/BuildFinishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/BuildFinishedCDEvent.java
index cfab154..4f07610 100644
--- a/sdk/src/main/java/dev/cdevents/events/BuildFinishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/BuildFinishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.build.finished.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class BuildFinishedCDEvent extends Buildfinished implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "buildfinished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/BuildQueuedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/BuildQueuedCDEvent.java
index 3630127..2c5d0d0 100644
--- a/sdk/src/main/java/dev/cdevents/events/BuildQueuedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/BuildQueuedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.build.queued.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class BuildQueuedCDEvent extends Buildqueued implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "buildqueued.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/BuildStartedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/BuildStartedCDEvent.java
index d820b72..6dc16d6 100644
--- a/sdk/src/main/java/dev/cdevents/events/BuildStartedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/BuildStartedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.build.started.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class BuildStartedCDEvent extends Buildstarted implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "buildstarted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ChangeAbandonedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ChangeAbandonedCDEvent.java
index 34a75a0..687a1ae 100644
--- a/sdk/src/main/java/dev/cdevents/events/ChangeAbandonedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ChangeAbandonedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.change.abandoned.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ChangeAbandonedCDEvent extends Changeabandoned implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "changeabandoned.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ChangeCreatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ChangeCreatedCDEvent.java
index b4fa060..f10cdf1 100644
--- a/sdk/src/main/java/dev/cdevents/events/ChangeCreatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ChangeCreatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.change.created.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ChangeCreatedCDEvent extends Changecreated implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "changecreated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ChangeMergedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ChangeMergedCDEvent.java
index 497155b..a4ee586 100644
--- a/sdk/src/main/java/dev/cdevents/events/ChangeMergedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ChangeMergedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.change.merged.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ChangeMergedCDEvent extends Changemerged implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "changemerged.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ChangeReviewedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ChangeReviewedCDEvent.java
index b2a5020..4833946 100644
--- a/sdk/src/main/java/dev/cdevents/events/ChangeReviewedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ChangeReviewedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.change.reviewed.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ChangeReviewedCDEvent extends Changereviewed implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "changereviewed.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ChangeUpdatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ChangeUpdatedCDEvent.java
index f5be20d..453183e 100644
--- a/sdk/src/main/java/dev/cdevents/events/ChangeUpdatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ChangeUpdatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.change.updated.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ChangeUpdatedCDEvent extends Changeupdated implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "changeupdated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/CustomTypeEvent.java b/sdk/src/main/java/dev/cdevents/events/CustomTypeEvent.java
new file mode 100644
index 0000000..63d0820
--- /dev/null
+++ b/sdk/src/main/java/dev/cdevents/events/CustomTypeEvent.java
@@ -0,0 +1,192 @@
+// Code generated by dev.cdevents.generator.CDEventsGenerator. DO NOT EDIT.
+
+/*
+Copyright 2023 The CDEvents Authors
+
+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.
+
+SPDX-License-Identifier: Apache-2.0
+*/
+
+package dev.cdevents.events;
+
+
+import dev.cdevents.constants.CDEventConstants;
+import dev.cdevents.models.CDEvent;
+import dev.cdevents.models.custom.*;
+import java.util.Map;
+import java.net.URI;
+import java.util.Date;
+import java.util.UUID;
+import java.util.List;
+
+public class CustomTypeEvent extends Schema implements CDEvent {
+
+
+ /**
+ * Constructor to init CustomTypeEvent.
+ */
+
+ public CustomTypeEvent() {
+ initCDEvent();
+ }
+
+
+ /**
+ * Initialize the CDEvent with the context values.
+ */
+
+ @Override
+ public void initCDEvent() {
+ setContext(new Context());
+ setSubject(new Subject());
+ setCustomData(new Object());
+ setCustomDataContentType("application/json");
+ Context context = getContext();
+ context.setId(UUID.randomUUID().toString());
+ context.setTimestamp(new Date());
+ context.setVersion(CDEventConstants.CDEVENTS_SPEC_VERSION);
+ getSubject().setContent(new Content());
+ }
+
+ /**
+ * @return the event source
+ */
+
+ @Override
+ public String eventSource() {
+ return getContext().getSource();
+ }
+
+
+ /**
+ * @return the current CDEvent type
+ */
+
+ @Override
+ public String currentCDEventType() {
+ return getContext().getType();
+ }
+
+
+ /**
+ * @return the schema.json schema URL
+ */
+
+ @Override
+ public String schemaURL() {
+ return "https://cdevents.dev/0.4.1/schema/custom";
+ }
+
+ /**
+ * @return the base URI of the schema
+ */
+
+ @Override
+ public String baseURI() {
+ return "https://cdevents.dev/0.4.1/schema/";
+ }
+
+
+ /**
+ * @return the CDEvent's schema file name
+ */
+
+ @Override
+ public String schemaFileName() {
+ return "schema.json";
+ }
+
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
+
+ /**
+ * @param source
+ * Sets the {@link Context} source value
+ */
+
+ public void setSource(URI source) {
+ getContext().setSource(source.toString());
+ }
+
+ /**
+ * @param chainId
+ * Sets the {@link Context} chainId value
+ */
+
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
+ }
+
+ /**
+ * @param schemaUri
+ * Sets the {@link Context} custom schemaUri value
+ */
+
+ public void setContextSchemaUri(URI schemaUri) {
+ getContext().setSchemaUri(schemaUri);
+ }
+
+ /**
+ * @param subjectId
+ * sets the subject Id
+ */
+
+ public void setSubjectId(String subjectId) {
+ getSubject().setId(subjectId);
+ }
+
+
+ /**
+ * @param subjectSource
+ * sets the subject source
+ */
+
+ public void setSubjectSource(URI subjectSource) {
+ getSubject().setSource(subjectSource.toString());
+ }
+
+ /**
+ * @param type
+ * Sets the {@link Context} type value,
+ * must be in the format dev.cdeventsx.-..
+ */
+
+ public void setType(String type) {
+ getContext().setType(type);
+ }
+
+ /**
+ * @param subjectType
+ * sets the subject type, must be in the format -
+ */
+ public void setSubjectType(String subjectType) {
+ getSubject().setType(subjectType);
+ }
+
+ /**
+ * @param contentProperty
+ * sets the subject content custom properties
+ */
+ public void setSubjectContentProperty(Map contentProperty) {
+ contentProperty.forEach((key, value) -> getSubject().getContent().setAdditionalProperty(key, value));
+ }
+
+}
diff --git a/sdk/src/main/java/dev/cdevents/events/EnvironmentCreatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/EnvironmentCreatedCDEvent.java
index 4dcd27d..593df24 100644
--- a/sdk/src/main/java/dev/cdevents/events/EnvironmentCreatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/EnvironmentCreatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.environment.created.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class EnvironmentCreatedCDEvent extends Environmentcreated implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "environmentcreated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/EnvironmentDeletedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/EnvironmentDeletedCDEvent.java
index e9e7d7f..6c77f85 100644
--- a/sdk/src/main/java/dev/cdevents/events/EnvironmentDeletedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/EnvironmentDeletedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.environment.deleted.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class EnvironmentDeletedCDEvent extends Environmentdeleted implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "environmentdeleted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/EnvironmentModifiedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/EnvironmentModifiedCDEvent.java
index d986389..e3300e1 100644
--- a/sdk/src/main/java/dev/cdevents/events/EnvironmentModifiedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/EnvironmentModifiedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.environment.modified.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class EnvironmentModifiedCDEvent extends Environmentmodified implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "environmentmodified.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/IncidentDetectedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/IncidentDetectedCDEvent.java
index c2b91b4..359efcf 100644
--- a/sdk/src/main/java/dev/cdevents/events/IncidentDetectedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/IncidentDetectedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.incident.detected.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class IncidentDetectedCDEvent extends Incidentdetected implements CDEvent {
@@ -111,6 +109,15 @@ public String schemaFileName() {
return "incidentdetected.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -126,8 +133,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -135,7 +142,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/IncidentReportedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/IncidentReportedCDEvent.java
index 46cfa47..108d8e2 100644
--- a/sdk/src/main/java/dev/cdevents/events/IncidentReportedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/IncidentReportedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.incident.reported.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class IncidentReportedCDEvent extends Incidentreported implements CDEvent {
@@ -111,6 +109,15 @@ public String schemaFileName() {
return "incidentreported.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -126,8 +133,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -135,7 +142,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/IncidentResolvedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/IncidentResolvedCDEvent.java
index 6ae693e..8aeb2cb 100644
--- a/sdk/src/main/java/dev/cdevents/events/IncidentResolvedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/IncidentResolvedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.incident.resolved.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class IncidentResolvedCDEvent extends Incidentresolved implements CDEvent {
@@ -111,6 +109,15 @@ public String schemaFileName() {
return "incidentresolved.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -126,8 +133,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -135,7 +142,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/PipelinerunFinishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/PipelinerunFinishedCDEvent.java
index 3b18a82..a98684a 100644
--- a/sdk/src/main/java/dev/cdevents/events/PipelinerunFinishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/PipelinerunFinishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.pipelinerun.finished.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class PipelinerunFinishedCDEvent extends Pipelinerunfinished implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "pipelinerunfinished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/PipelinerunQueuedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/PipelinerunQueuedCDEvent.java
index 355bac5..376b08f 100644
--- a/sdk/src/main/java/dev/cdevents/events/PipelinerunQueuedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/PipelinerunQueuedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.pipelinerun.queued.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class PipelinerunQueuedCDEvent extends Pipelinerunqueued implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "pipelinerunqueued.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/PipelinerunStartedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/PipelinerunStartedCDEvent.java
index 64c39da..f1948b7 100644
--- a/sdk/src/main/java/dev/cdevents/events/PipelinerunStartedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/PipelinerunStartedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.pipelinerun.started.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class PipelinerunStartedCDEvent extends Pipelinerunstarted implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "pipelinerunstarted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/RepositoryCreatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/RepositoryCreatedCDEvent.java
index 97a9e5d..7190dd9 100644
--- a/sdk/src/main/java/dev/cdevents/events/RepositoryCreatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/RepositoryCreatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.repository.created.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class RepositoryCreatedCDEvent extends Repositorycreated implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "repositorycreated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/RepositoryDeletedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/RepositoryDeletedCDEvent.java
index ec9fd9f..3debdbe 100644
--- a/sdk/src/main/java/dev/cdevents/events/RepositoryDeletedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/RepositoryDeletedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.repository.deleted.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class RepositoryDeletedCDEvent extends Repositorydeleted implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "repositorydeleted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/RepositoryModifiedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/RepositoryModifiedCDEvent.java
index 431f972..8b71615 100644
--- a/sdk/src/main/java/dev/cdevents/events/RepositoryModifiedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/RepositoryModifiedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.repository.modified.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class RepositoryModifiedCDEvent extends Repositorymodified implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "repositorymodified.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ServiceDeployedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ServiceDeployedCDEvent.java
index 14a7e5d..58bd5f0 100644
--- a/sdk/src/main/java/dev/cdevents/events/ServiceDeployedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ServiceDeployedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.service.deployed.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ServiceDeployedCDEvent extends Servicedeployed implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "servicedeployed.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ServicePublishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ServicePublishedCDEvent.java
index 7a552b3..b9951d4 100644
--- a/sdk/src/main/java/dev/cdevents/events/ServicePublishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ServicePublishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.service.published.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ServicePublishedCDEvent extends Servicepublished implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "servicepublished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ServiceRemovedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ServiceRemovedCDEvent.java
index 35ccb71..3518195 100644
--- a/sdk/src/main/java/dev/cdevents/events/ServiceRemovedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ServiceRemovedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.service.removed.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ServiceRemovedCDEvent extends Serviceremoved implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "serviceremoved.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ServiceRolledbackCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ServiceRolledbackCDEvent.java
index d188698..1535314 100644
--- a/sdk/src/main/java/dev/cdevents/events/ServiceRolledbackCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ServiceRolledbackCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.service.rolledback.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ServiceRolledbackCDEvent extends Servicerolledback implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "servicerolledback.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/ServiceUpgradedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/ServiceUpgradedCDEvent.java
index 0bac592..a9c9061 100644
--- a/sdk/src/main/java/dev/cdevents/events/ServiceUpgradedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/ServiceUpgradedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.service.upgraded.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class ServiceUpgradedCDEvent extends Serviceupgraded implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "serviceupgraded.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TaskrunFinishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TaskrunFinishedCDEvent.java
index d815520..fe2fe99 100644
--- a/sdk/src/main/java/dev/cdevents/events/TaskrunFinishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TaskrunFinishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.taskrun.finished.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TaskrunFinishedCDEvent extends Taskrunfinished implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "taskrunfinished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TaskrunStartedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TaskrunStartedCDEvent.java
index 0d6e31d..298bca3 100644
--- a/sdk/src/main/java/dev/cdevents/events/TaskrunStartedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TaskrunStartedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.taskrun.started.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TaskrunStartedCDEvent extends Taskrunstarted implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "taskrunstarted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestcaserunFinishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestcaserunFinishedCDEvent.java
index 7016070..e447a58 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestcaserunFinishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestcaserunFinishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testcaserun.finished.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestcaserunFinishedCDEvent extends Testcaserunfinished implements CDEvent {
@@ -112,6 +110,15 @@ public String schemaFileName() {
return "testcaserunfinished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -127,8 +134,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -136,7 +143,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestcaserunQueuedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestcaserunQueuedCDEvent.java
index f1906db..4e22f91 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestcaserunQueuedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestcaserunQueuedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testcaserun.queued.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestcaserunQueuedCDEvent extends Testcaserunqueued implements CDEvent {
@@ -113,6 +111,15 @@ public String schemaFileName() {
return "testcaserunqueued.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -128,8 +135,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -137,7 +144,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestcaserunSkippedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestcaserunSkippedCDEvent.java
index 669f212..3a9731a 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestcaserunSkippedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestcaserunSkippedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testcaserun.skipped.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestcaserunSkippedCDEvent extends Testcaserunskipped implements CDEvent {
@@ -112,6 +110,15 @@ public String schemaFileName() {
return "testcaserunskipped.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -127,8 +134,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -136,7 +143,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestcaserunStartedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestcaserunStartedCDEvent.java
index f45603e..88f210e 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestcaserunStartedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestcaserunStartedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testcaserun.started.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestcaserunStartedCDEvent extends Testcaserunstarted implements CDEvent {
@@ -113,6 +111,15 @@ public String schemaFileName() {
return "testcaserunstarted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -128,8 +135,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -137,7 +144,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestoutputPublishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestoutputPublishedCDEvent.java
index 4ddea29..ab64aa6 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestoutputPublishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestoutputPublishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testoutput.published.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestoutputPublishedCDEvent extends Testoutputpublished implements CDEvent {
@@ -110,6 +108,15 @@ public String schemaFileName() {
return "testoutputpublished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -125,8 +132,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -134,7 +141,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestsuiterunFinishedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestsuiterunFinishedCDEvent.java
index 0a95033..d378c38 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestsuiterunFinishedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestsuiterunFinishedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testsuiterun.finished.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestsuiterunFinishedCDEvent extends Testsuiterunfinished implements CDEvent {
@@ -111,6 +109,15 @@ public String schemaFileName() {
return "testsuiterunfinished.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -126,8 +133,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -135,7 +142,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestsuiterunQueuedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestsuiterunQueuedCDEvent.java
index ae59a73..b2fc360 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestsuiterunQueuedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestsuiterunQueuedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testsuiterun.queued.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestsuiterunQueuedCDEvent extends Testsuiterunqueued implements CDEvent {
@@ -112,6 +110,15 @@ public String schemaFileName() {
return "testsuiterunqueued.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -127,8 +134,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -136,7 +143,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TestsuiterunStartedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TestsuiterunStartedCDEvent.java
index 3ccce8e..821d02c 100644
--- a/sdk/src/main/java/dev/cdevents/events/TestsuiterunStartedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TestsuiterunStartedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.testsuiterun.started.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TestsuiterunStartedCDEvent extends Testsuiterunstarted implements CDEvent {
@@ -112,6 +110,15 @@ public String schemaFileName() {
return "testsuiterunstarted.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -127,8 +134,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -136,7 +143,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TicketClosedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TicketClosedCDEvent.java
index 6b3c172..634ce6c 100644
--- a/sdk/src/main/java/dev/cdevents/events/TicketClosedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TicketClosedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.ticket.closed.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TicketClosedCDEvent extends Ticketclosed implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "ticketclosed.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TicketCreatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TicketCreatedCDEvent.java
index ef01d2e..2fe10f4 100644
--- a/sdk/src/main/java/dev/cdevents/events/TicketCreatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TicketCreatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.ticket.created.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TicketCreatedCDEvent extends Ticketcreated implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "ticketcreated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/events/TicketUpdatedCDEvent.java b/sdk/src/main/java/dev/cdevents/events/TicketUpdatedCDEvent.java
index ab779fb..b5627e3 100644
--- a/sdk/src/main/java/dev/cdevents/events/TicketUpdatedCDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/events/TicketUpdatedCDEvent.java
@@ -24,13 +24,11 @@
import dev.cdevents.constants.CDEventConstants;
import dev.cdevents.models.CDEvent;
import dev.cdevents.models.ticket.updated.*;
-
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import java.util.List;
-
public class TicketUpdatedCDEvent extends Ticketupdated implements CDEvent {
@@ -109,6 +107,15 @@ public String schemaFileName() {
return "ticketupdated.json";
}
+ /**
+ *
+ * @return context schema URI
+ */
+ @Override
+ public URI contextSchemaUri() {
+ return getContext().getSchemaUri();
+ }
+
/**
* @param source
@@ -124,8 +131,8 @@ public void setSource(URI source) {
* Sets the {@link Context} chainId value
*/
- public void setChainId(URI chainId) {
- getContext().setChainId(chainId.toString());
+ public void setChainId(String chainId) {
+ getContext().setChainId(chainId);
}
/**
@@ -133,7 +140,7 @@ public void setChainId(URI chainId) {
* Sets the {@link Context} custom schemaUri value
*/
- public void setCustomSchemaUri(URI schemaUri) {
+ public void setContextSchemaUri(URI schemaUri) {
getContext().setSchemaUri(schemaUri);
}
diff --git a/sdk/src/main/java/dev/cdevents/models/CDEvent.java b/sdk/src/main/java/dev/cdevents/models/CDEvent.java
index 740efba..ca5eb02 100644
--- a/sdk/src/main/java/dev/cdevents/models/CDEvent.java
+++ b/sdk/src/main/java/dev/cdevents/models/CDEvent.java
@@ -1,5 +1,7 @@
package dev.cdevents.models;
+import java.net.URI;
+
public interface CDEvent {
/**
@@ -32,4 +34,10 @@ public interface CDEvent {
*/
String eventSource();
+ /**
+ *
+ * @return custom schema URI
+ */
+ URI contextSchemaUri();
+
}
diff --git a/sdk/src/main/java/dev/cdevents/models/custom/Content.java b/sdk/src/main/java/dev/cdevents/models/custom/Content.java
new file mode 100644
index 0000000..25d8453
--- /dev/null
+++ b/sdk/src/main/java/dev/cdevents/models/custom/Content.java
@@ -0,0 +1,52 @@
+
+package dev.cdevents.models.custom;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+
+})
+@Generated("jsonschema2pojo")
+public class Content {
+
+ @JsonIgnore
+ private Map additionalProperties = new LinkedHashMap();
+
+ @JsonAnyGetter
+ public Map getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof Content) == false) {
+ return false;
+ }
+ Content rhs = ((Content) other);
+ return ((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties)));
+ }
+
+}
diff --git a/sdk/src/main/java/dev/cdevents/models/custom/Context.java b/sdk/src/main/java/dev/cdevents/models/custom/Context.java
new file mode 100644
index 0000000..c65d578
--- /dev/null
+++ b/sdk/src/main/java/dev/cdevents/models/custom/Context.java
@@ -0,0 +1,225 @@
+
+package dev.cdevents.models.custom;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "version",
+ "id",
+ "source",
+ "type",
+ "timestamp",
+ "schemaUri",
+ "chainId",
+ "links"
+})
+@Generated("jsonschema2pojo")
+public class Context {
+
+ /**
+ *
+ * (Required)
+ *
+ */
+ @JsonProperty("version")
+ private String version;
+ /**
+ *
+ * (Required)
+ *
+ */
+ @JsonProperty("id")
+ private String id;
+ /**
+ *
+ * (Required)
+ *
+ */
+ @JsonProperty("source")
+ private String source;
+ /**
+ *
+ * (Required)
+ *
+ */
+ @JsonProperty("type")
+ private String type;
+ /**
+ *
+ * (Required)
+ *
+ */
+ @JsonProperty("timestamp")
+ private Date timestamp;
+ @JsonProperty("schemaUri")
+ private URI schemaUri;
+ @JsonProperty("chainId")
+ private String chainId;
+ @JsonProperty("links")
+ private List