use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class ImporterOperation method fromXls.
/**
* Imports the Pricemanagement from an XLS file with a defined form.
* The Form is as follows
* <ul>
* <li>Column 1 (A) = Refurbished Id, Type:Integer</li>
* <li>Column 2 (C) = Manufacturer PartNo, Type:String</li>
* <li>Column 4 (E) = Retailer Price, Type:Double</li>
* <li>Column 7 (H) = Customer Price without Tax, Type:Double</li>
* <li>Column 9 (J) = Set/Unset PartNoFixed Price, Type:Integer</li>
* <li>Column 10 (K) = Warranty Id, Type:Integer</li>
* </ul>
*
* @param jacket the file in a jacket
* @param arranger
* @return a Reply of FileJacket
* @throws UserInfoException
*/
@Override
public Reply<File> fromXls(FileJacket jacket, String arranger) throws UserInfoException {
final SubMonitor m = monitorFactory.newSubMonitor("Import from Xls", 10);
m.start();
File f = jacket.toTemporaryFile();
LucidCalcReader reader = new JExcelLucidCalcReader();
// RefurbishedId
reader.addColumn(0, String.class);
// PartNo
reader.addColumn(2, String.class);
// RetailerPrice
reader.addColumn(4, Double.class);
// CustomerPrice
reader.addColumn(7, Double.class);
// UnitFixPrice
reader.addColumn(9, Integer.class);
// PartFixPrice
reader.addColumn(10, Integer.class);
// WarrantyId
reader.addColumn(11, Integer.class);
List<PriceEngineResult> imports = reader.read(f, new PriceEngineResult());
m.worked(2);
if (reader.isError()) {
m.finish();
throw new UserInfoException(reader.getErrors());
}
core.store(imports, "ImportPriceManagementOperation.fromXls()", arranger, m);
return Reply.success(f);
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class StockTransactionProcessorOperation method removeFromPreparedTransaction.
/**
* Remove the stockUnit represented by the refurbishId from a stock transaction, if that transaction exists and is in state prepared.
* <p/>
* @param refurbishId the refurbishId
* @param arranger the arranger
* @param comment a optional comment
* @throws UserInfoException if no unit exists, the unit is not on a transaction or the transaction has another state then prepared.
*/
@Override
public void removeFromPreparedTransaction(final String refurbishId, final String arranger, final String comment) throws UserInfoException {
StockUnit stockUnit = new StockUnitEao(stockEm).findByRefurbishId(refurbishId);
if (stockUnit == null)
throw new UserInfoException("SopoNr: " + refurbishId + " existiert nicht.");
if (!stockUnit.isInTransaction())
throw new UserInfoException("SopoNr: " + refurbishId + " nicht in Transaction.");
StockTransaction transaction = stockUnit.getTransaction();
if (transaction.getStatus().getType() != PREPARED) {
throw new UserInfoException("SopoNr: " + refurbishId + " auf Transaction, aber Transaction(" + transaction.getId() + ") not in Status prepared");
}
// The one case we remove the position as well, but dont need to set the stock because of beeing in status prepared
StockTransactionPosition position = stockUnit.getPosition();
stockEm.remove(position);
transaction.setComment(transaction.getComment() + ", Unit " + stockUnit.getRefurbishId() + " removed by " + arranger + ", cause=" + comment);
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Unit returned to Stock(" + transaction.getSource().getId() + ") " + transaction.getSource().getName() + ", removed from Transaction, cause: " + comment, arranger));
L.info("{} removed from {}", stockUnit, transaction);
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class StockTransactionProcessorOperation method cancel.
/**
* Cancels a stock transaction.
* <p/>
* @param transaction the transaction to cancel.
* @param arranger the arranger
* @param comment a comment to describe why
* @throws UserInfoException if the transaction is not in state prepared.
*/
@Override
public void cancel(StockTransaction transaction, final String arranger, final String comment) throws UserInfoException {
transaction = stockEm.find(StockTransaction.class, transaction.getId());
if (transaction.getStatus().getType() != PREPARED) {
throw new UserInfoException("Supplied transaction is not in state prepared, but " + transaction.getStatus() + ", cancel not allowed");
}
StockTransactionStatus status = new StockTransactionStatus(CANCELLED, new Date(), comment);
status.addParticipation(new StockTransactionParticipation(ARRANGER, arranger));
transaction.addStatus(status);
for (StockUnit stockUnit : transaction.getUnits()) {
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Unit returned to Stock(" + transaction.getSource().getId() + ") " + transaction.getSource().getName() + ", cancelled Transaction(" + transaction.getId() + ")", arranger));
L.info("cancelTransaction(): Returning {} to Stock {} ", stockUnit, transaction.getSource());
stockUnit.setPosition(null);
// Nothing to do because of special case prepared transaction, which allows the unit to be on transaction and on stock
}
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class StockTransactionEmo method prepare.
/**
* Prepares the transfer of multiple units.
* Creates an amount of needed transactions in the form,
* - that the transactions are correct (all units of a transaction have the same source as the transaciton)
* - that no transaction has more units than maxUnitSize.
* <p/>
* @param t a merged parameter view.
* @param partialMonitor an optional monitor
* @return a map containing uniqueUnitIds and comments for their history.
* @throws UserInfoException
*/
public SortedMap<Integer, String> prepare(Transfer t, IMonitor partialMonitor) throws UserInfoException {
SubMonitor m = SubMonitor.convert(partialMonitor, "Preparing Transfer Transaciton", (t.getStockUnitIds().size() * 2) + 15);
m.start();
ValidationUtil.validate(t);
Stock destination = em.find(Stock.class, t.getDestinationStockId());
Stock source = null;
List<StockUnit> unhandledUnits = new ArrayList<>();
for (int unitId : t.getStockUnitIds()) {
m.worked(1, "Loading StockUnit(" + unitId + ")");
StockUnit stockUnit = em.find(StockUnit.class, unitId);
if (stockUnit == null)
throw new UserInfoException("StockUnit " + unitId + " nicht vorhanden.");
if (stockUnit.getStock() == null)
throw new UserInfoException(stockUnit + " nicht auf einem Lagerplatz.");
if (source == null)
source = stockUnit.getStock();
if (!source.equals(stockUnit.getStock()))
throw new UserInfoException(stockUnit + " nicht auf Quelle " + source.getName() + ", wie alle anderen");
unhandledUnits.add(stockUnit);
}
L.debug("Unhandeled units {}", unhandledUnits.stream().map(StockUnit::toSimple).collect(Collectors.joining(",")));
SortedMap<Integer, String> result = new TreeMap<>();
for (int i = 0; i < unhandledUnits.size(); i += t.getMaxTransactionSize()) {
List<StockUnit> subList = unhandledUnits.subList(i, Math.min(unhandledUnits.size(), i + t.getMaxTransactionSize()));
L.debug("Eplizit Transfer {}", subList.stream().map(StockUnit::toSimple).collect(Collectors.joining(",")));
result.putAll(prepareExplicitTransfer(subList, destination, t.getArranger(), t.getComment()));
m.worked(t.getMaxTransactionSize());
}
m.message("committing");
m.finish();
return result;
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class CommissioningManagerModel method addUnit.
void addUnit(StockUnit su) throws UserInfoException {
if (stockTransactions.isEmpty()) {
referenceTransaction = su.getTransaction();
stockTransactions.add(referenceTransaction);
missingStockUnits.addAll(referenceTransaction.getUnits());
if (su.getTransaction().getStatus().getType() == StockTransactionStatusType.PREPARED) {
setParticipantOne("Kommisionierer");
setParticipantTwo("Transporter");
} else if (su.getTransaction().getStatus().getType() == StockTransactionStatusType.IN_TRANSFER) {
setParticipantOne("Transporter");
setParticipantTwo("Warenannehmer");
}
} else if (!stockTransactions.contains(su.getTransaction())) {
String msg = StockTransactionUtil.equalStateMessage(referenceTransaction, su.getTransaction());
if (msg != null) {
setStatusMessage(msg);
throw new UserInfoException(msg);
}
stockTransactions.add(su.getTransaction());
missingStockUnits.addAll(su.getTransaction().getUnits());
}
setStatusMessage("SopoNr " + su.getRefurbishId() + " hinzugefĆ¼gt");
missingStockUnits.remove(su);
stockUnits.add(su);
unitModel.fireChange();
transactionModel.fireChange();
boolean c = true;
for (StockTransaction st : stockTransactions) {
if (!stockUnits.containsAll(st.getUnits())) {
c = false;
}
}
if (c) {
setFull(true);
} else {
// To be sure, that everything is reseted
reset();
}
}
Aggregations