Franciaflex-magalie-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 438 discussions
r97 - in trunk: magalie-services/src/main/java/com/franciaflex/magalie/services/exception magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/test/java/com/franciaflex/magalie/services/service magalie-web/src/main/java/com/franciaflex/magalie/web/action
by bleny@users.forge.codelutin.com 15 Apr '13
by bleny@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: bleny
Date: 2013-04-15 17:37:46 +0200 (Mon, 15 Apr 2013)
New Revision: 97
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
remove usage of exceptions for task assignement
Added:
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleResult.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FindOrderToExecuteResult.java
Removed:
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/RequiredDriverLicenceException.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/UnavailableArticleException.java
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/FulfilKanbanService.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/RequestedArticleServiceTest.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/DeliverRequestedArticleAction.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/WithdrawItemAction.java
Deleted: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/RequiredDriverLicenceException.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/RequiredDriverLicenceException.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/RequiredDriverLicenceException.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -1,54 +0,0 @@
-package com.franciaflex.magalie.services.exception;
-
-import com.franciaflex.magalie.persistence.Locations;
-import com.franciaflex.magalie.persistence.entity.Article;
-import com.franciaflex.magalie.persistence.entity.Location;
-import com.franciaflex.magalie.persistence.entity.MagalieUser;
-import com.google.common.base.Predicate;
-
-public class RequiredDriverLicenceException extends MagalieException {
-
- protected Article article;
-
- protected MagalieUser magalieUser;
-
- protected Location location;
-
- protected RequiredDriverLicenceException(String message) {
- super(message);
- }
-
- public Article getArticle() {
- return article;
- }
-
- public MagalieUser getMagalieUser() {
- return magalieUser;
- }
-
- public Location getLocation() {
- return location;
- }
-
- public static void throwIfUserCannotAccessLocation(MagalieUser magalieUser, Location location, Article article) throws RequiredDriverLicenceException {
-
- Predicate<Location> isLocationInaccessiblePredicate = Locations.inaccessibleLocationPredicate(magalieUser);
-
- if (isLocationInaccessiblePredicate.apply(location)) {
-
- String message = "requested article " + article
- + " can not be retrieved since user " + magalieUser
- + " has no driver license";
-
- RequiredDriverLicenceException newException = new RequiredDriverLicenceException(message);
-
- newException.magalieUser = magalieUser;
-
- newException.location = location;
-
- newException.article = article;
-
- throw newException;
- }
- }
-}
Deleted: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/UnavailableArticleException.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/UnavailableArticleException.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/exception/UnavailableArticleException.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -1,49 +0,0 @@
-package com.franciaflex.magalie.services.exception;
-
-import com.franciaflex.magalie.persistence.entity.Article;
-
-public class UnavailableArticleException extends MagalieException {
-
- protected Article article;
-
- protected double availableQuantity;
-
- protected double requestedQuantity;
-
- protected UnavailableArticleException(String message) {
- super(message);
- }
-
- public static void throwIfRequestMoreThanAvailable(double requestedQuantity, double availableQuantity, Article article) throws UnavailableArticleException {
-
- if (requestedQuantity > availableQuantity) {
-
- String message = "requested article " + article
- + " is not available at expected quantity: requested = " + requestedQuantity
- + " available = " + availableQuantity;
-
- UnavailableArticleException newException = new UnavailableArticleException(message);
-
- newException.article = article;
-
- newException.availableQuantity = availableQuantity;
-
- newException.requestedQuantity = requestedQuantity;
-
- throw newException;
-
- }
- }
-
- public Article getArticle() {
- return article;
- }
-
- public double getAvailableQuantity() {
- return availableQuantity;
- }
-
- public double getRequestedQuantity() {
- return requestedQuantity;
- }
-}
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-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -17,8 +17,6 @@
import com.franciaflex.magalie.services.MagalieServiceContext;
import com.franciaflex.magalie.services.StorageMovementConfirmation;
import com.franciaflex.magalie.services.StorageMovementTask;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
@@ -45,8 +43,7 @@
this.serviceContext = serviceContext;
}
- public StorageMovementOrder bookArticle(BookArticleRequest bookArticleRequest)
- throws UnavailableArticleException, RequiredDriverLicenceException {
+ public BookArticleResult bookArticle(BookArticleRequest bookArticleRequest) {
Preconditions.checkNotNull(bookArticleRequest.getMagalieUser());
@@ -66,21 +63,27 @@
Queue<StoredArticle> sortedStoredArticles = sortStoredArticlesByPriority(storedArticles);
- StorageMovementOrder storageMovementOrder = buildStorageMovementOrder(bookArticleRequest, sortedStoredArticles);
+ BookArticleResult bookArticleResult = buildStorageMovementOrder(bookArticleRequest, sortedStoredArticles);
- MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
- StorageMovementOrderDao dao = persistenceContext.getStorageMovementOrderDao();
+ if (storageMovementOrder != null) {
- dao.persist(storageMovementOrder);
+ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
- persistenceContext.commit();
+ StorageMovementOrderDao dao = persistenceContext.getStorageMovementOrderDao();
- return storageMovementOrder;
+ dao.persist(storageMovementOrder);
+ persistenceContext.commit();
+
+ }
+
+ return bookArticleResult;
+
}
- protected StorageMovementOrder buildStorageMovementOrder(BookArticleRequest bookArticleRequest, Queue<StoredArticle> sortedStoredArticles) throws RequiredDriverLicenceException, UnavailableArticleException {
+ protected BookArticleResult buildStorageMovementOrder(BookArticleRequest bookArticleRequest, Queue<StoredArticle> sortedStoredArticles) {
Article article = bookArticleRequest.getArticle();
@@ -88,6 +91,10 @@
double requestedQuantity = bookArticleRequest.getRequestedQuantity();
+ BookArticleResult bookArticleResult = new BookArticleResult();
+
+ bookArticleResult.setBookArticleRequest(bookArticleRequest);
+
StorageMovementOrder storageMovementOrder = new StorageMovementOrder();
double quantity = 0;
@@ -106,7 +113,7 @@
Location originLocation = storedArticle.getLocation();
- RequiredDriverLicenceException.throwIfUserCannotAccessLocation(magalieUser, originLocation, article);
+ bookArticleResult.userMustAccessLocation(originLocation);
quantity += quantityWithdrawn;
@@ -129,28 +136,40 @@
}
}
- if (bookArticleRequest.isBestEffortPolicy()) {
+ // TODO brendan 15/04/13 refactor
- log.debug("best effort policy, requested quantity was "
- + requestedQuantity + " but only " + quantity +
- " available");
+ bookArticleResult.setAvailableQuantity(quantity);
- if (storageMovementOrder.getStorageMovements().isEmpty()) {
+ if (storageMovementOrder.getStorageMovements().isEmpty()) {
- UnavailableArticleException.throwIfRequestMoreThanAvailable(requestedQuantity, 0., article);
+ storageMovementOrder = null;
- }
-
} else {
- // strict policy, we must deliver all requested quantity
+ if (quantity < requestedQuantity) {
- UnavailableArticleException.throwIfRequestMoreThanAvailable(requestedQuantity, quantity, article);
+ if (bookArticleRequest.isBestEffortPolicy()) {
+ log.debug("best effort policy, requested quantity was "
+ + requestedQuantity + " but only " + quantity +
+ " available");
+
+ } else {
+
+ // strict policy, we must deliver all requested quantity
+
+ storageMovementOrder = null;
+
+ }
+
+ }
+
}
- return storageMovementOrder;
+ bookArticleResult.setStorageMovementOrder(storageMovementOrder);
+ return bookArticleResult;
+
}
protected Queue<StoredArticle> sortStoredArticlesByPriority(List<StoredArticle> storedArticles) {
Added: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleResult.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleResult.java (rev 0)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleResult.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -0,0 +1,72 @@
+package com.franciaflex.magalie.services.service;
+
+import com.franciaflex.magalie.persistence.Locations;
+import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.MagalieUser;
+import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
+import com.google.common.base.Predicate;
+
+public class BookArticleResult {
+
+ protected StorageMovementOrder storageMovementOrder;
+
+ protected BookArticleRequest bookArticleRequest;
+
+ protected double availableQuantity;
+
+ protected Location inaccessibleLocation;
+
+ public void setStorageMovementOrder(StorageMovementOrder storageMovementOrder) {
+ this.storageMovementOrder = storageMovementOrder;
+ }
+
+ public StorageMovementOrder getStorageMovementOrder() {
+ return storageMovementOrder;
+ }
+
+ public void setBookArticleRequest(BookArticleRequest bookArticleRequest) {
+ this.bookArticleRequest = bookArticleRequest;
+ }
+
+ public BookArticleRequest getBookArticleRequest() {
+ return bookArticleRequest;
+ }
+
+ public void userMustAccessLocation(Location location) {
+
+ if (inaccessibleLocation == null) {
+
+ MagalieUser magalieUser = bookArticleRequest.getMagalieUser();
+
+ Predicate<Location> isLocationInaccessiblePredicate = Locations.inaccessibleLocationPredicate(magalieUser);
+
+ if (isLocationInaccessiblePredicate.apply(location)) {
+
+ this.inaccessibleLocation = location;
+
+ }
+
+ }
+
+ }
+
+ public boolean isArticleInaccessible() {
+ return inaccessibleLocation != null;
+ }
+
+ public boolean isArticleUnavailable() {
+ return storageMovementOrder == null;
+ }
+
+ public void setAvailableQuantity(double availableQuantity) {
+ this.availableQuantity = availableQuantity;
+ }
+
+ public double getAvailableQuantity() {
+ return availableQuantity;
+ }
+
+ public boolean isSuccess() {
+ return ! isArticleInaccessible() && ! isArticleUnavailable();
+ }
+}
Added: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FindOrderToExecuteResult.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FindOrderToExecuteResult.java (rev 0)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FindOrderToExecuteResult.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -0,0 +1,44 @@
+package com.franciaflex.magalie.services.service;
+
+import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
+
+public class FindOrderToExecuteResult {
+
+ protected StorageMovementOrder storageMovementOrder;
+
+ protected boolean nothingToDo;
+
+ protected boolean driverLicenseRequired;
+
+ public boolean isSuccess() {
+ return storageMovementOrder != null;
+ }
+
+ public void setStorageMovementOrder(StorageMovementOrder storageMovementOrder) {
+ this.storageMovementOrder = storageMovementOrder;
+ }
+
+ public StorageMovementOrder getStorageMovementOrder() {
+ return storageMovementOrder;
+ }
+
+ public void setNothingToDo(boolean nothingToDo) {
+ this.nothingToDo = nothingToDo;
+ }
+
+ public boolean isNothingToDo() {
+ return nothingToDo;
+ }
+
+ public void setDriverLicenseRequired(boolean driverLicenseRequired) {
+ this.driverLicenseRequired = driverLicenseRequired;
+ }
+
+ public boolean isDriverLicenseRequired() {
+ return driverLicenseRequired;
+ }
+
+ public boolean isEverythingUnavailable() {
+ return ! driverLicenseRequired && ! nothingToDo;
+ }
+}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -8,13 +8,10 @@
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.Location;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
-import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.services.MagalieService;
import com.franciaflex.magalie.services.MagalieServiceContext;
import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,12 +40,10 @@
}
- public StorageMovementOrder fulfilKanbanTask(
+ public BookArticleResult fulfilKanbanTask(
String articleBarcode,
MagalieUser magalieUser,
- String destinationStoreId) throws InvalidMagalieBarcodeException,
- UnavailableArticleException,
- RequiredDriverLicenceException {
+ String destinationStoreId) throws InvalidMagalieBarcodeException {
if (log.isInfoEnabled()) {
log.info(magalieUser + " requested fulfil kanban with barcode " + articleBarcode);
@@ -77,10 +72,10 @@
magalieUser, building, article,
quantityInKanban, destinationLocation, true);
- StorageMovementOrder storageMovementOrder =
+ BookArticleResult bookArticleResult =
articleStorageService.bookArticle(bookArticleRequest);
- return storageMovementOrder;
+ return bookArticleResult;
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -36,8 +36,6 @@
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
import com.franciaflex.magalie.services.MagalieService;
import com.franciaflex.magalie.services.MagalieServiceContext;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
@@ -60,7 +58,7 @@
this.serviceContext = serviceContext;
}
- public StorageMovementOrder getStorageMovementOrder(
+ public FindOrderToExecuteResult getStorageMovementOrder(
MagalieUser magalieUser,
Building building) {
@@ -68,13 +66,14 @@
Queue<RequestedArticle> requestedArticlesByPriority = getRequestedArticlesByPriority(requestedArticles);
- StorageMovementOrder storageMovementOrder =
+
+ FindOrderToExecuteResult findOrderToExecuteResult =
findOrderToExecute(
requestedArticlesByPriority,
magalieUser,
building);
- return storageMovementOrder;
+ return findOrderToExecuteResult;
}
@@ -92,25 +91,23 @@
}
- protected StorageMovementOrder findOrderToExecute(Queue<RequestedArticle> requestedArticlesByPriority, MagalieUser magalieUser, Building building) {
+ protected FindOrderToExecuteResult findOrderToExecute(Queue<RequestedArticle> requestedArticlesByPriority, MagalieUser magalieUser, Building building) {
ArticleStorageService articleStorageService =
serviceContext.newService(ArticleStorageService.class);
- StorageMovementOrder storageMovementOrder = null;
+ BookArticleResult bookArticleResult = null;
- int requestedArticlesCount = requestedArticlesByPriority.size();
+ RequestedArticle requestedArticle = null;
+ boolean success = false;
+
Iterator<RequestedArticle> requestedArticleIterator = requestedArticlesByPriority.iterator();
- boolean everythingIsUnavailable = true;
+ boolean driverLicenseRequired = false;
- boolean requiredDriverLicence = false;
+ while ( ! success && requestedArticleIterator.hasNext()) {
- RequestedArticle requestedArticle = null;
-
- while (storageMovementOrder == null && requestedArticleIterator.hasNext()) {
-
requestedArticle = requestedArticleIterator.next();
Article article = requestedArticle.getArticle();
@@ -121,48 +118,18 @@
BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, quantity, destinationLocation, false);
- try {
+ bookArticleResult = articleStorageService.bookArticle(bookArticleRequest);
- storageMovementOrder = articleStorageService.bookArticle(bookArticleRequest);
+ driverLicenseRequired |= bookArticleResult.isArticleInaccessible() && ! bookArticleResult.isArticleUnavailable();
- everythingIsUnavailable = false;
+ success = bookArticleResult.isSuccess();
- } catch (UnavailableArticleException e) {
-
- if (log.isDebugEnabled()) {
- log.debug("cannot work for order", e);
- }
-
- } catch (RequiredDriverLicenceException e) {
-
- if (log.isDebugEnabled()) {
- log.debug("cannot work for order", e);
- }
-
- requiredDriverLicence = true;
-
- }
-
}
- if (storageMovementOrder == null && requestedArticlesCount > 0) {
+ FindOrderToExecuteResult findOrderToExecuteResult = new FindOrderToExecuteResult();
- if (everythingIsUnavailable) {
+ if (success) {
- if (requiredDriverLicence) {
-
- // throw new RequiredDriverLicenceException();
-
- } else {
-
- // throw new UnavailableArticleException();
-
- }
- }
- }
-
- if (storageMovementOrder != null) {
-
Preconditions.checkState(requestedArticle != null);
MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
@@ -173,15 +140,33 @@
newDeliveredRequestedArticle.setRequestedArticle(requestedArticle);
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
+
newDeliveredRequestedArticle.setStorageMovementOrder(storageMovementOrder);
dao.persist(newDeliveredRequestedArticle);
persistenceContext.commit();
+ findOrderToExecuteResult = new FindOrderToExecuteResult();
+
+ findOrderToExecuteResult.setStorageMovementOrder(storageMovementOrder);
+
+ } else {
+
+ if (requestedArticlesByPriority.isEmpty()) {
+
+ findOrderToExecuteResult.setNothingToDo(true);
+
+ } else {
+
+ findOrderToExecuteResult.setDriverLicenseRequired(driverLicenseRequired);
+
+ }
+
}
- return storageMovementOrder;
+ return findOrderToExecuteResult;
}
Modified: trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
===================================================================
--- trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -7,8 +7,6 @@
import com.franciaflex.magalie.persistence.entity.StorageMovement;
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
import com.franciaflex.magalie.services.AbstractMagalieServiceTest;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
import com.google.common.collect.Iterables;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -27,6 +25,8 @@
protected Building building;
+ protected Location destinationLocation;
+
@Before
public void setUp() throws ParseException {
@@ -34,71 +34,44 @@
building = fixture("B1");
+ destinationLocation = fixture("location5");
+
service = newService(ArticleStorageService.class);
serviceContext.setDate(new Date(1363948427576l));
}
- protected StorageMovementOrder bookArticle(MagalieUser magalieUser, Building building, Article article, double requestedQuantity) throws UnavailableArticleException, RequiredDriverLicenceException {
+ @Test
+ public void testThrowUnavailableArticle() throws Exception {
- BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, requestedQuantity, null, false);
-
- return service.bookArticle(bookArticleRequest);
+ MagalieUser alexandre = fixture("alexandre");
+ Article article = fixture("article1");
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(alexandre, building, article, 100., destinationLocation, false);
- public StorageMovementOrder bookArticleWithBestEffortPolicy(
- MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation)
- throws RequiredDriverLicenceException, UnavailableArticleException {
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
- BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, requestedQuantity, null, true);
+ Assert.assertFalse(bookArticleResult.isSuccess());
- return service.bookArticle(bookArticleRequest);
+ Assert.assertTrue(bookArticleResult.isArticleUnavailable());
}
@Test
- public void testThrowUnavailableArticle() throws Exception {
+ public void testThrowRequiredDriverLicenceException() throws Exception {
- MagalieUser alexandre = fixture("alexandre");
+ MagalieUser basile = fixture("basile");
Article article = fixture("article1");
- StorageMovementOrder storageMovementOrder;
- try {
- storageMovementOrder = bookArticle(alexandre, building, article, 100.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.assertEquals(70., e.getAvailableQuantity(), DELTA);
- }
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(basile, building, article, 70., destinationLocation, false);
- @Test
- public void testThrowRequiredDriverLicenceException() throws Exception {
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
- MagalieUser basile = fixture("basile");
- Article article = fixture("article1");
- Location location2 = fixture("location2");
- StorageMovementOrder storageMovementOrder;
+ Assert.assertFalse(bookArticleResult.isSuccess());
+ Assert.assertTrue(bookArticleResult.isArticleInaccessible());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
- try {
- storageMovementOrder = bookArticle(basile, building, article, 70.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- Assert.fail();
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.assertEquals(location2.getId(), e.getLocation().getId());
- }
}
@Test
@@ -106,26 +79,17 @@
MagalieUser basile = fixture("basile");
Article article = fixture("article2");
- StorageMovementOrder storageMovementOrder = null;
- try {
- storageMovementOrder = bookArticle(basile, building, article, 5.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(basile, building, article, 5., destinationLocation, false);
- Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
+
+ Assert.assertEquals(1, bookArticleResult.getStorageMovementOrder().getStorageMovements().size());
+
}
@Test
@@ -133,30 +97,21 @@
MagalieUser alexandre = fixture("alexandre");
Article article = fixture("article1");
- StorageMovementOrder storageMovementOrder = null;
- try {
- storageMovementOrder = bookArticle(alexandre, building, article, 50.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(alexandre, building, article, 50., destinationLocation, false);
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
+
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
Assert.assertEquals(2, storageMovementOrder.getStorageMovements().size());
StorageMovement location1 = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
Assert.assertEquals(20., location1.getExpectedQuantity(), DELTA);
StorageMovement location2 = Iterables.get(storageMovementOrder.getStorageMovements(), 1, null);
Assert.assertEquals(30., location2.getExpectedQuantity(), DELTA);
+
}
@Test
@@ -167,13 +122,14 @@
Article article = fixture("article1");
- StorageMovementOrder storageMovementOrder = null;
+ {
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(alexandre, building, article, 30., destinationLocation, false);
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
- try {
- storageMovementOrder = bookArticle(alexandre, building, article, 30.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
Assert.assertEquals(2, storageMovementOrder.getStorageMovements().size());
StorageMovement storageMovement1 = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
Assert.assertEquals(20., storageMovement1.getExpectedQuantity(), DELTA);
@@ -181,37 +137,21 @@
StorageMovement storageMovement2 = Iterables.get(storageMovementOrder.getStorageMovements(), 1, null);
Assert.assertEquals(10., storageMovement2.getExpectedQuantity(), DELTA);
Assert.assertEquals("A1", storageMovement2.getOriginLocation().getCode());
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
}
- try {
- storageMovementOrder = bookArticle(cathy, building, article, 30.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
+ {
+
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(cathy, building, article, 30., destinationLocation, false);
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
+
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
Assert.assertEquals(30., storageMovement.getExpectedQuantity(), DELTA);
Assert.assertEquals("A1", storageMovement.getOriginLocation().getCode());
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
}
}
@@ -228,28 +168,21 @@
LocationErrorsService locationErrorsService = newService(LocationErrorsService.class);
locationErrorsService.reportError(location2, alexandre);
- try {
- StorageMovementOrder storageMovementOrder = bookArticle(cathy, building, article, 30.);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
- StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
- Assert.assertNotEquals(
- "location2 must not be returned because it was reported in error",
- location2.getId(),
- storageMovement.getOriginLocation().getId());
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(cathy, building, article, 30., destinationLocation, false);
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
+
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
+
+ Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
+ StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
+ Assert.assertNotEquals(
+ "location2 must not be returned because it was reported in error",
+ location2.getId(),
+ storageMovement.getOriginLocation().getId());
+
}
@Test
@@ -259,26 +192,18 @@
Article article = fixture("article2");
Location location1 = fixture("location1");
- try {
- StorageMovementOrder storageMovementOrder = bookArticleWithBestEffortPolicy(alexandre, building, article, 30., null);
- if (log.isDebugEnabled()) {
- log.debug("storageMovementOrder = " + storageMovementOrder);
- }
- Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
- StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
- Assert.assertEquals("only 10 is available, so don't propose more", 10., storageMovement.getQuantity(), DELTA);
- Assert.assertEquals(location1.getId(), storageMovement.getOriginLocation().getId());
- } catch (RequiredDriverLicenceException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- } catch (UnavailableArticleException e) {
- if (log.isDebugEnabled()) {
- log.debug("exception raised = " + e);
- }
- Assert.fail();
- }
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(alexandre, building, article, 30., destinationLocation, true);
+ BookArticleResult bookArticleResult = service.bookArticle(bookArticleRequest);
+ StorageMovementOrder storageMovementOrder = bookArticleResult.getStorageMovementOrder();
+
+ Assert.assertTrue(bookArticleResult.isSuccess());
+ Assert.assertFalse(bookArticleResult.isArticleUnavailable());
+ Assert.assertFalse(bookArticleResult.isArticleInaccessible());
+ Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
+ StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
+ Assert.assertEquals("only 10 is available, so don't propose more", 10., storageMovement.getQuantity(), DELTA);
+ Assert.assertEquals(location1.getId(), storageMovement.getOriginLocation().getId());
+
}
}
Modified: trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/RequestedArticleServiceTest.java
===================================================================
--- trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/RequestedArticleServiceTest.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/RequestedArticleServiceTest.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -4,6 +4,7 @@
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
import com.franciaflex.magalie.services.AbstractMagalieServiceTest;
+import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -54,10 +55,21 @@
}
@Test
- public void testName() {
+ public void testFindOrderWhenNoRequestedArticles() {
MagalieUser magalieUser = fixture("bruno");
+ Building building = fixture("B1");
+ Queue<RequestedArticle> emptyQueue = Lists.newLinkedList();
+
+ FindOrderToExecuteResult orderToExecute = service.findOrderToExecute(emptyQueue, magalieUser, building);
+
+ Assert.assertTrue(orderToExecute.isNothingToDo());
+ Assert.assertFalse(orderToExecute.isEverythingUnavailable());
+ Assert.assertFalse(orderToExecute.isSuccess());
+ Assert.assertFalse(orderToExecute.isDriverLicenseRequired());
+
}
+
}
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/DeliverRequestedArticleAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/DeliverRequestedArticleAction.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/DeliverRequestedArticleAction.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -3,6 +3,7 @@
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
+import com.franciaflex.magalie.services.service.FindOrderToExecuteResult;
import com.franciaflex.magalie.services.service.RequestedArticleService;
import com.franciaflex.magalie.web.MagalieActionSupport;
import com.franciaflex.magalie.web.MagalieSession;
@@ -39,20 +40,37 @@
Building building = session.getBuilding();
- storageMovementOrder = service.getStorageMovementOrder(magalieUser, building);
+ FindOrderToExecuteResult findOrderToExecuteResult =
+ service.getStorageMovementOrder(magalieUser, building);
- String result = SUCCESS;
+ if (findOrderToExecuteResult.isSuccess()) {
- if (storageMovementOrder == null) {
+ storageMovementOrder = findOrderToExecuteResult.getStorageMovementOrder();
- addActionMessage("Aucun article");
+ return SUCCESS;
- result = INPUT;
+ }
+ if (findOrderToExecuteResult.isNothingToDo()) {
+
+ addActionMessage("Il n'y a aucune demande. Vous n'avez rien à faire");
+
}
- return result;
+ if (findOrderToExecuteResult.isDriverLicenseRequired()) {
+ addActionMessage("Il y a des demandes en cours, mais un permis est requis");
+
+ }
+
+ if (findOrderToExecuteResult.isEverythingUnavailable()) {
+
+ addActionMessage("Toutes les demandes en cours concernent des articles indisponibles");
+
+ }
+
+ return INPUT;
+
}
public String getStorageMovementOrderId() {
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -5,8 +5,7 @@
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
+import com.franciaflex.magalie.services.service.BookArticleResult;
import com.franciaflex.magalie.services.service.FulfilKanbanService;
import com.franciaflex.magalie.web.MagalieActionSupport;
import com.franciaflex.magalie.web.MagalieSession;
@@ -96,9 +95,11 @@
// save used destination warehouse to propose it by default on next kanban
session.setLastUsedDestinationWarehouseForKanbans(destinationWarehouse);
+ BookArticleResult bookArticleResult;
+
try {
- storageMovementOrder = service.fulfilKanbanTask(articleBarcode, magalieUser, destinationWarehouseId);
+ bookArticleResult = service.fulfilKanbanTask(articleBarcode, magalieUser, destinationWarehouseId);
} catch (InvalidMagalieBarcodeException e) {
@@ -106,20 +107,26 @@
return INPUT;
- } catch (UnavailableArticleException e) {
+ }
+ if (bookArticleResult.isArticleUnavailable()) {
+
addActionError("Cet article n'est pas disponible");
return INPUT;
- } catch (RequiredDriverLicenceException e) {
+ }
+ if (bookArticleResult.isArticleInaccessible()) {
+
addActionError("Un permis est nécessaire pour obtenir cet article");
return INPUT;
}
+ storageMovementOrder = bookArticleResult.getStorageMovementOrder();
+
return SUCCESS;
}
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/WithdrawItemAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/WithdrawItemAction.java 2013-04-15 12:51:16 UTC (rev 96)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/WithdrawItemAction.java 2013-04-15 15:37:46 UTC (rev 97)
@@ -27,8 +27,6 @@
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.services.StorageMovementConfirmation;
import com.franciaflex.magalie.services.StorageMovementTask;
-import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
-import com.franciaflex.magalie.services.exception.UnavailableArticleException;
import com.franciaflex.magalie.services.service.ArticleStorageService;
import com.franciaflex.magalie.web.MagalieActionSupport;
import com.franciaflex.magalie.web.MagalieSession;
@@ -73,7 +71,7 @@
}
@Override
- public String input() throws RequiredDriverLicenceException, UnavailableArticleException {
+ public String input() {
Preconditions.checkNotNull(storageMovementOrderId);
1
0
15 Apr '13
Author: bleny
Date: 2013-04-15 14:51:16 +0200 (Mon, 15 Apr 2013)
New Revision: 96
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
add B2 building in fixtures
Modified:
trunk/magalie-services/src/main/resources/fixtures.yaml
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 13:54:08 UTC (rev 95)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-15 12:51:16 UTC (rev 96)
@@ -37,8 +37,14 @@
id: building_1
code: B1
+B2:
+ &B2 !building
+ id: building_2
+ code: B2
+
buildings:
- *B1
+ - *B2
U01:
&U01 !warehouse
@@ -56,13 +62,13 @@
&U03 !warehouse
id: warehouse_u03
code: U03
- building: *B1
+ building: *B2
U04:
&U04 !warehouse
id: warehouse_u04
code: U04
- building: *B1
+ building: *B2
SOM:
&SOM !warehouse
1
0
r95 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/main/resources magalie-web/src/main/webapp/WEB-INF/content
by bleny@users.forge.codelutin.com 12 Apr '13
by bleny@users.forge.codelutin.com 12 Apr '13
12 Apr '13
Author: bleny
Date: 2013-04-12 15:54:08 +0200 (Fri, 12 Apr 2013)
New Revision: 95
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce supplier
Added:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Supplier.java
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java
trunk/magalie-services/src/main/resources/fixtures.yaml
trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java 2013-04-12 12:40:47 UTC (rev 94)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java 2013-04-12 13:54:08 UTC (rev 95)
@@ -3,6 +3,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
import java.util.Set;
@Entity
@@ -14,6 +15,9 @@
@ManyToMany
protected Set<Location> fixedLocations;
+ @ManyToOne
+ protected Supplier supplier;
+
protected String description;
protected String code;
@@ -89,4 +93,12 @@
public void setFixedLocationsFirst(boolean fixedLocationsFirst) {
this.fixedLocationsFirst = fixedLocationsFirst;
}
+
+ public Supplier getSupplier() {
+ return supplier;
+ }
+
+ public void setSupplier(Supplier supplier) {
+ this.supplier = supplier;
+ }
}
Added: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Supplier.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Supplier.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Supplier.java 2013-04-12 13:54:08 UTC (rev 95)
@@ -0,0 +1,30 @@
+package com.franciaflex.magalie.persistence.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Supplier extends AbstractEntity {
+
+ @Id
+ protected String id;
+
+ protected String name;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
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-04-12 12:40:47 UTC (rev 94)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-04-12 13:54:08 UTC (rev 95)
@@ -54,6 +54,8 @@
Preconditions.checkNotNull(bookArticleRequest.getArticle());
+ Preconditions.checkNotNull(bookArticleRequest.getDestinationLocation());
+
Preconditions.checkArgument(bookArticleRequest.getRequestedQuantity() > 0.);
if (log.isInfoEnabled()) {
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 12:40:47 UTC (rev 94)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 13:54:08 UTC (rev 95)
@@ -426,6 +426,7 @@
article: *article1
quantity: 80
requestedList: *requestedList1
+ destinationLocation: *location14
requestedArticle2:
&requestedArticle2 !requested-article
@@ -433,6 +434,7 @@
article: *article2
quantity: 11
requestedList: *requestedList1
+ destinationLocation: *location14
requestedArticle3:
&requestedArticle3 !requested-article
@@ -440,6 +442,7 @@
article: *article3
quantity: 111
requestedList: *requestedList1
+ destinationLocation: *location14
requestedArticle4:
&requestedArticle4 !requested-article
@@ -447,6 +450,7 @@
article: *article4
quantity: 2
requestedList: *requestedList1
+ destinationLocation: *location14
requestedArticle5:
&requestedArticle5 !requested-article
@@ -454,6 +458,7 @@
article: *article5
quantity: 5
requestedList: *requestedList2
+ destinationLocation: *location14
requestedArticle6:
&requestedArticle6 !requested-article
@@ -461,6 +466,7 @@
article: *article6
quantity: 27
requestedList: *requestedList2
+ destinationLocation: *location14
requestedArticles:
- *requestedArticle1
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-04-12 12:40:47 UTC (rev 94)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-04-12 13:54:08 UTC (rev 95)
@@ -90,8 +90,6 @@
<dd><s:property value="storageMovementTask.article.code" /></dd>
<dt>Desc.</dt>
<dd><s:property value="storageMovementTask.article.description" /></dd>
- <dt>LàS</dt>
- <dd>123456789</dd>
<dt>Prélev.</dt>
<dd><span id="withdrawn">0</span> / <s:property value="storageMovementTask.quantity" /> <s:property value="storageMovementTask.article.unit" /></dd>
</dl>
1
0
r94 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/main/resources
by bleny@users.forge.codelutin.com 12 Apr '13
by bleny@users.forge.codelutin.com 12 Apr '13
12 Apr '13
Author: bleny
Date: 2013-04-12 14:40:47 +0200 (Fri, 12 Apr 2013)
New Revision: 94
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce requestList.building
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/main/resources/fixtures.yaml
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java 2013-04-12 10:23:19 UTC (rev 93)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java 2013-04-12 12:40:47 UTC (rev 94)
@@ -3,6 +3,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
@Entity
public class RequestedArticle extends AbstractEntity {
@@ -16,6 +17,9 @@
@ManyToOne
protected RequestedList requestedList;
+ @OneToOne
+ protected Location destinationLocation;
+
protected double quantity;
@Override
@@ -50,4 +54,12 @@
public void setRequestedList(RequestedList requestedList) {
this.requestedList = requestedList;
}
+
+ public Location getDestinationLocation() {
+ return destinationLocation;
+ }
+
+ public void setDestinationLocation(Location destinationLocation) {
+ this.destinationLocation = destinationLocation;
+ }
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-12 10:23:19 UTC (rev 93)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-12 12:40:47 UTC (rev 94)
@@ -30,6 +30,7 @@
import com.franciaflex.magalie.persistence.entity.Article;
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.DeliveredRequestedArticle;
+import com.franciaflex.magalie.persistence.entity.Location;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
@@ -116,8 +117,10 @@
double quantity = requestedArticle.getQuantity();
- BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, quantity, null, false);
+ Location destinationLocation = requestedArticle.getDestinationLocation();
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, quantity, destinationLocation, false);
+
try {
storageMovementOrder = articleStorageService.bookArticle(bookArticleRequest);
@@ -184,22 +187,28 @@
protected Queue<RequestedArticle> getRequestedArticlesByPriority(List<RequestedArticle> requests) {
- Comparator<RequestedArticle> priorityComparator =
- Ordering.compound(
- Lists.newArrayList(
- RequestedArticles.finishEarlyFirstComparator(requests),
- RequestedArticles.urgentFirstComparator(),
- RequestedArticles.requestDateFirstComparator()
- )
- );
+ PriorityQueue<RequestedArticle> requestedArticles = new PriorityQueue<RequestedArticle>();
- PriorityQueue<RequestedArticle> requestedArticles =
- new PriorityQueue<RequestedArticle>(
- requests.size(),
- priorityComparator);
+ if ( ! requests.isEmpty()) {
- requestedArticles.addAll(requests);
+ Comparator<RequestedArticle> priorityComparator =
+ Ordering.compound(
+ Lists.newArrayList(
+ RequestedArticles.finishEarlyFirstComparator(requests),
+ RequestedArticles.urgentFirstComparator(),
+ RequestedArticles.requestDateFirstComparator()
+ )
+ );
+ requestedArticles =
+ new PriorityQueue<RequestedArticle>(
+ requests.size(),
+ priorityComparator);
+
+ requestedArticles.addAll(requests);
+
+ }
+
return requestedArticles;
}
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 10:23:19 UTC (rev 93)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 12:40:47 UTC (rev 94)
@@ -70,12 +70,19 @@
code: SOM
building: *B1
+B01:
+ &B01 !warehouse
+ id: warehouse_b01
+ code: B01
+ building: *B1
+
warehouses:
- *U01
- *U02
- *U03
- *U04
- *SOM
+ - *B01
location1:
&location1 !location
@@ -168,6 +175,13 @@
code: REC
requiredAccreditationLevel: 0
+location14:
+ &location14 !location
+ id: location14
+ warehouse: *B01
+ code: SANS
+ requiredAccreditationLevel: 0
+
locations:
- *location1
- *location2
@@ -182,6 +196,7 @@
- *location11
- *location12
- *location13
+ - *location14
article1:
&article1 !article
@@ -391,6 +406,7 @@
code: 123456789
requestDate: 2013-04-08 12:00:00
urgent: true
+ building: *B1
requestedList2:
&requestedList2 !requested-list
@@ -398,6 +414,7 @@
code: 123456789
requestDate: 2013-04-08 12:00:00
urgent: false
+ building: *B1
requestedLists:
- *requestedList1
1
0
r93 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-web/src/main/java/com/franciaflex/magalie/web/action
by bleny@users.forge.codelutin.com 12 Apr '13
by bleny@users.forge.codelutin.com 12 Apr '13
12 Apr '13
Author: bleny
Date: 2013-04-12 12:23:19 +0200 (Fri, 12 Apr 2013)
New Revision: 93
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce notion of warehouses without locations
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java
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/WarehouseJpaDao.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.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-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/Locations.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -70,4 +70,9 @@
public static Predicate<Location> locationIsNotReportedInError(Collection<Location> allLocationsInError) {
return Predicates.not(Predicates.in(allLocationsInError));
}
+
+ public static String codeForWarehouseWithoutLocations() {
+ return "SANS";
+ }
+
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -1,7 +1,10 @@
package com.franciaflex.magalie.persistence.dao;
import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
public interface LocationDao extends Dao<Location> {
+ Location find(String code, Warehouse warehouse);
+
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -1,10 +1,15 @@
package com.franciaflex.magalie.persistence.dao;
+import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.Warehouse;
+import java.util.List;
+
/**
* @author bleny
*/
public interface WarehouseDao extends Dao<Warehouse> {
+ List<Warehouse> findAllWithoutLocations(Building building);
+
}
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-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -2,10 +2,10 @@
import com.franciaflex.magalie.persistence.dao.LocationDao;
import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.List;
+import javax.persistence.TypedQuery;
public class LocationJpaDao extends AbstractJpaDao<Location> implements LocationDao {
@@ -18,4 +18,12 @@
return Location.class;
}
+ @Override
+ public Location find(String code, Warehouse warehouse) {
+ TypedQuery<Location> query = entityManager.createQuery("from Location l where l.code = :code and l.warehouse = :warehouse", getEntityClass());
+ query.setParameter("code", code);
+ query.setParameter("warehouse", warehouse);
+ Location singleResult = query.getSingleResult();
+ return singleResult;
+ }
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java 2013-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -1,9 +1,13 @@
package com.franciaflex.magalie.persistence.dao.jpa;
+import com.franciaflex.magalie.persistence.Locations;
import com.franciaflex.magalie.persistence.dao.WarehouseDao;
+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 AbstractJpaDao<Warehouse> implements WarehouseDao {
@@ -15,4 +19,12 @@
protected Class<Warehouse> getEntityClass() {
return Warehouse.class;
}
+
+ @Override
+ public List<Warehouse> findAllWithoutLocations(Building building) {
+ TypedQuery<Warehouse> query = entityManager.createQuery("from Warehouse w where w.building = :building and w in (select l.warehouse from Location l where l.code = :code)", getEntityClass());
+ query.setParameter("building", building);
+ query.setParameter("code", Locations.codeForWarehouseWithoutLocations());
+ return query.getResultList();
+ }
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -1,6 +1,8 @@
package com.franciaflex.magalie.services.service;
+import com.franciaflex.magalie.persistence.Locations;
import com.franciaflex.magalie.persistence.MagaliePersistenceContext;
+import com.franciaflex.magalie.persistence.dao.LocationDao;
import com.franciaflex.magalie.persistence.dao.WarehouseDao;
import com.franciaflex.magalie.persistence.entity.Article;
import com.franciaflex.magalie.persistence.entity.Building;
@@ -84,21 +86,25 @@
protected Location getDestinationLocation(Warehouse destinationWarehouse) {
- // TODO brendan 10/04/13 how to define destination for warehouse, something like "INC" ?
+ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
- return null;
+ LocationDao locationDao = persistenceContext.getLocationDao();
+ Location location = locationDao.find(Locations.codeForWarehouseWithoutLocations(), destinationWarehouse);
+
+ return location;
+
}
- public List<Warehouse> getDestinationStores(Building building) {
+ public List<Warehouse> getDestinationWarehouses(Building building) {
MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
WarehouseDao warehouseDao = persistenceContext.getWarehouseDao();
- // FIXME brendan 10/04/13 consider building
+ List<Warehouse> destinationWarehouses = warehouseDao.findAllWithoutLocations(building);
- return warehouseDao.findAll();
+ return destinationWarehouses;
}
}
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-12 10:09:55 UTC (rev 92)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-12 10:23:19 UTC (rev 93)
@@ -50,7 +50,7 @@
Building building = session.getBuilding();
- destinationWarehouses = service.getDestinationStores(building);
+ destinationWarehouses = service.getDestinationWarehouses(building);
// let's help user by selecting by default the previously used destination warehouse
1
0
r92 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/main/resources
by bleny@users.forge.codelutin.com 12 Apr '13
by bleny@users.forge.codelutin.com 12 Apr '13
12 Apr '13
Author: bleny
Date: 2013-04-12 12:09:55 +0200 (Fri, 12 Apr 2013)
New Revision: 92
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
add building in RequestList
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedArticleJpaDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/main/resources/fixtures2.yaml
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedArticleJpaDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedArticleJpaDao.java 2013-04-12 09:24:13 UTC (rev 91)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedArticleJpaDao.java 2013-04-12 10:09:55 UTC (rev 92)
@@ -21,12 +21,12 @@
@Override
public List<RequestedArticle> findAllUndelivered(Building building) {
- // XXX brendan 10/04/13 what about building ???
TypedQuery<RequestedArticle> query =
entityManager.createQuery(
- "from RequestedArticle ra where ra not in (select dra.requestedArticle from DeliveredRequestedArticle dra)",
+ "from RequestedArticle ra where ra not in (select dra.requestedArticle from DeliveredRequestedArticle dra) and ra.requestedList.building = :building",
getEntityClass()
);
+ query.setParameter("building", building);
return query.getResultList();
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java 2013-04-12 09:24:13 UTC (rev 91)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java 2013-04-12 10:09:55 UTC (rev 92)
@@ -2,6 +2,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
+import javax.persistence.ManyToOne;
import java.util.Date;
@Entity
@@ -10,6 +11,9 @@
@Id
protected String id;
+ @ManyToOne
+ protected Building building;
+
protected String code;
protected Date requestDate;
@@ -48,4 +52,12 @@
public void setCode(String code) {
this.code = code;
}
+
+ public Building getBuilding() {
+ return building;
+ }
+
+ public void setBuilding(Building building) {
+ this.building = building;
+ }
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-12 09:24:13 UTC (rev 91)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-12 10:09:55 UTC (rev 92)
@@ -87,8 +87,6 @@
log.info(allRequestedArticles.size() + " articles requested in building " + building.getCode());
}
- // TODO brendan 05/04/13 consider warehouse.code
-
return allRequestedArticles;
}
Modified: trunk/magalie-services/src/main/resources/fixtures2.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-12 09:24:13 UTC (rev 91)
+++ trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-12 10:09:55 UTC (rev 92)
@@ -199,6 +199,7 @@
code: 987654321
requestDate: 2013-04-08 12:00:00
urgent: true
+ building: *B1
requestedList2:
&requestedList2 !requested-list
@@ -206,6 +207,7 @@
code: 123456789
requestDate: 2013-04-08 12:00:00
urgent: false
+ building: *B1
requestedLists:
- *requestedList1
1
0
12 Apr '13
Author: bleny
Date: 2013-04-12 11:24:13 +0200 (Fri, 12 Apr 2013)
New Revision: 91
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce requested lists
Added:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedListJpaDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/RequestedArticles.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/main/resources/fixtures.yaml
trunk/magalie-services/src/main/resources/fixtures2.yaml
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -7,6 +7,7 @@
import com.franciaflex.magalie.persistence.dao.RequestedArticleDao;
import com.franciaflex.magalie.persistence.dao.LocationDao;
import com.franciaflex.magalie.persistence.dao.LocationErrorDao;
+import com.franciaflex.magalie.persistence.dao.RequestedListDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao;
import com.franciaflex.magalie.persistence.dao.WarehouseDao;
@@ -18,6 +19,7 @@
import com.franciaflex.magalie.persistence.dao.jpa.LocationJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.MagalieUserJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.RequestedArticleJpaDao;
+import com.franciaflex.magalie.persistence.dao.jpa.RequestedListJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.StorageMovementJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.StorageMovementOrderJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.WarehouseJpaDao;
@@ -41,6 +43,27 @@
}
@Override
+ public void commit() {
+ entityTransaction.commit();
+ entityTransaction = entityManager.getTransaction();
+ entityTransaction.begin();
+ }
+
+ @Override
+ public void rollback() {
+ entityTransaction.rollback();
+ entityTransaction = entityManager.getTransaction();
+ entityTransaction.begin();
+ }
+
+ @Override
+ public void clearDatabase() {
+ rollback();
+ JpaUtil.cleanDatabase(entityManager);
+ commit();
+ }
+
+ @Override
public MagalieUserDao getMagalieUserDao() {
return new MagalieUserJpaDao(entityManager);
}
@@ -96,23 +119,8 @@
}
@Override
- public void commit() {
- entityTransaction.commit();
- entityTransaction = entityManager.getTransaction();
- entityTransaction.begin();
+ public RequestedListDao getRequestedListDao() {
+ return new RequestedListJpaDao(entityManager);
}
- @Override
- public void rollback() {
- entityTransaction.rollback();
- entityTransaction = entityManager.getTransaction();
- entityTransaction.begin();
- }
-
- @Override
- public void clearDatabase() {
- rollback();
- JpaUtil.cleanDatabase(entityManager);
- commit();
- }
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -3,14 +3,15 @@
import com.franciaflex.magalie.persistence.dao.ArticleDao;
import com.franciaflex.magalie.persistence.dao.BuildingDao;
import com.franciaflex.magalie.persistence.dao.DeliveredRequestedArticleDao;
+import com.franciaflex.magalie.persistence.dao.LocationDao;
+import com.franciaflex.magalie.persistence.dao.LocationErrorDao;
import com.franciaflex.magalie.persistence.dao.MagalieUserDao;
import com.franciaflex.magalie.persistence.dao.RequestedArticleDao;
-import com.franciaflex.magalie.persistence.dao.LocationDao;
-import com.franciaflex.magalie.persistence.dao.LocationErrorDao;
+import com.franciaflex.magalie.persistence.dao.RequestedListDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao;
+import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
import com.franciaflex.magalie.persistence.dao.WarehouseDao;
-import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
/**
* @author bleny
@@ -44,4 +45,7 @@
BuildingDao getBuildingDao();
WarehouseDao getWarehouseDao();
+
+ RequestedListDao getRequestedListDao();
+
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/RequestedArticles.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/RequestedArticles.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/RequestedArticles.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -1,18 +1,25 @@
package com.franciaflex.magalie.persistence;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
+import com.franciaflex.magalie.persistence.entity.RequestedList;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimaps;
import org.apache.commons.collections.comparators.BooleanComparator;
+import java.util.Collection;
import java.util.Comparator;
+import java.util.List;
import java.util.Map;
public class RequestedArticles {
- protected static final class UrgentFirstComparator implements Comparator<RequestedArticle> {
+ protected static class UrgentFirstComparator implements Comparator<RequestedArticle> {
@Override
public int compare(RequestedArticle x, RequestedArticle y) {
- return BooleanComparator.getTrueFirstComparator().compare(x.isUrgent(), y.isUrgent());
+ return BooleanComparator.getTrueFirstComparator().compare(x.getRequestedList().isUrgent(), y.getRequestedList().isUrgent());
}
}
@@ -21,32 +28,41 @@
@Override
public int compare(RequestedArticle x, RequestedArticle y) {
- return x.getRequestDate().compareTo(y.getRequestDate());
+ return x.getRequestedList().getRequestDate().compareTo(y.getRequestedList().getRequestDate());
}
}
protected static class FinishEarlyFirstComparator implements Comparator<RequestedArticle> {
- protected Map<String, Integer> requestListToArticleRemainingCount;
+ protected Map<RequestedList, Integer> requestListToArticleRemainingCount;
- // TODO brendan 05/04/13 something to do here
+ public FinishEarlyFirstComparator(Map<RequestedList, Integer> requestListToArticleRemainingCount) {
+ this.requestListToArticleRemainingCount = requestListToArticleRemainingCount;
+ }
protected int getRemainingCount(RequestedArticle requestedArticle) {
- Integer remainingCount = requestListToArticleRemainingCount.get(requestedArticle.getRequestList());
- return remainingCount == null ? Integer.MAX_VALUE : remainingCount;
+ Integer remainingCount = requestListToArticleRemainingCount.get(requestedArticle.getRequestedList());
+ return remainingCount;
}
@Override
public int compare(RequestedArticle x, RequestedArticle y) {
- return 0;
-// int xRemainingCount = getRemainingCount(x);
-// int yRemainingCount = getRemainingCount(y);
-// return xRemainingCount - yRemainingCount;
+ int xRemainingCount = getRemainingCount(x);
+ int yRemainingCount = getRemainingCount(y);
+ return xRemainingCount - yRemainingCount;
}
}
+ protected static class GetRequestList implements Function<RequestedArticle, RequestedList> {
+
+ @Override
+ public RequestedList apply(RequestedArticle requestedArticle) {
+ return requestedArticle.getRequestedList();
+ }
+ }
+
public static Comparator<RequestedArticle> urgentFirstComparator() {
return new UrgentFirstComparator();
}
@@ -55,7 +71,28 @@
return new RequestDateFistComparator();
}
- public static Comparator<RequestedArticle> finishEarlyFirstComparator() {
- return new FinishEarlyFirstComparator();
+ public static Comparator<RequestedArticle> finishEarlyFirstComparator(List<RequestedArticle> requests) {
+
+ ImmutableListMultimap<RequestedList, RequestedArticle> index =
+ Multimaps.index(requests, RequestedArticles.getRequestList());
+
+ Map<RequestedList, Integer> requestListToArticleRemainingCount = Maps.newHashMap();
+
+ for (Map.Entry<RequestedList, Collection<RequestedArticle>> requestedListCollectionEntry : index.asMap().entrySet()) {
+
+ RequestedList requestedList = requestedListCollectionEntry.getKey();
+
+ int remainingCount = requestedListCollectionEntry.getValue().size();
+
+ requestListToArticleRemainingCount.put(requestedList, remainingCount);
+
+ }
+
+ return new FinishEarlyFirstComparator(requestListToArticleRemainingCount);
+
}
+
+ public static Function<RequestedArticle, RequestedList> getRequestList() {
+ return new GetRequestList();
+ }
}
Added: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/RequestedListDao.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -0,0 +1,10 @@
+package com.franciaflex.magalie.persistence.dao;
+
+import com.franciaflex.magalie.persistence.entity.RequestedList;
+
+/**
+ * @author bleny
+ */
+public interface RequestedListDao extends Dao<RequestedList> {
+
+}
Added: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedListJpaDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedListJpaDao.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/RequestedListJpaDao.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -0,0 +1,19 @@
+package com.franciaflex.magalie.persistence.dao.jpa;
+
+import com.franciaflex.magalie.persistence.dao.RequestedListDao;
+import com.franciaflex.magalie.persistence.entity.RequestedList;
+
+import javax.persistence.EntityManager;
+
+public class RequestedListJpaDao extends AbstractJpaDao<RequestedList> implements RequestedListDao {
+
+ public RequestedListJpaDao(EntityManager entityManager) {
+ super(entityManager);
+ }
+
+ @Override
+ protected Class<RequestedList> getEntityClass() {
+ return RequestedList.class;
+ }
+
+}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedArticle.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -3,7 +3,6 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
-import java.util.Date;
@Entity
public class RequestedArticle extends AbstractEntity {
@@ -14,12 +13,9 @@
@ManyToOne
protected Article article;
- protected String requestList;
+ @ManyToOne
+ protected RequestedList requestedList;
- protected Date requestDate;
-
- protected boolean urgent;
-
protected double quantity;
@Override
@@ -31,30 +27,6 @@
this.id = id;
}
- public String getRequestList() {
- return requestList;
- }
-
- public void setRequestList(String requestList) {
- this.requestList = requestList;
- }
-
- public Date getRequestDate() {
- return requestDate;
- }
-
- public void setRequestDate(Date requestDate) {
- this.requestDate = requestDate;
- }
-
- public boolean isUrgent() {
- return urgent;
- }
-
- public void setUrgent(boolean urgent) {
- this.urgent = urgent;
- }
-
public Article getArticle() {
return article;
}
@@ -70,4 +42,12 @@
public void setQuantity(double quantity) {
this.quantity = quantity;
}
+
+ public RequestedList getRequestedList() {
+ return requestedList;
+ }
+
+ public void setRequestedList(RequestedList requestedList) {
+ this.requestedList = requestedList;
+ }
}
Added: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/RequestedList.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -0,0 +1,51 @@
+package com.franciaflex.magalie.persistence.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.util.Date;
+
+@Entity
+public class RequestedList extends AbstractEntity {
+
+ @Id
+ protected String id;
+
+ protected String code;
+
+ protected Date requestDate;
+
+ protected boolean urgent;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Date getRequestDate() {
+ return requestDate;
+ }
+
+ public void setRequestDate(Date requestDate) {
+ this.requestDate = requestDate;
+ }
+
+ public boolean isUrgent() {
+ return urgent;
+ }
+
+ public void setUrgent(boolean urgent) {
+ this.urgent = urgent;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -8,6 +8,7 @@
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.RequestedList;
import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.persistence.entity.StoredArticle;
import org.apache.commons.io.Charsets;
@@ -37,6 +38,7 @@
reader.getConfig().setClassTag("stored-article", StoredArticle.class);
reader.getConfig().setClassTag("user", MagalieUser.class);
reader.getConfig().setClassTag("requested-article", RequestedArticle.class);
+ reader.getConfig().setClassTag("requested-list", RequestedList.class);
reader.getConfig().setClassTag("location", Location.class);
try {
fixtures = (Map<String, Object>) reader.read();
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -3,18 +3,20 @@
import com.franciaflex.magalie.persistence.MagaliePersistenceContext;
import com.franciaflex.magalie.persistence.dao.ArticleDao;
import com.franciaflex.magalie.persistence.dao.BuildingDao;
+import com.franciaflex.magalie.persistence.dao.LocationDao;
import com.franciaflex.magalie.persistence.dao.MagalieUserDao;
import com.franciaflex.magalie.persistence.dao.RequestedArticleDao;
-import com.franciaflex.magalie.persistence.dao.LocationDao;
+import com.franciaflex.magalie.persistence.dao.RequestedListDao;
+import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
import com.franciaflex.magalie.persistence.dao.WarehouseDao;
-import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
import com.franciaflex.magalie.persistence.entity.Article;
import com.franciaflex.magalie.persistence.entity.Building;
+import com.franciaflex.magalie.persistence.entity.Location;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
-import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.RequestedList;
+import com.franciaflex.magalie.persistence.entity.StoredArticle;
import com.franciaflex.magalie.persistence.entity.Warehouse;
-import com.franciaflex.magalie.persistence.entity.StoredArticle;
import com.franciaflex.magalie.services.MagalieFixtures;
import com.franciaflex.magalie.services.MagalieService;
import com.franciaflex.magalie.services.MagalieServiceContext;
@@ -145,6 +147,18 @@
persistenceContext.commit();
+ RequestedListDao requestedListDao = persistenceContext.getRequestedListDao();
+
+ Collection<RequestedList> requestedLists = fixtures.fixture("requestedLists");
+
+ for (RequestedList requestedList : requestedLists) {
+
+ requestedListDao.persist(requestedList);
+
+ }
+
+ persistenceContext.commit();
+
RequestedArticleDao requestedArticleDao = persistenceContext.getRequestedArticleDao();
Collection<RequestedArticle> requestedArticles = fixtures.fixture("requestedArticles");
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-12 09:24:13 UTC (rev 91)
@@ -189,7 +189,7 @@
Comparator<RequestedArticle> priorityComparator =
Ordering.compound(
Lists.newArrayList(
- RequestedArticles.finishEarlyFirstComparator(),
+ RequestedArticles.finishEarlyFirstComparator(requests),
RequestedArticles.urgentFirstComparator(),
RequestedArticles.requestDateFirstComparator()
)
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-12 09:24:13 UTC (rev 91)
@@ -385,61 +385,66 @@
storedArticlesForArticle6:
- *storedArticle13
+requestedList1:
+ &requestedList1 !requested-list
+ id: requestedList1
+ code: 123456789
+ requestDate: 2013-04-08 12:00:00
+ urgent: true
+
+requestedList2:
+ &requestedList2 !requested-list
+ id: requestedList2
+ code: 123456789
+ requestDate: 2013-04-08 12:00:00
+ urgent: false
+
+requestedLists:
+ - *requestedList1
+ - *requestedList2
+
requestedArticle1:
&requestedArticle1 !requested-article
id: requestedArticle1
article: *article1
quantity: 80
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList1
requestedArticle2:
&requestedArticle2 !requested-article
id: requestedArticle2
article: *article2
quantity: 11
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: false
+ requestedList: *requestedList1
requestedArticle3:
&requestedArticle3 !requested-article
id: requestedArticle3
article: *article3
quantity: 111
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList1
requestedArticle4:
&requestedArticle4 !requested-article
id: requestedArticle4
article: *article4
quantity: 2
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList1
requestedArticle5:
&requestedArticle5 !requested-article
id: requestedArticle5
article: *article5
quantity: 5
- requestList: 987654321
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList2
requestedArticle6:
&requestedArticle6 !requested-article
id: requestedArticle6
article: *article6
quantity: 27
- requestList: 987654321
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList2
-
requestedArticles:
- *requestedArticle1
- *requestedArticle2
Modified: trunk/magalie-services/src/main/resources/fixtures2.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-11 21:40:01 UTC (rev 90)
+++ trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-12 09:24:13 UTC (rev 91)
@@ -193,23 +193,37 @@
- *storedArticle1
- *storedArticle2
+requestedList1:
+ &requestedList1 !requested-list
+ id: requestedList1
+ code: 987654321
+ requestDate: 2013-04-08 12:00:00
+ urgent: true
+
+requestedList2:
+ &requestedList2 !requested-list
+ id: requestedList2
+ code: 123456789
+ requestDate: 2013-04-08 12:00:00
+ urgent: false
+
+requestedLists:
+ - *requestedList1
+ - *requestedList2
+
requestedArticle1:
&requestedArticle1 !requested-article
id: requestedArticle1
article: *article3
quantity: 100
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: true
+ requestedList: *requestedList1
requestedArticle2:
&requestedArticle2 !requested-article
id: requestedArticle2
article: *article3
quantity: 250
- requestList: 123456789
- requestDate: 2013-04-08 12:00:00
- urgent: false
+ requestedList: *requestedList2
requestedArticles:
- *requestedArticle1
1
0
r90 - in trunk/magalie-services/src: main/java/com/franciaflex/magalie/services/service test/java/com/franciaflex/magalie/services/service
by bleny@users.forge.codelutin.com 11 Apr '13
by bleny@users.forge.codelutin.com 11 Apr '13
11 Apr '13
Author: bleny
Date: 2013-04-11 23:40:01 +0200 (Thu, 11 Apr 2013)
New Revision: 90
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce BookArticleRequest
Added:
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleRequest.java
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/FulfilKanbanService.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
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-04-11 21:07:14 UTC (rev 89)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-04-11 21:40:01 UTC (rev 90)
@@ -45,52 +45,26 @@
this.serviceContext = serviceContext;
}
- public StorageMovementOrder bookArticle(MagalieUser magalieUser, Building building, Article article, double requestedQuantity) throws UnavailableArticleException, RequiredDriverLicenceException {
-
- return bookArticle(magalieUser, building, article, requestedQuantity, null);
-
- }
-
- public StorageMovementOrder bookArticleWithBestEffortPolicy(
- MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation)
- throws RequiredDriverLicenceException, UnavailableArticleException {
-
- return bookArticle(magalieUser, building, article ,requestedQuantity, destinationLocation, true);
-
- }
-
- public StorageMovementOrder bookArticle(
- MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation)
+ public StorageMovementOrder bookArticle(BookArticleRequest bookArticleRequest)
throws UnavailableArticleException, RequiredDriverLicenceException {
- return bookArticle(magalieUser, building, article ,requestedQuantity, destinationLocation, false);
+ Preconditions.checkNotNull(bookArticleRequest.getMagalieUser());
- }
+ Preconditions.checkNotNull(bookArticleRequest.getBuilding());
- protected StorageMovementOrder bookArticle(
- MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation, boolean bestEffortPolicy)
- throws UnavailableArticleException, RequiredDriverLicenceException {
+ Preconditions.checkNotNull(bookArticleRequest.getArticle());
- Preconditions.checkNotNull(magalieUser);
+ Preconditions.checkArgument(bookArticleRequest.getRequestedQuantity() > 0.);
- Preconditions.checkNotNull(building);
-
- Preconditions.checkNotNull(article);
-
- Preconditions.checkArgument(requestedQuantity > 0.);
-
if (log.isInfoEnabled()) {
- log.info("will process article request"
- + ": requested = " + requestedQuantity
- );
+ log.info("will process article request" + bookArticleRequest);
}
- List<StoredArticle> storedArticles = getStoredArticles(building, article);
+ List<StoredArticle> storedArticles = getStoredArticles(bookArticleRequest.getBuilding(), bookArticleRequest.getArticle());
Queue<StoredArticle> sortedStoredArticles = sortStoredArticlesByPriority(storedArticles);
- StorageMovementOrder storageMovementOrder = buildStorageMovementOrder(
- magalieUser, article, requestedQuantity, destinationLocation, bestEffortPolicy, sortedStoredArticles);
+ StorageMovementOrder storageMovementOrder = buildStorageMovementOrder(bookArticleRequest, sortedStoredArticles);
MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
@@ -104,8 +78,14 @@
}
- protected StorageMovementOrder buildStorageMovementOrder(MagalieUser magalieUser, Article article, double requestedQuantity, Location destinationLocation, boolean bestEffortPolicy, Queue<StoredArticle> sortedStoredArticles) throws RequiredDriverLicenceException, UnavailableArticleException {
+ protected StorageMovementOrder buildStorageMovementOrder(BookArticleRequest bookArticleRequest, Queue<StoredArticle> sortedStoredArticles) throws RequiredDriverLicenceException, UnavailableArticleException {
+ Article article = bookArticleRequest.getArticle();
+
+ MagalieUser magalieUser = bookArticleRequest.getMagalieUser();
+
+ double requestedQuantity = bookArticleRequest.getRequestedQuantity();
+
StorageMovementOrder storageMovementOrder = new StorageMovementOrder();
double quantity = 0;
@@ -138,7 +118,7 @@
newStorageMovement.setOriginLocation(originLocation);
- newStorageMovement.setDestinationLocation(destinationLocation);
+ newStorageMovement.setDestinationLocation(bookArticleRequest.getDestinationLocation());
newStorageMovement.setExpectedQuantity(quantityWithdrawn);
@@ -147,7 +127,7 @@
}
}
- if (bestEffortPolicy) {
+ if (bookArticleRequest.isBestEffortPolicy()) {
log.debug("best effort policy, requested quantity was "
+ requestedQuantity + " but only " + quantity +
Added: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleRequest.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleRequest.java (rev 0)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BookArticleRequest.java 2013-04-11 21:40:01 UTC (rev 90)
@@ -0,0 +1,60 @@
+package com.franciaflex.magalie.services.service;
+
+import com.franciaflex.magalie.persistence.entity.Article;
+import com.franciaflex.magalie.persistence.entity.Building;
+import com.franciaflex.magalie.persistence.entity.Location;
+import com.franciaflex.magalie.persistence.entity.MagalieUser;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+public class BookArticleRequest {
+
+ protected MagalieUser magalieUser;
+
+ protected Building building;
+
+ protected Article article;
+
+ protected double requestedQuantity;
+
+ protected Location destinationLocation;
+
+ protected boolean bestEffortPolicy;
+
+ public BookArticleRequest(MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation, boolean bestEffortPolicy) {
+ this.magalieUser = magalieUser;
+ this.building = building;
+ this.article = article;
+ this.requestedQuantity = requestedQuantity;
+ this.destinationLocation = destinationLocation;
+ this.bestEffortPolicy = bestEffortPolicy;
+ }
+
+ public MagalieUser getMagalieUser() {
+ return magalieUser;
+ }
+
+ public Building getBuilding() {
+ return building;
+ }
+
+ public Article getArticle() {
+ return article;
+ }
+
+ public double getRequestedQuantity() {
+ return requestedQuantity;
+ }
+
+ public Location getDestinationLocation() {
+ return destinationLocation;
+ }
+
+ public boolean isBestEffortPolicy() {
+ return bestEffortPolicy;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.reflectionToString(this);
+ }
+}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-11 21:07:14 UTC (rev 89)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-11 21:40:01 UTC (rev 90)
@@ -70,13 +70,13 @@
Location destinationLocation = getDestinationLocation(destinationWarehouse);
+ BookArticleRequest bookArticleRequest =
+ new BookArticleRequest(
+ magalieUser, building, article,
+ quantityInKanban, destinationLocation, true);
+
StorageMovementOrder storageMovementOrder =
- articleStorageService.bookArticleWithBestEffortPolicy(
- magalieUser,
- building,
- article,
- quantityInKanban,
- destinationLocation);
+ articleStorageService.bookArticle(bookArticleRequest);
return storageMovementOrder;
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-11 21:07:14 UTC (rev 89)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-11 21:40:01 UTC (rev 90)
@@ -118,9 +118,11 @@
double quantity = requestedArticle.getQuantity();
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, quantity, null, false);
+
try {
- storageMovementOrder = articleStorageService.bookArticle(magalieUser, building, article, quantity, null);
+ storageMovementOrder = articleStorageService.bookArticle(bookArticleRequest);
everythingIsUnavailable = false;
Modified: trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
===================================================================
--- trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-11 21:07:14 UTC (rev 89)
+++ trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-11 21:40:01 UTC (rev 90)
@@ -40,6 +40,24 @@
}
+ protected StorageMovementOrder bookArticle(MagalieUser magalieUser, Building building, Article article, double requestedQuantity) throws UnavailableArticleException, RequiredDriverLicenceException {
+
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, requestedQuantity, null, false);
+
+ return service.bookArticle(bookArticleRequest);
+
+ }
+
+ public StorageMovementOrder bookArticleWithBestEffortPolicy(
+ MagalieUser magalieUser, Building building, Article article, double requestedQuantity, Location destinationLocation)
+ throws RequiredDriverLicenceException, UnavailableArticleException {
+
+ BookArticleRequest bookArticleRequest = new BookArticleRequest(magalieUser, building, article, requestedQuantity, null, true);
+
+ return service.bookArticle(bookArticleRequest);
+
+ }
+
@Test
public void testThrowUnavailableArticle() throws Exception {
@@ -48,7 +66,7 @@
StorageMovementOrder storageMovementOrder;
try {
- storageMovementOrder = service.bookArticle(alexandre, building, article, 100.);
+ storageMovementOrder = bookArticle(alexandre, building, article, 100.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -70,7 +88,7 @@
StorageMovementOrder storageMovementOrder;
try {
- storageMovementOrder = service.bookArticle(basile, building, article, 70.);
+ storageMovementOrder = bookArticle(basile, building, article, 70.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -91,7 +109,7 @@
StorageMovementOrder storageMovementOrder = null;
try {
- storageMovementOrder = service.bookArticle(basile, building, article, 5.);
+ storageMovementOrder = bookArticle(basile, building, article, 5.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -118,7 +136,7 @@
StorageMovementOrder storageMovementOrder = null;
try {
- storageMovementOrder = service.bookArticle(alexandre, building, article, 50.);
+ storageMovementOrder = bookArticle(alexandre, building, article, 50.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -152,7 +170,7 @@
StorageMovementOrder storageMovementOrder = null;
try {
- storageMovementOrder = service.bookArticle(alexandre, building, article, 30.);
+ storageMovementOrder = bookArticle(alexandre, building, article, 30.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -176,7 +194,7 @@
}
try {
- storageMovementOrder = service.bookArticle(cathy, building, article, 30.);
+ storageMovementOrder = bookArticle(cathy, building, article, 30.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -211,7 +229,7 @@
locationErrorsService.reportError(location2, alexandre);
try {
- StorageMovementOrder storageMovementOrder = service.bookArticle(cathy, building, article, 30.);
+ StorageMovementOrder storageMovementOrder = bookArticle(cathy, building, article, 30.);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
@@ -242,7 +260,7 @@
Location location1 = fixture("location1");
try {
- StorageMovementOrder storageMovementOrder = service.bookArticleWithBestEffortPolicy(alexandre, building, article, 30., null);
+ StorageMovementOrder storageMovementOrder = bookArticleWithBestEffortPolicy(alexandre, building, article, 30., null);
if (log.isDebugEnabled()) {
log.debug("storageMovementOrder = " + storageMovementOrder);
}
1
0
r89 - in trunk: magalie-persistence/src/main/java/com/franciaflex/magalie/persistence magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity magalie-services/src/main/java/com/franciaflex/magalie/services/service magalie-services/src/main/resources
by bleny@users.forge.codelutin.com 11 Apr '13
by bleny@users.forge.codelutin.com 11 Apr '13
11 Apr '13
Author: bleny
Date: 2013-04-11 23:07:14 +0200 (Thu, 11 Apr 2013)
New Revision: 89
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
introduce fixedLocationsFirst in Article
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java
trunk/magalie-services/src/main/resources/fixtures.yaml
trunk/magalie-services/src/main/resources/fixtures2.yaml
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-04-11 20:24:53 UTC (rev 88)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/StoredArticles.java 2013-04-11 21:07:14 UTC (rev 89)
@@ -5,6 +5,7 @@
import com.franciaflex.magalie.persistence.entity.Location;
import com.franciaflex.magalie.persistence.entity.StoredArticle;
import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Ordering;
@@ -15,19 +16,19 @@
public class StoredArticles {
- protected static class FixedLocationForArticleFirst implements Comparator<StoredArticle> {
+ /**
+ * Put fixed sites for given article first, or last according to the value of
+ * {@link com.franciaflex.magalie.persistence.entity.Article#isFixedLocationsFirst()}
+ */
+ protected static class FixedLocationForArticle implements Comparator<StoredArticle> {
- protected Article article;
-
- public FixedLocationForArticleFirst(Article article) {
- this.article = article;
- }
-
@Override
public int compare(StoredArticle x, StoredArticle y) {
+ Article article = x.getArticle();
+ Preconditions.checkArgument(article.equals(y.getArticle()));
boolean xIsInFixedLocation = article.isFixedLocation(x.getLocation());
boolean yIsInFixedLocation = article.isFixedLocation(y.getLocation());
- return BooleanComparator.getTrueFirstComparator().compare(xIsInFixedLocation, yIsInFixedLocation);
+ return BooleanComparator.getBooleanComparator( ! article.isFixedLocationsFirst()).compare(xIsInFixedLocation, yIsInFixedLocation);
}
}
@@ -94,14 +95,10 @@
return new AccessibleLocationFirst(magalieUser);
}
- public static Comparator<StoredArticle> fixedLocationForArticleFirstComparator(Article article) {
- return new FixedLocationForArticleFirst(article);
+ public static Comparator<StoredArticle> fixedLocationForArticleComparator() {
+ return Ordering.from(new FixedLocationForArticle()).reverse();
}
- public static Comparator<StoredArticle> fixedLocationForArticleLastComparator(Article article) {
- return Ordering.from(new FixedLocationForArticleFirst(article)).reverse();
- }
-
public static Function<StoredArticle, Location> getLocationFunction() {
return new GetLocationFunction();
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java 2013-04-11 20:24:53 UTC (rev 88)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Article.java 2013-04-11 21:07:14 UTC (rev 89)
@@ -22,6 +22,8 @@
protected String unit;
+ protected boolean fixedLocationsFirst;
+
@Override
public String getId() {
return id;
@@ -79,4 +81,12 @@
}
return isFixedLocation;
}
+
+ public boolean isFixedLocationsFirst() {
+ return fixedLocationsFirst;
+ }
+
+ public void setFixedLocationsFirst(boolean fixedLocationsFirst) {
+ this.fixedLocationsFirst = fixedLocationsFirst;
+ }
}
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-04-11 20:24:53 UTC (rev 88)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-04-11 21:07:14 UTC (rev 89)
@@ -25,13 +25,14 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
-import com.google.common.collect.Sets;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import java.util.PriorityQueue;
+import java.util.Queue;
import java.util.Set;
public class ArticleStorageService implements MagalieService {
@@ -86,20 +87,25 @@
List<StoredArticle> storedArticles = getStoredArticles(building, article);
- Ordering<StoredArticle> storedArticlesOrdering =
- Ordering.compound(
- Lists.newArrayList(
- StoredArticles.fixedLocationForArticleLastComparator(article),
- StoredArticles.locationWithLowestQuantityFirstComparator(),
- StoredArticles.articleStoredInLocationsRequiringDriverLicenseFirstComparator()
- )
- );
+ Queue<StoredArticle> sortedStoredArticles = sortStoredArticlesByPriority(storedArticles);
- Set<StoredArticle> sortedStoredArticles =
- Sets.newTreeSet(storedArticlesOrdering);
+ StorageMovementOrder storageMovementOrder = buildStorageMovementOrder(
+ magalieUser, article, requestedQuantity, destinationLocation, bestEffortPolicy, sortedStoredArticles);
- Iterables.addAll(sortedStoredArticles, storedArticles);
+ MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
+ StorageMovementOrderDao dao = persistenceContext.getStorageMovementOrderDao();
+
+ dao.persist(storageMovementOrder);
+
+ persistenceContext.commit();
+
+ return storageMovementOrder;
+
+ }
+
+ protected StorageMovementOrder buildStorageMovementOrder(MagalieUser magalieUser, Article article, double requestedQuantity, Location destinationLocation, boolean bestEffortPolicy, Queue<StoredArticle> sortedStoredArticles) throws RequiredDriverLicenceException, UnavailableArticleException {
+
StorageMovementOrder storageMovementOrder = new StorageMovementOrder();
double quantity = 0;
@@ -161,16 +167,30 @@
}
- MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
+ return storageMovementOrder;
- StorageMovementOrderDao dao = persistenceContext.getStorageMovementOrderDao();
+ }
- dao.persist(storageMovementOrder);
+ protected Queue<StoredArticle> sortStoredArticlesByPriority(List<StoredArticle> storedArticles) {
- persistenceContext.commit();
+ Ordering<StoredArticle> orderingByPriority = Ordering.compound(
+ Lists.newArrayList(
+ StoredArticles.fixedLocationForArticleComparator(),
+ StoredArticles.locationWithLowestQuantityFirstComparator(),
+ StoredArticles.articleStoredInLocationsRequiringDriverLicenseFirstComparator()
+ )
+ );
- return storageMovementOrder;
+ Queue<StoredArticle> storedArticlesByPriority =
+ new PriorityQueue<StoredArticle>(
+ storedArticles.size(),
+ orderingByPriority
+ );
+ storedArticlesByPriority.addAll(storedArticles);
+
+ return storedArticlesByPriority;
+
}
public StorageMovementTask getStorageMovementTask(String storageMovementOrderId) {
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-11 20:24:53 UTC (rev 88)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-11 21:07:14 UTC (rev 89)
@@ -193,6 +193,7 @@
quantityInKanban: 50
unit: M
description: Jonc Souple D5
+ fixedLocationsFirst: false
article2:
&article2 !article
@@ -203,6 +204,7 @@
quantityInKanban: 3
unit: PCE
description: Moteur Oréa Slt 50 RTS 50/12
+ fixedLocationsFirst: false
article3:
&article3 !article
@@ -213,6 +215,7 @@
quantityInKanban: 50
unit: PCE
description: Interface ASA/SOMFY + clip
+ fixedLocationsFirst: false
article4:
&article4 !article
@@ -221,6 +224,7 @@
quantityInKanban: 20
unit: PCE
description: Kit Tr.PM Fixe 122G D40Plat 10
+ fixedLocationsFirst: false
article5:
&article5 !article
@@ -231,6 +235,7 @@
quantityInKanban: 10
unit: B60
description: Caisson 2005 3F 6000 Brun
+ fixedLocationsFirst: false
article6:
&article6 !article
@@ -241,6 +246,7 @@
quantityInKanban: 9
unit: PCE
description: Ensemble SOLIRIS UNO
+ fixedLocationsFirst: false
articles:
- *article1
Modified: trunk/magalie-services/src/main/resources/fixtures2.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-11 20:24:53 UTC (rev 88)
+++ trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-11 21:07:14 UTC (rev 89)
@@ -128,6 +128,7 @@
quantityInKanban: 10
unit: kg
description: very big screws
+ fixedLocationsFirst: false
article2:
&article2 !article
@@ -136,6 +137,7 @@
quantityInKanban: 2
unit: box
description: little buttons
+ fixedLocationsFirst: false
article3:
&article3 !article
@@ -146,6 +148,7 @@
quantityInKanban: 50
unit: g
description: magic powder
+ fixedLocationsFirst: false
articles:
- *article1
1
0
11 Apr '13
Author: bleny
Date: 2013-04-11 22:24:53 +0200 (Thu, 11 Apr 2013)
New Revision: 88
Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revision…
Log:
replace Building.name by Building.code
Added:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Warehouse.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java
Removed:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoreDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoreJpaDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Store.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/StoreService.java
Modified:
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java
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/StoredArticleJpaDao.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Building.java
trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Location.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.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/FixturesService.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
trunk/magalie-services/src/main/resources/fixtures.yaml
trunk/magalie-services/src/main/resources/fixtures2.yaml
trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieSession.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java
trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/LoginAction.java
trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp
trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp
trunk/magalie-web/src/main/webapp/WEB-INF/content/login-input.jsp
trunk/magalie-web/src/main/webapp/WEB-INF/content/report.jsp
trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp
trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/JpaMagaliePersistenceContext.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -9,7 +9,7 @@
import com.franciaflex.magalie.persistence.dao.LocationErrorDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao;
-import com.franciaflex.magalie.persistence.dao.StoreDao;
+import com.franciaflex.magalie.persistence.dao.WarehouseDao;
import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
import com.franciaflex.magalie.persistence.dao.jpa.ArticleJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.BuildingJpaDao;
@@ -20,7 +20,7 @@
import com.franciaflex.magalie.persistence.dao.jpa.RequestedArticleJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.StorageMovementJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.StorageMovementOrderJpaDao;
-import com.franciaflex.magalie.persistence.dao.jpa.StoreJpaDao;
+import com.franciaflex.magalie.persistence.dao.jpa.WarehouseJpaDao;
import com.franciaflex.magalie.persistence.dao.jpa.StoredArticleJpaDao;
import javax.persistence.EntityManager;
@@ -86,8 +86,8 @@
}
@Override
- public StoreDao getStoreDao() {
- return new StoreJpaDao(entityManager);
+ public WarehouseDao getWarehouseDao() {
+ return new WarehouseJpaDao(entityManager);
}
@Override
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/MagaliePersistenceContext.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -9,7 +9,7 @@
import com.franciaflex.magalie.persistence.dao.LocationErrorDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementDao;
import com.franciaflex.magalie.persistence.dao.StorageMovementOrderDao;
-import com.franciaflex.magalie.persistence.dao.StoreDao;
+import com.franciaflex.magalie.persistence.dao.WarehouseDao;
import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
/**
@@ -43,5 +43,5 @@
BuildingDao getBuildingDao();
- StoreDao getStoreDao();
+ WarehouseDao getWarehouseDao();
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/LocationDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -2,10 +2,6 @@
import com.franciaflex.magalie.persistence.entity.Location;
-import java.util.List;
-
public interface LocationDao extends Dao<Location> {
- List<String> getAllStoreCodes();
-
}
Deleted: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoreDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoreDao.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoreDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -1,10 +0,0 @@
-package com.franciaflex.magalie.persistence.dao;
-
-import com.franciaflex.magalie.persistence.entity.Store;
-
-/**
- * @author bleny
- */
-public interface StoreDao extends Dao<Store> {
-
-}
Copied: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java (from rev 86, trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/StoreDao.java)
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/WarehouseDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -0,0 +1,10 @@
+package com.franciaflex.magalie.persistence.dao;
+
+import com.franciaflex.magalie.persistence.entity.Warehouse;
+
+/**
+ * @author bleny
+ */
+public interface WarehouseDao extends Dao<Warehouse> {
+
+}
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-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/LocationJpaDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -18,10 +18,4 @@
return Location.class;
}
- @Override
- public List<String> getAllStoreCodes() {
- Query query = entityManager.createQuery("select distinct s.storeCode from Location s order by s.storeCode");
- List<String> resultList = query.getResultList();
- return resultList;
- }
}
Deleted: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoreJpaDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoreJpaDao.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoreJpaDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -1,18 +0,0 @@
-package com.franciaflex.magalie.persistence.dao.jpa;
-
-import com.franciaflex.magalie.persistence.dao.StoreDao;
-import com.franciaflex.magalie.persistence.entity.Store;
-
-import javax.persistence.EntityManager;
-
-public class StoreJpaDao extends AbstractJpaDao<Store> implements StoreDao {
-
- public StoreJpaDao(EntityManager entityManager) {
- super(entityManager);
- }
-
- @Override
- protected Class<Store> getEntityClass() {
- return Store.class;
- }
-}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoredArticleJpaDao.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoredArticleJpaDao.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoredArticleJpaDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -22,7 +22,7 @@
@Override
public List<StoredArticle> findAllForArticleInBuilding(Article article, Building building) {
- Query query = entityManager.createQuery("from StoredArticle sa where sa.article = :article and sa.location.store.building = :building");
+ Query query = entityManager.createQuery("from StoredArticle sa where sa.article = :article and sa.location.warehouse.building = :building");
query.setParameter("article", article);
query.setParameter("building", building);
List<StoredArticle> resultList = query.getResultList();
Copied: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java (from rev 86, trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/StoreJpaDao.java)
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/dao/jpa/WarehouseJpaDao.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -0,0 +1,18 @@
+package com.franciaflex.magalie.persistence.dao.jpa;
+
+import com.franciaflex.magalie.persistence.dao.WarehouseDao;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
+
+import javax.persistence.EntityManager;
+
+public class WarehouseJpaDao extends AbstractJpaDao<Warehouse> implements WarehouseDao {
+
+ public WarehouseJpaDao(EntityManager entityManager) {
+ super(entityManager);
+ }
+
+ @Override
+ protected Class<Warehouse> getEntityClass() {
+ return Warehouse.class;
+ }
+}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Building.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Building.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Building.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -9,7 +9,7 @@
@Id
protected String id;
- protected String name;
+ protected String code;
@Override
public String getId() {
@@ -20,11 +20,11 @@
this.id = id;
}
- public String getName() {
- return name;
+ public String getCode() {
+ return code;
}
- public void setName(String name) {
- this.name = name;
+ public void setCode(String code) {
+ this.code = code;
}
}
Modified: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Location.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Location.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Location.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -11,9 +11,9 @@
protected String id;
@ManyToOne
- protected Store store;
+ protected Warehouse warehouse;
- protected String locationCode;
+ protected String code;
protected int requiredAccreditationLevel;
@@ -26,20 +26,20 @@
this.id = id;
}
- public Store getStore() {
- return store;
+ public Warehouse getWarehouse() {
+ return warehouse;
}
- public void setStore(Store store) {
- this.store = store;
+ public void setWarehouse(Warehouse warehouse) {
+ this.warehouse = warehouse;
}
- public String getLocationCode() {
- return locationCode;
+ public String getCode() {
+ return code;
}
- public void setLocationCode(String locationCode) {
- this.locationCode = locationCode;
+ public void setCode(String code) {
+ this.code = code;
}
public int getRequiredAccreditationLevel() {
@@ -51,7 +51,7 @@
}
public String getBarcode() {
- String barcode = getStoreCode() + getLocationCode();
+ String barcode = getWarehouse().getCode() + getCode();
return barcode;
}
@@ -59,7 +59,4 @@
return requiredAccreditationLevel == 9;
}
- public String getStoreCode() {
- return getStore().getName();
- }
}
Deleted: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Store.java
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Store.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Store.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -1,42 +0,0 @@
-package com.franciaflex.magalie.persistence.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-
-@Entity
-public class Store extends AbstractEntity {
-
- @Id
- protected String id;
-
- protected String name;
-
- @ManyToOne
- protected Building building;
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Building getBuilding() {
- return building;
- }
-
- public void setBuilding(Building building) {
- this.building = building;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
Copied: trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Warehouse.java (from rev 86, trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Store.java)
===================================================================
--- trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Warehouse.java (rev 0)
+++ trunk/magalie-persistence/src/main/java/com/franciaflex/magalie/persistence/entity/Warehouse.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -0,0 +1,42 @@
+package com.franciaflex.magalie.persistence.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Warehouse extends AbstractEntity {
+
+ @Id
+ protected String id;
+
+ protected String code;
+
+ @ManyToOne
+ protected Building building;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Building getBuilding() {
+ return building;
+ }
+
+ public void setBuilding(Building building) {
+ this.building = building;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/MagalieFixtures.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -8,7 +8,7 @@
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
import com.franciaflex.magalie.persistence.entity.Location;
-import com.franciaflex.magalie.persistence.entity.Store;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.persistence.entity.StoredArticle;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
@@ -32,7 +32,7 @@
}
YamlReader reader = new YamlReader(yaml);
reader.getConfig().setClassTag("building", Building.class);
- reader.getConfig().setClassTag("store", Store.class);
+ reader.getConfig().setClassTag("warehouse", Warehouse.class);
reader.getConfig().setClassTag("article", Article.class);
reader.getConfig().setClassTag("stored-article", StoredArticle.class);
reader.getConfig().setClassTag("user", MagalieUser.class);
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-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ArticleStorageService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -190,7 +190,7 @@
Set<Location> locationsInOrder = storageMovementOrder.getLocations();
// we suppose the order concerns movement in the same building
- Building building = Iterables.get(locationsInOrder, 0).getStore().getBuilding();
+ Building building = Iterables.get(locationsInOrder, 0).getWarehouse().getBuilding();
List<StoredArticle> storedArticles = getStoredArticles(building, article);
Copied: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java (from rev 86, trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/StoreService.java)
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java (rev 0)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/BuildingsService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -0,0 +1,35 @@
+package com.franciaflex.magalie.services.service;
+
+import com.franciaflex.magalie.persistence.dao.BuildingDao;
+import com.franciaflex.magalie.persistence.entity.Building;
+import com.franciaflex.magalie.services.MagalieService;
+import com.franciaflex.magalie.services.MagalieServiceContext;
+
+import java.util.List;
+
+public class BuildingsService implements MagalieService {
+
+ protected MagalieServiceContext serviceContext;
+
+ @Override
+ public void setServiceContext(MagalieServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ public List<Building> getAllBuildings() {
+
+ BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao();
+
+ return dao.findAll();
+
+ }
+
+ public Building getBuilding(String buildingId) {
+
+ BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao();
+
+ return dao.findById(buildingId);
+
+ }
+
+}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FixturesService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -6,14 +6,14 @@
import com.franciaflex.magalie.persistence.dao.MagalieUserDao;
import com.franciaflex.magalie.persistence.dao.RequestedArticleDao;
import com.franciaflex.magalie.persistence.dao.LocationDao;
-import com.franciaflex.magalie.persistence.dao.StoreDao;
+import com.franciaflex.magalie.persistence.dao.WarehouseDao;
import com.franciaflex.magalie.persistence.dao.StoredArticleDao;
import com.franciaflex.magalie.persistence.entity.Article;
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.RequestedArticle;
import com.franciaflex.magalie.persistence.entity.Location;
-import com.franciaflex.magalie.persistence.entity.Store;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.persistence.entity.StoredArticle;
import com.franciaflex.magalie.services.MagalieFixtures;
import com.franciaflex.magalie.services.MagalieService;
@@ -97,13 +97,13 @@
}
- StoreDao storeDao = persistenceContext.getStoreDao();
+ WarehouseDao warehouseDao = persistenceContext.getWarehouseDao();
- Collection<Store> stores = fixtures.fixture("stores");
+ Collection<Warehouse> warehouses = fixtures.fixture("warehouses");
- for (Store store : stores) {
+ for (Warehouse warehouse : warehouses) {
- storeDao.persist(store);
+ warehouseDao.persist(warehouse);
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/FulfilKanbanService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -1,13 +1,13 @@
package com.franciaflex.magalie.services.service;
import com.franciaflex.magalie.persistence.MagaliePersistenceContext;
-import com.franciaflex.magalie.persistence.dao.StoreDao;
+import com.franciaflex.magalie.persistence.dao.WarehouseDao;
import com.franciaflex.magalie.persistence.entity.Article;
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.Location;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
-import com.franciaflex.magalie.persistence.entity.Store;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.services.MagalieService;
import com.franciaflex.magalie.services.MagalieServiceContext;
import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException;
@@ -29,15 +29,15 @@
this.serviceContext = serviceContext;
}
- public Store getStore(String storeId) {
+ public Warehouse getStore(String storeId) {
MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
- StoreDao storeDao = persistenceContext.getStoreDao();
+ WarehouseDao warehouseDao = persistenceContext.getWarehouseDao();
- Store store = storeDao.findById(storeId);
+ Warehouse warehouse = warehouseDao.findById(storeId);
- return store;
+ return warehouse;
}
@@ -62,13 +62,13 @@
ArticleStorageService articleStorageService =
serviceContext.newService(ArticleStorageService.class);
- StoreDao storeDao = serviceContext.getPersistenceContext().getStoreDao();
+ WarehouseDao warehouseDao = serviceContext.getPersistenceContext().getWarehouseDao();
- Store destinationStore = storeDao.findById(destinationStoreId);
+ Warehouse destinationWarehouse = warehouseDao.findById(destinationStoreId);
- Building building = destinationStore.getBuilding();
+ Building building = destinationWarehouse.getBuilding();
- Location destinationLocation = getDestinationLocation(destinationStore);
+ Location destinationLocation = getDestinationLocation(destinationWarehouse);
StorageMovementOrder storageMovementOrder =
articleStorageService.bookArticleWithBestEffortPolicy(
@@ -82,23 +82,23 @@
}
- protected Location getDestinationLocation(Store destinationStore) {
+ protected Location getDestinationLocation(Warehouse destinationWarehouse) {
- // TODO brendan 10/04/13 how to define destination for store, something like "INC" ?
+ // TODO brendan 10/04/13 how to define destination for warehouse, something like "INC" ?
return null;
}
- public List<Store> getDestinationStores(Building building) {
+ public List<Warehouse> getDestinationStores(Building building) {
MagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext();
- StoreDao storeDao = persistenceContext.getStoreDao();
+ WarehouseDao warehouseDao = persistenceContext.getWarehouseDao();
// FIXME brendan 10/04/13 consider building
- return storeDao.findAll();
+ return warehouseDao.findAll();
}
}
Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/RequestedArticleService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -84,10 +84,10 @@
List<RequestedArticle> allRequestedArticles = requestedArticleDao.findAllUndelivered(building);
if (log.isInfoEnabled()) {
- log.info(allRequestedArticles.size() + " articles requested in building " + building.getName());
+ log.info(allRequestedArticles.size() + " articles requested in building " + building.getCode());
}
- // TODO brendan 05/04/13 consider storeCode
+ // TODO brendan 05/04/13 consider warehouse.code
return allRequestedArticles;
Deleted: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/StoreService.java
===================================================================
--- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/StoreService.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/StoreService.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -1,35 +0,0 @@
-package com.franciaflex.magalie.services.service;
-
-import com.franciaflex.magalie.persistence.dao.BuildingDao;
-import com.franciaflex.magalie.persistence.entity.Building;
-import com.franciaflex.magalie.services.MagalieService;
-import com.franciaflex.magalie.services.MagalieServiceContext;
-
-import java.util.List;
-
-public class StoreService implements MagalieService {
-
- protected MagalieServiceContext serviceContext;
-
- @Override
- public void setServiceContext(MagalieServiceContext serviceContext) {
- this.serviceContext = serviceContext;
- }
-
- public List<Building> getAllBuildings() {
-
- BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao();
-
- return dao.findAll();
-
- }
-
- public Building getBuilding(String buildingId) {
-
- BuildingDao dao = serviceContext.getPersistenceContext().getBuildingDao();
-
- return dao.findById(buildingId);
-
- }
-
-}
Modified: trunk/magalie-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/resources/fixtures.yaml 2013-04-11 20:24:53 UTC (rev 88)
@@ -35,42 +35,42 @@
B1:
&B1 !building
id: building_1
- name: B1
+ code: B1
buildings:
- *B1
U01:
- &U01 !store
- id: store_u01
- name: U01
+ &U01 !warehouse
+ id: warehouse_u01
+ code: U01
building: *B1
U02:
- &U02 !store
- id: store_u02
- name: U02
+ &U02 !warehouse
+ id: warehouse_u02
+ code: U02
building: *B1
U03:
- &U03 !store
- id: store_u03
- name: U03
+ &U03 !warehouse
+ id: warehouse_u03
+ code: U03
building: *B1
U04:
- &U04 !store
- id: store_u04
- name: U04
+ &U04 !warehouse
+ id: warehouse_u04
+ code: U04
building: *B1
SOM:
- &SOM !store
- id: store_som
- name: SOM
+ &SOM !warehouse
+ id: warehouse_som
+ code: SOM
building: *B1
-stores:
+warehouses:
- *U01
- *U02
- *U03
@@ -80,92 +80,92 @@
location1:
&location1 !location
id: location1
- store: *U01
- locationCode: A01
+ warehouse: *U01
+ code: A01
requiredAccreditationLevel: 0
location2:
&location2 !location
id: location2
- store: *U01
- locationCode: B02
+ warehouse: *U01
+ code: B02
requiredAccreditationLevel: 9
location3:
&location3 !location
id: location3
- store: *U01
- locationCode: C03
+ warehouse: *U01
+ code: C03
requiredAccreditationLevel: 0
location4:
&location4 !location
id: location4
- store: *U01
- locationCode: D04
+ warehouse: *U01
+ code: D04
requiredAccreditationLevel: 9
location5:
&location5 !location
id: location5
- store: *U02
- locationCode: F01
+ warehouse: *U02
+ code: F01
requiredAccreditationLevel: 0
location6:
&location6 !location
id: location6
- store: *U02
- locationCode: G02
+ warehouse: *U02
+ code: G02
requiredAccreditationLevel: 0
location7:
&location7 !location
id: location7
- store: *U02
- locationCode: H03
+ warehouse: *U02
+ code: H03
requiredAccreditationLevel: 9
location8:
&location8 !location
id: location8
- store: *U04
- locationCode: A010
+ warehouse: *U04
+ code: A010
requiredAccreditationLevel: 0
location9:
&location9 !location
id: location9
- store: *SOM
- locationCode: B10
+ warehouse: *SOM
+ code: B10
requiredAccreditationLevel: 0
location10:
&location10 !location
id: location10
- store: *SOM
- locationCode: B24
+ warehouse: *SOM
+ code: B24
requiredAccreditationLevel: 0
location11:
&location11 !location
id: location11
- store: *SOM
- locationCode: B77
+ warehouse: *SOM
+ code: B77
requiredAccreditationLevel: 0
location12:
&location12 !location
id: location12
- store: *SOM
- locationCode: C12
+ warehouse: *SOM
+ code: C12
requiredAccreditationLevel: 0
location13:
&location13 !location
id: location13
- store: *U01
- locationCode: REC
+ warehouse: *U01
+ code: REC
requiredAccreditationLevel: 0
locations:
Modified: trunk/magalie-services/src/main/resources/fixtures2.yaml
===================================================================
--- trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/main/resources/fixtures2.yaml 2013-04-11 20:24:53 UTC (rev 88)
@@ -35,42 +35,42 @@
B1:
&B1 !building
id: building_1
- name: B1
+ code: B1
buildings:
- *B1
U01:
- &U01 !store
- id: store_u01
- name: U01
+ &U01 !warehouse
+ id: warehouse_u01
+ code: U01
building: *B1
U02:
- &U02 !store
- id: store_u02
- name: U02
+ &U02 !warehouse
+ id: warehouse_u02
+ code: U02
building: *B1
U03:
- &U03 !store
- id: store_u03
- name: U03
+ &U03 !warehouse
+ id: warehouse_u03
+ code: U03
building: *B1
U04:
- &U04 !store
- id: store_u04
- name: U04
+ &U04 !warehouse
+ id: warehouse_u04
+ code: U04
building: *B1
SOM:
- &SOM !store
- id: store_som
- name: SOM
+ &SOM !warehouse
+ id: warehouse_som
+ code: SOM
building: *B1
-stores:
+warehouses:
- *U01
- *U02
- *U03
@@ -80,36 +80,36 @@
location1:
&location1 !location
id: location1
- store: *U01
- locationCode: A1
+ warehouse: *U01
+ code: A1
requiredAccreditationLevel: 0
location2:
&location2 !location
id: location2
- store: *U01
- locationCode: B2
+ warehouse: *U01
+ code: B2
requiredAccreditationLevel: 9
location3:
&location3 !location
id: location3
- store: *U01
- locationCode: C3
+ warehouse: *U01
+ code: C3
requiredAccreditationLevel: 0
location4:
&location4 !location
id: location4
- store: *U01
- locationCode: D4
+ warehouse: *U01
+ code: D4
requiredAccreditationLevel: 9
location5:
&location5 !location
id: location5
- store: *U02
- locationCode: A1
+ warehouse: *U02
+ code: A1
requiredAccreditationLevel: 0
locations:
Modified: trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java
===================================================================
--- trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-services/src/test/java/com/franciaflex/magalie/services/service/ArticleStorageServiceTest.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -159,10 +159,10 @@
Assert.assertEquals(2, storageMovementOrder.getStorageMovements().size());
StorageMovement storageMovement1 = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
Assert.assertEquals(20., storageMovement1.getExpectedQuantity(), DELTA);
- Assert.assertEquals("B2", storageMovement1.getOriginLocation().getLocationCode());
+ Assert.assertEquals("B2", storageMovement1.getOriginLocation().getCode());
StorageMovement storageMovement2 = Iterables.get(storageMovementOrder.getStorageMovements(), 1, null);
Assert.assertEquals(10., storageMovement2.getExpectedQuantity(), DELTA);
- Assert.assertEquals("A1", storageMovement2.getOriginLocation().getLocationCode());
+ Assert.assertEquals("A1", storageMovement2.getOriginLocation().getCode());
} catch (RequiredDriverLicenceException e) {
if (log.isDebugEnabled()) {
log.debug("exception raised = " + e);
@@ -183,7 +183,7 @@
Assert.assertEquals(1, storageMovementOrder.getStorageMovements().size());
StorageMovement storageMovement = Iterables.get(storageMovementOrder.getStorageMovements(), 0, null);
Assert.assertEquals(30., storageMovement.getExpectedQuantity(), DELTA);
- Assert.assertEquals("A1", storageMovement.getOriginLocation().getLocationCode());
+ Assert.assertEquals("A1", storageMovement.getOriginLocation().getCode());
} catch (RequiredDriverLicenceException e) {
if (log.isDebugEnabled()) {
log.debug("exception raised = " + e);
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieSession.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieSession.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieSession.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -2,7 +2,7 @@
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
-import com.franciaflex.magalie.persistence.entity.Store;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import java.io.Serializable;
@@ -21,7 +21,7 @@
protected MagalieUser magalieUser;
protected Building building;
- private Store lastUsedDestinationStoreForKanbans;
+ private Warehouse lastUsedDestinationWarehouseForKanbans;
public MagalieUser getMagalieUser() {
return magalieUser;
@@ -39,11 +39,11 @@
this.building = building;
}
- public Store getLastUsedDestinationStoreForKanbans() {
- return lastUsedDestinationStoreForKanbans;
+ public Warehouse getLastUsedDestinationWarehouseForKanbans() {
+ return lastUsedDestinationWarehouseForKanbans;
}
- public void setLastUsedDestinationStoreForKanbans(Store lastUsedDestinationStoreForKanbans) {
- this.lastUsedDestinationStoreForKanbans = lastUsedDestinationStoreForKanbans;
+ public void setLastUsedDestinationWarehouseForKanbans(Warehouse lastUsedDestinationWarehouseForKanbans) {
+ this.lastUsedDestinationWarehouseForKanbans = lastUsedDestinationWarehouseForKanbans;
}
}
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/FulfilKanbanAction.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -3,7 +3,7 @@
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
import com.franciaflex.magalie.persistence.entity.StorageMovementOrder;
-import com.franciaflex.magalie.persistence.entity.Store;
+import com.franciaflex.magalie.persistence.entity.Warehouse;
import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException;
import com.franciaflex.magalie.services.exception.RequiredDriverLicenceException;
import com.franciaflex.magalie.services.exception.UnavailableArticleException;
@@ -33,9 +33,9 @@
protected StorageMovementOrder storageMovementOrder;
- protected List<Store> destinationStores;
+ protected List<Warehouse> destinationWarehouses;
- protected String destinationStoreId;
+ protected String destinationWarehouseId;
public void setService(FulfilKanbanService service) {
this.service = service;
@@ -50,15 +50,15 @@
Building building = session.getBuilding();
- destinationStores = service.getDestinationStores(building);
+ destinationWarehouses = service.getDestinationStores(building);
- // let's help user by selecting by default the previously used destination store
+ // let's help user by selecting by default the previously used destination warehouse
- Store lastUsedDestinationStoreForKanbans = session.getLastUsedDestinationStoreForKanbans();
+ Warehouse lastUsedDestinationWarehouseForKanbans = session.getLastUsedDestinationWarehouseForKanbans();
- if (lastUsedDestinationStoreForKanbans != null) {
+ if (lastUsedDestinationWarehouseForKanbans != null) {
- destinationStoreId = lastUsedDestinationStoreForKanbans.getId();
+ destinationWarehouseId = lastUsedDestinationWarehouseForKanbans.getId();
}
@@ -66,20 +66,20 @@
}
- public String getDestinationStoreId() {
- return destinationStoreId;
+ public String getDestinationWarehouseId() {
+ return destinationWarehouseId;
}
- public List<Store> getDestinationStores() {
- return destinationStores;
+ public List<Warehouse> getDestinationWarehouses() {
+ return destinationWarehouses;
}
public void setArticleBarcode(String articleBarcode) {
this.articleBarcode = articleBarcode;
}
- public void setDestinationStoreId(String destinationStoreId) {
- this.destinationStoreId = destinationStoreId;
+ public void setDestinationWarehouseId(String destinationWarehouseId) {
+ this.destinationWarehouseId = destinationWarehouseId;
}
@Override
@@ -91,14 +91,14 @@
MagalieUser magalieUser = session.getMagalieUser();
- Store destinationStore = service.getStore(destinationStoreId);
+ Warehouse destinationWarehouse = service.getStore(destinationWarehouseId);
- // save used destination store to propose it by default on next kanban
- session.setLastUsedDestinationStoreForKanbans(destinationStore);
+ // save used destination warehouse to propose it by default on next kanban
+ session.setLastUsedDestinationWarehouseForKanbans(destinationWarehouse);
try {
- storageMovementOrder = service.fulfilKanbanTask(articleBarcode, magalieUser, destinationStoreId);
+ storageMovementOrder = service.fulfilKanbanTask(articleBarcode, magalieUser, destinationWarehouseId);
} catch (InvalidMagalieBarcodeException e) {
Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/LoginAction.java
===================================================================
--- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/LoginAction.java 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/LoginAction.java 2013-04-11 20:24:53 UTC (rev 88)
@@ -2,8 +2,8 @@
import com.franciaflex.magalie.persistence.entity.Building;
import com.franciaflex.magalie.persistence.entity.MagalieUser;
+import com.franciaflex.magalie.services.service.BuildingsService;
import com.franciaflex.magalie.services.service.MagalieUsersService;
-import com.franciaflex.magalie.services.service.StoreService;
import com.franciaflex.magalie.web.MagalieActionSupport;
import com.franciaflex.magalie.web.MagalieSession;
import org.apache.struts2.convention.annotation.Result;
@@ -18,7 +18,7 @@
protected MagalieUsersService magalieUsersService;
- protected StoreService storeService;
+ protected BuildingsService buildingsService;
protected List<MagalieUser> allMagalieUsers;
@@ -34,8 +34,8 @@
this.magalieUsersService = magalieUsersService;
}
- public void setStoreService(StoreService storeService) {
- this.storeService = storeService;
+ public void setBuildingsService(BuildingsService buildingsService) {
+ this.buildingsService = buildingsService;
}
public void setSession(MagalieSession session) {
@@ -55,7 +55,7 @@
allMagalieUsers = magalieUsersService.getAllMagalieUsers();
- allBuildings = storeService.getAllBuildings();
+ allBuildings = buildingsService.getAllBuildings();
return INPUT;
@@ -82,7 +82,7 @@
MagalieUser magalieUser = magalieUsersService.getMagalieUser(login);
- Building building = storeService.getBuilding(buildingId);
+ Building building = buildingsService.getBuilding(buildingId);
session.setMagalieUser(magalieUser);
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp 2013-04-11 20:24:53 UTC (rev 88)
@@ -35,7 +35,7 @@
<dt>Identifiant</dt>
<dd><s:property value="magalieUser.name" /> (<s:property value="magalieUser.login" />)</dd>
<dt>Bâtiment</dt>
- <dd><s:property value="building.name" /></dd>
+ <dd><s:property value="building.code" /></dd>
</dl>
</header>
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp 2013-04-11 20:24:53 UTC (rev 88)
@@ -9,10 +9,10 @@
<s:textfield name="articleBarcode" label="Article" inputAppendIcon="barcode" cssClass="input-medium" />
<s:select label="Magasin destination"
- key="destinationStoreId"
- list="destinationStores"
+ key="destinationWarehouseId"
+ list="destinationWarehouses"
listKey="id"
- listValue="name"
+ listValue="code"
required="true"
/>
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/login-input.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/login-input.jsp 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/login-input.jsp 2013-04-11 20:24:53 UTC (rev 88)
@@ -19,7 +19,7 @@
key="buildingId"
list="allBuildings"
listKey="id"
- listValue="name"
+ listValue="code"
required="true"
/>
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/report.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/report.jsp 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/report.jsp 2013-04-11 20:24:53 UTC (rev 88)
@@ -48,15 +48,15 @@
<s:property value="id" />
</td>
<td>
- <s:property value="originLocation.storeCode" />
+ <s:property value="originLocation.warehouse.code" />
-
- <s:property value="originLocation.locationCode" />
+ <s:property value="originLocation.code" />
</td>
<td>
<s:if test="destinationLocation">
- <s:property value="destinationLocation.storeCode" />
+ <s:property value="destinationLocation.warehouse.code" />
-
- <s:property value="destinationLocation.locationCode" />
+ <s:property value="destinationLocation.code" />
</s:if>
</td>
<td>
@@ -120,15 +120,15 @@
<s:property value="id" />
</td>
<td>
- <s:property value="originLocation.storeCode" />
+ <s:property value="originLocation.warehouse.code" />
-
- <s:property value="originLocation.locationCode" />
+ <s:property value="originLocation.code" />
</td>
<td>
<s:if test="destinationLocation">
- <s:property value="destinationLocation.storeCode" />
+ <s:property value="destinationLocation.warehouse.code" />
-
- <s:property value="destinationLocation.locationCode" />
+ <s:property value="destinationLocation.code" />
</s:if>
</td>
<td>
@@ -186,10 +186,10 @@
<s:property value="id" />
</td>
<td>
- <s:property value="location.storeCode" />
+ <s:property value="location.warehouse.code" />
</td>
<td>
- <s:property value="location.locationCode" />
+ <s:property value="location.code" />
</td>
<td>
<s:property value="magalieUser.name" />
Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp
===================================================================
--- trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-04-11 20:24:53 UTC (rev 88)
@@ -111,7 +111,7 @@
<div id="storageMovementTemplate" class="template">
<dl class="dl-horizontal">
<dt>Empl.</dt>
- <dd><span data="originLocation.store.name"></span> <span data="originLocation.locationCode"></span></dd>
+ <dd><span data="originLocation.warehouse.code"></span> <span data="originLocation.code"></span></dd>
<dt>Prélev.</dt>
<dd><span data="withdrawn">0</span> / <span data="expectedQuantity"></span> <s:property value="storageMovementTask.article.unit" /></dd>
</dl>
Modified: trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js
===================================================================
--- trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-04-11 19:44:51 UTC (rev 87)
+++ trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-04-11 20:24:53 UTC (rev 88)
@@ -111,7 +111,7 @@
} else {
var storageMovement = this.storageMovements[this.storageMovementsIndex];
if (storageMovement.expectedQuantity == 0.) {
- console.debug("will use extra location " + storageMovement.originLocation.locationCode);
+ console.debug("will use extra location " + storageMovement.originLocation.code);
var remainingQuantity = this.quantity - this.withdrawn();
storageMovement.expectedQuantity = remainingQuantity;
// var availableQuantityInLocation = storageMovement.availableQuantity;
1
0