001// license-header java merge-point 002// 003// Attention: Generated code! Do not modify by hand! 004// Generated by: SpringHibernateDaoImpl.vsl in andromda-spring-cartridge. 005// 006package fr.ifremer.adagio.core.dao.administration.user; 007 008/* 009 * #%L 010 * SIH-Adagio :: Core 011 * $Id: PersonDaoImpl.java 11945 2014-02-07 16:07:23Z bl05b3e $ 012 * $HeadURL: https://forge.ifremer.fr/svn/sih-adagio/tags/adagio-3.5.6/core/src/main/java/fr/ifremer/adagio/core/dao/administration/user/PersonDaoImpl.java $ 013 * %% 014 * Copyright (C) 2012 - 2013 Ifremer 015 * %% 016 * This program is free software: you can redistribute it and/or modify 017 * it under the terms of the GNU Affero General Public License as published by 018 * the Free Software Foundation, either version 3 of the License, or 019 * (at your option) any later version. 020 * 021 * This program is distributed in the hope that it will be useful, 022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 024 * GNU General Public License for more details. 025 * 026 * You should have received a copy of the GNU Affero General Public License 027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 028 * #L% 029 */ 030 031import java.util.Date; 032 033import org.hibernate.Session; 034 035import com.google.common.collect.Sets; 036 037import fr.ifremer.adagio.core.dao.referential.Status; 038import fr.ifremer.adagio.core.dao.referential.StatusCode; 039import fr.ifremer.adagio.core.dao.referential.StatusImpl; 040import fr.ifremer.adagio.core.dao.technical.hibernate.TemporaryDataHelper; 041 042/** 043 * @see fr.ifremer.adagio.core.dao.administration.user.Person 044 */ 045@org.springframework.stereotype.Repository("personDao") 046@org.springframework.context.annotation.Lazy 047public class PersonDaoImpl 048 extends fr.ifremer.adagio.core.dao.administration.user.PersonDaoBase 049 implements PersonExtendDao { 050 051 /** 052 * Constructor used by Spring 053 */ 054 @org.springframework.beans.factory.annotation.Autowired 055 public PersonDaoImpl(org.hibernate.SessionFactory sessionFactory) { 056 super(); 057 setSessionFactory(sessionFactory); 058 } 059 060 @Override 061 public Person createAsTemporary(String lastname, String firstname, Integer departmentId) { 062 Session session = getSession(); 063 064 Integer personId = TemporaryDataHelper.getNewNegativeIdForTemporaryData(session, PersonImpl.class); 065 066 // Fill the adagio entity 067 fr.ifremer.adagio.core.dao.administration.user.Person target = fr.ifremer.adagio.core.dao.administration.user.Person.Factory.newInstance(); 068 target.setId(personId); 069 target.setLastname(lastname); 070 target.setFirstname(firstname); 071 target.setDepartment((Department) session.load(DepartmentImpl.class, departmentId)); 072 target.setCreationDate(new Date()); 073 target.setStatus((Status) session.load(StatusImpl.class, StatusCode.TEMPORARY.getValue())); 074 075 // Add a profil 'user' 076 UserProfil userProfil = (UserProfil) session.load(UserProfilImpl.class, UserProfilId.USER.getValue()); 077 target.setProfils(Sets.newHashSet(userProfil)); 078 079 target = create(target); 080 081 return target; 082 } 083 084}