use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class IncomingDocumentPresentationSubscriber_IntegTest method setupData.
@Before
public void setupData() throws IOException {
runFixtureScript(new FixtureScript() {
@Override
protected void execute(final ExecutionContext executionContext) {
executionContext.executeChild(this, new DocumentTypesAndTemplatesForCapexFixture());
}
});
List<Document> incomingDocumentsBefore = repository.findIncomingDocuments();
assertThat(incomingDocumentsBefore).isEmpty();
// given
final String fileName = "1020100123.pdf";
final byte[] pdfBytes = Resources.toByteArray(Resources.getResource(IncomingDocumentPresentationSubscriber_IntegTest.class, fileName));
final Blob blob = new Blob(fileName, "application/pdf", pdfBytes);
wrap(documentMenu).upload(blob);
transactionService.nextTransaction();
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class DeriveBlobFromReturnedDocumentAbstract method process.
@Override
public CommandDto process(final Command command, final CommandDto commandDto) {
final Bookmark result = command.getResult();
if (result == null) {
return commandDto;
}
try {
final Document document = bookmarkService.lookup(result, Document.class);
if (document != null) {
ParamDto paramDto = getParamDto(commandDto, paramNum);
CommonDtoUtils.setValueOn(paramDto, ValueType.BLOB, document.getBlob(), bookmarkService);
}
} catch (Exception ex) {
return commandDto;
}
return commandDto;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class TaskIncomingDocumentPdfService method doLookupPdfFor.
private Blob doLookupPdfFor(final Task task) {
StateTransition<?, ?, ?, ?> stateTransition = stateTransitionService.findFor(task);
if (stateTransition == null) {
return null;
}
if (stateTransition instanceof IncomingDocumentCategorisationStateTransition) {
IncomingDocumentCategorisationStateTransition idcst = (IncomingDocumentCategorisationStateTransition) stateTransition;
final Document document = idcst.getDocument();
if (document == null) {
return null;
}
if (!Objects.equals(document.getMimeType(), "application/pdf")) {
return null;
}
return document.getBlob();
}
if (stateTransition instanceof OrderApprovalStateTransition) {
final OrderApprovalStateTransition oast = (OrderApprovalStateTransition) stateTransition;
final Order order = oast.getOrdr();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupOrderPdfFrom(order);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof IncomingInvoiceApprovalStateTransition) {
final IncomingInvoiceApprovalStateTransition iiast = (IncomingInvoiceApprovalStateTransition) stateTransition;
final IncomingInvoice invoice = iiast.getInvoice();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof BankAccountVerificationStateTransition) {
final BankAccountVerificationStateTransition bavst = (BankAccountVerificationStateTransition) stateTransition;
final BankAccount bankAccount = bavst.getBankAccount();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIbanProofPdfFrom(bankAccount);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
return null;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class BuyerFinder_Test method testerWhenNullOrTooShort.
private void testerWhenNullOrTooShort(final String documentName) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class BuyerFinder_Test method testWhenParamIsInvoice.
private void testWhenParamIsInvoice(final String documentName, final String derivedPartyReference) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
Aggregations