Skip to end of banner
Go to start of banner

Business Objects

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 26 Next »

Business objects (BOs) implement the software's business logic. They are responsible for handling data objects (constructing, loading, saving, deleting) and any other business logic related to the business module. For every data object, there is a business object that handles it. Business objects offer services to the Controller layer (UI, API, Process) but they do not implement any process flows.

In CRM.COM Software, business object classes are implemented using EJBs (Enterprise Java Beans) J2EE server-side components, and more specifically, Stateless Session Beans. More information about EJBs can be found here.

Creating the Business Object Classes

 

All business objects should be placed under com.crm.businessobject.* named packages and extend com.crm.businessobject.CRMBO.

 

 Creating CRMBOBankBean.java

 

Defining Bussiness Object Methods

 

To implement the basic business logic in our class, we will need to create the following methods:

 

constructDO
    /**
     * Constructs a bank.
     * 
     * @param mainDTO - the main data object
     * @return a bank
     * @throws Exception
     */
	@Override
	protected CRMDO constructDO(CRMDO mainDTO) throws Exception {
		...
	}

This method creates a new instance of the data object. In this method we add any business logic required when creating a new entity. The mainDTO parameter is not null in case the data object to be created should be related with another data object.

 

saveDO
    /**
     * Saves a bank.
     * 
     * @param dto - the bank to save
     * @return the saved bank
     * @throws Exception
     */
	@Override
	protected CRMDO saveDO(CRMDO dto) throws Exception {
		...
	}

This method saves the data objects to the database. In this method we add any business logic required to be executed when saving an entity.

 

deleteDO
    /**
     * Deletes a bank.
     * 
     * @param dto - the bank to delete
     * @return the deleted bank
     * @throws Exception
     */
	@Override
	protected CRMDO deleteDO(CRMDO dto) throws Exception {
		...
	}

This method deletes the data objects. In this method we add any business logic required to be executed when deleting an entity. Note that records are not physically deleted but marked as deleted. 

 

validateDOonSave
    /**
     * Validates a bank on save.
     * 
     * @param dto - the bank to validate
     * @throws Exception
     */
	@Override
	protected void validateDOonSave(CRMDO dto) throws Exception {
		...
	}

This method validates the data objects before saving to the database. Any validations that should be done before saving the data object to the database should be performed in this method.

 

validateDOonDelete
    /**
     * Validates a bank on delete.
     * 
     * @param dto - the bank to validate
     * @throws Exception
     */
	@Override
	protected void validateDOonDelete(CRMDO dto) throws Exception {
		...
	}

This method validates the data objects before saving to the database as deleted. Any validations that should be done before deleting the data object should be performed in this method.

 

getDataObjectClass
    /**
     * Returns the data object class of a bank.
     * 
     * @return the data object class of the bank
     */
	@Override
	protected Class<CRMDOBank> getDataObjectClass() {
		return CRMDOBank.class;
	}

This method returns the class of the data object that is handled by the specific business object. It is used mainly to construct the HQL (Hibernate Query Language) dynamically.

 

getDefaultAssociations
    /**
     * Returns the default associated data objects of a bank.
     * 
     * @return the default associated data objects of the bank
     */
	@Override
	public ArrayList<String> getDefaultAssociations() {
		
		ArrayList<String> defaultAssociations = new ArrayList<String>();
		...
		return defaultAssociations;
	}

This method returns a list of the associated data objects that should be loaded by default when loading a data object. It is called by abstract functionality to load the data objects associated data objects.

 

getSequenceNumber
    /**
     * Returns the next sequence number of a bank.
     * 
     * @param dto - the bank to return the next sequence number for
     * @return the next sequence number of the bank
     * @throws Exception
     */
	@Override
	protected String getSequenceNumber(CRMDO dto) throws Exception {
		...
	}

This method returns a sequence number that is set on the data object in case it has a number property. It is called by abstract functionality to set the data object's number when saving the data object.

 

getMandatoryFields
    /**
     * Returns the mandatory fields of a bank.
     * 
     * @param dto - the bank to return the mandatory fields for
     * @return the mandatory fields of the bank
     * @throws Exception
     */
	@Override
	protected LinkedHashMap<String, String> getMandatoryFields(CRMDO dto) throws Exception {
		
		LinkedHashMap<String, String> mandatoryFields = new LinkedHashMap<String, String>();
		...
		return mandatoryFields;
	}

This method returns a list of the data object's mandatory fields (fields that should be always set). This method is called by abstract functionality to validate that all mandatory fields are set.

 

To start implementing the controller layer, go to Developing the Controller layer

  • No labels