001    /*
002     * Copyright 2008 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 1.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl1.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.student.r1.common.assembly;
017    
018    import java.util.ArrayList;
019    import java.util.List;
020    
021    
022    /**
023     * A node in the sorted map of disassembled base DTOs. The node provides the
024     * data for the base DTO along with the operation information on the data.
025     * 
026     * The consumer of the map of these nodes is required to process the nodes in
027     * sorted order to guarantee data integrity within the base DTOs.
028     * 
029     * @author Kuali Student Team
030     * 
031     */
032    public class BaseDTOAssemblyNode<E,T> {
033    
034            public enum NodeOperation {
035                    CREATE, UPDATE, DELETE;
036            }
037    
038            protected NodeOperation operation;
039    
040            protected E businessDTORef;
041            
042            protected T nodeData;
043    
044            
045            protected BOAssembler<E, T> assembler;
046            
047            protected List<BaseDTOAssemblyNode<?,?>> childNodes;
048    
049            public BaseDTOAssemblyNode(BOAssembler<E, T> assembler) {
050                    super();
051                    this.assembler = assembler;
052            }
053    
054            /**
055             * @return the nodeData
056             */
057            public T getNodeData() {
058                    return nodeData;
059            }
060    
061            /**
062             * @param nodeData
063             *            the nodeData to set
064             */
065            public void setNodeData(T nodeData) {
066                    this.nodeData = nodeData;
067            }
068    
069            /**
070             * @return the operation
071             */
072            public NodeOperation getOperation() {
073                    return operation;
074            }
075    
076            /**
077             * @param operation
078             *            the operation to set
079             */
080            public void setOperation(NodeOperation operation) {
081                    this.operation = operation;
082            }
083    
084            public List<BaseDTOAssemblyNode<?,?>> getChildNodes() {
085                    if (childNodes == null) {
086                            childNodes = new ArrayList<BaseDTOAssemblyNode<?,?>>();
087                    }
088                    return childNodes;
089            }
090    
091            public void setChildNodes(List<BaseDTOAssemblyNode<?,?>> childNodes) {
092                    this.childNodes = childNodes;
093            }
094            
095            /**
096             * @return the assembler
097             */
098            public BOAssembler<E, T> getAssembler() {
099                    return assembler;
100            }
101    
102            /**
103             * @param assembler the assembler to set
104             */
105            public void setAssembler(BOAssembler<E, T> assembler) {
106                    this.assembler = assembler;
107            }
108    
109            /**
110             * @return the businessDTORef
111             */
112            public E getBusinessDTORef() {
113                    return businessDTORef;
114            }
115    
116            /**
117             * @param businessDTORef the businessDTORef to set
118             */
119            public void setBusinessDTORef(E businessDTORef) {
120                    this.businessDTORef = businessDTORef;
121            }
122            
123    }