Search in sources :

Example 86 with Programmatic

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();
}
Also used : Party(org.estatio.module.party.dom.Party) BankAccount(org.estatio.module.financial.dom.BankAccount) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 87 with Programmatic

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());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Task(org.estatio.module.capex.dom.task.Task) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 88 with Programmatic

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);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) ApplicationException(org.apache.isis.applib.ApplicationException) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 89 with Programmatic

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;
}
Also used : Person(org.estatio.module.party.dom.Person) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 90 with Programmatic

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);
}
Also used : PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) Person(org.estatio.module.party.dom.Person) 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