use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class TaskRepository method findIncompleteForMeAndCreatedOnBefore.
/**
* Incomplete, assigned explicitly to me, AND ALSO any tasks not assigned to anyone but for which
* I have the (party) roles to perform them (so should be part of "my tasks") before {@param createdOn}
* @param createdOn
* @return
*/
@Programmatic
public List<Task> findIncompleteForMeAndCreatedOnBefore(final LocalDateTime createdOn) {
final Person meAsPerson = meAsPerson();
if (meAsPerson == null) {
return Lists.newArrayList();
}
final List<Task> tasks = findIncompleteForAndCreatedOnBefore(meAsPerson, createdOn);
final List<Task> myRolesTasksUnassigned = findIncompleteForMyRolesAndUnassignedAndCreatedOnBefore(createdOn);
tasks.addAll(myRolesTasksUnassigned);
tasks.sort(Ordering.natural().nullsLast().reverse().onResultOf(Task::getCreatedOn));
return tasks;
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class TaskRepository method previousTaskBefore.
@Programmatic
public Task previousTaskBefore(final Task previousTask) {
final LocalDateTime previousCreatedOn = previousTask.getCreatedOn();
final Optional<Task> firstTaskIfAny = findIncompleteForMeAndCreatedOnBefore(previousCreatedOn).stream().findFirst();
return firstTaskIfAny.orElse(previousTask);
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class PartySubscriptionsForIncomingInvoices 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 (incomingInvoiceRepository.findByBuyer(sourceParty).size() > 0) {
sourceParty.addRole(Constants.InvoiceRoleTypeEnum.BUYER);
sourceParty.addRole(IncomingInvoiceRoleTypeEnum.ECP);
}
if (incomingInvoiceRepository.findBySeller(sourceParty).size() > 0) {
sourceParty.addRole(Constants.InvoiceRoleTypeEnum.SELLER);
sourceParty.addRole(IncomingInvoiceRoleTypeEnum.SUPPLIER);
}
break;
default:
break;
}
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class PartySubscriptionsForIncomingInvoices method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
Party sourceParty = (Party) ev.getSource();
Party replacementParty = ev.getReplacement();
switch(ev.getEventPhase()) {
case VALIDATE:
if (replacementParty == null && incomingInvoiceRepository.findBySeller(sourceParty).size() > 0) {
ev.invalidate("Party is in use as seller in an invoice. Provide replacement");
}
if (replacementParty == null && incomingInvoiceRepository.findByBuyer(sourceParty).size() > 0) {
ev.invalidate("Party is in use as buyer in an invoice. Provide replacement");
}
break;
case EXECUTING:
if (replacementParty != null) {
for (Invoice invoice : incomingInvoiceRepository.findByBuyer(sourceParty)) {
invoice.setBuyer(replacementParty);
}
for (Invoice invoice : incomingInvoiceRepository.findBySeller(sourceParty)) {
invoice.setSeller(replacementParty);
}
}
break;
default:
break;
}
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class ChargeRepository method chargesForCountry.
@Programmatic
public List<Charge> chargesForCountry(final ApplicationTenancy countryOrLowerLevel) {
final ApplicationTenancyLevel level = ApplicationTenancyLevel.of(countryOrLowerLevel);
final String countryPath = level.getCountryPath();
return chargesForCountry(countryPath);
}
Aggregations