use of io.apicurio.datamodels.openapi.models.OasSchema in project apicurio-data-models by Apicurio.
the class DeleteAllChildSchemasCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteAllChildSchemasCommand] Reverting.");
if (this.isNullOrUndefined(this._oldSchemas) || this._oldSchemas.size() == 0) {
return;
}
OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
if (this.isNullOrUndefined(schema)) {
return;
}
this.copySchemaJsTo(_oldSchemas, schema, _childSchemaType);
}
use of io.apicurio.datamodels.openapi.models.OasSchema in project apicurio-data-models by Apicurio.
the class ChangeSchemaInheritanceCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[ChangeSchemaInheritanceCommand] Reverting: " + this._oldInheritanceType);
OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
if (this.isNullOrUndefined(schema)) {
return;
}
switchInheritance(schema, this._newInheritanceType, this._oldInheritanceType, true);
// model might have had are lost.
if (NodeCompat.equals(TYPE_NONE, this._newInheritanceType) && !this._oldSchemas.isEmpty()) {
copySchemaJsTo(this._oldSchemas, schema, this._oldInheritanceType);
}
}
use of io.apicurio.datamodels.openapi.models.OasSchema in project apicurio-data-models by Apicurio.
the class ChangeSchemaTypeCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[ChangeSchemaTypeCommand] Reverting.");
if (this._oldType == null) {
return;
}
OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
if (this.isNullOrUndefined(schema)) {
return;
}
SimplifiedTypeUtil.setSimplifiedType((OasSchema) schema, this._oldType);
}
use of io.apicurio.datamodels.openapi.models.OasSchema in project apicurio-data-models by Apicurio.
the class DeleteChildSchemaCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteChildSchemaCommand] Reverting.");
if (this.isNullOrUndefined(this._oldSchema)) {
return;
}
OasSchema parent = (OasSchema) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parent)) {
return;
}
// Create the schema and unmarshal it from the saved JSON data
OasSchema schema = this.createSchema(parent, this._oldSchemaType);
Library.readNode(this._oldSchema, schema);
// Add the schema back to the parent
SchemaAdderVisitor schemaAdder = new SchemaAdderVisitor();
Library.visitNode(schema, schemaAdder);
}
use of io.apicurio.datamodels.openapi.models.OasSchema in project apicurio-data-models by Apicurio.
the class DeleteChildSchemaCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[DeleteChildSchemaCommand] Executing.");
this._oldSchema = null;
OasSchema childSchema = (OasSchema) this._schemaPath.resolve(document);
if (this.isNullOrUndefined(childSchema)) {
return;
}
// Remove the schema from its parent
SchemaRemoverVisitor schemaRemover = new SchemaRemoverVisitor();
Library.visitNode(childSchema, schemaRemover);
this._oldSchema = Library.writeNode(childSchema);
this._oldSchemaType = schemaRemover.type;
}
Aggregations