org.silverpeas.persistence.repository
Class OperationContext

java.lang.Object
  extended by org.silverpeas.persistence.repository.OperationContext

public class OperationContext
extends Object

This class permits to give details about operation actions (save action for now), especially the user who is the author of the operation. It is usually used from service method implementation. It is used by JPA Silverpeas API to set the technical entity informations on:

Author:
Yohann Chastagnier

Method Summary
 void applyToPersistOperation(Entity entity)
          Applying informations of the context to the given entity on a persist operation.
 void applyToUpdateOperation(Entity entity)
          Applying informations of the context to the given entity on a update opearation.
static OperationContext createInstance()
          Creates an empty instance.
static OperationContext fromUser(String userId)
          Creates an instance from the given identifier which aims a user.
static OperationContext fromUser(UserDetail user)
          Creates an instance from the given user.
static OperationContext getFromCache()
          Get the current instance of the transaction from a cache (thread cache (request cache exactly)).
 UserDetail getUser()
          Gets the user behind the operation.
 boolean isUpdatingInCaseOfCreation()
          Indicates if the date update is performed in a case of creation.
 void putIntoCache()
          Put the current instance into a cache (thread cache (request cache exactly)) to be retrieved from @PrePersist or @PreUpdate operations.
 OperationContext setUpdatingInCaseOfCreation()
          Calling this method to indicates that the current data update is performed in a case of a creation.
 OperationContext setUpdatingInCaseOfCreation(boolean updatingInCaseOfCreation)
          Calling this method to indicates that the current data update is performed in a case of a creation or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstance

public static OperationContext createInstance()
Creates an empty instance.

Returns:

fromUser

public static OperationContext fromUser(String userId)
Creates an instance from the given identifier which aims a user.

Parameters:
userId -
Returns:

fromUser

public static OperationContext fromUser(UserDetail user)
Creates an instance from the given user.

Parameters:
user -
Returns:

getFromCache

public static OperationContext getFromCache()
Get the current instance of the transaction from a cache (thread cache (request cache exactly)). The call of this method is automatically done by tachnical JPA tools.

Returns:

setUpdatingInCaseOfCreation

public OperationContext setUpdatingInCaseOfCreation()
Calling this method to indicates that the current data update is performed in a case of a creation. Indeed, in some cases, the creation of a resource into database is done by a chaining of inserts and updates.


setUpdatingInCaseOfCreation

public OperationContext setUpdatingInCaseOfCreation(boolean updatingInCaseOfCreation)
Calling this method to indicates that the current data update is performed in a case of a creation or not. Indeed, in some cases, the creation of a resource into database is done by a chaining of inserts and updates.

Parameters:
updatingInCaseOfCreation - true to specify that the update is performed in a case of data creation.

isUpdatingInCaseOfCreation

public boolean isUpdatingInCaseOfCreation()
Indicates if the date update is performed in a case of creation.

Returns:

getUser

public UserDetail getUser()
Gets the user behind the operation.

Returns:

putIntoCache

public void putIntoCache()
Put the current instance into a cache (thread cache (request cache exactly)) to be retrieved from @PrePersist or @PreUpdate operations. The call of this method is automatically done by technical JPA tools.


applyToPersistOperation

public void applyToPersistOperation(Entity entity)
Applying informations of the context to the given entity on a persist operation.

Parameters:
entity -

applyToUpdateOperation

public void applyToUpdateOperation(Entity entity)
Applying informations of the context to the given entity on a update opearation.

Parameters:
entity -


Copyright © 2016 Silverpeas. All Rights Reserved.