ccc.domain
Class ActionEntity

java.lang.Object
  extended by ccc.domain.Entity
      extended by ccc.domain.ActionEntity
All Implemented Interfaces:
Jsonable, java.io.Serializable

public class ActionEntity
extends Entity

An action that will be performed for a resource.

Author:
Civic Computing Ltd.
See Also:
Serialized Form

Constructor Summary
protected ActionEntity()
          Constructor: for persistence only.
  ActionEntity(CommandType type, java.util.Date executeAfter, UserEntity actor, ResourceEntity subject, java.util.Map<java.lang.String,java.lang.String> parameters)
          Constructor.
 
Method Summary
 void cancel()
          Mark the action as cancelled.
 void complete()
          Mark the action as completed.
 void fail(Failure f)
          Mark the action as failed.
 UserEntity getActor()
          Accessor.
 FailureCode getCode()
          Accessor.
 java.util.Date getExecuteAfter()
          Accessor.
 java.lang.String getFailureId()
          Accessor.
 java.util.Map<java.lang.String,java.lang.String> getParameters()
          Accessor.
 java.util.Map<java.lang.String,java.lang.String> getParams()
          Accessor.
 ActionStatus getStatus()
          Accessor.
 ResourceEntity getSubject()
          Accessor.
 CommandType getType()
          Accessor.
 ActionSummary mapAction()
          Create a summary for an action.
static java.util.List<ActionSummary> mapActions(java.util.Collection<ActionEntity> actions)
          Create summaries for a list of actions.
 void toJson(Json json)
          Convert to JSON.
 
Methods inherited from class ccc.domain.Entity
equals, getId, getVersion, hashCode, setId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActionEntity

protected ActionEntity()
Constructor: for persistence only.


ActionEntity

public ActionEntity(CommandType type,
                    java.util.Date executeAfter,
                    UserEntity actor,
                    ResourceEntity subject,
                    java.util.Map<java.lang.String,java.lang.String> parameters)
Constructor.

Parameters:
type - The type of action that will be performed.
executeAfter - The earliest the action may be executed.
actor - The user that scheduled the action.
subject - The resource the action will operate on.
parameters - Additional parameters required by the action.
Method Detail

getType

public CommandType getType()
Accessor.

Returns:
The type of the action.

getParameters

public java.util.Map<java.lang.String,java.lang.String> getParameters()
Accessor.

Returns:
The parameters for this action.

getActor

public UserEntity getActor()
Accessor.

Returns:
The user that scheduled the action.

getExecuteAfter

public java.util.Date getExecuteAfter()
Accessor.

Returns:
The earliest the action may be executed.

complete

public void complete()
Mark the action as completed.


getStatus

public ActionStatus getStatus()
Accessor.

Returns:
The status of the action.

getCode

public FailureCode getCode()
Accessor.

Returns:
Returns the failure code.

getParams

public java.util.Map<java.lang.String,java.lang.String> getParams()
Accessor.

Returns:
Returns the failure param's.

getFailureId

public java.lang.String getFailureId()
Accessor.

Returns:
Returns the failure Id.

fail

public void fail(Failure f)
Mark the action as failed.

Parameters:
f - Details of the failure.

cancel

public void cancel()
Mark the action as cancelled.


getSubject

public ResourceEntity getSubject()
Accessor.

Returns:
The resource the action will operate on.

mapActions

public static java.util.List<ActionSummary> mapActions(java.util.Collection<ActionEntity> actions)
Create summaries for a list of actions.

Parameters:
actions - The actions.
Returns:
The corresponding summaries.

mapAction

public ActionSummary mapAction()
Create a summary for an action.

Returns:
The corresponding summary.

toJson

public void toJson(Json json)
Convert to JSON.

Specified by:
toJson in interface Jsonable
Overrides:
toJson in class Entity
Parameters:
json - The JSON object to write to.


Copyright © 2010. All Rights Reserved.