1 package fr.ifremer.quadrige2.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.quadrige2.core.dao.administration.user.DepartmentImpl;
26 import fr.ifremer.quadrige2.core.dao.referential.AnalysisInstrumentImpl;
27 import fr.ifremer.quadrige2.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 } else {
88 target.setPmfmStratId(source.getPmfmStrategy().getPmfmStratId());
89 }
90
91
92 if (source.getAppliedStrategy() == null) {
93 target.setAppliedStratId(null);
94 } else {
95 target.setAppliedStratId(source.getAppliedStrategy().getAppliedStratId());
96 }
97 }
98
99
100 if (source.getDepartment() == null) {
101 target.setDepId(null);
102 }
103 else {
104 target.setDepId(source.getDepartment().getDepId());
105 }
106
107
108 if (source.getAnalysisInstrument() == null) {
109 target.setAnalInstId(null);
110 }
111 else {
112 target.setAnalInstId(source.getAnalysisInstrument().getAnalInstId());
113 }
114 }
115
116
117
118
119
120
121 private PmfmAppliedStrategy loadPmfmAppliedStrategyFromPmfmAppliedStrategyVO(PmfmAppliedStrategyVO source)
122 {
123 PmfmAppliedStrategyPK pk = new PmfmAppliedStrategyPK();
124
125
126 Integer pmfmStratId = source.getPmfmStratId();
127 if (pmfmStratId == null && source.getPmfmStrategyVO() != null) {
128 pmfmStratId = source.getPmfmStrategyVO().getPmfmStratId();
129 }
130 pk.setPmfmStrategy(load(PmfmStrategyImpl.class, pmfmStratId));
131
132
133 Integer appliedStratId = source.getAppliedStratId();
134 if (appliedStratId == null && source.getAppliedStrategyVO() != null) {
135 appliedStratId = source.getAppliedStrategyVO().getAppliedStratId();
136 }
137 pk.setAppliedStrategy(load(AppliedStrategyImpl.class, appliedStratId));
138
139 PmfmAppliedStrategy pmfmAppliedStrategy = this.get(pk);
140 if (pmfmAppliedStrategy == null)
141 {
142 pmfmAppliedStrategy = PmfmAppliedStrategy.Factory.newInstance();
143 pmfmAppliedStrategy.setPmfmAppliedStrategyPk(pk);
144 }
145 return pmfmAppliedStrategy;
146 }
147
148
149 public PmfmAppliedStrategy pmfmAppliedStrategyVOToEntity(PmfmAppliedStrategyVO pmfmAppliedStrategyVO)
150 {
151 PmfmAppliedStrategy entity = this.loadPmfmAppliedStrategyFromPmfmAppliedStrategyVO(pmfmAppliedStrategyVO);
152 this.pmfmAppliedStrategyVOToEntity(pmfmAppliedStrategyVO, entity, true);
153 return entity;
154 }
155
156
157 @Override
158 public void pmfmAppliedStrategyVOToEntity(
159 PmfmAppliedStrategyVO source,
160 PmfmAppliedStrategy target,
161 boolean copyIfNull)
162 {
163 super.pmfmAppliedStrategyVOToEntity(source, target, copyIfNull);
164
165
166 if (copyIfNull || source.getAppliedStrategyVO() != null || source.getAppliedStratId() != null) {
167 if (source.getAppliedStrategyVO() == null && source.getAppliedStratId() == null) {
168 target.setAppliedStrategy(null);
169 }
170 else {
171 Integer appliedStratId = source.getAppliedStratId();
172 if (appliedStratId == null && source.getAppliedStrategyVO() != null) {
173 appliedStratId = source.getAppliedStrategyVO().getAppliedStratId();
174 }
175 target.setAppliedStrategy(load(AppliedStrategyImpl.class, appliedStratId));
176 }
177 }
178
179
180 if (copyIfNull || source.getPmfmStrategyVO() != null || source.getPmfmStratId() != null) {
181 if (source.getPmfmStrategyVO() == null && source.getPmfmStratId() == null) {
182 target.setPmfmStrategy(null);
183 }
184 else {
185 Integer pmfmStratId = source.getPmfmStratId();
186 if (pmfmStratId == null && source.getPmfmStrategyVO() != null) {
187 pmfmStratId = source.getPmfmStrategyVO().getPmfmStratId();
188 }
189 target.setPmfmStrategy(load(PmfmStrategyImpl.class, pmfmStratId));
190 }
191 }
192
193
194 if (copyIfNull || source.getDepId() != null) {
195 if (source.getDepId() == null) {
196 target.setDepartment(null);
197 }
198 else {
199 target.setDepartment(load(DepartmentImpl.class, source.getDepId()));
200 }
201 }
202
203
204 if (copyIfNull || source.getAnalInstId() != null) {
205 if (source.getAnalInstId() == null) {
206 target.setAnalysisInstrument(null);
207 } else {
208 target.setAnalysisInstrument(load(AnalysisInstrumentImpl.class, source.getAnalInstId()));
209 }
210 }
211 }
212 }