Search in sources :

Example 91 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class TaskRepository method findIncompleteForMyRolesAndUnassignedAndCreatedOnAfter.

/**
 * Those tasks which are assigned to no-one, but for which I have the (party) roles to perform after {@param createdOn}
 * @param createdOn
 * @return
 */
@Programmatic
public List<Task> findIncompleteForMyRolesAndUnassignedAndCreatedOnAfter(final LocalDateTime createdOn) {
    final Person meAsPerson = meAsPerson();
    if (meAsPerson == null) {
        return Lists.newArrayList();
    }
    final List<PartyRoleType> myRoleTypes = partyRoleTypesFor(meAsPerson);
    return findIncompleteByUnassignedForRolesAndCreatedOnAfter(myRoleTypes, createdOn);
}
Also used : PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) Person(org.estatio.module.party.dom.Person) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 92 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class TaskRepository method nextTaskAfter.

@Programmatic
public Task nextTaskAfter(final Task previousTask) {
    final LocalDateTime previousCreatedOn = previousTask.getCreatedOn();
    final Optional<Task> firstTaskIfAny = findIncompleteForMeAndCreatedOnAfter(previousCreatedOn).stream().findFirst();
    return firstTaskIfAny.orElse(previousTask);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 93 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class PdfManipulator method extractAndStamp.

@Programmatic
public byte[] extractAndStamp(final byte[] docBytes, final ExtractSpec extractSpec, final Stamp stamp) throws IOException {
    List<byte[]> extractedPageDocBytes = Lists.newArrayList();
    final PDDocument pdDoc = PDDocument.load(docBytes);
    try {
        final Splitter splitter = new Splitter();
        final List<PDDocument> splitDocs = splitter.split(pdDoc);
        final int sizeOfDoc = splitDocs.size();
        final Integer[] pageNums = extractSpec.pageNumbersFor(sizeOfDoc);
        for (Integer pageNum : pageNums) {
            final PDDocument docOfExtractedPage = splitDocs.get(pageNum);
            if (stamp != null) {
                final List<Line> leftLines = stamp.getLeftLines();
                final List<Line> rightLines = stamp.getRightLines();
                leftLines.add(new Line(String.format("Page: %d/%d", (pageNum + 1), sizeOfDoc), TEXT_COLOR, null));
                stamp.appendHyperlinkIfAnyTo(leftLines);
                extractedPageDocBytes.add(stamp(docOfExtractedPage, leftLines, rightLines));
            } else {
                extractedPageDocBytes.add(asBytes(docOfExtractedPage));
            }
        }
        for (PDDocument splitDoc : splitDocs) {
            splitDoc.close();
        }
    } finally {
        pdDoc.close();
    }
    final byte[] mergedBytes = pdfBoxService.merge(extractedPageDocBytes.toArray(new byte[][] {}));
    return mergedBytes;
}
Also used : Splitter(org.apache.pdfbox.multipdf.Splitter) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 94 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class ChargeRepository method chargesForCountry.

@Programmatic
public List<Charge> chargesForCountry(final String applicationTenancyPath) {
    // assert the path (must not be root)
    final String countryPath = ApplicationTenancyLevel.of(applicationTenancyPath).getCountryPath();
    final List<Charge> charges = allInstances();
    return Lists.newArrayList(Iterables.filter(charges, new Predicate<Charge>() {

        @Override
        public boolean apply(final Charge charge) {
            final ApplicationTenancyLevel chargeLevel = ApplicationTenancyLevel.of(charge);
            return chargeLevel.isRoot() || chargeLevel.isCountry() && chargeLevel.getPath().equalsIgnoreCase(countryPath);
        }
    }));
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) Predicate(com.google.common.base.Predicate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 95 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class PartySubscriptionsForOrders method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.FixEvent ev) {
    switch(ev.getEventPhase()) {
        case EXECUTING:
            Party sourceParty = ev.getSource();
            if (orderRepository.findBySellerParty(sourceParty).size() > 0) {
                sourceParty.addRole(Constants.InvoiceRoleTypeEnum.SELLER);
                sourceParty.addRole(IncomingInvoiceRoleTypeEnum.SUPPLIER);
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)162 Party (org.estatio.module.party.dom.Party)21 Lease (org.estatio.module.lease.dom.Lease)16 DomainObject (org.apache.isis.applib.annotation.DomainObject)11 BankAccount (org.estatio.module.financial.dom.BankAccount)11 Charge (org.estatio.module.charge.dom.Charge)10 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)10 LocalDate (org.joda.time.LocalDate)10 BigDecimal (java.math.BigDecimal)9 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)9 ApplicationException (org.apache.isis.applib.ApplicationException)8 Property (org.estatio.module.asset.dom.Property)8 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)8 ArrayList (java.util.ArrayList)7 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)7 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)7 Inject (javax.inject.Inject)6 Unit (org.estatio.module.asset.dom.Unit)6 Document (org.incode.module.document.dom.impl.docs.Document)6