View Javadoc
1   package fr.ifremer.quadrige3.core.dao.referential;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 Client Core
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  import fr.ifremer.quadrige3.core.dao.administration.user.PrivilegeCode;
26  import fr.ifremer.quadrige3.core.dao.technical.Assert;
27  import fr.ifremer.quadrige3.core.vo.administration.user.PrivilegeVO;
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   * <p>
35   * PrivilegeDaoImpl class.
36   * </p>
37   * 
38   * @see Privilege
39   */
40  @Repository("privilegeDao")
41  @Lazy
42  public class PrivilegeDaoImpl
43  		extends PrivilegeDaoBase
44  {
45  	/**
46  	 * Constructor used by Spring
47  	 * 
48  	 * @param sessionFactory
49  	 *            a {@link org.hibernate.SessionFactory} object.
50  	 */
51  	@Autowired
52  	public PrivilegeDaoImpl(SessionFactory sessionFactory) {
53  		super();
54  		setSessionFactory(sessionFactory);
55  	}
56  
57  	/** {@inheritDoc} */
58  	public void toPrivilegeVO(
59  			Privilege source,
60  			PrivilegeVO target)
61  	{
62  		// TODO verify behavior of toPrivilegeVO
63  		super.toPrivilegeVO(source, target);
64  	}
65  
66  	/** {@inheritDoc} */
67  	public PrivilegeVO toPrivilegeVO(final Privilege entity)
68  	{
69  		// TODO verify behavior of toPrivilegeVO
70  		return super.toPrivilegeVO(entity);
71  	}
72  
73  	/**
74  	 * Retrieves the entity object that is associated with the specified value object
75  	 * from the object store. If no such entity object exists in the object store,
76  	 * a new, blank entity is created
77  	 */
78  	private Privilege loadPrivilegeFromPrivilegeVO(PrivilegeVO privilegeVO)
79  	{
80  		// TODO implement loadPrivilegeFromPrivilegeVO
81  		throw new UnsupportedOperationException(
82  				"fr.ifremer.quadrige3.core.dao.referential.loadPrivilegeFromPrivilegeVO(PrivilegeVO) not yet implemented.");
83  
84  		/*
85  		 * A typical implementation looks like this:
86  		 * Privilege privilege = this.get(privilegeVO.getId());
87  		 * if (privilege == null)
88  		 * {
89  		 * privilege = Privilege.Factory.newInstance();
90  		 * }
91  		 * return privilege;
92  		 */
93  	}
94  
95  	/** {@inheritDoc} */
96  	public Privilege privilegeVOToEntity(PrivilegeVO privilegeVO)
97  	{
98  		// TODO verify behavior of privilegeVOToEntity
99  		Privilege entity = this.loadPrivilegeFromPrivilegeVO(privilegeVO);
100 		this.privilegeVOToEntity(privilegeVO, entity, true);
101 		return entity;
102 	}
103 
104 	/** {@inheritDoc} */
105 	@Override
106 	public void privilegeVOToEntity(
107 			PrivilegeVO source,
108 			Privilege target,
109 			boolean copyIfNull)
110 	{
111 		// TODO verify behavior of privilegeVOToEntity
112 		super.privilegeVOToEntity(source, target, copyIfNull);
113 	}
114 
115 	/** {@inheritDoc} */
116 	@Override
117 	public Privilege privilegeCodeToEntity(PrivilegeCode privilegeCode) {
118 		Assert.notNull(privilegeCode);
119 		return load(privilegeCode.getValue());
120 	}
121 }