use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class UnitDestroyerOperation method verifyScarpOrDeleteAble.
/**
* Validates if a unit identified by refurbishedId is scrapable.
* Throws Exception if:
* <ul>
* <li>No UniqueUnit,SopoUnit or StockUnit exists.</li>
* <li>StockUnit is inTransaction</li>
* <li>SopoUnit is in Auftrag or Balanced.</li>
* </ul>
*
* @param refurbishId the refurbishedId
* @return
* @throws UserInfoException if not scrapable.
*/
@Override
public UniqueUnit verifyScarpOrDeleteAble(String refurbishId) throws UserInfoException {
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
UniqueUnit uniqueUnit = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
if (uniqueUnit == null)
throw new UserInfoException("Keine Gerät mit SopoNr " + refurbishId + " gefunden");
StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
StockUnit stockUnit = stockUnitEao.findByUniqueUnitId(uniqueUnit.getId());
if (stockUnit == null)
throw new UserInfoException("Keine Lagergerät für SopoNr " + refurbishId + " gefunden, Verschrottung/Löschung unnötig");
if (stockUnit.isInTransaction())
throw new UserInfoException("StockUnit ist auf einer Transaktion, Verschrottung/Löschung unzulässig");
uniqueUnit.fetchEager();
return uniqueUnit;
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class UnitProcessorOperation method findEditableUnit.
/**
* Returns a editable UniqueUnit.
* An Exception is thrown if:
* <ul>
* <li>No UniqueUnit with refurbishedId</li>
* <li>No StockUnit for UniqueUnit</li>
* <li>StockUnit is on Transaction</li>
* <li>No SopoUnit with refurbishedId</li>
* <li>No SopoUnit UniqueUnit miss match</li>
* </ul>
* The Operation is discovert via:
* <ul>
* <li>If on an AlphaAcount, and operation is allowed, returns appropriated operation</li>
* <li>If on no Auftrag, returns Sales</li>
* <li>If on any other Auftrag, returns null</li>
* </ul>
*
* @param refurbishedIdOrSerial the refurbishedId or the serial, both are tried
* @return a EditableUnit with, the editable UniqueUnit, the refrencing StockUnit, the Operation it is in, and the PartNo
* @throws UserInfoException if refurbishedId is not ok.
*/
@Override
public EditableUnit findEditableUnit(String refurbishedIdOrSerial) throws UserInfoException {
if (StringUtils.isBlank(refurbishedIdOrSerial))
throw new UserInfoException("Keine SopoNr/Seriennummer eingegeben");
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
UniqueUnit uniqueUnit = uniqueUnitEao.findByIdentifier(REFURBISHED_ID, refurbishedIdOrSerial);
if (uniqueUnit == null)
uniqueUnit = uniqueUnitEao.findByIdentifier(SERIAL, refurbishedIdOrSerial);
if (uniqueUnit == null)
throw new UserInfoException("Keine Gerät mit SopoNr/Seriennummer " + refurbishedIdOrSerial + " gefunden");
StockUnit stockUnit;
ReceiptOperation operation = ReceiptOperation.SALEABLE;
stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
if (stockUnit == null)
throw new UserInfoException("Keine Lagergerät für SopoNr " + uniqueUnit.getIdentifier(REFURBISHED_ID) + " gefunden, bearbeitung unzulässig");
LogicTransaction lt = new LogicTransactionEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
if (lt != null) {
operation = receiptCustomers.getOperation(new DossierEao(redTapeEm).findById(lt.getDossierId()).getCustomerId()).orElse(ReceiptOperation.IN_SALE);
}
// Lazyinit
uniqueUnit.fetchEager();
return new EditableUnit(uniqueUnit, stockUnit, operation, uniqueUnit.getProduct() == null ? "" : uniqueUnit.getProduct().getPartNo());
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class RedTapeWorkerOperation method revertCreate.
/**
* This method handles necessary cleanups if creation or update is canceled.
* <p/>
* If stock.LogicTransaction differs form Dossier.Document.Positions ⇒ change LogicTransaction.
* <ul><li>Only LogicTransaction > Dossier.Document.Positions should be possible</li></ul>
* If Dossier.isEmpty → delete.
* If stock.LogicTransaction is empty → delete.
*/
@Override
public Document revertCreate(Document detached) throws UserInfoException {
Document original = new DocumentEao(redTapeEm).findById(detached.getId());
if (original.isActive() != detached.isActive())
throw new UserInfoException("Das Document wurde durch jemand anderen inzwischen geändert, bitte neu laden.\n" + "Hint: original(" + original.getId() + ").active=" + original.isActive() + ", detached(" + detached.getId() + ").active=" + detached.isActive());
if (original.getOptLock() != detached.getOptLock())
throw new UserInfoException("Das Document wurde durch jemand anderen inzwischen geändert, bitte neu laden.\n" + "Hint: original(" + original.getId() + ").optLock=" + original.getOptLock() + ", detached(" + detached.getId() + ").optLock=" + detached.getOptLock());
LogicTransactionEmo ltEmo = new LogicTransactionEmo(stockEm);
if (!detached.isClosed())
ltEmo.equilibrate(original.getDossier().getId(), original.getPositionsUniqueUnitIds());
if (original.getDossier().getDocuments().size() == 1 && original.getPositions().isEmpty()) {
redTapeEm.remove(original.getDossier());
return null;
}
return original;
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class UnitOverseerBean method throwNotAvailable.
/**
* Build and throw an exception for a not available unit.
* <p>
* @param refurbishId the refurbished id of the unit
* @param us the unit shard
* @throws UserInfoException
*/
private void throwNotAvailable(String refurbishId, UnitShard us) throws UserInfoException {
// <- auch in di auslagerung...
if (us.getAvailable() == null)
throw new UserInfoException("SopoNr " + refurbishId + " existiert nicht");
StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(us.getUniqueUnitId());
if (stockUnit != null && stockUnit.getLogicTransaction() != null) {
Dossier dos = new DossierEao(redTapeEm).findById(stockUnit.getLogicTransaction().getDossierId());
if (dos == null)
throw new UserInfoException("SopoNr " + refurbishId + " is on a LogicTransaction, but there is no Dossier, inform Team Software");
UiCustomer customer = customerService.asUiCustomer(dos.getCustomerId());
if (customer == null)
throw new UserInfoException("SopoNr " + refurbishId + " is on Dossier " + dos.getIdentifier() + ", but Customer " + dos.getCustomerId() + " does not exist.");
throw new UserInfoException("SopoNr " + refurbishId + " ist schon vergeben" + "\nKID = " + customer.getId() + "\nKunde = " + customer.toTitleNameLine() + "\n\nVorgang = " + dos.getIdentifier());
}
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class RedTapeTryout method main.
public static void main(String[] args) {
Dl.local().add(RemoteLookup.class, new RemoteLookup() {
@Override
public <T> boolean contains(Class<T> clazz) {
return false;
}
@Override
public <T> T lookup(Class<T> clazz) {
return null;
}
});
Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
Dl.remote().add(CustomerService.class, new CustomerServiceStub());
Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {
@Override
public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
System.out.println("Mailing " + document);
}
@Override
public JasperPrint render(Document document, DocumentViewType viewType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Dossier briefed(Document detached, String arranger) {
detached.add(Document.Flag.CUSTOMER_BRIEFED);
detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
return detached.getDossier();
}
@Override
public FileJacket toXls(String identifier) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.local().add(Guardian.class, new AbstractGuardian() {
@Override
public void login(String user, char[] pass) throws AuthenticationException {
setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
}
});
Dl.remote().add(StockAgent.class, null);
Dl.remote().add(UniqueUnitAgent.class, null);
// Dl.remote().add(LegacyRemoteBridge.class, null);
Dl.remote().add(ShippingCostService.class, null);
Mandators mandatorSupporterMock = mock(Mandators.class);
when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
Dl.remote().add(Mandators.class, mandatorSupporterMock);
CustomerUpi ccos = mock(CustomerUpi.class);
when(ccos.createCustomer(any())).thenReturn(0L);
when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
Dl.local().add(CustomerUpi.class, ccos);
UiCore.startSwing(() -> new JLabel("Main Applikation"));
Ui.exec(() -> {
Ui.build().swing().show(() -> RedTapeController.build().getView());
});
}
Aggregations