-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b7fb2d
commit 6d40d0d
Showing
10 changed files
with
78 additions
and
98 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/AbstractSchemaInhCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/io/apicurio/datamodels/cmd/commands/ChangeContactCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
package io.apicurio.datamodels.cmd.commands; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/ChangeDescriptionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/ChangeVersionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/DeleteAllChildSchemasCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/DeleteAllExamplesCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/io/apicurio/datamodels/cmd/commands/DeleteAllExtensionsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package io.apicurio.datamodels.cmd.commands; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.apicurio.datamodels.Library; | ||
import io.apicurio.datamodels.cmd.AbstractCommand; | ||
import io.apicurio.datamodels.models.Document; | ||
import io.apicurio.datamodels.models.Extensible; | ||
import io.apicurio.datamodels.models.Node; | ||
import io.apicurio.datamodels.paths.NodePath; | ||
import io.apicurio.datamodels.paths.NodePathUtil; | ||
import io.apicurio.datamodels.util.LoggerUtil; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* A command used to delete all extensions from a node. | ||
* @author [email protected] | ||
*/ | ||
public class DeleteAllExtensionsCommand extends AbstractCommand { | ||
|
||
public NodePath _parentPath; | ||
|
||
public Map<String, JsonNode> _oldExtensions; | ||
|
||
public DeleteAllExtensionsCommand() { | ||
} | ||
|
||
public DeleteAllExtensionsCommand(Extensible parent) { | ||
this._parentPath = Library.createNodePath((Node) parent); | ||
} | ||
|
||
/** | ||
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document) | ||
*/ | ||
@Override | ||
public void execute(Document document) { | ||
LoggerUtil.info("[DeleteAllExtensionsCommand] Executing."); | ||
this._oldExtensions = new LinkedHashMap<>(); | ||
|
||
Extensible parent = (Extensible) NodePathUtil.resolveNodePath(this._parentPath, document); | ||
|
||
Map<String, JsonNode> extensions = parent.getExtensions(); | ||
|
||
// Save the old extensions (if any) | ||
if (!this.isNullOrUndefined(extensions)) { | ||
extensions.keySet().forEach(k -> { | ||
JsonNode value = extensions.get(k); | ||
this._oldExtensions.put(k, value); | ||
}); | ||
} | ||
|
||
// Remove all extensions | ||
parent.clearExtensions(); | ||
} | ||
|
||
/** | ||
* @see io.apicurio.datamodels.cmd.ICommand#undo(Document) | ||
*/ | ||
@Override | ||
public void undo(Document document) { | ||
LoggerUtil.info("[DeleteAllExtensionsCommand] Reverting."); | ||
if (this._oldExtensions.size() == 0) { | ||
return; | ||
} | ||
|
||
Extensible parent = (Extensible) NodePathUtil.resolveNodePath(this._parentPath, document); | ||
|
||
this._oldExtensions.keySet().forEach(k -> { | ||
JsonNode value = _oldExtensions.get(k); | ||
parent.addExtension(k, value); | ||
}); | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
src/main/java/io/apicurio/datamodels/cmd/commands/DeleteLicenseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters