use of org.apache.isis.applib.value.Blob in project estatio by estatio.
the class CodaMappingManager_IntegTest method upload.
@Test
public void upload() throws Exception {
String fileName = "CODAMappings.xlsx";
final byte[] pdfBytes = Resources.toByteArray(Resources.getResource(CodaMappingManager_IntegTest.class, fileName));
final Blob blob = new Blob(fileName, "application/pdf", pdfBytes);
// When
wrap(new CodaMappingManager()).upload(blob);
// Then
assertThat(codaMappingRepository.all()).hasSize(46);
}
use of org.apache.isis.applib.value.Blob 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.apache.isis.applib.value.Blob in project estatio by estatio.
the class IncomingPdfBuilder method execute.
@Override
protected void execute(final ExecutionContext executionContext) {
checkParam("contextClass", executionContext, Class.class);
checkParam("resourceName", executionContext, String.class);
final String runAsParam = executionContext.getParameter("runAs");
String runAs = runAsParam != null ? runAsParam : // could still be null; that's ok
this.runAs;
final URL url = Resources.getResource(contextClass, resourceName);
byte[] bytes;
try {
bytes = Resources.toByteArray(url);
} catch (IOException e) {
throw new RuntimeException(e);
}
final Blob blob = new Blob(resourceName, "application/pdf", bytes);
object = runAs != null ? sudoService.sudo(runAs, () -> upload(blob)) : upload(blob);
}
use of org.apache.isis.applib.value.Blob in project estatio by estatio.
the class CodaMappingManager method downloadToExcel.
@Action(semantics = SemanticsOf.SAFE)
@MemberOrder(name = "mappings", sequence = "1")
public Blob downloadToExcel(final String fileName) {
final List<CodaMappingImport> exports = getMappings().stream().map(x -> new CodaMappingImport(x)).collect(Collectors.toList());
WorksheetSpec spec = new WorksheetSpec(CodaMappingImport.class, SHEET_NAME);
WorksheetContent worksheetContent = new WorksheetContent(exports, spec);
return excelService.toExcel(worksheetContent, fileName);
}
use of org.apache.isis.applib.value.Blob in project estatio by estatio.
the class BankAccount_attachPdfAsIbanProof method act.
@Action(semantics = SemanticsOf.IDEMPOTENT, commandDtoProcessor = DeriveBlobFromDummyPdfArg0.class)
public BankAccount act(@Parameter(fileAccept = "application/pdf") final Blob document) {
final DocumentType ibanProofDocType = DocumentTypeData.IBAN_PROOF.findUsing(documentTypeRepository);
final List<Paperclip> ibanProofPaperclips = paperclipRepository.findByAttachedToAndRoleName(bankAccount, ROLE_NAME_FOR_IBAN_PROOF);
// delete all existing paperclips for this role whose type is also not IBAN_PROOF
// (ie any incoming invoices that were automatically attached as candidate iban proofs)
final Predicate<Paperclip> hasIbanProofDocType = paperclip -> Objects.equals(ibanProofDocType, paperclip.getDocument().getType());
final Predicate<Paperclip> doesNotHaveIbanProofDocType = hasIbanProofDocType.negate();
ibanProofPaperclips.stream().filter(doesNotHaveIbanProofDocType).forEach(paperclip -> paperclipRepository.delete(paperclip));
final String name = document.getName();
documentService.createAndAttachDocumentForBlob(ibanProofDocType, bankAccount.getAtPath(), name, document, ROLE_NAME_FOR_IBAN_PROOF, bankAccount);
return bankAccount;
}
Aggregations