use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionUtilTest method testEqualMessage.
@Test
public void testEqualMessage() {
StockTransaction t1 = new StockTransaction();
StockTransaction t2 = new StockTransaction();
Stock s1 = new Stock(1);
Stock s2 = new Stock(2);
t1.setSource(s1);
t2.setSource(s1);
t1.setDestination(s2);
t2.setDestination(s2);
t1.setType(StockTransactionType.TRANSFER);
t2.setType(StockTransactionType.TRANSFER);
t1.addStatus(new StockTransactionStatus(PREPARED, new Date()));
t2.addStatus(new StockTransactionStatus(PREPARED, new Date()));
assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setSource(s2);
assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setSource(s1);
assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setDestination(s1);
assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setDestination(s2);
assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setType(StockTransactionType.ROLL_IN);
assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
t1.setType(StockTransactionType.TRANSFER);
assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
t2.addStatus(new StockTransactionStatus(FAILED, new Date()));
assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class CreateSelectionTryout method tryout.
@Test
public void tryout() throws InterruptedException {
JButton b = new JButton("Press to close");
b.setPreferredSize(new Dimension(200, 50));
CountDownLatch l = new CountDownLatch(1);
b.addActionListener(e -> {
l.countDown();
});
Dl.remote().add(StockAgent.class, new StockAgent() {
@Override
public <T> List<T> findAll(Class<T> entityClass) {
if (entityClass.equals(Stock.class))
return (List<T>) Arrays.asList(new Stock(0, "Rotes Lager"), new Stock(1, "Blaues Lager"));
return null;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T persist(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T merge(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void delete(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
UiCore.startSwing(() -> b);
Ui.exec(() -> {
Ui.build().fxml().eval(CreateSelectionController.class).opt().ifPresent(System.out::println);
});
l.await();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class CreateSimpleActionTryout method tryout.
@Test
public void tryout() throws InterruptedException {
JPanel p = new JPanel();
JButton b = new JButton("Press to close");
b.setPreferredSize(new Dimension(200, 50));
CountDownLatch l = new CountDownLatch(1);
b.addActionListener(e -> {
l.countDown();
});
p.add(new JButton(new CreateSimpleAction()));
p.add(b);
Dl.remote().add(StockAgent.class, new StockAgent() {
@Override
public <T> List<T> findAll(Class<T> entityClass) {
if (entityClass.equals(Stock.class))
return (List<T>) Arrays.asList(new Stock(0, "Rotes Lager"), new Stock(1, "Blaues Lager"));
return null;
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
if (refurbishIds.contains("1")) {
Stock s = new Stock(0, "Lager1");
StockUnit s1 = new StockUnit("1", "Gerät Eins", 1);
s1.setStock(s);
return Arrays.asList(s1);
}
return Collections.EMPTY_LIST;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T persist(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T merge(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void delete(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(StockTransactionProcessor.class, new StockTransactionProcessor() {
@Override
public SortedMap<Integer, String> perpareTransfer(List<StockUnit> stockUnits, int destinationStockId, String arranger, String comment) throws UserInfoException {
SortedMap<Integer, String> r = new TreeMap<>();
r.put(1, "1");
return r;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public List<Integer> rollIn(List<StockTransaction> detachtedTransactions, String arranger) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancel(StockTransaction transaction, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void commission(List<StockTransaction> transactions, String picker, String deliverer) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void receive(List<StockTransaction> transactions, String deliverer, String reciever) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeFromPreparedTransaction(String refurbishId, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Guardian guardianMock = mock(Guardian.class);
given(guardianMock.getUsername()).willAnswer(i -> "Testuser");
Dl.local().add(Guardian.class, guardianMock);
UiCore.startSwing(() -> p);
l.await();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class ReceiptUnitOperationIT method testReceiptAndUpdate.
@Test
public void testReceiptAndUpdate() throws InterruptedException {
customerGenerator.makeSystemCustomers(contractors.all().toArray(new TradeName[0]));
// Constants ,later permutate throug all
Stock stock = stockGenerator.makeStocksAndLocations(2).get(0);
List<ReceiptOperation> operations = Arrays.asList(SALEABLE, INTERNAL_REWORK, MISSING_PARTS, REPAIR);
// Receipt a Unit
ProductSpec productSpec = receiptGenerator.makeProductSpec();
Product product = uniqueUnitAgent.findById(Product.class, productSpec.getProductId());
StockTransaction stockTransaction = stockTransactionEmo.requestRollInPrepared(stock.getId(), "No User", "Rollin via ReceiptUnitOperationHelper.findOrCreateRollInTransaction");
for (TradeName contractor : contractors.all()) {
Shipment productShipment = stockAgent.persist(new Shipment("SHIPMENTNAME_" + contractor, contractor, TradeName.ACER, Shipment.Status.OPENED));
for (ReceiptOperation receiptOperation : operations) {
UniqueUnit receiptUnit = unitGenerator.makeUniqueUnit(contractor, product);
unitProcessor.receipt(receiptUnit, product, productShipment, stockTransaction, receiptOperation, "Receipt Operation from Test", "Testuser");
asserts(receiptUnit, stockTransaction, receiptOperation, contractor);
for (ReceiptOperation updateOperation : operations) {
UniqueUnit uniqueUnit = uniqueUnitAgent.findUnitByIdentifierEager(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
unitProcessor.update(uniqueUnit, product, updateOperation, "Update Operation from Test", "Testuser");
assertsUpdate(receiptUnit, stockTransaction, updateOperation, contractor);
}
}
}
Thread.sleep(3000);
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class RedTapeCloserOperation method closeStock.
/**
* Rolling out the units from the stocks. For this, a {@link StockTransaction} with {@link StockTransactionType#ROLL_OUT} is created,
* all {@link StockUnit}<code>s</code> which are on a {@link LogicTransaction} with matching dossierId are added to this {@link StockTransaction} and
* it gets {@link StockTransactionStatusType#COMPLETED}.
* <p/>
* @param dossierIds the dossierId as reference.
* @param msg a msg for the stocktransaction.
* @param arranger the arranger.
* @param monitor a optional monitor.
* @return the amount of rolled out units.
*/
private int closeStock(Set<Long> dossierIds, String msg, String arranger, IMonitor monitor) {
SubMonitor m = SubMonitor.convert(monitor, 100);
final String h = "Stock:";
m.message(h + "lade logische Transaktionen");
// Rolling out
List<LogicTransaction> lts = ltEao.findByDossierIds(dossierIds);
m.worked(3, h + "sortiere Geräte nach Lager");
stockEao.findAll();
Map<Stock, List<StockUnit>> unitsByStock = lts.stream().flatMap((t) -> t.getUnits().stream()).collect(Collectors.groupingBy(StockUnit::getStock));
validateStockUnits(unitsByStock);
m.setWorkRemaining((int) unitsByStock.values().stream().count());
List<StockTransaction> stockTransactions = new ArrayList<>();
for (Entry<Stock, List<StockUnit>> entry : unitsByStock.entrySet()) {
StockTransaction st = stEmo.requestRollOutPrepared(entry.getKey().getId(), arranger, msg);
for (StockUnit stockUnit : entry.getValue()) {
m.worked(1, h + "verbuche (refurbishId=" + stockUnit.getRefurbishId() + ",uniqueUnitId=" + stockUnit.getUniqueUnitId() + ")");
st.addUnit(stockUnit);
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), msg, arranger));
}
stockTransactions.add(st);
}
m.message(h + "auslagern");
if (!stockTransactions.isEmpty())
stEmo.completeRollOut(arranger, stockTransactions);
m.finish();
return (int) unitsByStock.values().stream().count();
}
Aggregations