r161 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/main/resources magalie-services/src/test/java/com/franciaflex/magalie/services/service
Author: bleny Date: 2013-05-17 11:11:15 +0200 (Fri, 17 May 2013) New Revision: 161 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: refs #2165 exclude full locations from suggested locations on reception Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java trunk/magalie-services/src/main/resources/fixtures.yaml trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.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-05-17 08:45:28 UTC (rev 160) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java 2013-05-17 09:11:15 UTC (rev 161) @@ -23,10 +23,11 @@ * #L% */ +import com.franciaflex.magalie.persistence.entity.Location; import com.franciaflex.magalie.persistence.entity.MagalieUser; -import com.franciaflex.magalie.persistence.entity.Location; 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; @@ -41,6 +42,14 @@ } } + protected static class IsFullLocation implements Predicate<Location> { + + @Override + public boolean apply(Location location) { + return location.isFullLocation(); + } + } + protected static class AccessibleLocationPredicate implements Predicate<Location> { protected MagalieUser magalieUser; @@ -93,4 +102,19 @@ public static Predicate<Location> isNotReceptionLocation() { return Predicates.not(new IsReceptionLocation()); } + + public static Predicate<Location> isNotFullLocation() { + return Predicates.not(new IsFullLocation()); + } + + public static Predicate<Location> isAcceptableForReception() { + Predicate<Location> isAcceptableForReception = + Predicates.and( + Lists.newArrayList( + isNotReceptionLocation(), + isNotFullLocation() + ) + ); + return isAcceptableForReception; + } } Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java =================================================================== --- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java 2013-05-17 08:45:28 UTC (rev 160) +++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java 2013-05-17 09:11:15 UTC (rev 161) @@ -58,7 +58,8 @@ " from Location l where" + " l.warehouse.building = :building and " + " l.code != :codeForReceptionLocations and " - + " l.code != :codeForWarehouseWithoutLocations " + + " l.code != :codeForWarehouseWithoutLocations and " + + " l.fullLocation = false " + " order by l.warehouse.building.code, l.warehouse.code, l.code"); query.setParameter("building", building); query.setParameter("codeForReceptionLocations", Locations.codeForReceptionLocations()); 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-05-17 08:45:28 UTC (rev 160) +++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-05-17 09:11:15 UTC (rev 161) @@ -164,11 +164,12 @@ // fourth step, remove reception locations because it's stupid to // move an article from reception location to another reception location + // also, remove full locations List<Location> result = Lists.newArrayList( Iterables.filter( locations, - Locations.isNotReceptionLocation() + Locations.isAcceptableForReception() ) ); Modified: trunk/magalie-services/src/main/resources/fixtures.yaml =================================================================== --- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-05-17 08:45:28 UTC (rev 160) +++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-05-17 09:11:15 UTC (rev 161) @@ -260,6 +260,15 @@ requiredAccreditationLevel: 0 requiredCraneMan : false +locationFull1: + &locationFull1 !location + id: locationFull1 + warehouse: *U01 + code: C04 + requiredAccreditationLevel: 0 + requiredCraneMan : false + fullLocation: true + locations: - *location1 - *location2 @@ -281,6 +290,7 @@ - *locationRecU04 - *locationRecSOM - *locationRecB01 + - *locationFull1 supplier1: &supplier1 !supplier Modified: trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java =================================================================== --- trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java 2013-05-17 08:45:28 UTC (rev 160) +++ trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ReceptionServiceTest.java 2013-05-17 09:11:15 UTC (rev 161) @@ -123,6 +123,10 @@ for (Location location : receptionTask.getLocations()) { + if (log.isDebugEnabled()) { + log.debug("location " + location.getBarcode()); + } + Assert.assertNotEquals( "we should never suggest someone to store something in a reception location", Locations.codeForReceptionLocations(), @@ -133,6 +137,10 @@ Locations.codeForWarehouseWithoutLocations(), location.getCode()); + Assert.assertFalse( + "we should never suggest someone to store something in a full location", + location.isFullLocation()); + } }
participants (1)
-
bleny@users.forge.codelutin.com