atg.svc.repository.service
Class RepositoryService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.svc.repository.service.RepositoryService
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener

public class RepositoryService
extends atg.nucleus.GenericService

Provides convenience service for updating and saving new beans implementations for a single repository represented by the home provided in the configuration. The bean implementations are converted to repository implementations inside of a transaction so the business code doesn't have to worry about transaction support. Why is all this necessary? 1. There is no relationship in r2j generated code between the bean and repository implementations. In order to commit a bean to the repository you first have to turn the bean into a repository impl. r2j generates a copyTo() method to do this but it's not easy to do so in a generic way because the generated beans and repository impls do not share any interfaces, base classes, etc. The alternative to some base services is that every business method that does a create(), update() or delete() has to write these methods by hand. 2. We often want to group heterogenous bean type operations together in a single transaction. Again, since the generated code doesn't share any interfaces or base classes and we want to do this in a generic manner we have to write all the code to do so and it's complicated. Again, the alternative to some base services is that every business method that does a create(), update() or delete() has to write these methods by hand.


Nested Class Summary
protected  class RepositoryService.SaveCollectionRunner
          Save Runner that creates a collection of new repository objects from a collection of new beans.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String REMOVE_REFERENCES_ON_DELETE_ATTRIBUTE
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RepositoryService()
           
 
Method Summary
 void delete(java.lang.Object pRepositoryObject)
          Deletes a repository item represented by the given repository object.
 void deleteCollection(java.util.Collection pObjects)
          Deletes a collection of repository items represented by the given bean impls.
 atg.repository.tojava.runtime.RJBeanObject edit(java.lang.Object pRepositoryObject)
          Deprecated. Bean impl objects are not required to edit repository impl objects.
 java.util.List editCollection(java.util.Collection pCollection)
          Deprecated. Bean impl objects are not required to edit repository impl objects.
 atg.repository.tojava.runtime.RJBeanObject getBeanImpl(java.lang.Object pRepositoryObject)
          Gets a bean impl copy of a repository object by creating a bean of the same item-descriptor and then copying the properties and id into the newly created bean impl.
 java.util.List getBeanImplCollection(java.util.Collection pReposImplCollection)
          Gets a list with bean impl copies of the given collection of repository impl objects.
 java.lang.String[] getExcludedProperties()
          Gets the set of excluded properties that should not be copied in transformMembers().
 atg.repository.RepositoryItem getRepositoryItem(java.lang.Object pRepositoryObject)
          Gets a repository item from an r2j repository impl.
 TransactionService getTransactionService()
          Gets the transaction service used by this service.
 boolean isBean(java.lang.Object pBeanObject)
          Returns true if the given object is a bean impl vs.
 boolean isNew(java.lang.Object pBeanObject)
          Returns true if the bean is new.
 void removeRepositoryCollection(java.util.Collection pObjects)
          Removes a collection of repository items from the repository.
 void save(java.lang.Object pBeanObject)
          Saves the given bean object to the repository.
 void saveCollection(java.util.Collection pObjects)
          Saves a collection of bean objects to the repository.
 void setExcludedProperties(java.lang.String[] pExcludedProperties)
          Sets the set of excluded properties that should not be copied in transformMembers().
 void setTransactionService(TransactionService pTransactionService)
          Sets the transaction service used by this service.
 void writeRepositoryCollection(java.util.Collection pObjects)
          Writes a collection of repository items to the repository.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

REMOVE_REFERENCES_ON_DELETE_ATTRIBUTE

public static final java.lang.String REMOVE_REFERENCES_ON_DELETE_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

RepositoryService

public RepositoryService()
Method Detail

getTransactionService

public TransactionService getTransactionService()
Gets the transaction service used by this service. This is set through the component configuration layer.

Returns:

setTransactionService

public void setTransactionService(TransactionService pTransactionService)
Sets the transaction service used by this service. This is set through the component configuration layer.

Parameters:
pTransactionService -

getExcludedProperties

public java.lang.String[] getExcludedProperties()
Gets the set of excluded properties that should not be copied in transformMembers().

Returns:
The set of excluded properties that should not be copied in transformMembers().

setExcludedProperties

public void setExcludedProperties(java.lang.String[] pExcludedProperties)
Sets the set of excluded properties that should not be copied in transformMembers().

Parameters:
pExcludedProperties - The set of excluded properties that should not be copied in transformMembers().

getBeanImpl

public atg.repository.tojava.runtime.RJBeanObject getBeanImpl(java.lang.Object pRepositoryObject)
Gets a bean impl copy of a repository object by creating a bean of the same item-descriptor and then copying the properties and id into the newly created bean impl.

Parameters:
pRepositoryObject - The repository object to copy into a bean object.
Returns:
The bean impl with all of the repository impl fields copied.
Throws:
java.lang.IllegalArgumentException - If the impl underlying the input param doesn't implement RJRepositoryObject an IllegalArgumentException is thrown.

edit

public atg.repository.tojava.runtime.RJBeanObject edit(java.lang.Object pRepositoryObject)
Deprecated. Bean impl objects are not required to edit repository impl objects.

Gets am editable bean impl copy of a repository object.

Parameters:
pRepositoryObject - The repository object to create the editable bean from.

getBeanImplCollection

public java.util.List getBeanImplCollection(java.util.Collection pReposImplCollection)
Gets a list with bean impl copies of the given collection of repository impl objects. The copies are created by creating a bean impl of the same item-descriptor and then copying the properties and id of the repository impl into the bean impl.

Parameters:
pReposImplCollection - A collection of repository impl object to create bean copies from.
Returns:
The collection bean impl copies.

editCollection

public java.util.List editCollection(java.util.Collection pCollection)
Deprecated. Bean impl objects are not required to edit repository impl objects.

Gets a list of editable bean objects for the given collection of repository objects.

Parameters:
pCollection - The non-null collection of repository objects.
Returns:
A collection of BeanImpls or EMPTY_LIST if an empty collection is passed.

save

public void save(java.lang.Object pBeanObject)
          throws ObjectNotFoundException,
                 PersistenceException
Saves the given bean object to the repository.

Parameters:
pBeanObject - The bean to save. This is passed as an object because the objects used by r2j implement an interface specific to each object that is generated. It's the underlying implementation that we care about but we shouldn't force the caller to do the cast.
Throws:
ObjectNotFoundException - In the case of update, if the repository item represented by the bean is not found.
PersistenceException - If the save operation fails.
java.lang.IllegalArgumentException - If the impl underlying the input param doesn't implement RJBeanObject an IllegalArgumentException is thrown.

saveCollection

public void saveCollection(java.util.Collection pObjects)
                    throws ObjectNotFoundException,
                           PersistenceException
Saves a collection of bean objects to the repository.

Parameters:
pObjects - The collection of bean impls to save.
Throws:
PersistenceException - If the save fails.
ObjectNotFoundException

writeRepositoryCollection

public void writeRepositoryCollection(java.util.Collection pObjects)
                               throws PersistenceException
Writes a collection of repository items to the repository.

Parameters:
pObjects - A collection of RJRepositoryObjects.
Throws:
PersistenceException

delete

public void delete(java.lang.Object pRepositoryObject)
            throws ObjectNotFoundException,
                   PersistenceException
Deletes a repository item represented by the given repository object.

Parameters:
pRepositoryObject - The bean object to delete.
Throws:
ObjectNotFoundException - If the repository object is not found.
PersistenceException - If the repository object cannot be deleted.
java.lang.IllegalArgumentException - If the impl underlying the input param doesn't implement RJBeanObject an IllegalArgumentException is thrown.

deleteCollection

public void deleteCollection(java.util.Collection pObjects)
                      throws ObjectNotFoundException,
                             PersistenceException
Deletes a collection of repository items represented by the given bean impls.

Parameters:
pObjects - The collection of bean impls.
Throws:
ObjectNotFoundException - If a repository item is not found (no longer used).
PersistenceException - If a repository item cannot be deleted.

removeRepositoryCollection

public void removeRepositoryCollection(java.util.Collection pObjects)
                                throws PersistenceException
Removes a collection of repository items from the repository.

Parameters:
pObjects - A collection of RJRepositoryObjects.
Throws:
PersistenceException - If the remove operation fails.

getRepositoryItem

public atg.repository.RepositoryItem getRepositoryItem(java.lang.Object pRepositoryObject)
Gets a repository item from an r2j repository impl.

Parameters:
pRepositoryObject - The repository object impl.
Returns:
The repository item.
Throws:
java.lang.IllegalArgumentException - If the impl underlying the input param doesn't implement RepositoryItemWrapper an IllegalArgumentException is thrown.

isNew

public boolean isNew(java.lang.Object pBeanObject)
Returns true if the bean is new. It is new if it doesn't have an id.

Parameters:
pBeanObject - The bean to check.
Returns:
True if the bean is new.

isBean

public boolean isBean(java.lang.Object pBeanObject)
Returns true if the given object is a bean impl vs. a repository impl.

Parameters:
pBeanObject - The object to test.
Returns:
True if the object is a bean impl.