r239 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao magalie-services/src/main/java/com/franciaflex/magalie/services/service
Author: bleny Date: 2013-06-05 14:29:41 +0200 (Wed, 05 Jun 2013) New Revision: 239 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: fixes #2165 exclude locations reported in error from suggested locations Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java =================================================================== --- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java 2013-06-05 12:29:41 UTC (rev 239) @@ -28,7 +28,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import com.google.common.collect.Lists; import java.util.Collection; import java.util.Comparator; @@ -116,17 +115,6 @@ return Predicates.not(new IsFullLocation()); } - public static Predicate<Location> isAcceptableForReception() { - Predicate<Location> isAcceptableForReception = - Predicates.and( - Lists.newArrayList( - isNotReceptionLocation(), - isNotFullLocation() - ) - ); - return isAcceptableForReception; - } - public static Predicate<Location> barcodeEquals(String originLocationBarcode) { return Predicates.compose(Predicates.equalTo(originLocationBarcode), getBarcodeFunction()); } Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java =================================================================== --- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java 2013-06-05 12:29:41 UTC (rev 239) @@ -36,7 +36,6 @@ import com.google.common.collect.Ordering; import org.apache.commons.collections.comparators.BooleanComparator; -import java.util.Collection; import java.util.Comparator; public class StoredArticles { @@ -156,10 +155,6 @@ return new ArticleStoredInLocationsRequiringDriverLicenseFirstComparator(); } - public static Predicate<StoredArticle> articleNotStoredInLocationReportedInError(Collection<Location> allLocationsInError) { - return Predicates.compose(Locations.locationIsNotReportedInError(allLocationsInError), getLocationFunction()); - } - public static Predicate<StoredArticle> notEmpty() { return new NotEmptyPredicate(); } Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java =================================================================== --- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorDao.java 2013-06-05 12:29:41 UTC (rev 239) @@ -23,7 +23,6 @@ * #L% */ -import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.LocationError; @@ -34,7 +33,7 @@ LocationError findByLocation(Location location); - List<Location> getAllLocationsInError(Article article); + List<Location> findAllLocationsInError(); List<LocationError> findAll(); } Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java =================================================================== --- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationErrorJpaDao.java 2013-06-05 12:29:41 UTC (rev 239) @@ -23,7 +23,6 @@ * #L% */ -import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.LocationError; @@ -46,9 +45,8 @@ } @Override - public List<Location> getAllLocationsInError(Article article) { - Query query = entityManager.createQuery("select se.location from LocationError se where se.article = :article"); - query.setParameter("article", article); + public List<Location> findAllLocationsInError() { + Query query = entityManager.createQuery("select se.location from LocationError se"); List<Location> allLocationsInError = query.getResultList(); return allLocationsInError; } Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java =================================================================== --- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-06-05 12:29:41 UTC (rev 239) @@ -351,12 +351,13 @@ storedArticles = computeActualQuantities(storedArticles, storageMovementsForArticle); // exclude storageMovements on a location reported in error - LocationErrorsService locationErrorsService = serviceContext.newService(LocationErrorsService.class); + LocationErrorsService locationErrorsService = + serviceContext.newService(LocationErrorsService.class); - List<Location> allLocationsInError = locationErrorsService.getAllLocationsInError(article); + storedArticles = Iterables.filter( + storedArticles, + locationErrorsService.getArticleNotStoredInLocationReportedInErrorPredicate()); - storedArticles = Iterables.filter(storedArticles, StoredArticles.articleNotStoredInLocationReportedInError(allLocationsInError)); - return storedArticles; } Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java =================================================================== --- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/LocationErrorsService.java 2013-06-05 12:29:41 UTC (rev 239) @@ -23,13 +23,18 @@ * #L% */ +import com.franciaflex.magalie.persistence.Locations; +import com.franciaflex.magalie.persistence.StoredArticles; import com.franciaflex.magalie.persistence.dao.LocationErrorJpaDao; import com.franciaflex.magalie.persistence.entity.Article; import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.LocationError; import com.franciaflex.magalie.persistence.entity.MagalieUser; +import com.franciaflex.magalie.persistence.entity.StoredArticle; import com.franciaflex.magalie.services.MagalieService; import com.franciaflex.magalie.services.MagalieServiceContext; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -86,23 +91,30 @@ } } - public List<Location> getAllLocationsInError(Article article) { + public List<LocationError> getAllLocationErrors() { LocationErrorJpaDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); - List<Location> allLocationsInError = locationErrorDao.getAllLocationsInError(article); + List<LocationError> allLocationErrors = locationErrorDao.findAll(); - return allLocationsInError; + return allLocationErrors; } - public List<LocationError> getAllLocationErrors() { + public Predicate<Location> getLocationNotReportedInErrorPredicate() { LocationErrorJpaDao locationErrorDao = serviceContext.getPersistenceContext().getLocationErrorDao(); - List<LocationError> allLocationErrors = locationErrorDao.findAll(); + List<Location> allLocationsInError = locationErrorDao.findAllLocationsInError(); - return allLocationErrors; + return Locations.locationIsNotReportedInError(allLocationsInError); } + + public Predicate<StoredArticle> getArticleNotStoredInLocationReportedInErrorPredicate() { + + return Predicates.compose(getLocationNotReportedInErrorPredicate(), StoredArticles.getLocationFunction()); + + } + } Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java =================================================================== --- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-06-05 11:27:23 UTC (rev 238) +++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-06-05 12:29:41 UTC (rev 239) @@ -44,6 +44,9 @@ import com.franciaflex.magalie.persistence.entity.Warehouse; import com.franciaflex.magalie.services.MagalieService; import com.franciaflex.magalie.services.MagalieServiceContext; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; @@ -228,12 +231,25 @@ // fourth step, remove reception locations because it's stupid to // move an article from reception location to another reception location - // also, remove full locations + // also, remove full locations and locations reported in error + + LocationErrorsService locationErrorsService = + serviceContext.newService(LocationErrorsService.class); + + Predicate<Location> isAcceptableForReception = + Predicates.and( + ImmutableSet.of( + Locations.isNotReceptionLocation(), + Locations.isNotFullLocation(), + locationErrorsService.getLocationNotReportedInErrorPredicate() + ) + ); + List<Location> result = Lists.newArrayList( Iterables.filter( locations, - Locations.isAcceptableForReception() + isAcceptableForReception ) );
participants (1)
-
bleny@users.forge.codelutin.com