Author: tchemit Date: 2013-05-29 15:24:06 +0200 (Wed, 29 May 2013) New Revision: 212 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: remove generic from dao Added: 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 Removed: 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 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/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/pom.xml Deleted: 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/AbstractArticleJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractArticleJpaDao<E extends Article> extends GeneratedArticleJpaDao<E> { - - public AbstractArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E findByCode(String articleCode) { - TypedQuery<E> query = createQuery("from Article a where a.code = :code"); - query.setParameter(Article.PROPERTY_CODE, articleCode); - return findUniqueOrNull(query); - } -} Deleted: 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/AbstractDeliveredRequestedArticleJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractDeliveredRequestedArticleJpaDao<E extends DeliveredRequestedArticle> extends GeneratedDeliveredRequestedArticleJpaDao<E> { - - public AbstractDeliveredRequestedArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E find(StorageMovementOrder storageMovementOrder) { - TypedQuery<E> query = - createQuery( - "from DeliveredRequestedArticle dra where dra.storageMovementOrder = :storageMovementOrder"); - query.setParameter("storageMovementOrder", storageMovementOrder); - return findUniqueOrNull(query); - } - - @Override - public List<E> findAll(RequestedList requestedList) { - TypedQuery<E> query = - createQuery( - "from DeliveredRequestedArticle dra where dra.requestedArticle.requestedList = :requestedList"); - query.setParameter("requestedList", requestedList); - return findAll(query); - } -} Deleted: 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/AbstractDeliveredRequestedListJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractDeliveredRequestedListJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractDeliveredRequestedListJpaDao<E extends DeliveredRequestedList> extends GeneratedDeliveredRequestedListJpaDao<E> { - - public AbstractDeliveredRequestedListJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E 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 E findByRequestedList(RequestedList requestedList) { - - TypedQuery<E> query = createQuery( - "from DeliveredRequestedList drl where drl.requestedList = :requestedList"); - - query.setParameter("requestedList", requestedList); - - return findUniqueOrNull(query); - - } -} Deleted: 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/AbstractKanbanJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractKanbanJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractKanbanJpaDao<E extends Kanban> extends GeneratedKanbanJpaDao<E> { - - public AbstractKanbanJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E find(Article article, Warehouse warehouse) { - TypedQuery<E> query = createQuery("from Kanban k where k.article = :article and k.warehouse = :warehouse"); - query.setParameter("article", article); - query.setParameter("warehouse", warehouse); - return query.getSingleResult(); - } -} Deleted: 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/AbstractLocationErrorJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationErrorJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -1,63 +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 AbstractLocationErrorJpaDao<E extends LocationError> extends GeneratedLocationErrorJpaDao<E> { - - public AbstractLocationErrorJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E 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) { - TypedQuery<Location> query = createQuery(Location.class, - "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() { - TypedQuery<E> query = createQuery("from LocationError se order by se.reportDate"); - List<E> all = query.getResultList(); - return all; - } -} Deleted: 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/AbstractLocationJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractLocationJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractLocationJpaDao<E extends Location> extends GeneratedLocationJpaDao<E> { - - public AbstractLocationJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E 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<E> 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 findAll(query); - } - - @Override - public List<E> findAllWithoutReception(Building building) { - return findAllWithoutReception(building, null); - } - - @Override - public List<E> findAllWithoutReception(Warehouse warehouse) { - return findAllWithoutReception(null, warehouse); - } -} Deleted: 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/AbstractMagalieUserJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractMagalieUserJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractMagalieUserJpaDao<E extends MagalieUser> extends GeneratedMagalieUserJpaDao<E> { - - public AbstractMagalieUserJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E 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() { - TypedQuery<E> query = createQuery("from MagalieUser mu order by mu.login"); - List<E> resultList = query.getResultList(); - return resultList; - } -} Deleted: 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/AbstractPreparedArticleReceptionJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractPreparedArticleReceptionJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractPreparedArticleReceptionJpaDao<E extends PreparedArticleReception> extends GeneratedPreparedArticleReceptionJpaDao<E> { - - public AbstractPreparedArticleReceptionJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E findByBarcode(String barcode) { - TypedQuery<E> query = createQuery("from PreparedArticleReception par where par.barcode = :barcode"); - query.setParameter("barcode", barcode); - return findUniqueOrNull(query); - } -} Deleted: 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/AbstractRequestedArticleJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractRequestedArticleJpaDao<E extends RequestedArticle> extends GeneratedRequestedArticleJpaDao<E> { - - public AbstractRequestedArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> 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 findAll(query); - } - - @Override - public List<E> findAll(RequestedList requestedList) { - TypedQuery<E> query = createQuery("from RequestedArticle ra where ra.requestedList = :requestedList"); - query.setParameter("requestedList", requestedList); - return findAll(query); - } - -} Deleted: 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/AbstractRequestedListJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractRequestedListJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractRequestedListJpaDao<E extends RequestedList> extends GeneratedRequestedListJpaDao<E> { - - public AbstractRequestedListJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<String> findAllDistinctListTypes() { - TypedQuery<String> query = createQuery(String.class, "select distinct rl.listType from RequestedList rl"); - return query.getResultList(); - } -} Deleted: 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/AbstractStorageMovementJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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.TypedQuery; -import java.util.List; - -public class AbstractStorageMovementJpaDao<E extends StorageMovement> extends GeneratedStorageMovementJpaDao<E> { - - public AbstractStorageMovementJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> findAllByArticle(Article article) { - TypedQuery<E> query = createQuery("from StorageMovement sm where sm.article = :article"); - query.setParameter("article", article); - return query.getResultList(); - } - - @Override - public List<E> findAllInReception(Building building) { - TypedQuery<E> query = 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() { - TypedQuery<E> query = createQuery("from StorageMovement sm order by sm.orderDate"); - return query.getResultList(); - } -} Deleted: 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/AbstractStorageMovementOrderJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStorageMovementOrderJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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.TypedQuery; -import java.util.List; - -public class AbstractStorageMovementOrderJpaDao<E extends StorageMovementOrder> extends GeneratedStorageMovementOrderJpaDao<E> { - - public AbstractStorageMovementOrderJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> findNotConfirmedByUser(MagalieUser magalieUser, Building building) { - TypedQuery<E> query = 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(); - } -} Deleted: 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/AbstractStoredArticleJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractStoredArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractStoredArticleJpaDao<E extends StoredArticle> extends GeneratedStoredArticleJpaDao<E> { - - public AbstractStoredArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> 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<E> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } - - @Override - public List<E> 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<E> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } - - @Override - public List<E> 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<E> resultList = findAll(query); - for (StoredArticle storedArticle : resultList) { - entityManager.detach(storedArticle); - } - return resultList; - } -} Deleted: 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/AbstractSupplierJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractSupplierJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractSupplierJpaDao<E extends Supplier> extends GeneratedSupplierJpaDao<E> { - - public AbstractSupplierJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> 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 findAll(query); - } - -} Deleted: 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/AbstractUnavailableArticleJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractUnavailableArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractUnavailableArticleJpaDao<E extends UnavailableArticle> extends GeneratedUnavailableArticleJpaDao<E> { - - public AbstractUnavailableArticleJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public E 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); - } -} Deleted: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 AbstractWarehouseJpaDao<E extends Warehouse> extends GeneratedWarehouseJpaDao<E> { - - public AbstractWarehouseJpaDao(EntityManager entityManager) { - super(entityManager); - } - - @Override - public List<E> findAllWithoutLocations(Building building) { - TypedQuery<E> query = createQuery("from Warehouse w where w.building = :building and w in (select l.warehouse from Location l where l.code = :code)"); - query.setParameter(Warehouse.PROPERTY_BUILDING, building); - query.setParameter(Warehouse.PROPERTY_CODE, Locations.codeForWarehouseWithoutLocations()); - return 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -26,8 +26,8 @@ import com.franciaflex.magalie.persistence.entity.Article; /** @author bleny */ -public interface ArticleDao<E extends Article> { +public interface ArticleDao { - E findByCode(String articleCode); + Article findByCode(String articleCode); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java (from rev 207, 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/ArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/ArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 ArticleJpaDao extends AbstractArticleJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/BuildingDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -26,6 +26,6 @@ import com.franciaflex.magalie.persistence.entity.Building; /** @author bleny */ -public interface BuildingDao<E extends Building> { +public interface BuildingDao { } 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -30,10 +30,10 @@ import java.util.List; /** @author bleny */ -public interface DeliveredRequestedArticleDao<E extends DeliveredRequestedArticle> { +public interface DeliveredRequestedArticleDao { - E find(StorageMovementOrder storageMovementOrder); + DeliveredRequestedArticle find(StorageMovementOrder storageMovementOrder); - List<E> findAll(RequestedList requestedList); + List<DeliveredRequestedArticle> findAll(RequestedList requestedList); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java (from rev 207, 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/DeliveredRequestedArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 DeliveredRequestedArticleJpaDao extends AbstractDeliveredRequestedArticleJpaDao { + + public DeliveredRequestedArticleJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public DeliveredRequestedArticle find(StorageMovementOrder storageMovementOrder) { + TypedQuery<DeliveredRequestedArticle> query = + createQuery( + "from DeliveredRequestedArticle dra where dra.storageMovementOrder = :storageMovementOrder"); + query.setParameter("storageMovementOrder", storageMovementOrder); + return findUniqueOrNull(query); + } + + @Override + public List<DeliveredRequestedArticle> findAll(RequestedList requestedList) { + TypedQuery<DeliveredRequestedArticle> query = + createQuery( + "from DeliveredRequestedArticle dra where dra.requestedArticle.requestedList = :requestedList"); + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -28,10 +28,10 @@ import com.franciaflex.magalie.persistence.entity.RequestedList; /** @author bleny */ -public interface DeliveredRequestedListDao<E extends DeliveredRequestedList> { +public interface DeliveredRequestedListDao { - E findByAffectedTo(MagalieUser affectedTo); + DeliveredRequestedList findByAffectedTo(MagalieUser affectedTo); - E findByRequestedList(RequestedList requestedList); + DeliveredRequestedList findByRequestedList(RequestedList requestedList); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java (from rev 207, 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/DeliveredRequestedListJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/DeliveredRequestedListJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 DeliveredRequestedListJpaDao extends AbstractDeliveredRequestedListJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -28,8 +28,8 @@ import com.franciaflex.magalie.persistence.entity.Warehouse; /** @author bleny */ -public interface KanbanDao<E extends Kanban> { +public interface KanbanDao { - public E find(Article article, Warehouse warehouse); + public Kanban find(Article article, Warehouse warehouse); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java (from rev 207, 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/KanbanJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/KanbanJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 KanbanJpaDao extends AbstractKanbanJpaDao { + + public KanbanJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public Kanban find(Article article, Warehouse warehouse) { + TypedQuery<Kanban> query = createQuery("from Kanban k where k.article = :article and k.warehouse = :warehouse"); + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -29,11 +29,11 @@ import java.util.List; -public interface LocationDao<E extends Location> { +public interface LocationDao { - E find(String code, Warehouse warehouse); + Location find(String code, Warehouse warehouse); - List<E> findAllWithoutReception(Building building); + List<Location> findAllWithoutReception(Building building); - List<E> findAllWithoutReception(Warehouse warehouse); + List<Location> findAllWithoutReception(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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -30,12 +30,11 @@ import java.util.List; /** @author bleny */ -public interface LocationErrorDao<E extends LocationError> { +public interface LocationErrorDao { - E findByLocation(Location location); + LocationError findByLocation(Location location); List<Location> getAllLocationsInError(Article article); - List<E> findAll(); - + List<LocationError> findAll(); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java (from rev 207, 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/LocationErrorJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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.TypedQuery; +import java.util.List; + +public class LocationErrorJpaDao extends AbstractLocationErrorJpaDao { + + 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) { + TypedQuery<Location> query = createQuery(Location.class, + "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() { + TypedQuery<LocationError> query = createQuery("from LocationError se order by se.reportDate"); + List<LocationError> all = query.getResultList(); + return all; + } +} Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java (from rev 207, 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/LocationJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 LocationJpaDao extends AbstractLocationJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -28,10 +28,10 @@ import java.util.List; /** @author bleny */ -public interface MagalieUserDao<E extends MagalieUser> { +public interface MagalieUserDao { - E findByLogin(String login); + MagalieUser findByLogin(String login); - List<E> findAll(); + List<MagalieUser> findAll(); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java (from rev 207, 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/MagalieUserJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/MagalieUserJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 MagalieUserJpaDao extends AbstractMagalieUserJpaDao { + + 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() { + TypedQuery<MagalieUser> query = 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -3,7 +3,7 @@ import com.franciaflex.magalie.persistence.entity.PreparedArticleReception; /** @author bleny */ -public interface PreparedArticleReceptionDao<E extends PreparedArticleReception> { +public interface PreparedArticleReceptionDao { - E findByBarcode(String barcode); + PreparedArticleReception findByBarcode(String barcode); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java (from rev 207, 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/PreparedArticleReceptionJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/PreparedArticleReceptionJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 PreparedArticleReceptionJpaDao extends AbstractPreparedArticleReceptionJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -31,10 +31,10 @@ import java.util.List; /** @author bleny */ -public interface RequestedArticleDao<E extends RequestedArticle> { +public interface RequestedArticleDao { - List<E> findAllUndelivered(Building building, MagalieUser affectedTo, String listType); + List<RequestedArticle> findAllUndelivered(Building building, MagalieUser affectedTo, String listType); - List<E> findAll(RequestedList requestedList); + List<RequestedArticle> findAll(RequestedList requestedList); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java (from rev 207, 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/RequestedArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 RequestedArticleJpaDao extends AbstractRequestedArticleJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -28,7 +28,7 @@ import java.util.List; /** @author bleny */ -public interface RequestedListDao<E extends RequestedList> { +public interface RequestedListDao { List<String> findAllDistinctListTypes(); Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java (from rev 207, 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/RequestedListJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 RequestedListJpaDao extends AbstractRequestedListJpaDao { + + public RequestedListJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<String> findAllDistinctListTypes() { + TypedQuery<String> query = createQuery(String.class, "select distinct rl.listType from RequestedList rl"); + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -30,11 +30,11 @@ import java.util.List; /** @author bleny */ -public interface StorageMovementDao <E extends StorageMovement>{ +public interface StorageMovementDao { - List<E> findAllByArticle(Article article); + List<StorageMovement> findAllByArticle(Article article); - List<E> findAll(); + List<StorageMovement> findAll(); - List<E> findAllInReception(Building building); + List<StorageMovement> findAllInReception(Building building); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java (from rev 207, 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/StorageMovementJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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.TypedQuery; +import java.util.List; + +public class StorageMovementJpaDao extends AbstractStorageMovementJpaDao { + + public StorageMovementJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<StorageMovement> findAllByArticle(Article article) { + TypedQuery<StorageMovement> query = createQuery("from StorageMovement sm where sm.article = :article"); + query.setParameter("article", article); + return query.getResultList(); + } + + @Override + public List<StorageMovement> findAllInReception(Building building) { + TypedQuery<StorageMovement> query = 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() { + TypedQuery<StorageMovement> query = 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -29,8 +29,8 @@ import java.util.List; -public interface StorageMovementOrderDao<E extends StorageMovementOrder> { +public interface StorageMovementOrderDao { - public List<E> findNotConfirmedByUser(MagalieUser magalieUser, Building building); + public List<StorageMovementOrder> findNotConfirmedByUser(MagalieUser magalieUser, Building building); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java (from rev 207, 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/StorageMovementOrderJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StorageMovementOrderJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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.TypedQuery; +import java.util.List; + +public class StorageMovementOrderJpaDao extends AbstractStorageMovementOrderJpaDao{ + + public StorageMovementOrderJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<StorageMovementOrder> findNotConfirmedByUser(MagalieUser magalieUser, Building building) { + TypedQuery<StorageMovementOrder> query = 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -29,11 +29,11 @@ import java.util.List; -public interface StoredArticleDao<E extends StoredArticle> { +public interface StoredArticleDao { - List<E> findAllForArticleInBuilding(Article article, Building building); + List<StoredArticle> findAllForArticleInBuilding(Article article, Building building); - List<E> findAllReceivedForAllSupplier(Building building); + List<StoredArticle> findAllReceivedForAllSupplier(Building building); - List<E> findAllReceivedForSupplier(Building building, String supplierId); + List<StoredArticle> findAllReceivedForSupplier(Building building, String supplierId); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java (from rev 207, 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/StoredArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoredArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 StoredArticleJpaDao extends AbstractStoredArticleJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -29,8 +29,8 @@ import java.util.List; /** @author bleny */ -public interface SupplierDao<E extends Supplier> { +public interface SupplierDao { - List<E> findAllWithReceivedArticles(Building building); + List<Supplier> findAllWithReceivedArticles(Building building); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java (from rev 207, 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/SupplierJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/SupplierJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 SupplierJpaDao extends AbstractSupplierJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -28,8 +28,8 @@ import com.franciaflex.magalie.persistence.entity.UnavailableArticle; /** @author bleny */ -public interface UnavailableArticleDao<E extends UnavailableArticle> { +public interface UnavailableArticleDao { - E findByArticle(Building building, Article article); + UnavailableArticle findByArticle(Building building, Article article); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java (from rev 207, 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/UnavailableArticleJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/UnavailableArticleJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 UnavailableArticleJpaDao extends AbstractUnavailableArticleJpaDao { + + 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-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -29,8 +29,8 @@ import java.util.List; /** @author bleny */ -public interface WarehouseDao<E extends Warehouse> { +public interface WarehouseDao { - List<E> findAllWithoutLocations(Building building); + List<Warehouse> findAllWithoutLocations(Building building); } Copied: branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java (from rev 207, branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/AbstractWarehouseJpaDao.java) =================================================================== --- branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java (rev 0) +++ branches/magalie-eugene/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseJpaDao.java 2013-05-29 13:24:06 UTC (rev 212) @@ -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 WarehouseJpaDao extends AbstractWarehouseJpaDao { + + public WarehouseJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public List<Warehouse> findAllWithoutLocations(Building building) { + TypedQuery<Warehouse> query = createQuery("from Warehouse w where w.building = :building and w in (select l.warehouse from Location l where l.code = :code)"); + query.setParameter(Warehouse.PROPERTY_BUILDING, building); + query.setParameter(Warehouse.PROPERTY_CODE, Locations.codeForWarehouseWithoutLocations()); + return query.getResultList(); + } +} Modified: branches/magalie-eugene/pom.xml =================================================================== --- branches/magalie-eugene/pom.xml 2013-05-29 12:54:54 UTC (rev 211) +++ branches/magalie-eugene/pom.xml 2013-05-29 13:24:06 UTC (rev 212) @@ -107,7 +107,7 @@ <mockitoVersion>1.9.5</mockitoVersion> <nuitonI18nVersion>2.5</nuitonI18nVersion> <topiaVersion>2.7.1</topiaVersion> - <eugeneVersion>2.6.3-SNAPSHOT</eugeneVersion> + <eugeneVersion>2.6.3</eugeneVersion> <!-- license to use --> <license.licenseName>agpl_v3</license.licenseName>