Search in sources :

Example 1 with UserInfoException

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;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 2 with UserInfoException

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());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) LogicTransactionEao(eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 3 with UserInfoException

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 &rArr; change LogicTransaction.
 * <ul><li>Only LogicTransaction > Dossier.Document.Positions should be possible</li></ul>
 * If Dossier.isEmpty &rarr; delete.
 * If stock.LogicTransaction is empty &rarr; 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;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)

Example 4 with UserInfoException

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());
    }
}
Also used : StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer)

Example 5 with UserInfoException

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());
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JLabel(javax.swing.JLabel) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Mandators(eu.ggnet.dwoss.mandator.Mandators) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Aggregations

UserInfoException (eu.ggnet.dwoss.util.UserInfoException)26 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)7 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)5 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)4 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)4 Test (org.junit.Test)4 CustomerGeneratorOperation (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation)3 UnitHistory (eu.ggnet.dwoss.event.UnitHistory)3 ReceiptGeneratorOperation (eu.ggnet.dwoss.receipt.ee.gen.ReceiptGeneratorOperation)3 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)3 UnitOverseer (eu.ggnet.dwoss.redtapext.ee.UnitOverseer)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)3 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)3 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)3 Collectors (java.util.stream.Collectors)3 EJB (javax.ejb.EJB)3 Inject (javax.inject.Inject)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Arquillian (org.jboss.arquillian.junit.Arquillian)3