use of io.apicurio.datamodels.asyncapi.models.AaiMessage in project apicurio-data-models by Apicurio.
the class NewMessageDefinitionCommand method execute.
@Override
public void execute(Document document) {
LoggerCompat.info("[NewMessageDefinitionCommand] Executing.");
Aai20Document doc20 = (Aai20Document) document;
if (this.isNullOrUndefined(doc20.components)) {
doc20.components = doc20.createComponents();
this._nullComponents = true;
}
this._nullComponents = false;
Aai20Components components = (Aai20Components) doc20.components;
if (this.isNullOrUndefined(components.getMessageTraitDefinition(_newName))) {
Aai20NodeFactory factory = new Aai20NodeFactory();
AaiMessage msgDef = factory.createMessage(components, _newName);
if (!this.isNullOrUndefined(_newDescription != null)) {
msgDef.description = _newDescription;
}
components.addMessage(_newName, msgDef);
this._defExisted = false;
} else {
this._defExisted = true;
}
}
use of io.apicurio.datamodels.asyncapi.models.AaiMessage in project apicurio-data-models by Apicurio.
the class DeleteOneOfMessageCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
*/
@Override
public void execute(final Document document) {
LoggerCompat.info("[DeleteOneOfMessageCommand] Executing.");
final AaiMessage parent = (AaiMessage) this._parentPath.resolve(document);
final AaiMessage res = parent.deleteOneOfMessage(this._oneOfIdc);
boolean isOneOfMessage = res._isOneOfMessage;
if (!isOneOfMessage) {
return;
}
if (!this.isNullOrUndefined(res)) {
this._oldMessage = Library.writeNode(res);
}
}
use of io.apicurio.datamodels.asyncapi.models.AaiMessage in project apicurio-data-models by Apicurio.
the class ChangePayloadRefCommand_Aai20 method execute.
@Override
public void execute(Document document) {
LoggerCompat.info("[ChangePayloadRefCommand_Aai20] Executing.");
this._changed = false;
AaiMessage message;
// Legacy: lookup from operation path
if (!this.isNullOrUndefined(this._operationPath)) {
AaiOperation operation = (AaiOperation) this._operationPath.resolve(document);
if (this.isNullOrUndefined(operation) || this.isNullOrUndefined(operation.message)) {
return;
}
message = operation.message;
} else {
message = (AaiMessage) this._messagePath.resolve(document);
}
if (this.isNullOrUndefined(message)) {
return;
}
Object payload = message.payload;
if (payload == null) {
payload = JsonCompat.objectNode();
}
Object oldValue = JsonCompat.getProperty(payload, "$ref");
if (oldValue != null && JsonCompat.isString(oldValue)) {
this._oldPayloadRef = JsonCompat.toString(oldValue);
}
JsonCompat.setProperty(payload, "$ref", this._payloadRef);
this._changed = true;
}
use of io.apicurio.datamodels.asyncapi.models.AaiMessage in project apicurio-data-models by Apicurio.
the class ChangePayloadRefCommand_Aai20 method undo.
@Override
public void undo(Document document) {
LoggerCompat.info("[ChangePayloadRefCommand_Aai20] Reverting.");
if (!this._changed) {
return;
}
AaiMessage message;
if (!this.isNullOrUndefined(this._operationPath)) {
AaiOperation operation = (AaiOperation) this._operationPath.resolve(document);
if (this.isNullOrUndefined(operation)) {
return;
}
message = operation.message;
} else {
message = (AaiMessage) this._messagePath.resolve(document);
}
if (this.isNullOrUndefined(message)) {
return;
}
Object payload = message.payload;
if (this._oldPayloadRef != null) {
JsonCompat.setProperty(payload, "$ref", this._oldPayloadRef);
} else {
JsonCompat.consumeProperty(payload, "$ref");
}
}
use of io.apicurio.datamodels.asyncapi.models.AaiMessage in project apicurio-data-models by Apicurio.
the class AddOneOfInMessageCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[AddOneOfInMessageCommand] Reverting.");
if (this.isNullOrUndefined(this._oldMessage)) {
return;
}
final AaiMessage parentMessage = (AaiMessage) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parentMessage)) {
return;
}
NodeCompat.setProperty(parentMessage.parent(), "message", parentMessage);
parentMessage.oneOf = null;
Library.readNode(this._oldMessage, parentMessage);
}
Aggregations