Search in sources :

Example 1 with Aai20NodeFactory

use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.

the class DeleteSchemaDefinitionCommand_Aai20 method doRestoreSchemaDefinition.

/**
 * @see DeleteSchemaDefinitionCommand#doRestoreSchemaDefinition(Document, Object)
 */
@Override
protected void doRestoreSchemaDefinition(Document document, Object oldDefinition) {
    Aai20Document aai20Document = (Aai20Document) document;
    if (ModelUtils.isDefined(aai20Document.components)) {
        AaiSchema schemaDef = new Aai20NodeFactory().createSchemaDefinition(aai20Document.components, this._definitionName);
        Library.readNode(oldDefinition, schemaDef);
        aai20Document.components.addSchemaDefinition(this._definitionName, schemaDef);
    }
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) Aai20NodeFactory(io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory) AaiSchema(io.apicurio.datamodels.asyncapi.models.AaiSchema)

Example 2 with Aai20NodeFactory

use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory 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;
    }
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) Aai20NodeFactory(io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory) Aai20Components(io.apicurio.datamodels.asyncapi.v2.models.Aai20Components) AaiMessage(io.apicurio.datamodels.asyncapi.models.AaiMessage)

Example 3 with Aai20NodeFactory

use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.

the class NewOperationCommand_Aai20 method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[NewOperationCommand_Aai20] Executing.");
    AaiDocument adoc = (AaiDocument) document;
    this._created = false;
    if (this.isNullOrUndefined(adoc.channels)) {
        return;
    }
    AaiChannelItem channel = adoc.channels.get(this._channel);
    if (this.isNullOrUndefined(channel)) {
        return;
    }
    if (!"subscribe".equals(this._opType) && !"publish".equals(this._opType)) {
        return;
    }
    Aai20NodeFactory nodeFactory = new Aai20NodeFactory();
    AaiOperation operation = nodeFactory.createOperation(channel, this._opType);
    operation.message = nodeFactory.createMessage(operation, null);
    operation.message.payload = JsonCompat.objectNode();
    switch(this._opType) {
        case "subscribe":
            channel.subscribe = operation;
            break;
        case "publish":
            channel.publish = operation;
            break;
    }
    this._created = true;
}
Also used : AaiOperation(io.apicurio.datamodels.asyncapi.models.AaiOperation) AaiChannelItem(io.apicurio.datamodels.asyncapi.models.AaiChannelItem) Aai20NodeFactory(io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory) AaiDocument(io.apicurio.datamodels.asyncapi.models.AaiDocument)

Example 4 with Aai20NodeFactory

use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.

the class ChangeHeadersRefCommand_Aai20 method execute.

@Override
public void execute(Document document) {
    LoggerCompat.info("[ChangeHeadersRefCommand_Aai20] Executing.");
    AaiOperation operation = (AaiOperation) this._operationPath.resolve(document);
    this._changed = false;
    if (this.isNullOrUndefined(operation) || this.isNullOrUndefined(operation.message) || !isValidRef(this._headersRef)) {
        return;
    }
    AaiHeaderItem headerItem = operation.message.headers;
    if (headerItem == null) {
        Aai20NodeFactory nodeFactory = new Aai20NodeFactory();
        headerItem = nodeFactory.createHeaderItem(operation.message);
        operation.message.headers = headerItem;
    }
    if (headerItem.$ref != null) {
        this._oldHeadersRef = headerItem.$ref;
    }
    headerItem.$ref = this._headersRef;
    this._changed = true;
}
Also used : AaiOperation(io.apicurio.datamodels.asyncapi.models.AaiOperation) AaiHeaderItem(io.apicurio.datamodels.asyncapi.models.AaiHeaderItem) Aai20NodeFactory(io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory)

Example 5 with Aai20NodeFactory

use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.

the class NewSecuritySchemeCommand_Aai20 method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[NewSecuritySchemeCommand_Aai20] Executing.");
    Aai20Document aai20Document = (Aai20Document) document;
    this._nullComponents = false;
    if (this.isNullOrUndefined(aai20Document.components)) {
        aai20Document.components = aai20Document.createComponents();
        this._nullComponents = true;
    }
    if (this.isNullOrUndefined(aai20Document.components.getSecurityScheme(this._schemeName))) {
        AaiSecurityScheme scheme = new Aai20NodeFactory().createSecurityScheme(aai20Document.components, this._schemeName);
        Library.readNode(this._scheme, scheme);
        aai20Document.components.addSecurityScheme(this._schemeName, scheme);
        this._schemeExisted = false;
    } else {
        this._schemeExisted = true;
    }
}
Also used : AaiSecurityScheme(io.apicurio.datamodels.asyncapi.models.AaiSecurityScheme) Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) Aai20NodeFactory(io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory)

Aggregations

Aai20NodeFactory (io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory)15 Aai20Document (io.apicurio.datamodels.asyncapi.v2.models.Aai20Document)10 AaiChannelItem (io.apicurio.datamodels.asyncapi.models.AaiChannelItem)4 AaiOperation (io.apicurio.datamodels.asyncapi.models.AaiOperation)4 AaiSecurityScheme (io.apicurio.datamodels.asyncapi.models.AaiSecurityScheme)3 Aai20Components (io.apicurio.datamodels.asyncapi.v2.models.Aai20Components)3 AaiDocument (io.apicurio.datamodels.asyncapi.models.AaiDocument)2 AaiMessage (io.apicurio.datamodels.asyncapi.models.AaiMessage)2 AaiMessageTraitDefinition (io.apicurio.datamodels.asyncapi.models.AaiMessageTraitDefinition)2 AaiOperationTraitDefinition (io.apicurio.datamodels.asyncapi.models.AaiOperationTraitDefinition)2 AaiHeaderItem (io.apicurio.datamodels.asyncapi.models.AaiHeaderItem)1 AaiSchema (io.apicurio.datamodels.asyncapi.models.AaiSchema)1 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)1 Oas20SecurityScheme (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)1 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)1 Oas30SecurityScheme (io.apicurio.datamodels.openapi.v3.models.Oas30SecurityScheme)1