use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.
the class RedTapeWorkerOperation method delete.
/**
* Deletes a {@link Dossier}, cleaning up the Stock.
* <p/>
* @param dos the Dossier to be deleted.
*/
@Override
public void delete(Dossier dos) {
new LogicTransactionEmo(stockEm).equilibrate(dos.getId(), new ArrayList<>());
Dossier attachedDossier = new DossierEao(redTapeEm).findById(dos.getId());
redTapeEm.remove(attachedDossier);
}
use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.
the class RedTapeWorkerOperation method updateAllDocumentAdresses.
/**
* Changes the {@link Address} of all active {@link Document} of {@link DocumentType#ORDER} and no Invoices or CreditMemos found from every {@link Dossier}
* containing a specific customer id.
* <p/>
* If one of the addresses does not exist, it will be created.
* <p/>
* @param addressChange
*/
@Override
public void updateAllDocumentAdresses(AddressChange addressChange) {
AddressEmo addressEmo = new AddressEmo(redTapeEm);
Address address = addressEmo.request(addressService.defaultAddressLabel(addressChange.getCustomerId(), addressChange.getType()));
redTapeEm.detach(address);
List<Dossier> dossiers = new DossierEao(redTapeEm).findByCustomerId(addressChange.getCustomerId());
for (Dossier dossier : dossiers) {
if (!dossier.getActiveDocuments(DocumentType.INVOICE).isEmpty())
continue;
for (Document document : new HashSet<>(dossier.getActiveDocuments(DocumentType.ORDER))) {
if (document.getConditions().contains(Document.Condition.CANCELED))
continue;
// May be fetchEager
redTapeEm.detach(document);
if (addressChange.getType() == AddressType.INVOICE)
document.setInvoiceAddress(address);
if (addressChange.getType() == AddressType.SHIPPING)
document.setShippingAddress(address);
redTapeEm.flush();
redTapeEm.clear();
internalUpdate(document, null, addressChange.getArranger());
}
}
}
use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.
the class RedTapeWorkerOperation method updateComment.
/**
* Update Comments of the Dossier.
* <p/>
* @param dossier the dossier to update
* @param comment the comment
* @return returns the dossier
* @throws UserInfoException if something is not ok.
*/
@Override
public Dossier updateComment(Dossier dossier, String comment) throws UserInfoException {
if (Objects.equals(dossier.getComment(), comment))
return dossier;
long id = dossier.getId();
// This is some magic to find out if this is are SopoAuftrag.
if (id == 0)
throw new UserInfoException("Dossier is not in Database, but updateComment is called");
dossier = new DossierEao(redTapeEm).findById(dossier.getId());
if (dossier == null)
throw new UserInfoException("Dossier(id=" + id + ") is not in Database, but updateComment is called");
dossier.fetchEager();
dossier.setComment(comment);
return dossier;
}
use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.
the class UniversalSearcherOperation method findCustomer.
/**
* Find a Customer and return a html formated String representing it.
* Ensure to add the html start/end tags manually
* <p/>
* @param id CustomerId to search for
* @return a html formated String representing a Customer.
*/
@Override
public String findCustomer(int id) {
List<Dossier> dossiers = new DossierEao(redTapeEm).findOpenByCustomerId(id);
String res = "";
res += customerService.asHtmlHighDetailed(Integer.valueOf(id).longValue());
res += "<p><h3>Offene Vorgänge:</h3><ol>";
for (Dossier dossier : dossiers) {
res += "<li>" + DossierFormater.toHtmlSimpleWithDocument(dossier) + "</li>";
}
res += "</ol></p>";
return res;
}
Aggregations