added aggregateid attribute
This commit is contained in:
parent
0b8070e537
commit
d2e88d075c
20
examples/de/nclazz/registry/v0/events/ServiceEvent.java
Normal file
20
examples/de/nclazz/registry/v0/events/ServiceEvent.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Auto-generated from apibuilder.io service specification.
|
||||
* apidoc-version : 0.15.4
|
||||
* organisation : nclazz
|
||||
* service-version : 0.0.3-1-g6fccc33
|
||||
*
|
||||
* Documentation at:
|
||||
* <a href="https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33">https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33</a>
|
||||
*
|
||||
**/
|
||||
package de.nclazz.registry.v0.events;
|
||||
|
||||
/**
|
||||
*
|
||||
* See <a href="https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33#model-">https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33#model-</a>
|
||||
*
|
||||
**/
|
||||
public interface ServiceEvent {
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Auto-generated from apibuilder.io service specification.
|
||||
* apidoc-version : 0.15.4
|
||||
* organisation : nclazz
|
||||
* service-version : 0.0.3-1-g6fccc33
|
||||
*
|
||||
* Documentation at:
|
||||
* <a href="https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33">https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33</a>
|
||||
*
|
||||
**/
|
||||
package de.nclazz.registry.v0.events;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import de.nclazz.registry.v0.models.Service;
|
||||
|
||||
import org.axonframework.modelling.command.TargetAggregateIdentifier;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServiceHealthchanged implements ServiceEvent {
|
||||
|
||||
@TargetAggregateIdentifier
|
||||
private String serviceId;
|
||||
|
||||
@NonNull
|
||||
private String eventId;
|
||||
@NonNull
|
||||
private LocalDateTime timestamp;
|
||||
@NonNull
|
||||
private Service service;
|
||||
|
||||
}
|
34
examples/de/nclazz/registry/v0/events/ServiceRegistered.java
Normal file
34
examples/de/nclazz/registry/v0/events/ServiceRegistered.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Auto-generated from apibuilder.io service specification.
|
||||
* apidoc-version : 0.15.4
|
||||
* organisation : nclazz
|
||||
* service-version : 0.0.3-1-g6fccc33
|
||||
*
|
||||
* Documentation at:
|
||||
* <a href="https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33">https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33</a>
|
||||
*
|
||||
**/
|
||||
package de.nclazz.registry.v0.events;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import de.nclazz.registry.v0.models.Service;
|
||||
|
||||
import org.axonframework.modelling.command.TargetAggregateIdentifier;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServiceRegistered implements ServiceEvent {
|
||||
|
||||
@TargetAggregateIdentifier
|
||||
private String serviceId;
|
||||
|
||||
@NonNull
|
||||
private String eventId;
|
||||
@NonNull
|
||||
private LocalDateTime timestamp;
|
||||
@NonNull
|
||||
private Service service;
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Auto-generated from apibuilder.io service specification.
|
||||
* apidoc-version : 0.15.4
|
||||
* organisation : nclazz
|
||||
* service-version : 0.0.3-1-g6fccc33
|
||||
*
|
||||
* Documentation at:
|
||||
* <a href="https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33">https://app.apibuilder.io/nclazz/registry_events/0.0.3-1-g6fccc33</a>
|
||||
*
|
||||
**/
|
||||
package de.nclazz.registry.v0.events;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import de.nclazz.registry.v0.models.Service;
|
||||
|
||||
import org.axonframework.modelling.command.TargetAggregateIdentifier;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServiceUnregistered implements ServiceEvent {
|
||||
|
||||
@TargetAggregateIdentifier
|
||||
private String serviceId;
|
||||
|
||||
@NonNull
|
||||
private String eventId;
|
||||
@NonNull
|
||||
private LocalDateTime timestamp;
|
||||
@NonNull
|
||||
private Service service;
|
||||
|
||||
}
|
226
examples/example_events.json
Normal file
226
examples/example_events.json
Normal file
|
@ -0,0 +1,226 @@
|
|||
{
|
||||
"apidoc": {
|
||||
"version": "0.15.4"
|
||||
},
|
||||
"name": "registry_events",
|
||||
"organization": {
|
||||
"key": "nclazz"
|
||||
},
|
||||
"application": {
|
||||
"key": "registry_events"
|
||||
},
|
||||
"namespace": "de.nclazz.registry.v0",
|
||||
"version": "0.0.3-1-g6fccc33",
|
||||
"info": {
|
||||
"contact": {
|
||||
"name": "Niclas Thobaben",
|
||||
"url": "https://nclazz.de",
|
||||
"email": "info@nclazz.de"
|
||||
}
|
||||
},
|
||||
"headers": [],
|
||||
"imports": [
|
||||
{
|
||||
"uri": "https://app.apibuilder.io/nclazz/common/latest/service.json",
|
||||
"namespace": "de.nclazz.common.v0",
|
||||
"organization": {
|
||||
"key": "nclazz"
|
||||
},
|
||||
"application": {
|
||||
"key": "common"
|
||||
},
|
||||
"version": "0.0.3",
|
||||
"enums": [],
|
||||
"interfaces": [],
|
||||
"unions": [],
|
||||
"models": [
|
||||
"healthcheck"
|
||||
],
|
||||
"annotations": [
|
||||
{
|
||||
"name": "personal_data",
|
||||
"description": "Identifies a field that contains Personal Data, as defined by GDPR."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uri": "https://app.apibuilder.io/nclazz/registry/latest/service.json",
|
||||
"namespace": "de.nclazz.registry.v0",
|
||||
"organization": {
|
||||
"key": "nclazz"
|
||||
},
|
||||
"application": {
|
||||
"key": "registry"
|
||||
},
|
||||
"version": "0.0.2",
|
||||
"enums": [
|
||||
"serviceHealth"
|
||||
],
|
||||
"interfaces": [],
|
||||
"unions": [],
|
||||
"models": [
|
||||
"service",
|
||||
"service_form"
|
||||
],
|
||||
"annotations": [
|
||||
{
|
||||
"name": "personal_data",
|
||||
"description": "Identifies a field that contains Personal Data, as defined by GDPR."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
"interfaces": [],
|
||||
"unions": [
|
||||
{
|
||||
"name": "service_event",
|
||||
"plural": "service_events",
|
||||
"types": [
|
||||
{
|
||||
"type": "service_registered",
|
||||
"attributes": [],
|
||||
"discriminator_value": "service_registered"
|
||||
},
|
||||
{
|
||||
"type": "service_unregistered",
|
||||
"attributes": [],
|
||||
"discriminator_value": "service_unregistered"
|
||||
},
|
||||
{
|
||||
"type": "service_healthchanged",
|
||||
"attributes": [],
|
||||
"discriminator_value": "service_healthchanged"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"interfaces": [],
|
||||
"discriminator": "type"
|
||||
}
|
||||
],
|
||||
"models": [
|
||||
{
|
||||
"name": "service_healthchanged",
|
||||
"plural": "service_healthchangeds",
|
||||
"fields": [
|
||||
{
|
||||
"name": "event_id",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "timestamp",
|
||||
"type": "date-time-iso8601",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "service",
|
||||
"type": "de.nclazz.registry.v0.models.service",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
}
|
||||
],
|
||||
"attributes": [
|
||||
{
|
||||
"name": "aggregateId",
|
||||
"value": {
|
||||
"name": "serviceId",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"description": "A has changed its health status."
|
||||
},
|
||||
{
|
||||
"name": "service_registered",
|
||||
"plural": "service_registereds",
|
||||
"fields": [
|
||||
{
|
||||
"name": "event_id",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "timestamp",
|
||||
"type": "date-time-iso8601",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "service",
|
||||
"type": "de.nclazz.registry.v0.models.service",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
}
|
||||
],
|
||||
"attributes": [
|
||||
{
|
||||
"name": "aggregateId",
|
||||
"value": {
|
||||
"name": "serviceId",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"description": "A new service has been registered."
|
||||
},
|
||||
{
|
||||
"name": "service_unregistered",
|
||||
"plural": "service_unregistereds",
|
||||
"fields": [
|
||||
{
|
||||
"name": "event_id",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "timestamp",
|
||||
"type": "date-time-iso8601",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
},
|
||||
{
|
||||
"name": "service",
|
||||
"type": "de.nclazz.registry.v0.models.service",
|
||||
"required": true,
|
||||
"attributes": [],
|
||||
"annotations": []
|
||||
}
|
||||
],
|
||||
"attributes": [
|
||||
{
|
||||
"name": "aggregateId",
|
||||
"value": {
|
||||
"name": "serviceId",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"interfaces": [],
|
||||
"description": "A service has been unregistered."
|
||||
}
|
||||
],
|
||||
"resources": [],
|
||||
"attributes": [],
|
||||
"annotations": [
|
||||
{
|
||||
"name": "personal_data",
|
||||
"description": "Identifies a field that contains Personal Data, as defined by GDPR."
|
||||
}
|
||||
],
|
||||
"description": "Registry Event Schema for Kafka Streams."
|
||||
}
|
|
@ -10,7 +10,7 @@ const templateUnion = fs.readFileSync(path.resolve(path.join('templates', 'union
|
|||
|
||||
module.exports = (service) => {
|
||||
|
||||
const unions = javaUnions.mapUnions(service.unions, service.models, service.namespace)
|
||||
const unions = javaUnions.mapUnions(service.unions, service.models, service.namespace, 'events')
|
||||
let models = service.models.map(model => {
|
||||
let aggregateAttribute = (model.attributes.find(attr => attr.name === 'aggregateId') || { value: {} }).value
|
||||
let aggregateId = {}
|
||||
|
|
|
@ -19,7 +19,8 @@ module.exports = {
|
|||
imports = [ ...imports, ...field.type.imports ]
|
||||
}
|
||||
model.imports = [ ...new Set(imports) ]
|
||||
|
||||
model.implements = model.implements || []
|
||||
model['implements'][ model['implements'].length - 1 ].last = true;
|
||||
|
||||
|
||||
return model
|
||||
|
|
|
@ -12,9 +12,9 @@ module.exports = {
|
|||
|
||||
union.types.forEach(type => {
|
||||
models.forEach(model => {
|
||||
if(type.name === model.name) {
|
||||
if(type.type === model.name) {
|
||||
model.implements = model.implements || []
|
||||
model.implements.push(union.name)
|
||||
model.implements.push({ name: union.name })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ import lombok.*;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implements.length}} {
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}{{name}}{{^last}}, {{/last}}{{/implements}}{{/implements.length}} {
|
||||
|
||||
@TargetAggregateIdentifier
|
||||
private {{{aggregateId.type.name}}} {{aggregateId.name}};
|
||||
|
|
|
@ -27,7 +27,7 @@ import {{{.}}};
|
|||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implements.length}}{
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}{{name}}{{^last}}, {{/last}}{{/implements}}{{/implements.length}}{
|
||||
|
||||
{{#fields}}
|
||||
{{#description}}/** {{.}} **/{{/description}}
|
||||
|
|
Loading…
Reference in a new issue