Author: tchemit Date: 2013-05-27 23:29:10 +0200 (Mon, 27 May 2013) New Revision: 199 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: review persistence api Added: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedListJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractKanbanJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationErrorJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractMagalieUserJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractPreparedArticleReceptionJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedListJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementOrderJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStoredArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractSupplierJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractUnavailableArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java Removed: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/BuildingDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleDao.java branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/MagalieUsersService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReportService.java branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java branches/magalie-eugene/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,27 +23,25 @@ * #L% */ -import com.franciaflex.magalie.persistence.dao.ArticleDao; -import com.franciaflex.magalie.persistence.dao.BuildingDao; -import com.franciaflex.magalie.persistence.dao.DeliveredRequestedArticleDao; -import com.franciaflex.magalie.persistence.dao.DeliveredRequestedListDao; -import com.franciaflex.magalie.persistence.dao.KanbanDao; -import com.franciaflex.magalie.persistence.dao.LocationDao; -import com.franciaflex.magalie.persistence.dao.LocationErrorDao; -import com.franciaflex.magalie.persistence.dao.MagalieUserDao; -import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionDao; -import com.franciaflex.magalie.persistence.dao.RequestedArticleDao; -import com.franciaflex.magalie.persistence.dao.RequestedListDao; -import com.franciaflex.magalie.persistence.dao.StorageMovementDao; -import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao; -import com.franciaflex.magalie.persistence.dao.StoredArticleDao; -import com.franciaflex.magalie.persistence.dao.SupplierDao; -import com.franciaflex.magalie.persistence.dao.UnavailableArticleDao; -import com.franciaflex.magalie.persistence.dao.WarehouseDao; +import com.franciaflex.magalie.persistence.dao.ArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.BuildingJpaDao; +import com.franciaflex.magalie.persistence.dao.DeliveredRequestedArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.DeliveredRequestedListJpaDao; +import com.franciaflex.magalie.persistence.dao.KanbanJpaDao; +import com.franciaflex.magalie.persistence.dao.LocationErrorJpaDao; +import com.franciaflex.magalie.persistence.dao.LocationJpaDao; +import com.franciaflex.magalie.persistence.dao.MagalieUserJpaDao; +import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionJpaDao; +import com.franciaflex.magalie.persistence.dao.RequestedArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.RequestedListJpaDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementJpaDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementOrderJpaDao; +import com.franciaflex.magalie.persistence.dao.StoredArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.SupplierJpaDao; +import com.franciaflex.magalie.persistence.dao.UnavailableArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.WarehouseJpaDao; -/** - * @author bleny - */ +/** @author bleny */ public interface MagaliePersistenceContext { void commit(); @@ -52,38 +50,38 @@ void clearDatabase(); - MagalieUserDao getMagalieUserDao(); + MagalieUserJpaDao getMagalieUserDao(); - StoredArticleDao getStoredArticleDao(); + StoredArticleJpaDao getStoredArticleDao(); - RequestedArticleDao getRequestedArticleDao(); + RequestedArticleJpaDao getRequestedArticleDao(); - ArticleDao getArticleDao(); + ArticleJpaDao getArticleDao(); - StorageMovementDao getStorageMovementDao(); + StorageMovementJpaDao getStorageMovementDao(); - LocationErrorDao getLocationErrorDao(); + LocationErrorJpaDao getLocationErrorDao(); - StorageMovementOrderDao getStorageMovementOrderDao(); + StorageMovementOrderJpaDao getStorageMovementOrderDao(); - LocationDao getLocationDao(); + LocationJpaDao getLocationDao(); - DeliveredRequestedArticleDao getDeliveredRequestedArticleDao(); + DeliveredRequestedArticleJpaDao getDeliveredRequestedArticleDao(); - BuildingDao getBuildingDao(); + BuildingJpaDao getBuildingDao(); - WarehouseDao getWarehouseDao(); + WarehouseJpaDao getWarehouseDao(); - RequestedListDao getRequestedListDao(); + RequestedListJpaDao getRequestedListDao(); - DeliveredRequestedListDao getDeliveredRequestedListDao(); + DeliveredRequestedListJpaDao getDeliveredRequestedListDao(); - KanbanDao getKanbanDao(); + KanbanJpaDao getKanbanDao(); - SupplierDao getSupplierDao(); + SupplierJpaDao getSupplierDao(); - UnavailableArticleDao getUnavailableArticleDao(); + UnavailableArticleJpaDao getUnavailableArticleDao(); - PreparedArticleReceptionDao getPreparedArticleReceptionDao(); + PreparedArticleReceptionJpaDao getPreparedArticleReceptionDao(); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractArticleJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,43 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Article; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + +public class AbstractArticleJpaDao<E extends Article> extends GeneratedArticleJpaDao<E> { + + public AbstractArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public Article findByCode(String articleCode) { + TypedQuery<E> query = createQuery("from Article a where a.code = :code"); + query.setParameter(Article.PROPERTY_CODE, articleCode); + return findUniqueOrNull(query); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedArticleJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,57 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.DeliveredRequestedArticle; +import com.franciaflex.magalie.persistence.entity.RequestedList; +import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractDeliveredRequestedArticleJpaDao<E extends DeliveredRequestedArticle> extends GeneratedDeliveredRequestedArticleJpaDao<E> { + + public AbstractDeliveredRequestedArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public DeliveredRequestedArticle find(StorageMovementOrder storageMovementOrder) { + TypedQuery<E> query = + entityManager.createQuery( + "from DeliveredRequestedArticle dra where dra.storageMovementOrder = :storageMovementOrder", getEntityClass()); + query.setParameter("storageMovementOrder", storageMovementOrder); + return findUniqueOrNull(query); + } + + @Override + public List<DeliveredRequestedArticle> findAll(RequestedList requestedList) { + TypedQuery<E> query = + entityManager.createQuery( + "from DeliveredRequestedArticle dra where dra.requestedArticle.requestedList = :requestedList", getEntityClass()); + query.setParameter("requestedList", requestedList); + return (List<DeliveredRequestedArticle>) findAll(query); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedListJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedListJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedListJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,65 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.DeliveredRequestedList; +import com.franciaflex.magalie.persistence.entity.DeliveredRequestedListStatus; +import com.franciaflex.magalie.persistence.entity.MagalieUser; +import com.franciaflex.magalie.persistence.entity.RequestedList; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + +public class AbstractDeliveredRequestedListJpaDao<E extends DeliveredRequestedList> extends GeneratedDeliveredRequestedListJpaDao<E> { + + public AbstractDeliveredRequestedListJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public DeliveredRequestedList findByAffectedTo(MagalieUser affectedTo) { + + TypedQuery<E> query = createQuery( + "from DeliveredRequestedList drl where drl.status = :affected and drl.affectedTo = :affectedTo"); + + query.setParameter("affectedTo", affectedTo); + + query.setParameter("affected", DeliveredRequestedListStatus.AFFECTED); + + return findUniqueOrNull(query); + + } + + @Override + public DeliveredRequestedList findByRequestedList(RequestedList requestedList) { + + TypedQuery<E> query = createQuery( + "from DeliveredRequestedList drl where drl.requestedList = :requestedList"); + + query.setParameter("requestedList", requestedList); + + return findUniqueOrNull(query); + + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractKanbanJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractKanbanJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractKanbanJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,46 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Kanban; +import com.franciaflex.magalie.persistence.entity.Warehouse; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + +public class AbstractKanbanJpaDao<E extends Kanban> extends GeneratedKanbanJpaDao<E> { + + public AbstractKanbanJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public Kanban find(Article article, Warehouse warehouse) { + TypedQuery<E> query = entityManager.createQuery("from Kanban k where k.article = :article and k.warehouse = :warehouse", getEntityClass()); + query.setParameter("article", article); + query.setParameter("warehouse", warehouse); + return query.getSingleResult(); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationErrorJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationErrorJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationErrorJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,62 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Location; +import com.franciaflex.magalie.persistence.entity.LocationError; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractLocationErrorJpaDao<E extends LocationError> extends GeneratedLocationErrorJpaDao<E> { + + public AbstractLocationErrorJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public LocationError findByLocation(Location location) { + TypedQuery<E> query = createQuery("from LocationError se where se.location = :location"); + query.setParameter("location", location); + return findUniqueOrNull(query); + } + + @Override + public List<Location> getAllLocationsInError(Article article) { + Query query = entityManager.createQuery("select se.location from LocationError se where se.article = :article"); + query.setParameter("article", article); + List<Location> allLocationsInError = query.getResultList(); + return allLocationsInError; + } + + @Override + public List<E> findAll() { + Query query = entityManager.createQuery("from LocationError se order by se.reportDate"); + List<E> all = query.getResultList(); + return all; + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,84 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.Location; +import com.franciaflex.magalie.persistence.entity.Warehouse; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractLocationJpaDao<E extends Location> extends GeneratedLocationJpaDao<E> { + + public AbstractLocationJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public Location find(String code, Warehouse warehouse) { + TypedQuery<E> query = createQuery("from Location l where l.code = :code and l.warehouse = :warehouse"); + query.setParameter("code", code); + query.setParameter("warehouse", warehouse); + return findUnique(query); + } + + protected List<Location> findAllWithoutReception(Building building, Warehouse warehouse) { + boolean filterOnBuilding = building != null; + boolean filterOnWarehouse = warehouse != null; + String hql = " from Location l where"; + if (filterOnBuilding) { + hql += " l.warehouse.building = :building and "; + } + if (filterOnWarehouse) { + hql += " l.warehouse = :warehouse and "; + } + hql += " l.code != :codeForReceptionLocations and " + + " l.code != :codeForWarehouseWithoutLocations and " + + " l.fullLocation = false " + + " order by l.warehouse.building.code, l.warehouse.code, l.code"; + TypedQuery<E> query = createQuery(hql); + if (filterOnBuilding) { + query.setParameter("building", building); + } + if (filterOnWarehouse) { + query.setParameter("warehouse", warehouse); + } + query.setParameter("codeForReceptionLocations", Locations.codeForReceptionLocations()); + query.setParameter("codeForWarehouseWithoutLocations", Locations.codeForWarehouseWithoutLocations()); + return (List<Location>) findAll(query); + } + + @Override + public List<Location> findAllWithoutReception(Building building) { + return findAllWithoutReception(building, null); + } + + @Override + public List<Location> findAllWithoutReception(Warehouse warehouse) { + return findAllWithoutReception(null, warehouse); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractMagalieUserJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractMagalieUserJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractMagalieUserJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,52 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.MagalieUser; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractMagalieUserJpaDao<E extends MagalieUser> extends GeneratedMagalieUserJpaDao<E> { + + public AbstractMagalieUserJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public MagalieUser findByLogin(String login) { + TypedQuery<E> query = createQuery("from MagalieUser mu where mu.login = :login"); + query.setParameter("login", login); + return findUnique(query); + } + + @Override + public List<E> findAll() { + Query query = entityManager.createQuery("from MagalieUser mu order by mu.login"); + List<E> resultList = query.getResultList(); + return resultList; + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractPreparedArticleReceptionJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractPreparedArticleReceptionJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractPreparedArticleReceptionJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,20 @@ +package com.franciaflex.magalie.persistence.dao; + +import com.franciaflex.magalie.persistence.entity.PreparedArticleReception; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + +public class AbstractPreparedArticleReceptionJpaDao<E extends PreparedArticleReception> extends GeneratedPreparedArticleReceptionJpaDao<E> { + + public AbstractPreparedArticleReceptionJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public PreparedArticleReception findByBarcode(String barcode) { + TypedQuery<E> query = createQuery("from PreparedArticleReception par where par.barcode = :barcode"); + query.setParameter("barcode", barcode); + return findUniqueOrNull(query); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedArticleJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,65 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.DeliveredRequestedListStatus; +import com.franciaflex.magalie.persistence.entity.MagalieUser; +import com.franciaflex.magalie.persistence.entity.RequestedArticle; +import com.franciaflex.magalie.persistence.entity.RequestedList; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractRequestedArticleJpaDao<E extends RequestedArticle> extends GeneratedRequestedArticleJpaDao<E> { + + public AbstractRequestedArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<RequestedArticle> findAllUndelivered(Building building, MagalieUser affectedTo, String listType) { + TypedQuery<E> query = createQuery( + "from RequestedArticle ra where " + + " ra not in (select dra.requestedArticle from DeliveredRequestedArticle dra) " + + " and ra.requestedList.building = :building " + + " and ra.requestedList.listType = :listType " + + " and ra.requestedList not in (select drl.requestedList from DeliveredRequestedList drl where drl.status = :complete or drl.status = :affected and drl.affectedTo != :affectedTo)"); + query.setParameter("building", building); + query.setParameter("listType", listType); + query.setParameter("complete", DeliveredRequestedListStatus.COMPLETE); + query.setParameter("affected", DeliveredRequestedListStatus.AFFECTED); + query.setParameter("affectedTo", affectedTo); + return (List<RequestedArticle>) findAll(query); + } + + @Override + public List<RequestedArticle> findAll(RequestedList requestedList) { + TypedQuery<E> query = createQuery("from RequestedArticle ra where ra.requestedList = :requestedList"); + query.setParameter("requestedList", requestedList); + return (List<RequestedArticle>) findAll(query); + } + +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedListJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedListJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedListJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,43 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.RequestedList; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractRequestedListJpaDao<E extends RequestedList> extends GeneratedRequestedListJpaDao<E> { + + public AbstractRequestedListJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<String> findAllDistinctListTypes() { + TypedQuery<String> query = entityManager.createQuery("select distinct rl.listType from RequestedList rl", String.class); + return query.getResultList(); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,65 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.StorageMovement; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.List; + +public class AbstractStorageMovementJpaDao<E extends StorageMovement> extends GeneratedStorageMovementJpaDao<E> { + + public AbstractStorageMovementJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<StorageMovement> findAllByArticle(Article article) { + Query query = entityManager.createQuery("from StorageMovement sm where sm.article = :article"); + query.setParameter("article", article); + return query.getResultList(); + } + + @Override + public List<StorageMovement> findAllInReception(Building building) { + Query query = entityManager.createQuery( + " from StorageMovement sm" + + " where sm.originLocation.code = :codeForReceptionLocations and sm.originLocation.warehouse.building = :building" + + " or " + + " sm.destinationLocation.code = :codeForReceptionLocations and sm.destinationLocation.warehouse.building = :building"); + query.setParameter("building", building); + query.setParameter("codeForReceptionLocations", Locations.codeForReceptionLocations()); + return query.getResultList(); + } + + @Override + public List<E> findAll() { + Query query = entityManager.createQuery("from StorageMovement sm order by sm.orderDate"); + return query.getResultList(); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementOrderJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementOrderJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementOrderJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,53 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.MagalieUser; +import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.List; + +public class AbstractStorageMovementOrderJpaDao<E extends StorageMovementOrder> extends GeneratedStorageMovementOrderJpaDao<E> { + + public AbstractStorageMovementOrderJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<StorageMovementOrder> findNotConfirmedByUser(MagalieUser magalieUser, Building building) { + Query query = entityManager.createQuery( + " select distinct smo" + + " from StorageMovementOrder smo" + + " inner join smo.storageMovements as sm" + + " where sm.magalieUser = :magalieUser" + + " and sm.originLocation.warehouse.building = :building" + + " and sm.confirmDate is null"); + query.setParameter("magalieUser", magalieUser); + query.setParameter("building", building); + return query.getResultList(); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStoredArticleJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStoredArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStoredArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,77 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.StoredArticle; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractStoredArticleJpaDao<E extends StoredArticle> extends GeneratedStoredArticleJpaDao<E> { + + public AbstractStoredArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<StoredArticle> findAllForArticleInBuilding(Article article, Building building) { + TypedQuery<E> query = createQuery("from StoredArticle sa where sa.article = :article and sa.location.warehouse.withdrawAllowed = true and sa.location.warehouse.building = :building"); + query.setParameter("article", article); + query.setParameter("building", building); + List<StoredArticle> resultList = (List<StoredArticle>) findAll(query); + for (StoredArticle storedArticle : resultList) { + entityManager.detach(storedArticle); + } + return resultList; + } + + @Override + public List<StoredArticle> findAllReceivedForAllSupplier(Building building) { + TypedQuery<E> query = createQuery("from StoredArticle sa where sa.location.warehouse.building = :building and sa.location.code = :code"); + query.setParameter("building", building); + query.setParameter("code", Locations.codeForReceptionLocations()); + List<StoredArticle> resultList = (List<StoredArticle>) findAll(query); + for (StoredArticle storedArticle : resultList) { + entityManager.detach(storedArticle); + } + return resultList; + } + + @Override + public List<StoredArticle> findAllReceivedForSupplier(Building building, String supplierId) { + TypedQuery<E> query = createQuery("from StoredArticle sa where sa.location.warehouse.building = :building and sa.location.code = :code and sa.article.supplier.id = :supplierId"); + query.setParameter("building", building); + query.setParameter("supplierId", supplierId); + query.setParameter("code", Locations.codeForReceptionLocations()); + List<StoredArticle> resultList = (List<StoredArticle>) findAll(query); + for (StoredArticle storedArticle : resultList) { + entityManager.detach(storedArticle); + } + return resultList; + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractSupplierJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractSupplierJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractSupplierJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,50 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.Location; +import com.franciaflex.magalie.persistence.entity.Supplier; +import com.franciaflex.magalie.persistence.entity.Warehouse; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractSupplierJpaDao<E extends Supplier> extends GeneratedSupplierJpaDao<E> { + + public AbstractSupplierJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<Supplier> findAllWithReceivedArticles(Building building) { + TypedQuery<E> query = createQuery("select sa.article.supplier from StoredArticle sa where sa.location.code = :code and sa.location.warehouse.building = :building"); + query.setParameter(Warehouse.PROPERTY_BUILDING, building); + query.setParameter(Location.PROPERTY_CODE, Locations.codeForReceptionLocations()); + return (List<Supplier>) findAll(query); + } + +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractUnavailableArticleJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractUnavailableArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractUnavailableArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,46 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.UnavailableArticle; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + +public class AbstractUnavailableArticleJpaDao<E extends UnavailableArticle> extends GeneratedUnavailableArticleJpaDao<E> { + + public AbstractUnavailableArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public UnavailableArticle findByArticle(Building building, Article article) { + TypedQuery<E> query = createQuery("from UnavailableArticle ua where ua.article = :article and ua.building = :building"); + query.setParameter(UnavailableArticle.PROPERTY_ARTICLE, article); + query.setParameter(UnavailableArticle.PROPERTY_BUILDING, building); + return findUniqueOrNull(query); + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java (from rev 198, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -0,0 +1,47 @@ +package com.franciaflex.magalie.persistence.dao; + +/* + * #%L + * MagaLiE :: Persistence + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.Warehouse; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.List; + +public class AbstractWarehouseJpaDao<E extends Warehouse> extends GeneratedWarehouseJpaDao<E> { + + public AbstractWarehouseJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<Warehouse> findAllWithoutLocations(Building building) { + TypedQuery<E> query = entityManager.createQuery("from Warehouse w where w.building = :building and w in (select l.warehouse from Location l where l.code = :code)", getEntityClass()); + query.setParameter(Warehouse.PROPERTY_BUILDING, building); + query.setParameter(Warehouse.PROPERTY_CODE, Locations.codeForWarehouseWithoutLocations()); + return (List<Warehouse>) query.getResultList(); + } +} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -24,12 +24,9 @@ */ import com.franciaflex.magalie.persistence.entity.Article; -import org.nuiton.jpa.api.JpaDao; -/** - * @author bleny - */ -public interface ArticleDao extends JpaDao<Article> { +/** @author bleny */ +public interface ArticleDao { Article findByCode(String articleCode); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,43 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Article; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - -public class ArticleJpaDao extends AbstractArticleJpaDao<Article> implements ArticleDao { - - public ArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public Article findByCode(String articleCode) { - TypedQuery<Article> query = createQuery("from Article a where a.code = :code"); - query.setParameter(Article.PROPERTY_CODE, articleCode); - return findUniqueOrNull(query); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/BuildingDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/BuildingDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/BuildingDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,12 +23,7 @@ * #L% */ -import com.franciaflex.magalie.persistence.entity.Building; -import org.nuiton.jpa.api.JpaDao; +/** @author bleny */ +public interface BuildingDao { -/** - * @author bleny - */ -public interface BuildingDao extends JpaDao<Building> { - } Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,14 +26,11 @@ import com.franciaflex.magalie.persistence.entity.DeliveredRequestedArticle; import com.franciaflex.magalie.persistence.entity.RequestedList; import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface DeliveredRequestedArticleDao extends JpaDao<DeliveredRequestedArticle> { +/** @author bleny */ +public interface DeliveredRequestedArticleDao { DeliveredRequestedArticle find(StorageMovementOrder storageMovementOrder); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,57 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.DeliveredRequestedArticle; -import com.franciaflex.magalie.persistence.entity.RequestedList; -import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class DeliveredRequestedArticleJpaDao extends AbstractDeliveredRequestedArticleJpaDao<DeliveredRequestedArticle> implements DeliveredRequestedArticleDao{ - - public DeliveredRequestedArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public DeliveredRequestedArticle find(StorageMovementOrder storageMovementOrder) { - TypedQuery<DeliveredRequestedArticle> query = - entityManager.createQuery( - "from DeliveredRequestedArticle dra where dra.storageMovementOrder = :storageMovementOrder", getEntityClass()); - query.setParameter("storageMovementOrder", storageMovementOrder); - return findUniqueOrNull(query); - } - - @Override - public List<DeliveredRequestedArticle> findAll(RequestedList requestedList) { - TypedQuery<DeliveredRequestedArticle> query = - entityManager.createQuery( - "from DeliveredRequestedArticle dra where dra.requestedArticle.requestedList = :requestedList", getEntityClass()); - query.setParameter("requestedList", requestedList); - return findAll(query); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,12 +26,9 @@ import com.franciaflex.magalie.persistence.entity.DeliveredRequestedList; import com.franciaflex.magalie.persistence.entity.MagalieUser; import com.franciaflex.magalie.persistence.entity.RequestedList; -import org.nuiton.jpa.api.JpaDao; -/** - * @author bleny - */ -public interface DeliveredRequestedListDao extends JpaDao<DeliveredRequestedList> { +/** @author bleny */ +public interface DeliveredRequestedListDao { DeliveredRequestedList findByAffectedTo(MagalieUser affectedTo); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,65 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.DeliveredRequestedList; -import com.franciaflex.magalie.persistence.entity.DeliveredRequestedListStatus; -import com.franciaflex.magalie.persistence.entity.MagalieUser; -import com.franciaflex.magalie.persistence.entity.RequestedList; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - -public class DeliveredRequestedListJpaDao extends AbstractDeliveredRequestedListJpaDao<DeliveredRequestedList> implements DeliveredRequestedListDao{ - - public DeliveredRequestedListJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public DeliveredRequestedList findByAffectedTo(MagalieUser affectedTo) { - - TypedQuery<DeliveredRequestedList> query = createQuery( - "from DeliveredRequestedList drl where drl.status = :affected and drl.affectedTo = :affectedTo"); - - query.setParameter("affectedTo", affectedTo); - - query.setParameter("affected", DeliveredRequestedListStatus.AFFECTED); - - return findUniqueOrNull(query); - - } - - @Override - public DeliveredRequestedList findByRequestedList(RequestedList requestedList) { - - TypedQuery<DeliveredRequestedList> query = createQuery( - "from DeliveredRequestedList drl where drl.requestedList = :requestedList"); - - query.setParameter("requestedList", requestedList); - - return findUniqueOrNull(query); - - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,12 +26,9 @@ import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Kanban; import com.franciaflex.magalie.persistence.entity.Warehouse; -import org.nuiton.jpa.api.JpaDao; -/** - * @author bleny - */ -public interface KanbanDao extends JpaDao<Kanban> { +/** @author bleny */ +public interface KanbanDao { public Kanban find(Article article, Warehouse warehouse); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,46 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Article; -import com.franciaflex.magalie.persistence.entity.Kanban; -import com.franciaflex.magalie.persistence.entity.Warehouse; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - -public class KanbanJpaDao extends AbstractKanbanJpaDao<Kanban> implements KanbanDao{ - - public KanbanJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public Kanban find(Article article, Warehouse warehouse) { - TypedQuery<Kanban> query = entityManager.createQuery("from Kanban k where k.article = :article and k.warehouse = :warehouse", getEntityClass()); - query.setParameter("article", article); - query.setParameter("warehouse", warehouse); - return query.getSingleResult(); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,11 +26,10 @@ import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.Warehouse; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -public interface LocationDao extends JpaDao<Location> { +public interface LocationDao { Location find(String code, Warehouse warehouse); Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,19 +26,16 @@ import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.LocationError; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface LocationErrorDao extends JpaDao<LocationError> { +/** @author bleny */ +public interface LocationErrorDao { LocationError findByLocation(Location location); List<Location> getAllLocationsInError(Article article); - List<LocationError> findAll(); +// List<LocationError> findAll(); } Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,62 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Article; -import com.franciaflex.magalie.persistence.entity.Location; -import com.franciaflex.magalie.persistence.entity.LocationError; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import java.util.List; - -public class LocationErrorJpaDao extends AbstractLocationErrorJpaDao<LocationError> implements LocationErrorDao{ - - public LocationErrorJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public LocationError findByLocation(Location location) { - TypedQuery<LocationError> query = createQuery("from LocationError se where se.location = :location"); - query.setParameter("location", location); - return findUniqueOrNull(query); - } - - @Override - public List<Location> getAllLocationsInError(Article article) { - Query query = entityManager.createQuery("select se.location from LocationError se where se.article = :article"); - query.setParameter("article", article); - List<Location> allLocationsInError = query.getResultList(); - return allLocationsInError; - } - - @Override - public List<LocationError> findAll() { - Query query = entityManager.createQuery("from LocationError se order by se.reportDate"); - List<LocationError> all = query.getResultList(); - return all; - } -} Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,84 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.Locations; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.Location; -import com.franciaflex.magalie.persistence.entity.Warehouse; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class LocationJpaDao extends AbstractLocationJpaDao<Location> implements LocationDao { - - public LocationJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public Location find(String code, Warehouse warehouse) { - TypedQuery<Location> query = createQuery("from Location l where l.code = :code and l.warehouse = :warehouse"); - query.setParameter("code", code); - query.setParameter("warehouse", warehouse); - return findUnique(query); - } - - protected List<Location> findAllWithoutReception(Building building, Warehouse warehouse) { - boolean filterOnBuilding = building != null; - boolean filterOnWarehouse = warehouse != null; - String hql = " from Location l where"; - if (filterOnBuilding) { - hql += " l.warehouse.building = :building and "; - } - if (filterOnWarehouse) { - hql += " l.warehouse = :warehouse and "; - } - hql += " l.code != :codeForReceptionLocations and " - + " l.code != :codeForWarehouseWithoutLocations and " - + " l.fullLocation = false " - + " order by l.warehouse.building.code, l.warehouse.code, l.code"; - TypedQuery<Location> query = createQuery(hql); - if (filterOnBuilding) { - query.setParameter("building", building); - } - if (filterOnWarehouse) { - query.setParameter("warehouse", warehouse); - } - query.setParameter("codeForReceptionLocations", Locations.codeForReceptionLocations()); - query.setParameter("codeForWarehouseWithoutLocations", Locations.codeForWarehouseWithoutLocations()); - return findAll(query); - } - - @Override - public List<Location> findAllWithoutReception(Building building) { - return findAllWithoutReception(building, null); - } - - @Override - public List<Location> findAllWithoutReception(Warehouse warehouse) { - return findAllWithoutReception(null, warehouse); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -24,17 +24,12 @@ */ import com.franciaflex.magalie.persistence.entity.MagalieUser; -import org.nuiton.jpa.api.JpaDao; -import java.util.List; +/** @author bleny */ +public interface MagalieUserDao { -/** - * @author bleny - */ -public interface MagalieUserDao extends JpaDao<MagalieUser> { - MagalieUser findByLogin(String login); - List<MagalieUser> findAll(); +// List<MagalieUser> findAll(); } Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,52 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.MagalieUser; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import java.util.List; - -public class MagalieUserJpaDao extends AbstractMagalieUserJpaDao<MagalieUser> implements MagalieUserDao { - - public MagalieUserJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public MagalieUser findByLogin(String login) { - TypedQuery<MagalieUser> query = createQuery("from MagalieUser mu where mu.login = :login"); - query.setParameter("login", login); - return findUnique(query); - } - - @Override - public List<MagalieUser> findAll() { - Query query = entityManager.createQuery("from MagalieUser mu order by mu.login"); - List<MagalieUser> resultList = query.getResultList(); - return resultList; - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,12 +1,9 @@ package com.franciaflex.magalie.persistence.dao; import com.franciaflex.magalie.persistence.entity.PreparedArticleReception; -import org.nuiton.jpa.api.JpaDao; -/** - * @author bleny - */ -public interface PreparedArticleReceptionDao extends JpaDao<PreparedArticleReception> { +/** @author bleny */ +public interface PreparedArticleReceptionDao { PreparedArticleReception findByBarcode(String barcode); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,20 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -import com.franciaflex.magalie.persistence.entity.PreparedArticleReception; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - -public class PreparedArticleReceptionJpaDao extends AbstractPreparedArticleReceptionJpaDao<PreparedArticleReception> implements PreparedArticleReceptionDao{ - - public PreparedArticleReceptionJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public PreparedArticleReception findByBarcode(String barcode) { - TypedQuery<PreparedArticleReception> query = createQuery("from PreparedArticleReception par where par.barcode = :barcode"); - query.setParameter("barcode", barcode); - return findUniqueOrNull(query); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -27,14 +27,11 @@ import com.franciaflex.magalie.persistence.entity.MagalieUser; import com.franciaflex.magalie.persistence.entity.RequestedArticle; import com.franciaflex.magalie.persistence.entity.RequestedList; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface RequestedArticleDao extends JpaDao<RequestedArticle> { +/** @author bleny */ +public interface RequestedArticleDao { List<RequestedArticle> findAllUndelivered(Building building, MagalieUser affectedTo, String listType); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,65 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.DeliveredRequestedListStatus; -import com.franciaflex.magalie.persistence.entity.MagalieUser; -import com.franciaflex.magalie.persistence.entity.RequestedArticle; -import com.franciaflex.magalie.persistence.entity.RequestedList; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class RequestedArticleJpaDao extends AbstractRequestedArticleJpaDao<RequestedArticle> implements RequestedArticleDao{ - - public RequestedArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<RequestedArticle> findAllUndelivered(Building building, MagalieUser affectedTo, String listType) { - TypedQuery<RequestedArticle> query = createQuery( - "from RequestedArticle ra where " - + " ra not in (select dra.requestedArticle from DeliveredRequestedArticle dra) " - + " and ra.requestedList.building = :building " - + " and ra.requestedList.listType = :listType " - + " and ra.requestedList not in (select drl.requestedList from DeliveredRequestedList drl where drl.status = :complete or drl.status = :affected and drl.affectedTo != :affectedTo)"); - query.setParameter("building", building); - query.setParameter("listType", listType); - query.setParameter("complete", DeliveredRequestedListStatus.COMPLETE); - query.setParameter("affected", DeliveredRequestedListStatus.AFFECTED); - query.setParameter("affectedTo", affectedTo); - return findAll(query); - } - - @Override - public List<RequestedArticle> findAll(RequestedList requestedList) { - TypedQuery<RequestedArticle> query = createQuery("from RequestedArticle ra where ra.requestedList = :requestedList"); - query.setParameter("requestedList", requestedList); - return findAll(query); - } - -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,15 +23,10 @@ * #L% */ -import com.franciaflex.magalie.persistence.entity.RequestedList; -import org.nuiton.jpa.api.JpaDao; - import java.util.List; -/** - * @author bleny - */ -public interface RequestedListDao extends JpaDao<RequestedList> { +/** @author bleny */ +public interface RequestedListDao { List<String> findAllDistinctListTypes(); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,43 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.RequestedList; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class RequestedListJpaDao extends AbstractRequestedListJpaDao<RequestedList> implements RequestedListDao{ - - public RequestedListJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<String> findAllDistinctListTypes() { - TypedQuery<String> query = entityManager.createQuery("select distinct rl.listType from RequestedList rl", String.class); - return query.getResultList(); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,18 +26,15 @@ import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.StorageMovement; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface StorageMovementDao extends JpaDao<StorageMovement> { +/** @author bleny */ +public interface StorageMovementDao { List<StorageMovement> findAllByArticle(Article article); - List<StorageMovement> findAll(); +// List<StorageMovement> findAll(); List<StorageMovement> findAllInReception(Building building); } Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,65 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.Locations; -import com.franciaflex.magalie.persistence.entity.Article; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.StorageMovement; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.List; - -public class StorageMovementJpaDao extends AbstractStorageMovementJpaDao<StorageMovement> implements StorageMovementDao{ - - public StorageMovementJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<StorageMovement> findAllByArticle(Article article) { - Query query = entityManager.createQuery("from StorageMovement sm where sm.article = :article"); - query.setParameter("article", article); - return query.getResultList(); - } - - @Override - public List<StorageMovement> findAllInReception(Building building) { - Query query = entityManager.createQuery( - " from StorageMovement sm" + - " where sm.originLocation.code = :codeForReceptionLocations and sm.originLocation.warehouse.building = :building" + - " or " + - " sm.destinationLocation.code = :codeForReceptionLocations and sm.destinationLocation.warehouse.building = :building"); - query.setParameter("building", building); - query.setParameter("codeForReceptionLocations", Locations.codeForReceptionLocations()); - return query.getResultList(); - } - - @Override - public List<StorageMovement> findAll() { - Query query = entityManager.createQuery("from StorageMovement sm order by sm.orderDate"); - return query.getResultList(); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,11 +26,10 @@ import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.MagalieUser; import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -public interface StorageMovementOrderDao extends JpaDao<StorageMovementOrder> { +public interface StorageMovementOrderDao { public List<StorageMovementOrder> findNotConfirmedByUser(MagalieUser magalieUser, Building building); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,53 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.MagalieUser; -import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.List; - -public class StorageMovementOrderJpaDao extends AbstractStorageMovementOrderJpaDao<StorageMovementOrder> implements StorageMovementOrderDao{ - - public StorageMovementOrderJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<StorageMovementOrder> findNotConfirmedByUser(MagalieUser magalieUser, Building building) { - Query query = entityManager.createQuery( - " select distinct smo" + - " from StorageMovementOrder smo" + - " inner join smo.storageMovements as sm" + - " where sm.magalieUser = :magalieUser" + - " and sm.originLocation.warehouse.building = :building" + - " and sm.confirmDate is null"); - query.setParameter("magalieUser", magalieUser); - query.setParameter("building", building); - return query.getResultList(); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,11 +26,10 @@ import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.StoredArticle; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -public interface StoredArticleDao extends JpaDao<StoredArticle> { +public interface StoredArticleDao { List<StoredArticle> findAllForArticleInBuilding(Article article, Building building); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,77 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.Locations; -import com.franciaflex.magalie.persistence.entity.Article; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.StoredArticle; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class StoredArticleJpaDao extends AbstractStoredArticleJpaDao<StoredArticle> implements StoredArticleDao { - - public StoredArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<StoredArticle> findAllForArticleInBuilding(Article article, Building building) { - TypedQuery<StoredArticle> query = createQuery("from StoredArticle sa where sa.article = :article and sa.location.warehouse.withdrawAllowed = true and sa.location.warehouse.building = :building"); - query.setParameter("article", article); - query.setParameter("building", building); - List<StoredArticle> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } - - @Override - public List<StoredArticle> findAllReceivedForAllSupplier(Building building) { - TypedQuery<StoredArticle> query = createQuery("from StoredArticle sa where sa.location.warehouse.building = :building and sa.location.code = :code"); - query.setParameter("building", building); - query.setParameter("code", Locations.codeForReceptionLocations()); - List<StoredArticle> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } - - @Override - public List<StoredArticle> findAllReceivedForSupplier(Building building, String supplierId) { - TypedQuery<StoredArticle> query = createQuery("from StoredArticle sa where sa.location.warehouse.building = :building and sa.location.code = :code and sa.article.supplier.id = :supplierId"); - query.setParameter("building", building); - query.setParameter("supplierId", supplierId); - query.setParameter("code", Locations.codeForReceptionLocations()); - List<StoredArticle> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -25,14 +25,11 @@ import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Supplier; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface SupplierDao extends JpaDao<Supplier> { +/** @author bleny */ +public interface SupplierDao { List<Supplier> findAllWithReceivedArticles(Building building); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,50 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.Locations; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.Location; -import com.franciaflex.magalie.persistence.entity.Supplier; -import com.franciaflex.magalie.persistence.entity.Warehouse; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class SupplierJpaDao extends AbstractSupplierJpaDao<Supplier> implements SupplierDao{ - - public SupplierJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<Supplier> findAllWithReceivedArticles(Building building) { - TypedQuery<Supplier> query = createQuery("select sa.article.supplier from StoredArticle sa where sa.location.code = :code and sa.location.warehouse.building = :building"); - query.setParameter(Warehouse.PROPERTY_BUILDING, building); - query.setParameter(Location.PROPERTY_CODE, Locations.codeForReceptionLocations()); - return findAll(query); - } - -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,12 +26,9 @@ import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.UnavailableArticle; -import org.nuiton.jpa.api.JpaDao; -/** - * @author bleny - */ -public interface UnavailableArticleDao extends JpaDao<UnavailableArticle> { +/** @author bleny */ +public interface UnavailableArticleDao { UnavailableArticle findByArticle(Building building, Article article); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,46 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.entity.Article; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.UnavailableArticle; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - -public class UnavailableArticleJpaDao extends AbstractUnavailableArticleJpaDao<UnavailableArticle> implements UnavailableArticleDao{ - - public UnavailableArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public UnavailableArticle findByArticle(Building building, Article article) { - TypedQuery<UnavailableArticle> query = createQuery("from UnavailableArticle ua where ua.article = :article and ua.building = :building"); - query.setParameter(UnavailableArticle.PROPERTY_ARTICLE, article); - query.setParameter(UnavailableArticle.PROPERTY_BUILDING, building); - return findUniqueOrNull(query); - } -} Modified: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -25,14 +25,11 @@ import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Warehouse; -import org.nuiton.jpa.api.JpaDao; import java.util.List; -/** - * @author bleny - */ -public interface WarehouseDao extends JpaDao<Warehouse> { +/** @author bleny */ +public interface WarehouseDao { List<Warehouse> findAllWithoutLocations(Building building); Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java 2013-05-27 21:29:10 UTC (rev 199) @@ -1,47 +0,0 @@ -package com.franciaflex.magalie.persistence.dao; - -/* - * #%L - * MagaLiE :: Persistence - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.franciaflex.magalie.persistence.Locations; -import com.franciaflex.magalie.persistence.entity.Building; -import com.franciaflex.magalie.persistence.entity.Warehouse; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import java.util.List; - -public class WarehouseJpaDao extends AbstractWarehouseJpaDao<Warehouse> implements WarehouseDao { - - public WarehouseJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<Warehouse> findAllWithoutLocations(Building building) { - TypedQuery<Warehouse> query = entityManager.createQuery("from Warehouse w where w.building = :building and w in (select l.warehouse from Location l where l.code = :code)", getEntityClass()); - query.setParameter(Warehouse.PROPERTY_BUILDING, building); - query.setParameter(Warehouse.PROPERTY_CODE, Locations.codeForWarehouseWithoutLocations()); - return query.getResultList(); - } -} Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -25,14 +25,30 @@ import com.franciaflex.magalie.persistence.MagaliePersistenceContext; import com.franciaflex.magalie.persistence.StoredArticles; -import com.franciaflex.magalie.persistence.dao.*; -import com.franciaflex.magalie.persistence.entity.*; +import com.franciaflex.magalie.persistence.dao.LocationJpaDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementOrderJpaDao; +import com.franciaflex.magalie.persistence.dao.StoredArticleDao; +import com.franciaflex.magalie.persistence.dao.UnavailableArticleJpaDao; +import com.franciaflex.magalie.persistence.entity.Article; +import com.franciaflex.magalie.persistence.entity.Building; +import com.franciaflex.magalie.persistence.entity.Location; +import com.franciaflex.magalie.persistence.entity.MagalieUser; +import com.franciaflex.magalie.persistence.entity.StorageMovement; +import com.franciaflex.magalie.persistence.entity.StorageMovementOrder; +import com.franciaflex.magalie.persistence.entity.StoredArticle; +import com.franciaflex.magalie.persistence.entity.UnavailableArticle; import com.franciaflex.magalie.services.MagalieService; import com.franciaflex.magalie.services.MagalieServiceContext; import com.franciaflex.magalie.services.StorageMovementConfirmation; import com.franciaflex.magalie.services.StorageMovementTask; import com.google.common.base.Preconditions; -import com.google.common.collect.*; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; +import com.google.common.collect.Sets; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -96,7 +112,7 @@ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder(); - StorageMovementOrderDao dao = persistenceContext.getStorageMovementOrderDao(); + StorageMovementOrderJpaDao dao = persistenceContext.getStorageMovementOrderDao(); dao.persist(storageMovementOrder); @@ -110,9 +126,7 @@ } - /** - * Add or remove a line in table {@link UnavailableArticle} - */ + /** Add or remove a line in table {@link UnavailableArticle} */ protected void updateArticleAvailability(BookArticleResult bookArticleResult) { BookArticleRequest bookArticleRequest = bookArticleResult.getBookArticleRequest(); @@ -123,11 +137,11 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - UnavailableArticleDao dao = persistenceContext.getUnavailableArticleDao(); + UnavailableArticleJpaDao dao = persistenceContext.getUnavailableArticleDao(); UnavailableArticle unavailableArticle = dao.findByArticle(building, article); - boolean articleIsAvailable = ! bookArticleResult.isArticleUnavailable(); + boolean articleIsAvailable = !bookArticleResult.isArticleUnavailable(); if (articleIsAvailable) { @@ -231,8 +245,8 @@ if (bookArticleRequest.isBestEffortPolicy()) { log.debug("best effort policy, requested quantity was " - + requestedQuantity + " but only " + quantity + - " available"); + + requestedQuantity + " but only " + quantity + + " available"); } else { @@ -274,7 +288,7 @@ public StorageMovementTask getStorageMovementTask(String storageMovementOrderId) { - StorageMovementOrderDao dao = serviceContext.getPersistenceContext().getStorageMovementOrderDao(); + StorageMovementOrderJpaDao dao = serviceContext.getPersistenceContext().getStorageMovementOrderDao(); StorageMovementOrder storageMovementOrder = dao.findById(storageMovementOrderId); @@ -297,7 +311,7 @@ Location location = storedArticle.getLocation(); - if ( ! locationsInOrder.contains(location)) { + if (!locationsInOrder.contains(location)) { StorageMovement newStorageMovement = new StorageMovement(); @@ -316,9 +330,7 @@ } - /** - * Get a snapshot of the actual current state of the stock. - */ + /** Get a snapshot of the actual current state of the stock. */ protected Iterable<StoredArticle> getStoredArticles(Building building, Article article) { MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); @@ -389,10 +401,10 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - StorageMovementOrderDao storageMovementOrderDao = + StorageMovementOrderJpaDao storageMovementOrderDao = persistenceContext.getStorageMovementOrderDao(); - LocationDao locationDao = persistenceContext.getLocationDao(); + LocationJpaDao locationDao = persistenceContext.getLocationDao(); StorageMovementOrder storageMovementOrder = storageMovementOrderDao.findById( @@ -464,7 +476,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - StorageMovementOrderDao storageMovementOrderDao = + StorageMovementOrderJpaDao storageMovementOrderDao = persistenceContext.getStorageMovementOrderDao(); StorageMovementOrder storageMovementOrder = storageMovementOrderDao.findById(storageMovementOrderId); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,7 +23,7 @@ * #L% */ -import com.franciaflex.magalie.persistence.dao.BuildingDao; +import com.franciaflex.magalie.persistence.dao.BuildingJpaDao; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.services.MagalieService; import com.franciaflex.magalie.services.MagalieServiceContext; @@ -41,7 +41,7 @@ public List<Building> getAllBuildings() { - BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao(); + BuildingJpaDao dao = serviceContext.getPersistenceContext().getBuildingDao(); return dao.findAll(); @@ -49,7 +49,7 @@ public Building getBuilding(String buildingId) { - BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao(); + BuildingJpaDao dao = serviceContext.getPersistenceContext().getBuildingDao(); return dao.findById(buildingId); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -24,17 +24,17 @@ */ import com.franciaflex.magalie.persistence.MagaliePersistenceContext; -import com.franciaflex.magalie.persistence.dao.ArticleDao; -import com.franciaflex.magalie.persistence.dao.BuildingDao; -import com.franciaflex.magalie.persistence.dao.KanbanDao; -import com.franciaflex.magalie.persistence.dao.LocationDao; -import com.franciaflex.magalie.persistence.dao.MagalieUserDao; -import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionDao; -import com.franciaflex.magalie.persistence.dao.RequestedArticleDao; -import com.franciaflex.magalie.persistence.dao.RequestedListDao; -import com.franciaflex.magalie.persistence.dao.StoredArticleDao; -import com.franciaflex.magalie.persistence.dao.SupplierDao; -import com.franciaflex.magalie.persistence.dao.WarehouseDao; +import com.franciaflex.magalie.persistence.dao.ArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.BuildingJpaDao; +import com.franciaflex.magalie.persistence.dao.KanbanJpaDao; +import com.franciaflex.magalie.persistence.dao.LocationJpaDao; +import com.franciaflex.magalie.persistence.dao.MagalieUserJpaDao; +import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionJpaDao; +import com.franciaflex.magalie.persistence.dao.RequestedArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.RequestedListJpaDao; +import com.franciaflex.magalie.persistence.dao.StoredArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.SupplierJpaDao; +import com.franciaflex.magalie.persistence.dao.WarehouseJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Kanban; @@ -108,7 +108,7 @@ } - MagalieUserDao magalieUserDao = persistenceContext.getMagalieUserDao(); + MagalieUserJpaDao magalieUserDao = persistenceContext.getMagalieUserDao(); Collection<MagalieUser> users = fixtures.fixture("users"); @@ -118,7 +118,7 @@ } - BuildingDao buildingDao = persistenceContext.getBuildingDao(); + BuildingJpaDao buildingDao = persistenceContext.getBuildingDao(); Collection<Building> buildings = fixtures.fixture("buildings"); @@ -128,7 +128,7 @@ } - WarehouseDao warehouseDao = persistenceContext.getWarehouseDao(); + WarehouseJpaDao warehouseDao = persistenceContext.getWarehouseDao(); Collection<Warehouse> warehouses = fixtures.fixture("warehouses"); @@ -140,7 +140,7 @@ persistenceContext.commit(); - LocationDao locationDao = persistenceContext.getLocationDao(); + LocationJpaDao locationDao = persistenceContext.getLocationDao(); Collection<Location> locations = fixtures.fixture("locations"); @@ -152,7 +152,7 @@ persistenceContext.commit(); - SupplierDao supplierDao = persistenceContext.getSupplierDao(); + SupplierJpaDao supplierDao = persistenceContext.getSupplierDao(); Collection<Supplier> suppliers = fixtures.fixture("suppliers"); @@ -164,7 +164,7 @@ persistenceContext.commit(); - ArticleDao articleDao = persistenceContext.getArticleDao(); + ArticleJpaDao articleDao = persistenceContext.getArticleDao(); Collection<Article> articles = fixtures.fixture("articles"); @@ -174,7 +174,7 @@ } - KanbanDao kanbanDao = persistenceContext.getKanbanDao(); + KanbanJpaDao kanbanDao = persistenceContext.getKanbanDao(); Collection<Kanban> kanbans = fixtures.fixture("kanbans"); @@ -186,7 +186,7 @@ persistenceContext.commit(); - StoredArticleDao storedArticleDao = persistenceContext.getStoredArticleDao(); + StoredArticleJpaDao storedArticleDao = persistenceContext.getStoredArticleDao(); Collection<StoredArticle> storedArticles = fixtures.fixture("storedArticles"); @@ -198,7 +198,7 @@ persistenceContext.commit(); - RequestedListDao requestedListDao = persistenceContext.getRequestedListDao(); + RequestedListJpaDao requestedListDao = persistenceContext.getRequestedListDao(); Collection<RequestedList> requestedLists = fixtures.fixture("requestedLists"); @@ -210,7 +210,7 @@ persistenceContext.commit(); - RequestedArticleDao requestedArticleDao = persistenceContext.getRequestedArticleDao(); + RequestedArticleJpaDao requestedArticleDao = persistenceContext.getRequestedArticleDao(); Collection<RequestedArticle> requestedArticles = fixtures.fixture("requestedArticles"); @@ -222,7 +222,7 @@ persistenceContext.commit(); - PreparedArticleReceptionDao preparedArticleReceptionDao = persistenceContext.getPreparedArticleReceptionDao(); + PreparedArticleReceptionJpaDao preparedArticleReceptionDao = persistenceContext.getPreparedArticleReceptionDao(); Collection<PreparedArticleReception> preparedArticleReceptions = fixtures.fixture("preparedArticleReceptions"); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -28,6 +28,7 @@ import com.franciaflex.magalie.persistence.dao.KanbanDao; import com.franciaflex.magalie.persistence.dao.LocationDao; import com.franciaflex.magalie.persistence.dao.WarehouseDao; +import com.franciaflex.magalie.persistence.dao.WarehouseJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Kanban; @@ -57,7 +58,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - WarehouseDao warehouseDao = persistenceContext.getWarehouseDao(); + WarehouseJpaDao warehouseDao = persistenceContext.getWarehouseDao(); Warehouse warehouse = warehouseDao.findById(storeId); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,7 +23,7 @@ * #L% */ -import com.franciaflex.magalie.persistence.dao.LocationErrorDao; +import com.franciaflex.magalie.persistence.dao.LocationErrorJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.LocationError; @@ -57,7 +57,7 @@ public void reportError(Location location, Article article, MagalieUser magalieUser, Date reportDate) { - LocationErrorDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); + LocationErrorJpaDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); LocationError existingLocationError = locationErrorDao.findByLocation(location); @@ -88,7 +88,7 @@ public List<Location> getAllLocationsInError(Article article) { - LocationErrorDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); + LocationErrorJpaDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); List<Location> allLocationsInError = locationErrorDao.getAllLocationsInError(article); @@ -98,7 +98,7 @@ public List<LocationError> getAllLocationErrors() { - LocationErrorDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); + LocationErrorJpaDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); List<LocationError> allLocationErrors = locationErrorDao.findAll(); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/MagalieUsersService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/MagalieUsersService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/MagalieUsersService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -23,7 +23,7 @@ * #L% */ -import com.franciaflex.magalie.persistence.dao.MagalieUserDao; +import com.franciaflex.magalie.persistence.dao.MagalieUserJpaDao; import com.franciaflex.magalie.persistence.entity.MagalieUser; import com.franciaflex.magalie.services.MagalieService; import com.franciaflex.magalie.services.MagalieServiceContext; @@ -42,7 +42,7 @@ public MagalieUser getMagalieUser(String login) { - MagalieUserDao dao = serviceContext.getPersistenceContext().getMagalieUserDao(); + MagalieUserJpaDao dao = serviceContext.getPersistenceContext().getMagalieUserDao(); MagalieUser magalieUser = dao.findByLogin(login); @@ -54,7 +54,7 @@ public List<MagalieUser> getAllMagalieUsers() { - MagalieUserDao dao = serviceContext.getPersistenceContext().getMagalieUserDao(); + MagalieUserJpaDao dao = serviceContext.getPersistenceContext().getMagalieUserDao(); List<MagalieUser> allMagalieUsers = dao.findAll(); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -28,9 +28,12 @@ import com.franciaflex.magalie.persistence.StorageMovements; import com.franciaflex.magalie.persistence.StoredArticles; import com.franciaflex.magalie.persistence.dao.LocationDao; -import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionDao; +import com.franciaflex.magalie.persistence.dao.LocationJpaDao; +import com.franciaflex.magalie.persistence.dao.PreparedArticleReceptionJpaDao; import com.franciaflex.magalie.persistence.dao.StorageMovementDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementJpaDao; import com.franciaflex.magalie.persistence.dao.StoredArticleDao; +import com.franciaflex.magalie.persistence.dao.StoredArticleJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Location; @@ -69,10 +72,10 @@ Iterable<Supplier> suppliers = Sets.newHashSet( // to prevent multiple occurrence of the same supplier - Iterables.transform( - allReceivedArticles, - StoredArticles.getArticleSupplierFunction() - ) + Iterables.transform( + allReceivedArticles, + StoredArticles.getArticleSupplierFunction() + ) ); SuppliersToReceive suppliersToReceive = new SuppliersToReceive(suppliers); @@ -148,7 +151,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - StoredArticleDao storedArticleDao = persistenceContext.getStoredArticleDao(); + StoredArticleJpaDao storedArticleDao = persistenceContext.getStoredArticleDao(); StoredArticle storedArticle = storedArticleDao.findById(storedArticleId); @@ -258,15 +261,15 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - StoredArticleDao storedArticleDao = + StoredArticleJpaDao storedArticleDao = persistenceContext.getStoredArticleDao(); StoredArticle storedArticle = storedArticleDao.findById(storedArticleId); - LocationDao locationDao = persistenceContext.getLocationDao(); + LocationJpaDao locationDao = persistenceContext.getLocationDao(); - StorageMovementDao storageMovementDao = persistenceContext.getStorageMovementDao(); + StorageMovementJpaDao storageMovementDao = persistenceContext.getStorageMovementDao(); Date now = serviceContext.getNow(); @@ -303,7 +306,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - PreparedArticleReceptionDao dao = + PreparedArticleReceptionJpaDao dao = persistenceContext.getPreparedArticleReceptionDao(); PreparedArticleReception preparedArticleReception = Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReportService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReportService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReportService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -24,8 +24,8 @@ */ import com.franciaflex.magalie.persistence.MagaliePersistenceContext; -import com.franciaflex.magalie.persistence.dao.StorageMovementDao; -import com.franciaflex.magalie.persistence.dao.UnavailableArticleDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementJpaDao; +import com.franciaflex.magalie.persistence.dao.UnavailableArticleJpaDao; import com.franciaflex.magalie.persistence.entity.DeliveredRequestedList; import com.franciaflex.magalie.persistence.entity.LocationError; import com.franciaflex.magalie.persistence.entity.MagalieUser; @@ -62,7 +62,7 @@ magalieReport.setAllMagalieUsers(allMagalieUsers); - StorageMovementDao storageMovementDao = persistenceContext.getStorageMovementDao(); + StorageMovementJpaDao storageMovementDao = persistenceContext.getStorageMovementDao(); List<StorageMovement> allStorageMovements = storageMovementDao.findAll(); @@ -80,7 +80,7 @@ magalieReport.setAllDeliveredRequestedLists(allDeliveredRequestedLists); - UnavailableArticleDao unavailableArticleDao = persistenceContext.getUnavailableArticleDao(); + UnavailableArticleJpaDao unavailableArticleDao = persistenceContext.getUnavailableArticleDao(); magalieReport.setAllUnavailableArticles(unavailableArticleDao.findAll()); Modified: branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java =================================================================== --- branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-05-27 21:29:10 UTC (rev 199) @@ -26,11 +26,13 @@ import com.franciaflex.magalie.persistence.DeliveredRequestedArticles; import com.franciaflex.magalie.persistence.MagaliePersistenceContext; import com.franciaflex.magalie.persistence.RequestedArticles; -import com.franciaflex.magalie.persistence.dao.DeliveredRequestedArticleDao; +import com.franciaflex.magalie.persistence.dao.DeliveredRequestedArticleJpaDao; import com.franciaflex.magalie.persistence.dao.DeliveredRequestedListDao; +import com.franciaflex.magalie.persistence.dao.DeliveredRequestedListJpaDao; import com.franciaflex.magalie.persistence.dao.RequestedArticleDao; -import com.franciaflex.magalie.persistence.dao.RequestedListDao; -import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao; +import com.franciaflex.magalie.persistence.dao.RequestedArticleJpaDao; +import com.franciaflex.magalie.persistence.dao.RequestedListJpaDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementOrderJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.DeliveredRequestedArticle; @@ -111,7 +113,7 @@ boolean somethingIsAvailable = false; - while ( ! success && requestedArticleIterator.hasNext()) { + while (!success && requestedArticleIterator.hasNext()) { requestedArticle = requestedArticleIterator.next(); @@ -125,7 +127,7 @@ bookArticleResult = articleStorageService.bookArticle(bookArticleRequest); - boolean articleIsAvailable = ! bookArticleResult.isArticleUnavailable(); + boolean articleIsAvailable = !bookArticleResult.isArticleUnavailable(); if (articleIsAvailable) { @@ -151,7 +153,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - DeliveredRequestedArticleDao dao = persistenceContext.getDeliveredRequestedArticleDao(); + DeliveredRequestedArticleJpaDao dao = persistenceContext.getDeliveredRequestedArticleDao(); DeliveredRequestedArticle newDeliveredRequestedArticle = new DeliveredRequestedArticle(); @@ -166,7 +168,7 @@ findOrderToExecuteResult.setStorageMovementOrder(storageMovementOrder); // deal with affectations - DeliveredRequestedListDao deliveredRequestedListDao = + DeliveredRequestedListJpaDao deliveredRequestedListDao = persistenceContext.getDeliveredRequestedListDao(); DeliveredRequestedList oldAffectation = @@ -207,23 +209,23 @@ log.info("user is affected to " + oldAffectation.getRequestedList().getCode()); } - boolean affectationChanged = ! oldAffectation.getRequestedList().equals(requestedList); + boolean affectationChanged = !oldAffectation.getRequestedList().equals(requestedList); if (affectationChanged) { if (log.isInfoEnabled()) { log.info("user changed affectation from " - + oldAffectation.getRequestedList().getCode() - + " to " + requestedList.getCode()); + + oldAffectation.getRequestedList().getCode() + + " to " + requestedList.getCode()); } boolean isFinished = oldAffectation.getStatus().equals(DeliveredRequestedListStatus.COMPLETE); - if ( ! isFinished) { + if (!isFinished) { if (log.isInfoEnabled()) { log.info("request list " + oldAffectation.getRequestedList() - + " is not complete, putting it back to pending"); + + " is not complete, putting it back to pending"); } oldAffectation.setStatus(DeliveredRequestedListStatus.PENDING); @@ -270,7 +272,7 @@ log.info("no order to execute found: everything is unavailable"); } - Preconditions.checkState( ! driverLicenseRequired); + Preconditions.checkState(!driverLicenseRequired); findOrderToExecuteResult.setEverythingUnavailable(true); @@ -317,7 +319,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - DeliveredRequestedListDao dao = persistenceContext.getDeliveredRequestedListDao(); + DeliveredRequestedListJpaDao dao = persistenceContext.getDeliveredRequestedListDao(); List<DeliveredRequestedList> all = dao.findAll(); @@ -338,10 +340,10 @@ RequestedList requestedList = deliveredRequestedList.getRequestedList(); - RequestedArticleDao requestedArticleDao = + RequestedArticleJpaDao requestedArticleDao = persistenceContext.getRequestedArticleDao(); - DeliveredRequestedArticleDao deliveredRequestedArticleDao = + DeliveredRequestedArticleJpaDao deliveredRequestedArticleDao = persistenceContext.getDeliveredRequestedArticleDao(); List<RequestedArticle> requestedArticles = @@ -351,15 +353,15 @@ deliveredRequestedArticleDao.findAll(requestedList); boolean allIsConfirmed = deliveredRequestedArticles.size() == requestedArticles.size() - && Iterables.all( - deliveredRequestedArticles, - DeliveredRequestedArticles.isConfirmedPredicate()); + && Iterables.all( + deliveredRequestedArticles, + DeliveredRequestedArticles.isConfirmedPredicate()); if (allIsConfirmed) { if (log.isInfoEnabled()) { log.info("all requested articles have confirmed order, marking list " - + requestedList.getCode() + " as complete"); + + requestedList.getCode() + " as complete"); } deliveredRequestedList.setStatus(DeliveredRequestedListStatus.COMPLETE); @@ -385,8 +387,8 @@ if (log.isInfoEnabled()) { log.info("user " + magalieUser.getLogin() + - " is no longer affected to list " + - deliveredRequestedList.getRequestedList().getCode()); + " is no longer affected to list " + + deliveredRequestedList.getRequestedList().getCode()); } deliveredRequestedList.setAffectedTo(null); @@ -403,7 +405,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - DeliveredRequestedListDao dao = persistenceContext.getDeliveredRequestedListDao(); + DeliveredRequestedListJpaDao dao = persistenceContext.getDeliveredRequestedListDao(); DeliveredRequestedList deliveredRequestedList = dao.findByAffectedTo(magalieUser); @@ -423,7 +425,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - RequestedListDao dao = persistenceContext.getRequestedListDao(); + RequestedListJpaDao dao = persistenceContext.getRequestedListDao(); List<String> allDistinctListTypes = dao.findAllDistinctListTypes(); @@ -431,18 +433,16 @@ } - /** - * @return null if storage movement order is not about a requested-list (for example, kanban) - */ + /** @return null if storage movement order is not about a requested-list (for example, kanban) */ public DeliveredRequestedList getDeliveredRequestedList(String storageMovementOrderId) { MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - DeliveredRequestedArticleDao deliveredRequestedArticleDao = + DeliveredRequestedArticleJpaDao deliveredRequestedArticleDao = persistenceContext.getDeliveredRequestedArticleDao(); - StorageMovementOrderDao storageMovementOrderDao = + StorageMovementOrderJpaDao storageMovementOrderDao = persistenceContext.getStorageMovementOrderDao(); StorageMovementOrder storageMovementOrder = @@ -458,7 +458,7 @@ RequestedList requestedList = deliveredRequestedArticle.getRequestedArticle().getRequestedList(); - DeliveredRequestedListDao deliveredRequestedListDao = + DeliveredRequestedListJpaDao deliveredRequestedListDao = persistenceContext.getDeliveredRequestedListDao(); deliveredRequestedList = @@ -475,7 +475,7 @@ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); - DeliveredRequestedArticleDao deliveredRequestedArticleDao = + DeliveredRequestedArticleJpaDao deliveredRequestedArticleDao = persistenceContext.getDeliveredRequestedArticleDao(); DeliveredRequestedArticle deliveredRequestedArticle = Modified: branches/magalie-eugene/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java =================================================================== --- branches/magalie-eugene/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java 2013-05-27 14:32:50 UTC (rev 198) +++ branches/magalie-eugene/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java 2013-05-27 21:29:10 UTC (rev 199) @@ -25,6 +25,7 @@ import com.franciaflex.magalie.persistence.Locations; import com.franciaflex.magalie.persistence.dao.StorageMovementDao; +import com.franciaflex.magalie.persistence.dao.StorageMovementJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Building; import com.franciaflex.magalie.persistence.entity.Location; @@ -192,7 +193,7 @@ service.confirmReception(magalieUser, receptionConfirmation); - StorageMovementDao storageMovementDao = serviceContext.getPersistenceContext().getStorageMovementDao(); + StorageMovementJpaDao storageMovementDao = serviceContext.getPersistenceContext().getStorageMovementDao(); List<StorageMovement> storageMovements = storageMovementDao.findAll();