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.referential.gear;
007
008/*
009 * #%L
010 * SIH-Adagio :: Core
011 * $Id: FishingGearDaoImpl.java 11871 2013-12-03 14:59:35Z tc1fbb1 $
012 * $HeadURL: https://forge.ifremer.fr/svn/sih-adagio/tags/adagio-3.5.6/core/src/main/java/fr/ifremer/adagio/core/dao/referential/gear/FishingGearDaoImpl.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.administration.user.Department;
038import fr.ifremer.adagio.core.dao.administration.user.DepartmentImpl;
039import fr.ifremer.adagio.core.dao.administration.user.PersonImpl;
040import fr.ifremer.adagio.core.dao.administration.user.UserProfil;
041import fr.ifremer.adagio.core.dao.administration.user.UserProfilId;
042import fr.ifremer.adagio.core.dao.administration.user.UserProfilImpl;
043import fr.ifremer.adagio.core.dao.referential.Status;
044import fr.ifremer.adagio.core.dao.referential.StatusCode;
045import fr.ifremer.adagio.core.dao.referential.StatusImpl;
046import fr.ifremer.adagio.core.dao.technical.hibernate.TemporaryDataHelper;
047
048/**
049 * @see fr.ifremer.adagio.core.dao.referential.gear.Gear
050 */
051@org.springframework.stereotype.Repository("fishingGearDao")
052@org.springframework.context.annotation.Lazy
053public class FishingGearDaoImpl
054        extends fr.ifremer.adagio.core.dao.referential.gear.FishingGearDaoBase
055        implements FishingGearExtendDao {
056
057    /**
058     * Constructor used by Spring
059     */
060    @org.springframework.beans.factory.annotation.Autowired
061    public FishingGearDaoImpl(org.hibernate.SessionFactory sessionFactory) {
062        super();
063        setSessionFactory(sessionFactory);
064    }
065
066    @Override
067    public FishingGear createAsTemporary(String label, String name, Integer gearClassificationId) {
068        Session session = getSession(false);
069
070        Integer gearId = TemporaryDataHelper.getNewNegativeIdForTemporaryData(session, GearImpl.class);
071
072        // Fill the adagio entity
073        FishingGear target = FishingGear.Factory.newInstance();
074        target.setId(gearId);
075        target.setLabel(label);
076        target.setName(name);
077        target.setGearClassification((GearClassification) session.load(GearClassificationImpl.class, gearClassificationId));
078        target.setStatus((Status) session.load(StatusImpl.class, StatusCode.TEMPORARY.getValue()));
079
080        target = create(target);
081
082        return target;
083    }
084
085}