org.bsf.smartValueObject.demo
Class DemoMediator

java.lang.Object
  |
  +--org.bsf.smartValueObject.demo.DemoMediator
All Implemented Interfaces:
Mediator, java.io.Serializable

public class DemoMediator
extends java.lang.Object
implements Mediator, java.io.Serializable

Mock Mediator for the Demo.

See Also:
Serialized Form

Nested Class Summary
static class DemoMediator.CompanyEntity
          Mock class for real entity.
private  class DemoMediator.CompanyLocalHome
          LocalHome mock for Company.
static class DemoMediator.SubsidiaryEntity
          Mock class for real entity.
private  class DemoMediator.SubsidiaryLocalHome
          LocalHome mock for Subsidiary.
 
Field Summary
private  DemoMediator.CompanyLocalHome companyHome
           
private  java.lang.String indexField
          The index field in the VO (would be configured on runtime).
private static org.apache.commons.logging.Log log
           
private  java.util.Map storageCompany
          Our storage, to avoid EJB local entities.
private  java.util.Map storageSubsidiary
          Our storage, to avoid EJB local entities.
private  DemoMediator.SubsidiaryLocalHome subsidiaryHome
           
private  java.util.Map versionCache
           
private  java.lang.Class voClazzCompany
          Class of the VO (would be configured on runtime).
 
Fields inherited from interface org.bsf.smartValueObject.mediator.Mediator
INDEXFIELD
 
Constructor Summary
DemoMediator()
           
 
Method Summary
private  void checkConcurrency(java.lang.Object vo)
           
private static void copyProperties(java.lang.Object dst, java.lang.Object src)
          Wrapper around BeanUtils.copyProperties.
 void deleteGraph(java.lang.Object graph)
          Deletes a graph.
private  DemoMediator.CompanyEntity getCompanyEntityByVO(org.bsf.smartValueObject.demo.CompanyVO vo)
          Gets company entity from VO.
 java.lang.Object getGraph(java.lang.Object prototype)
          Retrieves graph based on given prototype.
private  java.lang.Object getPK(java.lang.Object o)
          Gets primary key from object (from the field specied in indexField).
private  DemoMediator.SubsidiaryEntity getSubsidiaryEntitybyVO(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
          Gets subsidiary entitiy from VO.
private  java.lang.Long getVersionCache(java.lang.Object vo)
           
private  DemoMediator.CompanyEntity newCompany(org.bsf.smartValueObject.demo.CompanyVO vo, java.io.PrintWriter logger)
          Creates new company based on VO.
private static org.bsf.smartValueObject.demo.CompanyVO newCompanyVO()
          Creates new CompanyVO object.
private static org.bsf.smartValueObject.demo.CompanyVO newCompanyVO(DemoMediator.CompanyEntity ce)
           
private  DemoMediator.SubsidiaryEntity newSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
          Creates new subsidiary based on VO.
private static org.bsf.smartValueObject.demo.SubsidiaryVO newSubsidiaryVO()
          Creates new SubsidiaryVO object.
private static org.bsf.smartValueObject.demo.SubsidiaryVO newSubsidiaryVO(DemoMediator.SubsidiaryEntity se)
          Creates new SubsidiaryVO object and initializes its field with the given SubsidiaryEntity.
private  void removeCompany(org.bsf.smartValueObject.demo.CompanyVO vo)
          Removes company based on VO.
private  void removeSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
          Removes subsidiary based on VO.
private  void removeVersionCache(java.lang.Object vo)
           
private  DemoMediator.CompanyEntity updateCompany(org.bsf.smartValueObject.demo.CompanyVO vo, java.io.PrintWriter logger)
          Updates (or creates) company based on VO.
 org.bsf.smartValueObject.mediator.ChangeSummary updateGraph(java.lang.Object graph)
          Stores graph and return summary of changes.
private  void updateSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
          Updates subsidiary based on VO.
private  void updateVersionCache(java.lang.Object vo)
           
private  void verifyGraph(java.lang.Object graph)
          Verifies if the graph argument is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

storageCompany

private java.util.Map storageCompany
Our storage, to avoid EJB local entities.


storageSubsidiary

private java.util.Map storageSubsidiary
Our storage, to avoid EJB local entities.


voClazzCompany

private java.lang.Class voClazzCompany
Class of the VO (would be configured on runtime).


indexField

private java.lang.String indexField
The index field in the VO (would be configured on runtime).


versionCache

private java.util.Map versionCache

companyHome

private DemoMediator.CompanyLocalHome companyHome

subsidiaryHome

private DemoMediator.SubsidiaryLocalHome subsidiaryHome
Constructor Detail

DemoMediator

public DemoMediator()
Method Detail

getGraph

public java.lang.Object getGraph(java.lang.Object prototype)
                          throws MediatorException
Retrieves graph based on given prototype.

Specified by:
getGraph in interface Mediator
Parameters:
prototype -
Returns:
Throws:
MediatorException

updateGraph

public org.bsf.smartValueObject.mediator.ChangeSummary updateGraph(java.lang.Object graph)
                                                            throws MediatorException
Stores graph and return summary of changes.

Specified by:
updateGraph in interface Mediator
Parameters:
graph -
Returns:
update log.
Throws:
MediatorException

deleteGraph

public void deleteGraph(java.lang.Object graph)
                 throws MediatorException
Deletes a graph.

Specified by:
deleteGraph in interface Mediator
Parameters:
graph - the root element of the graph.
Throws:
MediatorException

newCompany

private DemoMediator.CompanyEntity newCompany(org.bsf.smartValueObject.demo.CompanyVO vo,
                                              java.io.PrintWriter logger)
                                       throws MediatorException
Creates new company based on VO.

Parameters:
vo -
Throws:
MediatorException

updateCompany

private DemoMediator.CompanyEntity updateCompany(org.bsf.smartValueObject.demo.CompanyVO vo,
                                                 java.io.PrintWriter logger)
                                          throws MediatorException
Updates (or creates) company based on VO.

Parameters:
vo -
Throws:
MediatorException

removeCompany

private void removeCompany(org.bsf.smartValueObject.demo.CompanyVO vo)
                    throws MediatorException
Removes company based on VO.

Parameters:
vo -
Throws:
MediatorException

newSubsidiary

private DemoMediator.SubsidiaryEntity newSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
                                             throws MediatorException
Creates new subsidiary based on VO.

Parameters:
vo -
Returns:
Throws:
MediatorException

updateSubsidiary

private void updateSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
                       throws MediatorException
Updates subsidiary based on VO.

Parameters:
vo -
Throws:
MediatorException

removeSubsidiary

private void removeSubsidiary(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
                       throws MediatorException
Removes subsidiary based on VO.

Parameters:
vo -
Throws:
MediatorException

getPK

private java.lang.Object getPK(java.lang.Object o)
                        throws MediatorException
Gets primary key from object (from the field specied in indexField).

Parameters:
o -
Returns:
Throws:
MediatorException

getCompanyEntityByVO

private DemoMediator.CompanyEntity getCompanyEntityByVO(org.bsf.smartValueObject.demo.CompanyVO vo)
                                                 throws MediatorException
Gets company entity from VO.

Parameters:
vo -
Returns:
Throws:
MediatorException

getSubsidiaryEntitybyVO

private DemoMediator.SubsidiaryEntity getSubsidiaryEntitybyVO(org.bsf.smartValueObject.demo.SubsidiaryVO vo)
                                                       throws MediatorException
Gets subsidiary entitiy from VO.

Parameters:
vo -
Returns:
Throws:
MediatorException

verifyGraph

private void verifyGraph(java.lang.Object graph)
                  throws MediatorException
Verifies if the graph argument is valid.

Parameters:
graph -
Throws:
MediatorException

updateVersionCache

private void updateVersionCache(java.lang.Object vo)
                         throws MediatorException
MediatorException

getVersionCache

private java.lang.Long getVersionCache(java.lang.Object vo)
                                throws MediatorException
MediatorException

removeVersionCache

private void removeVersionCache(java.lang.Object vo)
                         throws MediatorException
MediatorException

checkConcurrency

private void checkConcurrency(java.lang.Object vo)
                       throws MediatorException
MediatorException

copyProperties

private static void copyProperties(java.lang.Object dst,
                                   java.lang.Object src)
                            throws MediatorException
Wrapper around BeanUtils.copyProperties.

Parameters:
dst -
src -
Throws:
MediatorException

newCompanyVO

private static org.bsf.smartValueObject.demo.CompanyVO newCompanyVO()
Creates new CompanyVO object.

Returns:

newSubsidiaryVO

private static org.bsf.smartValueObject.demo.SubsidiaryVO newSubsidiaryVO()
Creates new SubsidiaryVO object.

Returns:

newSubsidiaryVO

private static org.bsf.smartValueObject.demo.SubsidiaryVO newSubsidiaryVO(DemoMediator.SubsidiaryEntity se)
                                                                   throws MediatorException
Creates new SubsidiaryVO object and initializes its field with the given SubsidiaryEntity.

Parameters:
se -
Returns:
Throws:
MediatorException

newCompanyVO

private static org.bsf.smartValueObject.demo.CompanyVO newCompanyVO(DemoMediator.CompanyEntity ce)
                                                             throws MediatorException
MediatorException