Class MutatingCommand

    • Constructor Detail

      • MutatingCommand

        public MutatingCommand()
    • Method Detail

      • init

        protected abstract void init()
                              throws java.lang.Exception
        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 class ConfirmingCommand
        Throws:
        java.lang.Exception
      • execute

        protected java.lang.String execute()
                                    throws java.lang.Exception
        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 class ConfirmingCommand
        Throws:
        java.lang.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 entity
        newEntity - the new version of the entity to save, or null to delete the entity
      • stageEntityChange

        protected void stageEntityChange​(@Nullable
                                         ImmutableObject oldEntity,
                                         @Nullable
                                         ImmutableObject newEntity,
                                         VKey vkey)
        Stages an entity change which will be applied by execute(), with the support of Vkey override. It supports cases of SqlEntity instances that do not have primary keys before being persisted.
        Parameters:
        oldEntity - the existing version of the entity, or null to create a new entity
        newEntity - the new version of the entity to save, or null to delete the entity
        vkey - the key of 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

        protected java.lang.String prompt()
        Returns the changes that have been staged thus far.
        Overrides:
        prompt in class ConfirmingCommand
      • getChangedEntities

        protected com.google.common.collect.ImmutableList<ImmutableObject> getChangedEntities()
        Returns the collection of the new entity in the MutatingCommand.EntityChange.