1 | |
package org.kuali.student.core.statement.service.assembler; |
2 | |
|
3 | |
import org.apache.commons.beanutils.BeanUtils; |
4 | |
import org.apache.log4j.Logger; |
5 | |
import org.kuali.student.core.assembly.BOAssembler; |
6 | |
import org.kuali.student.core.assembly.BaseDTOAssemblyNode; |
7 | |
import org.kuali.student.core.assembly.BaseDTOAssemblyNode.NodeOperation; |
8 | |
import org.kuali.student.core.assembly.data.AssemblyException; |
9 | |
import org.kuali.student.core.service.impl.BaseAssembler; |
10 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | 0 | public class StatementTreeViewAssembler extends BaseAssembler implements BOAssembler<StatementTreeViewInfo, StatementTreeViewInfo>{ |
22 | 0 | final static Logger LOG = Logger.getLogger(StatementTreeViewAssembler.class); |
23 | |
|
24 | |
|
25 | |
@Override |
26 | |
public StatementTreeViewInfo assemble(StatementTreeViewInfo baseDTO, |
27 | |
StatementTreeViewInfo businessDTO, boolean shallowBuild) |
28 | |
throws AssemblyException { |
29 | 0 | StatementTreeViewInfo stmtTree = (null != businessDTO) ? businessDTO |
30 | |
: new StatementTreeViewInfo(); |
31 | |
try { |
32 | 0 | BeanUtils.copyProperties(stmtTree, baseDTO); |
33 | 0 | } catch (Exception e) { |
34 | 0 | throw new AssemblyException("Error assembling StatementTree",e); |
35 | 0 | } |
36 | |
|
37 | 0 | return stmtTree; |
38 | |
} |
39 | |
|
40 | |
|
41 | |
@Override |
42 | |
public BaseDTOAssemblyNode<StatementTreeViewInfo, StatementTreeViewInfo> disassemble( |
43 | |
StatementTreeViewInfo newTree, NodeOperation operation) |
44 | |
throws AssemblyException { |
45 | |
|
46 | 0 | if (newTree == null) { |
47 | |
|
48 | |
|
49 | 0 | LOG.error("StatementTreeView to disassemble is null!"); |
50 | 0 | throw new AssemblyException("StatementTreeView can not be null"); |
51 | |
} |
52 | |
|
53 | 0 | BaseDTOAssemblyNode<StatementTreeViewInfo, StatementTreeViewInfo> result = new BaseDTOAssemblyNode<StatementTreeViewInfo, StatementTreeViewInfo>(this); |
54 | 0 | if(newTree.getId()==null|newTree.getId().isEmpty()){ |
55 | 0 | result.setOperation(NodeOperation.CREATE); |
56 | |
}else{ |
57 | 0 | result.setOperation(operation); |
58 | |
} |
59 | 0 | result.setBusinessDTORef(newTree); |
60 | 0 | result.setNodeData(newTree); |
61 | 0 | return result; |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
} |