Search in sources :

Example 11 with Blob

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);
}
Also used : Blob(org.apache.isis.applib.value.Blob) CodaMappingManager(org.estatio.module.capex.imports.CodaMappingManager) Test(org.junit.Test)

Example 12 with Blob

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();
}
Also used : Blob(org.apache.isis.applib.value.Blob) DocumentTypesAndTemplatesForCapexFixture(org.estatio.module.capex.seed.DocumentTypesAndTemplatesForCapexFixture) FixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript) Document(org.incode.module.document.dom.impl.docs.Document) Before(org.junit.Before)

Example 13 with Blob

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);
}
Also used : Blob(org.apache.isis.applib.value.Blob) ToString(lombok.ToString) IOException(java.io.IOException) URL(java.net.URL)

Example 14 with 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);
}
Also used : Action(org.apache.isis.applib.annotation.Action) Nature(org.apache.isis.applib.annotation.Nature) CodaMappingRepository(org.estatio.module.capex.dom.coda.CodaMappingRepository) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) Inject(javax.inject.Inject) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) CollectionLayout(org.apache.isis.applib.annotation.CollectionLayout) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) DomainObject(org.apache.isis.applib.annotation.DomainObject) CodaMapping(org.estatio.module.capex.dom.coda.CodaMapping) WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) Contributed(org.apache.isis.applib.annotation.Contributed) Parameter(org.apache.isis.applib.annotation.Parameter) Publishing(org.apache.isis.applib.annotation.Publishing) ExcelService(org.isisaddons.module.excel.dom.ExcelService) Blob(org.apache.isis.applib.value.Blob) WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 15 with Blob

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;
}
Also used : Action(org.apache.isis.applib.annotation.Action) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) PaperclipRepository(org.incode.module.document.dom.impl.paperclips.PaperclipRepository) Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Predicate(java.util.function.Predicate) DocumentTypeRepository(org.incode.module.document.dom.impl.types.DocumentTypeRepository) Objects(java.util.Objects) Inject(javax.inject.Inject) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) DocumentService(org.incode.module.document.dom.api.DocumentService) DeriveBlobFromDummyPdfArg0(org.incode.module.base.spi.DeriveBlobFromDummyPdfArg0) BankAccount(org.estatio.module.financial.dom.BankAccount) Parameter(org.apache.isis.applib.annotation.Parameter) Blob(org.apache.isis.applib.value.Blob) DocumentTypeData(org.estatio.module.invoice.dom.DocumentTypeData) Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Action(org.apache.isis.applib.annotation.Action)

Aggregations

Blob (org.apache.isis.applib.value.Blob)19 Action (org.apache.isis.applib.annotation.Action)10 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)8 Document (org.incode.module.document.dom.impl.docs.Document)7 List (java.util.List)4 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)4 IOException (java.io.IOException)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3 DomainObject (org.apache.isis.applib.annotation.DomainObject)3 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)3 Nature (org.apache.isis.applib.annotation.Nature)3 Clob (org.apache.isis.applib.value.Clob)3 LocalDate (org.joda.time.LocalDate)3 URL (java.net.URL)2 Getter (lombok.Getter)2 Setter (lombok.Setter)2 CollectionLayout (org.apache.isis.applib.annotation.CollectionLayout)2 Contributed (org.apache.isis.applib.annotation.Contributed)2 Parameter (org.apache.isis.applib.annotation.Parameter)2