View Javadoc

1   /*
2    * Copyright 2008 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.common.assembly;
17  
18  import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation;
19  import org.kuali.student.common.assembly.data.AssemblyException;
20  
21  
22  /**
23   * An assembler that provides assembly and disassembly of business DTO from/to
24   * their base DTO.
25   * 
26   * During disassembly of business DTO, it is required that all implementations
27   * generate the id (if newly created base DTO) from UUID and use that in mapping
28   * relations.
29   * 
30   * Generic Mapping:
31   * E -> Business DTO e.g. CourseInfo
32   * T -> Base DTO e.g. CluInfo
33   * 
34   * It is a good practice to propagate state from the parent objects through to the children
35   * 
36   * @author Kuali Student Team
37   * 
38   */
39  public interface BOAssembler<E, T> {
40  
41  	/**
42  	 * 
43  	 * This method assembles the business DTO from its base DTO.
44  	 * 
45  	 * @param baseDTO
46  	 *            Base DTO that corresponds to the business DTO
47  	 * @param businessDTO
48  	 * 			  Reference to Business DTO
49  	 * @param shallowBuild
50  	 * 			  boolean flag to indicate if the assembly should be shallow or deep 
51  	 * @return Assembled business DTO
52  	 * @throws AssemblyException 
53  	 */
54  	public E assemble(T baseDTO, E businessDTO, boolean shallowBuild) throws AssemblyException;
55  
56  	/**
57  	 * 
58  	 * This method returns a collection of base DTOs and the operations that
59  	 * need to be performed on them in a given order
60  	 * 
61  	 * 
62  	 * @param businessDTO
63  	 *            Business DTO to be disassembled
64  	 * @param isCreate
65  	 *            Is the disassembly done for create
66  	 * 
67  	 * @return A sorted map of BaseDTOAssemblyNodes to be processed in the given
68  	 *         order. The key (Integer) is the sequence in which the nodes have
69  	 *         to be processed
70  	 * @throws AssemblyException 
71  	 */
72  	public BaseDTOAssemblyNode<E,	T> disassemble(
73  			E businessDTO, NodeOperation operation) throws AssemblyException;
74  }