View Javadoc
1   // Generated by: hibernate/SpringHibernateDaoImpl.vsl in andromda-spring-cartridge.
2   // license-header java merge-point
3   //
4   // Attention: Generated code! Do not modify by hand!
5   // Generated by: SpringHibernateDaoImpl.vsl in andromda-spring-cartridge.
6   //
7   package fr.ifremer.quadrige3.core.dao.system;
8   
9   /*-
10   * #%L
11   * Quadrige3 Core :: Client API
12   * %%
13   * Copyright (C) 2017 - 2019 Ifremer
14   * %%
15   * This program is free software: you can redistribute it and/or modify
16   * it under the terms of the GNU Affero General Public License as published by
17   * the Free Software Foundation, either version 3 of the License, or
18   * (at your option) any later version.
19   * 
20   * This program is distributed in the hope that it will be useful,
21   * but WITHOUT ANY WARRANTY; without even the implied warranty of
22   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23   * GNU General Public License for more details.
24   * 
25   * You should have received a copy of the GNU Affero General Public License
26   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27   * #L%
28   */
29  
30  import org.apache.commons.collections4.CollectionUtils;
31  import org.hibernate.SessionFactory;
32  import org.hibernate.type.IntegerType;
33  import org.hibernate.type.StringType;
34  import org.springframework.beans.factory.annotation.Autowired;
35  import org.springframework.context.annotation.Lazy;
36  import org.springframework.stereotype.Repository;
37  
38  import java.util.List;
39  
40  /**
41   * Extended ValidationHistoryDao
42   */
43  @Repository("validationHistoryDao")
44  @Lazy
45  public class ValidationHistoryDaoImpl extends ValidationHistoryDaoBase implements ValidationHistoryExtendDao
46  {
47      /**
48       * Constructor used by Spring
49       */
50  	@Autowired
51  	public ValidationHistoryDaoImpl(SessionFactory sessionFactory) {
52  		super();
53  		setSessionFactory(sessionFactory);
54  	}
55  
56  	@Override
57  	public String getLastValidationComment(Integer objectId, String objectTypeCode) {
58  
59  		List<String> comments = queryListTyped("validationComments",
60  				"objectTypeCd", StringType.INSTANCE, objectTypeCode,
61  				"validHistElementId", IntegerType.INSTANCE, objectId);
62  
63  		return CollectionUtils.isNotEmpty(comments) ? comments.get(0) : null;
64  	}
65  }