use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class BankAccountImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
if (IBANValidator.valid(iban)) {
final Party owner = partyRepository.findPartyByReference(ownerReference);
BankAccount bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, iban);
if (owner == null)
return Lists.newArrayList();
if (bankAccount == null) {
bankAccount = bankAccountRepository.newBankAccount(owner, iban, bic);
} else {
bankAccount.setIban(iban);
bankAccount.verifyIban();
bankAccount.setBic(BankAccount.trimBic(bic));
}
if (propertyReference != null) {
final Property property = propertyRepository.findPropertyByReference(propertyReference);
if (property == null) {
throw new IllegalArgumentException(String.format("Property with reference [%s] not found", propertyReference));
}
fixedAssetFinancialAccountRepository.findOrCreate(property, bankAccount);
}
}
return Lists.newArrayList();
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class StateTransitionAbstract method completed.
@Programmatic
@Override
public void completed(final String comment, final NatureOfTransition natureOfTransition) {
final LocalDateTime completedOn = clockService.nowAsLocalDateTime();
final String completedBy = meService.me().getUsername();
if (natureOfTransition == NatureOfTransition.EXPLICIT) {
setCompletedBy(completedBy);
}
setCompletedOn(completedOn);
setComment(comment);
final Task task = getTask();
if (task != null) {
if (natureOfTransition == NatureOfTransition.EXPLICIT) {
task.setCompletedBy(completedBy);
}
task.setCompletedOn(completedOn);
task.setComment(comment);
}
setCompleted(true);
setToState(getTransitionType().getToState());
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class ProjectImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
if (previousRow != null) {
// TODO: support sparse sheets ?
}
Project parent = null;
if (getParentReference() != null) {
parent = projectRepository.findByReference(getParentReference());
if (parent == null) {
throw new ApplicationException(String.format("Parent with reference %s not found.", getParentReference()));
}
if (!parent.getAtPath().equals(getAtPath())) {
throw new ApplicationException(String.format("AtPath parent %s does not match %s.", getParentReference(), getAtPath()));
}
if (!parent.getItems().isEmpty()) {
// TODO: (ECP-438) until we find out more about the process, prevent a the choice of a project having items
throw new ApplicationException(String.format("Parent with reference %s has items and cannot be a parent therefore.", getAtPath()));
}
}
Project project = findOrCreateProjectAndUpdateParent(getReference(), getName(), getStartDate(), getEndDate(), getAtPath(), parent);
if (getItemChargeReference() != null) {
Charge charge = chargeRepository.findByReference(getItemChargeReference());
Property property = propertyRepository.findPropertyByReference(getItemPropertyReference());
Tax tax = taxRepository.findByReference(getItemTaxReference());
wrapperFactory.wrap(project).addItem(charge, getItemDescription(), getItemBudgetedAmount(), getItemStartDate(), getItemEndDate(), property, tax);
}
return Lists.newArrayList(project);
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class TaskRepository method findIncompleteForMe.
/**
* 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")
*/
@Programmatic
public List<Task> findIncompleteForMe() {
final Person meAsPerson = meAsPerson();
if (meAsPerson == null) {
return Lists.newArrayList();
}
final List<Task> tasks = findIncompleteForMeOnly();
final List<Task> myRolesTasksUnassigned = findIncompleteForMyRolesAndUnassigned();
tasks.addAll(myRolesTasksUnassigned);
return tasks;
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class TaskRepository method findIncompleteForMyRolesAndUnassignedAndCreatedOnBefore.
/**
* Those tasks which are assigned to no-one, but for which I have the (party) roles to perform before {@param createdOn}
* @param createdOn
* @return
*/
@Programmatic
public List<Task> findIncompleteForMyRolesAndUnassignedAndCreatedOnBefore(final LocalDateTime createdOn) {
final Person meAsPerson = meAsPerson();
if (meAsPerson == null) {
return Lists.newArrayList();
}
final List<PartyRoleType> myRoleTypes = partyRoleTypesFor(meAsPerson);
return findIncompleteByUnassignedForRolesAndCreatedOnBefore(myRoleTypes, createdOn);
}
Aggregations