use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class IncomingInvoice_switchView method act.
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION, // not sure why this isn't being picked up from isis-non-changing.properties
cssClassFa = "fa-exchange")
@MemberOrder(sequence = "1")
public IncomingDocAsInvoiceViewModel act() {
Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(incomingInvoice);
// guaranteed to return, hidden if none
Document document = documentIfAny.get();
final IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel(incomingInvoice, document);
serviceRegistry2.injectServicesInto(viewModel);
viewModel.init();
return viewModel;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class T_createAndAttachDocumentAndScheduleRender method $$.
/**
* Create a {@link Document} and attach using a {@link Paperclip}.
*/
@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(contributed = Contributed.AS_ACTION)
@MemberOrder(name = "documents", sequence = "3.2")
public Object $$(final DocumentTemplate template) throws IOException {
final Document document = documentCreatorService.createDocumentAndAttachPaperclips(domainObject, template);
render(template, document);
return document;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class Paperclip method getDocumentDate.
/**
* Either the {@link Document#getCreatedAt()} or {@link Document#getRenderedAt()}, depending upon the
* {@link Document#getState()} of the {@link Document}. Returns <tt>null</tt> for {@link DocumentTemplate}s.
*/
@NotPersistent
@Property(domainEvent = DocumentDateDomainEvent.class, editing = Editing.DISABLED)
public DateTime getDocumentDate() {
final DocumentAbstract documentAbstract = getDocument();
if (documentAbstract instanceof Document) {
final Document document = (Document) documentAbstract;
DocumentState state = document.getState();
return state.dateOf(document);
}
return null;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class PaperclipRepository method attach.
// endregion
// region > attach (programmatic)
/**
* This is an idempotent operation.
*/
@Programmatic
public Paperclip attach(final DocumentAbstract documentAbstract, final String roleName, final Object attachTo) {
Paperclip paperclip = findByDocumentAndAttachedToAndRoleName(documentAbstract, attachTo, roleName);
if (paperclip != null) {
return paperclip;
}
final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo);
paperclip = repositoryService.instantiate(subtype);
paperclip.setDocument(documentAbstract);
paperclip.setRoleName(roleName);
if (documentAbstract instanceof Document) {
final Document document = (Document) documentAbstract;
paperclip.setDocumentCreatedAt(document.getCreatedAt());
}
if (!repositoryService.isPersistent(attachTo)) {
transactionService.flushTransaction();
}
final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo);
paperclip.setAttachedTo(attachTo);
paperclip.setAttachedToStr(bookmark.toString());
repositoryService.persistAndFlush(paperclip);
return paperclip;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class DocumentCreatorService method createDocumentAndAttachPaperclips.
/**
* Replaced by {@link org.incode.module.document.dom.api.DocumentService#createDocumentAndAttachPaperclips(Object, DocumentTemplate)} as formal API.
*
* @param domainObject
* @param template
* @return
*/
@Deprecated
@Programmatic
public Document createDocumentAndAttachPaperclips(final Object domainObject, final DocumentTemplate template) {
final Document createdDocument = template.create(domainObject);
final List<AttachmentAdvisor.PaperclipSpec> paperclipSpecs = template.newAttachmentAdvice(createdDocument, domainObject);
for (AttachmentAdvisor.PaperclipSpec paperclipSpec : paperclipSpecs) {
final String roleName = paperclipSpec.getRoleName();
final Object attachTo = paperclipSpec.getAttachTo();
final Document paperclipSpecCreatedDocument = paperclipSpec.getCreatedDocument();
if (paperclipRepository.canAttach(attachTo)) {
paperclipRepository.attach(paperclipSpecCreatedDocument, roleName, attachTo);
}
}
return createdDocument;
}
Aggregations