Search in sources :

Example 6 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentTemplate_cloneWhenText method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(named = "Clone", contributed = Contributed.AS_ACTION)
public DocumentTemplate $$(@Parameter(maxLength = NameType.Meta.MAX_LEN) @ParameterLayout(named = "Name") final String name, final ApplicationTenancy applicationTenancy, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Date") final LocalDate date, @ParameterLayout(named = "Text", multiLine = DocumentModule.Constants.TEXT_MULTILINE) final String templateText, @ParameterLayout(named = "Content rendering strategy") final RenderingStrategy contentRenderingStrategy, @Parameter(maxLength = DocumentTemplate.NameTextType.Meta.MAX_LEN) final String nameText, @ParameterLayout(named = "Name rendering strategy") final RenderingStrategy nameRenderingStrategy, @ParameterLayout(named = "Preview only?") final boolean previewOnly) {
    final DocumentType type = documentTemplate.getType();
    final String mimeType = documentTemplate.getMimeType();
    final String fileSuffix = documentTemplate.getFileSuffix();
    final DocumentTemplate template = documentTemplateRepository.createText(type, date, applicationTenancy.getPath(), fileSuffix, previewOnly, name, mimeType, templateText, contentRenderingStrategy, nameText, nameRenderingStrategy);
    final DocumentTemplate._applicable template_applicable = factoryService.mixin(DocumentTemplate._applicable.class, template);
    for (Applicability applicability : documentTemplate.getAppliesTo()) {
        template_applicable.applicable(applicability.getDomainClassName(), applicability.getRendererModelFactoryClassName(), applicability.getAttachmentAdvisorClassName());
    }
    return template;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 7 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentAttachmentAdvisorForDemo method append.

private void append(final String docTypeRef, final List<DocumentType> documentTypes) {
    final DocumentType documentType = documentTypeRepository.findByReference(docTypeRef);
    documentTypes.add(documentType);
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType)

Example 8 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentMenu method upload.

@Action(domainEvent = IncomingDocumentRepository.UploadDomainEvent.class, commandDtoProcessor = DeriveBlobFromReturnedDocumentArg0.class)
@MemberOrder(sequence = "3")
public Document upload(final Blob blob) {
    final String name = blob.getName();
    final DocumentType type = DocumentTypeData.INCOMING.findUsing(documentTypeRepository);
    final ApplicationUser me = meService.me();
    String atPath = me != null ? me.getAtPath() : null;
    if (atPath == null) {
        atPath = "/";
    }
    return incomingDocumentRepository.upsertAndArchive(type, atPath, name, blob);
}
Also used : ApplicationUser(org.isisaddons.module.security.dom.user.ApplicationUser) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 9 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType 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)

Example 10 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class Invoice_DocumentManagement_IntegTest method findDocumentTemplateFor.

DocumentTemplate findDocumentTemplateFor(final DocumentTypeData documentTypeData, final Invoice invoice) {
    final DocumentType documentType = documentTypeData.findUsing(documentTypeRepository);
    assertThat(documentType).isNotNull();
    DocumentTemplate documentTemplate = documentTemplateRepository.findFirstByTypeAndApplicableToAtPath(documentType, invoice.getApplicationTenancyPath());
    assertThat(documentType).isNotNull();
    return documentTemplate;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Aggregations

DocumentType (org.incode.module.document.dom.impl.types.DocumentType)13 Action (org.apache.isis.applib.annotation.Action)4 Blob (org.apache.isis.applib.value.Blob)3 RenderingStrategy (org.incode.module.document.dom.impl.rendering.RenderingStrategy)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)2 Clob (org.apache.isis.applib.value.Clob)2 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)2 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)2 LocalDate (org.joda.time.LocalDate)2 List (java.util.List)1 Objects (java.util.Objects)1 Predicate (java.util.function.Predicate)1 Inject (javax.inject.Inject)1 Mixin (org.apache.isis.applib.annotation.Mixin)1 Parameter (org.apache.isis.applib.annotation.Parameter)1 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)1 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)1 BankAccount (org.estatio.module.financial.dom.BankAccount)1 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)1