Package google.registry.tools
Class MutatingCommand
java.lang.Object
google.registry.tools.ConfirmingCommand
google.registry.tools.MutatingCommand
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
ConfigureFeatureFlagCommand
,ConfigureTldCommand
,CreateBulkPricingPackageCommand
,UpdateBulkPricingPackageCommand
A
ConfirmingCommand
that changes objects in the database.-
Field Summary
Fields inherited from class google.registry.tools.ConfirmingCommand
errorPrintStream, printStream
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
execute()
Performs the command and returns a result description.protected void
Subclasses can call this to write out all previously requested entity changes since the last transaction flush in a transaction.protected com.google.common.collect.ImmutableList
<ImmutableObject> Returns the collection of the new entity in theMutatingCommand.EntityChange
.protected abstract void
init()
Initializes the command.protected void
Performs any execution step after each batch.protected String
prompt()
Returns the changes that have been staged thus far.protected void
stageEntityChange
(ImmutableObject oldEntity, ImmutableObject newEntity) Stages an entity change that will be applied by execute().Methods inherited from class google.registry.tools.ConfirmingCommand
checkExecutionState, dontRunCommand, postExecute, run
-
Constructor Details
-
MutatingCommand
public MutatingCommand()
-
-
Method Details
-
init
Initializes the command.Subclasses override this method to populate
changedEntitiesMap
with updated entities. The old entity is the key and the new entity is the value; the key is null for newly created entities and the value is null for deleted entities.- Overrides:
init
in classConfirmingCommand
- Throws:
Exception
-
execute
Performs the command and returns a result description.Subclasses can override this method if the command does something besides update entities, such as running a full flow.
- Specified by:
execute
in classConfirmingCommand
- Throws:
Exception
-
postBatchExecute
protected void postBatchExecute()Performs any execution step after each batch. -
stageEntityChange
protected void stageEntityChange(@Nullable ImmutableObject oldEntity, @Nullable ImmutableObject newEntity) Stages an entity change that will be applied by execute(). Both ImmutableObject instances must be some version of the same entity with the same key.- Parameters:
oldEntity
- the existing version of the entity, or null to create a new entitynewEntity
- the new version of the entity to save, or null to delete the entity
-
flushTransaction
protected void flushTransaction()Subclasses can call this to write out all previously requested entity changes since the last transaction flush in a transaction. -
prompt
Returns the changes that have been staged thus far.- Overrides:
prompt
in classConfirmingCommand
-
getChangedEntities
Returns the collection of the new entity in theMutatingCommand.EntityChange
.
-