org.kuali.rice.krad.service.impl
Class BusinessObjectServiceImpl

java.lang.Object
  extended by org.kuali.rice.krad.service.impl.BusinessObjectServiceImpl
All Implemented Interfaces:
BusinessObjectService

public class BusinessObjectServiceImpl
extends Object
implements BusinessObjectService

This class is the service implementation for the BusinessObjectService structure. This is the default implementation, that is delivered with Kuali.


Constructor Summary
BusinessObjectServiceImpl()
           
 
Method Summary
 int countMatching(Class clazz, Map<String,?> fieldValues)
          This method retrieves a count of the business objects populated with data which match the criteria in the given Map.
 int countMatching(Class clazz, Map<String,?> positiveFieldValues, Map<String,?> negativeFieldValues)
          This method retrieves a count of the business objects populated with data which match both the positive criteria and the negative criteria in the given Map.
 void delete(List<? extends PersistableBusinessObject> boList)
          Deletes each business object in the given List.
 void delete(PersistableBusinessObject bo)
          Deletes a business object from the database.
 void deleteMatching(Class clazz, Map<String,?> fieldValues)
          Deletes the object(s) matching the given field values
<T extends BusinessObject>
Collection<T>
findAll(Class<T> clazz)
          Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
<T extends BusinessObject>
Collection<T>
findAllOrderBy(Class<T> clazz, String sortField, boolean sortAscending)
          Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
<T extends BusinessObject>
T
findByPrimaryKey(Class<T> clazz, Map<String,?> primaryKeys)
          Retrieves an object instance identified by its primary keys and values.
<T extends BusinessObject>
T
findBySinglePrimaryKey(Class<T> clazz, Object primaryKey)
          Retrieves an object instance identified by its primary key.
<T extends BusinessObject>
Collection<T>
findMatching(Class<T> clazz, Map<String,?> fieldValues)
          This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
<T extends BusinessObject>
Collection<T>
findMatchingOrderBy(Class<T> clazz, Map<String,?> fieldValues, String sortField, boolean sortAscending)
          This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
protected  BusinessObjectDao getBusinessObjectDao()
          Gets the businessObjectDao attribute.
protected  DataObjectMetaDataService getDataObjectMetaDataService()
           
protected  PersonService getPersonService()
           
 BusinessObject getReferenceIfExists(BusinessObject bo, String referenceName)
          This method attempts to retrieve the reference from a BO if it exists.
protected  boolean isBusinessObjectAllowedForSave(PersistableBusinessObject bo)
          Returns true if the BusinessObjectService should be permitted to save instances of the given PersistableBusinessObject.
 List<? extends PersistableBusinessObject> linkAndSave(List<? extends PersistableBusinessObject> businessObjects)
          Links up any contained objects, and Saves the businessObjects on the list via the persistence layer.
 PersistableBusinessObject linkAndSave(PersistableBusinessObject bo)
          Links up any contained objects, and then Saves the passed in object via the persistence layer.
 void linkUserFields(List<PersistableBusinessObject> bos)
          Updates all KualiUser or Person objects contained within this BO, based on the UserID as the authoritative key.
 void linkUserFields(PersistableBusinessObject bo)
          Updates all KualiUser or Person objects contained within this BO, based on the UserID as the authoritative key.
 PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo)
          Merges the given business object, but tells the ORM that the object is to be treated as Read Only, and even if it has changes, it will not be persisted to the database
 PersistableBusinessObject retrieve(PersistableBusinessObject object)
          Retrieves an object instance identified by the class of the given object and the object's primary key values.
 List<? extends PersistableBusinessObject> save(List<? extends PersistableBusinessObject> businessObjects)
          Saves the businessObjects on the list via the persistence layer.
<T extends PersistableBusinessObject>
T
save(T bo)
          Saves the passed in object via the persistence layer.
 void setBusinessObjectDao(BusinessObjectDao businessObjectDao)
          Sets the businessObjectDao attribute value.
 void setDataObjectMetaDataService(DataObjectMetaDataService dataObjectMetadataService)
           
 void setPersistenceService(PersistenceService persistenceService)
          Sets the persistenceService attribute value.
 void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
          Sets the persistenceStructureService attribute value.
 void setPersonService(PersonService personService)
          Sets the kualiUserService attribute value.
protected  void validateBusinessObjectForSave(List<? extends PersistableBusinessObject> businessObjects)
           
protected  void validateBusinessObjectForSave(PersistableBusinessObject bo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusinessObjectServiceImpl

public BusinessObjectServiceImpl()
Method Detail

save

@Transactional
public <T extends PersistableBusinessObject> T save(T bo)
Description copied from interface: BusinessObjectService
Saves the passed in object via the persistence layer. This will throw an IllegalArgumentException (runtime exception) if the object passed in is not a descendent of BusinessObject.

Specified by:
save in interface BusinessObjectService
Parameters:
bo - A BusinessObject instance or descendent that you wish to be stored.

save

@Transactional
public List<? extends PersistableBusinessObject> save(List<? extends PersistableBusinessObject> businessObjects)
Description copied from interface: BusinessObjectService
Saves the businessObjects on the list via the persistence layer. This will throw an IllegalArgumentException (runtime exception) if any of the objects passed in is not a descendent of BusinessObject.

Specified by:
save in interface BusinessObjectService
Parameters:
businessObjects - A List of objects to persist.

linkAndSave

@Transactional
public PersistableBusinessObject linkAndSave(PersistableBusinessObject bo)
Description copied from interface: BusinessObjectService
Links up any contained objects, and then Saves the passed in object via the persistence layer. This will throw an IllegalArgumentException (runtime exception) if the object passed in is not a descendent of BusinessObject.

Specified by:
linkAndSave in interface BusinessObjectService
Parameters:
bo - A BusinessObject instance or descendent that you wish to be stored.

linkAndSave

@Transactional
public List<? extends PersistableBusinessObject> linkAndSave(List<? extends PersistableBusinessObject> businessObjects)
Description copied from interface: BusinessObjectService
Links up any contained objects, and Saves the businessObjects on the list via the persistence layer. This will throw an IllegalArgumentException (runtime exception) if any of the objects passed in is not a descendent of BusinessObject.

Specified by:
linkAndSave in interface BusinessObjectService
Parameters:
businessObjects - A List of objects to persist.

validateBusinessObjectForSave

protected void validateBusinessObjectForSave(PersistableBusinessObject bo)

validateBusinessObjectForSave

protected void validateBusinessObjectForSave(List<? extends PersistableBusinessObject> businessObjects)

isBusinessObjectAllowedForSave

protected boolean isBusinessObjectAllowedForSave(PersistableBusinessObject bo)
Returns true if the BusinessObjectService should be permitted to save instances of the given PersistableBusinessObject. Implementation checks a configuration parameter for class names of PersistableBusinessObjects that shouldn't be allowed to be saved.


findBySinglePrimaryKey

public <T extends BusinessObject> T findBySinglePrimaryKey(Class<T> clazz,
                                                           Object primaryKey)
Description copied from interface: BusinessObjectService
Retrieves an object instance identified by its primary key. For composite keys, use BusinessObjectService.findByPrimaryKey(Class, Map)

Specified by:
findBySinglePrimaryKey in interface BusinessObjectService
Returns:

findByPrimaryKey

public <T extends BusinessObject> T findByPrimaryKey(Class<T> clazz,
                                                     Map<String,?> primaryKeys)
Description copied from interface: BusinessObjectService
Retrieves an object instance identified by its primary keys and values. This can be done by constructing a map where the key to the map entry is the primary key attribute and the value of the entry being the primary key value. For composite keys, pass in each primaryKey attribute and its value as a map entry.

Specified by:
findByPrimaryKey in interface BusinessObjectService
Returns:

retrieve

public PersistableBusinessObject retrieve(PersistableBusinessObject object)
Description copied from interface: BusinessObjectService
Retrieves an object instance identified by the class of the given object and the object's primary key values.

Specified by:
retrieve in interface BusinessObjectService
Returns:

findAll

public <T extends BusinessObject> Collection<T> findAll(Class<T> clazz)
Description copied from interface: BusinessObjectService
Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will only retrieve business objects by class type.

Specified by:
findAll in interface BusinessObjectService
Returns:

findAllOrderBy

public <T extends BusinessObject> Collection<T> findAllOrderBy(Class<T> clazz,
                                                               String sortField,
                                                               boolean sortAscending)
Description copied from interface: BusinessObjectService
Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will only retrieve business objects by class type.

Specified by:
findAllOrderBy in interface BusinessObjectService
Returns:

findMatching

public <T extends BusinessObject> Collection<T> findMatching(Class<T> clazz,
                                                             Map<String,?> fieldValues)
Description copied from interface: BusinessObjectService
This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs, specifically attribute name and its expected value.

Specified by:
findMatching in interface BusinessObjectService
Returns:

countMatching

public int countMatching(Class clazz,
                         Map<String,?> fieldValues)
Description copied from interface: BusinessObjectService
This method retrieves a count of the business objects populated with data which match the criteria in the given Map.

Specified by:
countMatching in interface BusinessObjectService
Returns:
number of businessObjects of the given class whose fields match the values in the given expected-value Map

countMatching

public int countMatching(Class clazz,
                         Map<String,?> positiveFieldValues,
                         Map<String,?> negativeFieldValues)
Description copied from interface: BusinessObjectService
This method retrieves a count of the business objects populated with data which match both the positive criteria and the negative criteria in the given Map.

Specified by:
countMatching in interface BusinessObjectService
Returns:
number of businessObjects of the given class whose fields match the values in the given expected-value Maps

findMatchingOrderBy

public <T extends BusinessObject> Collection<T> findMatchingOrderBy(Class<T> clazz,
                                                                    Map<String,?> fieldValues,
                                                                    String sortField,
                                                                    boolean sortAscending)
Description copied from interface: BusinessObjectService
This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs, specifically attribute name and its expected value. Performs an order by on sort field.

Specified by:
findMatchingOrderBy in interface BusinessObjectService
Returns:

delete

@Transactional
public void delete(PersistableBusinessObject bo)
Description copied from interface: BusinessObjectService
Deletes a business object from the database.

Specified by:
delete in interface BusinessObjectService

delete

@Transactional
public void delete(List<? extends PersistableBusinessObject> boList)
Description copied from interface: BusinessObjectService
Deletes each business object in the given List.

Specified by:
delete in interface BusinessObjectService

deleteMatching

@Transactional
public void deleteMatching(Class clazz,
                                         Map<String,?> fieldValues)
Description copied from interface: BusinessObjectService
Deletes the object(s) matching the given field values

Specified by:
deleteMatching in interface BusinessObjectService

getReferenceIfExists

public BusinessObject getReferenceIfExists(BusinessObject bo,
                                           String referenceName)
Description copied from interface: BusinessObjectService
This method attempts to retrieve the reference from a BO if it exists.

Specified by:
getReferenceIfExists in interface BusinessObjectService
Parameters:
bo - - populated BusinessObject instance that includes the referenceName property
referenceName - - name of the member/property to load
Returns:
A populated object from the DB, if it exists

linkUserFields

public void linkUserFields(PersistableBusinessObject bo)
Description copied from interface: BusinessObjectService
Updates all KualiUser or Person objects contained within this BO, based on the UserID as the authoritative key. The appropriate foreign-key field in the BO itself is also updated. This allows UserIDs to be entered on forms, and the back-end will link up correctly based on this non-key field.

Specified by:
linkUserFields in interface BusinessObjectService
Parameters:
bo - The populated BO (or descendent) instance to be linked & updated

linkUserFields

public void linkUserFields(List<PersistableBusinessObject> bos)
Description copied from interface: BusinessObjectService
Updates all KualiUser or Person objects contained within this BO, based on the UserID as the authoritative key. The appropriate foreign-key field in the BO itself is also updated. This allows UserIDs to be entered on forms, and the back-end will link up correctly based on this non-key field.

Specified by:
linkUserFields in interface BusinessObjectService
Parameters:
bos - A List of populated BusinessObject (or descendent) instances to be linked & updated.

manageReadOnly

public PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo)
Description copied from interface: BusinessObjectService
Merges the given business object, but tells the ORM that the object is to be treated as Read Only, and even if it has changes, it will not be persisted to the database

Specified by:
manageReadOnly in interface BusinessObjectService
Parameters:
bo - the business object to managed
Returns:
the managed copied of the business object

getBusinessObjectDao

protected BusinessObjectDao getBusinessObjectDao()
Gets the businessObjectDao attribute.

Returns:
Returns the businessObjectDao.

setBusinessObjectDao

public void setBusinessObjectDao(BusinessObjectDao businessObjectDao)
Sets the businessObjectDao attribute value.

Parameters:
businessObjectDao - The businessObjectDao to set.

setPersistenceStructureService

public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
Sets the persistenceStructureService attribute value.

Parameters:
persistenceStructureService - The persistenceStructureService to set.

setPersonService

public final void setPersonService(PersonService personService)
Sets the kualiUserService attribute value.


getPersonService

protected PersonService getPersonService()

setPersistenceService

public final void setPersistenceService(PersistenceService persistenceService)
Sets the persistenceService attribute value.

Parameters:
persistenceService - The persistenceService to set.

getDataObjectMetaDataService

protected DataObjectMetaDataService getDataObjectMetaDataService()

setDataObjectMetaDataService

public void setDataObjectMetaDataService(DataObjectMetaDataService dataObjectMetadataService)


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.