1 package fr.ifremer.quadrige3.core.dao.administration.strategy;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import fr.ifremer.quadrige3.core.dao.administration.user.DepartmentImpl;
26 import fr.ifremer.quadrige3.core.dao.referential.AnalysisInstrumentImpl;
27 import fr.ifremer.quadrige3.core.vo.administration.strategy.PmfmAppliedStrategyVO;
28 import org.hibernate.SessionFactory;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.context.annotation.Lazy;
31 import org.springframework.stereotype.Repository;
32
33
34
35
36
37
38
39
40 @Repository("pmfmAppliedStrategyDao")
41 @Lazy
42 public class PmfmAppliedStrategyDaoImpl
43 extends PmfmAppliedStrategyDaoBase
44 {
45
46
47
48
49
50
51 @Autowired
52 public PmfmAppliedStrategyDaoImpl(SessionFactory sessionFactory) {
53 super();
54 setSessionFactory(sessionFactory);
55 }
56
57
58 public void toPmfmAppliedStrategyVO(
59 PmfmAppliedStrategy source,
60 PmfmAppliedStrategyVO target)
61 {
62 super.toPmfmAppliedStrategyVO(source, target);
63
64 if (source.getPmfmAppliedStrategyPk() != null) {
65 PmfmAppliedStrategyPK pk = source.getPmfmAppliedStrategyPk();
66
67
68 if (pk.getPmfmStrategy() == null) {
69 target.setPmfmStratId(null);
70 }
71 else {
72 target.setPmfmStratId(pk.getPmfmStrategy().getPmfmStratId());
73 }
74
75
76 if (pk.getAppliedStrategy() == null) {
77 target.setAppliedStratId(null);
78 }
79 else {
80 target.setAppliedStratId(pk.getAppliedStrategy().getAppliedStratId());
81 }
82 }
83 else {
84
85 if (source.getPmfmStrategy() == null) {
86 target.setPmfmStratId(null);
87 }
88 else {
89 target.setPmfmStratId(source.getPmfmStrategy().getPmfmStratId());
90 }
91
92
93 if (source.getAppliedStrategy() == null) {
94 target.setAppliedStratId(null);
95 }
96 else {
97 target.setAppliedStratId(source.getAppliedStrategy().getAppliedStratId());
98 }
99 }
100
101
102 if (source.getDepartment() == null) {
103 target.setDepId(null);
104 }
105 else {
106 target.setDepId(source.getDepartment().getDepId());
107 }
108
109
110 if (source.getAnalysisInstrument() == null) {
111 target.setAnalInstId(null);
112 }
113 else {
114 target.setAnalInstId(source.getAnalysisInstrument().getAnalInstId());
115 }
116 }
117
118
119
120
121
122
123 private PmfmAppliedStrategy loadPmfmAppliedStrategyFromPmfmAppliedStrategyVO(PmfmAppliedStrategyVO source)
124 {
125 PmfmAppliedStrategyPK pk = new PmfmAppliedStrategyPK();
126
127
128 Integer pmfmStratId = source.getPmfmStratId();
129 if (pmfmStratId == null && source.getPmfmStrategyVO() != null) {
130 pmfmStratId = source.getPmfmStrategyVO().getPmfmStratId();
131 }
132 pk.setPmfmStrategy(load(PmfmStrategyImpl.class, pmfmStratId));
133
134
135 Integer appliedStratId = source.getAppliedStratId();
136 if (appliedStratId == null && source.getAppliedStrategyVO() != null) {
137 appliedStratId = source.getAppliedStrategyVO().getAppliedStratId();
138 }
139 pk.setAppliedStrategy(load(AppliedStrategyImpl.class, appliedStratId));
140
141 PmfmAppliedStrategy pmfmAppliedStrategy = this.get(pk);
142 if (pmfmAppliedStrategy == null)
143 {
144 pmfmAppliedStrategy = PmfmAppliedStrategy.Factory.newInstance();
145 pmfmAppliedStrategy.setPmfmAppliedStrategyPk(pk);
146 }
147 return pmfmAppliedStrategy;
148 }
149
150
151 public PmfmAppliedStrategy pmfmAppliedStrategyVOToEntity(PmfmAppliedStrategyVO pmfmAppliedStrategyVO)
152 {
153 PmfmAppliedStrategy entity = this.loadPmfmAppliedStrategyFromPmfmAppliedStrategyVO(pmfmAppliedStrategyVO);
154 this.pmfmAppliedStrategyVOToEntity(pmfmAppliedStrategyVO, entity, true);
155 return entity;
156 }
157
158
159 @Override
160 public void pmfmAppliedStrategyVOToEntity(
161 PmfmAppliedStrategyVO source,
162 PmfmAppliedStrategy target,
163 boolean copyIfNull)
164 {
165 super.pmfmAppliedStrategyVOToEntity(source, target, copyIfNull);
166
167
168 if (copyIfNull || source.getAppliedStrategyVO() != null || source.getAppliedStratId() != null) {
169 if (source.getAppliedStrategyVO() == null && source.getAppliedStratId() == null) {
170 target.setAppliedStrategy(null);
171 }
172 else {
173 Integer appliedStratId = source.getAppliedStratId();
174 if (appliedStratId == null && source.getAppliedStrategyVO() != null) {
175 appliedStratId = source.getAppliedStrategyVO().getAppliedStratId();
176 }
177 target.setAppliedStrategy(load(AppliedStrategyImpl.class, appliedStratId));
178 }
179 }
180
181
182 if (copyIfNull || source.getPmfmStrategyVO() != null || source.getPmfmStratId() != null) {
183 if (source.getPmfmStrategyVO() == null && source.getPmfmStratId() == null) {
184 target.setPmfmStrategy(null);
185 }
186 else {
187 Integer pmfmStratId = source.getPmfmStratId();
188 if (pmfmStratId == null && source.getPmfmStrategyVO() != null) {
189 pmfmStratId = source.getPmfmStrategyVO().getPmfmStratId();
190 }
191 target.setPmfmStrategy(load(PmfmStrategyImpl.class, pmfmStratId));
192 }
193 }
194
195
196 if (copyIfNull || source.getDepId() != null) {
197 if (source.getDepId() == null) {
198 target.setDepartment(null);
199 }
200 else {
201 target.setDepartment(load(DepartmentImpl.class, source.getDepId()));
202 }
203 }
204
205
206 if (copyIfNull || source.getAnalInstId() != null) {
207 if (source.getAnalInstId() == null) {
208 target.setAnalysisInstrument(null);
209 } else {
210 target.setAnalysisInstrument(load(AnalysisInstrumentImpl.class, source.getAnalInstId()));
211 }
212 }
213 }
214 }