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);
}
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);
}
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;
}
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);
}
}));
}
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;
}
}
Aggregations