Search in sources :

Example 36 with Programmatic

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

the class PartySubscriptions 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();
    List<AgreementRole> agreementRoles;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            agreementRoles = agreementRoleRepository.findByParty(sourceParty);
            if (replacementParty == null && agreementRoles.size() > 0) {
                ev.invalidate("Party is being used in an agreement role: remove roles or provide a replacement");
            } else {
                scratchpad.put(onPartyRemoveScratchpadKey = UUID.randomUUID(), agreementRoles);
            }
            break;
        case EXECUTING:
            agreementRoles = (List<AgreementRole>) scratchpad.get(onPartyRemoveScratchpadKey);
            for (AgreementRole agreementRole : agreementRoles) {
                agreementRole.setParty(replacementParty);
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 37 with Programmatic

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

the class CommunicationChannelSubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final CommunicationChannel.RemoveEvent ev) {
    CommunicationChannel sourceCommunicationChannel = ev.getSource();
    CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
    List<AgreementRoleCommunicationChannel> communicationChannels;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            communicationChannels = agreementRoleCommunicationChannelRepository.findByCommunicationChannel(sourceCommunicationChannel);
            if (communicationChannels.size() > 0 && replacementCommunicationChannel == null) {
                ev.invalidate("Communication channel is being used: provide a replacement");
            } else {
                scratchpad.put(onCommunicationChannelRemoveScratchpadKey = UUID.randomUUID(), communicationChannels);
            }
            break;
        case EXECUTING:
            communicationChannels = (List<AgreementRoleCommunicationChannel>) scratchpad.get(onCommunicationChannelRemoveScratchpadKey);
            for (AgreementRoleCommunicationChannel arcc : communicationChannels) {
                arcc.setCommunicationChannel(replacementCommunicationChannel);
            }
            break;
        default:
            break;
    }
}
Also used : AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 38 with Programmatic

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

the class PostalAddressDtoFactory method newDto.

@Programmatic
public PostalAddressDto newDto(final PostalAddress postalAddress) {
    PostalAddressDto dto = new PostalAddressDto();
    dto.setSelf(mappingHelper.oidDtoFor(postalAddress));
    dto.setAddress1(postalAddress.getAddress1());
    dto.setAddress2(postalAddress.getAddress2());
    dto.setAddress3(postalAddress.getAddress3());
    dto.setCity(postalAddress.getCity());
    final State postalAddressState = postalAddress.getState();
    if (postalAddressState != null) {
        dto.setStateReference(postalAddressState.getReference());
        dto.setStateName(postalAddressState.getName());
    }
    final Country postalAddressCountry = postalAddress.getCountry();
    if (postalAddressCountry != null) {
        dto.setCountryReference(postalAddressCountry.getReference());
        dto.setCountryAlpha2Code(postalAddressCountry.getAlpha2Code());
        dto.setCountryName(postalAddressCountry.getName());
    }
    return dto;
}
Also used : PostalAddressDto(org.estatio.canonical.communicationchannel.v1.PostalAddressDto) State(org.incode.module.country.dom.impl.State) Country(org.incode.module.country.dom.impl.Country) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 39 with Programmatic

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

the class IncomingInvoice method reasonItemsIncomplete.

@Programmatic
public String reasonItemsIncomplete() {
    StringBuffer buffer = new StringBuffer();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem incomingInvoiceItem = (IncomingInvoiceItem) item;
        if (incomingInvoiceItem.reasonIncomplete() != null) {
            buffer.append("(on item ");
            buffer.append(incomingInvoiceItem.getSequence().toString());
            buffer.append(") ");
            buffer.append(incomingInvoiceItem.reasonIncomplete());
        }
    }
    return buffer.length() == 0 ? null : buffer.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 40 with Programmatic

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

the class IncomingInvoice method getPropertySummary.

@Programmatic
public String getPropertySummary() {
    List<Property> distinctProperties = new ArrayList<>();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem iitem = (IncomingInvoiceItem) item;
        if (iitem.getFixedAsset() != null && !distinctProperties.contains(iitem.getFixedAsset())) {
            distinctProperties.add((Property) iitem.getFixedAsset());
        }
    }
    StringBuffer summary = new StringBuffer();
    for (Property property : distinctProperties) {
        if (summary.length() > 0) {
            summary.append(" | ");
        }
        summary.append(property.getName());
    }
    return summary.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) ArrayList(java.util.ArrayList) Property(org.estatio.module.asset.dom.Property) 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