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());
});
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class UnitAvailabillityTryout method main.
public static void main(String[] args) {
Dl.remote().add(UnitOverseer.class, new UnitOverseer() {
private Map<String, Tuple2<UnitShard, String>> data = new HashMap<>();
{
data.put("1", new Tuple2<>(new UnitShard("1", 1, "SopoNr.: 1", Boolean.TRUE, 1), "Details zu Unit 1"));
data.put("2", new Tuple2<>(new UnitShard("2", 2, "SopoNr.: 2", Boolean.FALSE, 1), "Details zu Unit 2"));
data.put("3", new Tuple2<>(new UnitShard("3", 3, "SopoNr.: 3", Boolean.TRUE, 1), "Details zu Unit 3"));
data.put("4", new Tuple2<>(new UnitShard("4", 4, "SopoNr.: 4", Boolean.FALSE, 1), "Details zu Unit 4"));
data.put("5", new Tuple2<>(new UnitShard("5", 5, "SopoNr.: 5 exitiert nicht", null, null), "Existiert Nicht"));
data.put("6", new Tuple2<>(new UnitShard("6", 6, "SopoNr.: 6", Boolean.FALSE, null), "Details zu Unit 6"));
}
@Override
public String toDetailedHtml(String refurbishId, String username) {
if (!data.containsKey(refurbishId))
return refurbishId + " existiert nicht";
return data.get(refurbishId)._2;
}
@Override
public UnitShard find(String refurbishId) {
if (!data.containsKey(refurbishId))
return new UnitShard(refurbishId, 0, "SopoNr.: " + refurbishId + " exitiert nicht", null, null);
return data.get(refurbishId)._1;
}
@Override
public boolean isAvailable(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void lockStockUnit(long dossierId, String refurbishedId) throws IllegalStateException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Result<List<Position>> createUnitPosition(String refurbishId, long documentId) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String toDetailedHtml(int uniqueUnitId, String username) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Ui.exec(() -> {
UiCore.startSwing(() -> new JLabel("Main Application"));
Ui.build().swing().show(() -> new UnitAvailabilityViewCask());
});
}
Aggregations