Search in sources :

Example 41 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class UnitImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Property property = propertyRepository.findPropertyByReference(propertyReference);
    Unit unit = unitRepository.findUnitByReference(reference);
    if (unit == null) {
        unit = property.newUnit(reference, name, UnitType.BOUTIQUE);
    }
    // set attributes
    unit.setName(name);
    unit.setType(UnitType.valueOf(type));
    unit.changeDates(startDate, endDate);
    unit.setArea(area);
    unit.setSalesArea(salesArea);
    unit.setStorageArea(storageArea);
    unit.setMezzanineArea(mezzanineArea);
    unit.setDehorsArea(dehorsArea);
    unit.setExternalReference(externalReference);
    if (communicationChannelRepository.findByOwnerAndType(unit, CommunicationChannelType.POSTAL_ADDRESS).size() == 0) {
        communicationChannelRepository.newPostal(unit, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
    }
    if (ownerReference != null) {
        Party party = partyRepository.findPartyByReference(ownerReference);
        if (party == null) {
            throw new IllegalArgumentException(String.format("Party with ownerReference %s not found", getOwnerReference()));
        }
        // create property owner of not found one already
        FixedAssetRole propertyOwnerRole = fixedAssetRoleRepository.findRole(unitRepository.findUnitByReference(reference), FixedAssetRoleTypeEnum.PROPERTY_OWNER);
        if (propertyOwnerRole == null) {
            unit.createRole(FixedAssetRoleTypeEnum.PROPERTY_OWNER, party, null, null);
        }
    }
    return Lists.newArrayList(unit);
}
Also used : Party(org.estatio.module.party.dom.Party) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) Unit(org.estatio.module.asset.dom.Unit) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 42 with Party

use of org.estatio.module.party.dom.Party 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 Party.DeleteEvent ev) {
    Party sourceParty = ev.getSource();
    Party replacementParty = ev.getReplacement();
    switch(ev.getEventPhase()) {
        case VALIDATE:
            // We don't care if being deleted
            break;
        case EXECUTING:
            for (CommunicationChannel communicationChannel : communicationChannelRepository.findByOwner(sourceParty)) {
                if (replacementParty == null) {
                    communicationChannel.remove(null);
                } else {
                    communicationChannel.setOwner(replacementParty);
                }
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 43 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class IncomingInvoiceItem_createOrderItemLink method choices0Act.

public List<OrderItem> choices0Act() {
    // the disable guard ensures this is non-null
    final Party seller = mixee.getInvoice().getSeller();
    final Property property = (Property) mixee.getFixedAsset();
    // candidates
    final List<OrderItem> orderItems;
    if (property == null) {
        orderItems = orderItemRepository.findBySeller(seller);
    } else {
        orderItems = orderItemRepository.findBySellerAndProperty(seller, property);
    }
    return orderItems.stream().filter(x -> x.getOrdr().getApprovalState() == null || x.getOrdr().getApprovalState() != OrderApprovalState.DISCARDED).collect(Collectors.toList());
}
Also used : Action(org.apache.isis.applib.annotation.Action) OrderApprovalState(org.estatio.module.capex.dom.order.approval.OrderApprovalState) Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) BigDecimal(java.math.BigDecimal) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2) Digits(javax.validation.constraints.Digits) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Party(org.estatio.module.party.dom.Party) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Property(org.estatio.module.asset.dom.Property)

Example 44 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class CommunicationChannelImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    List<Object> results = new ArrayList<>();
    // Party
    final Party party = fetchParty(partyReference);
    if (party == null)
        throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
    // Address
    if (address1 != null || address2 != null || address3 != null) {
        final Country country = countryRepository.findCountry(countryCode);
        PostalAddress comm = (PostalAddress) postalAddressRepository.findByAddress(party, address1, address2, address3, postalCode, city, country);
        if (comm == null) {
            comm = communicationChannelRepository.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
        }
        if (legal != null && legal) {
            comm.setLegal(true);
        }
        // attach to lease
        if (leaseReference != null) {
            Lease lease = fetchLease(leaseReference);
            if (lease != null && addressType != null) {
                final AgreementRoleType art = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
                final AgreementRoleCommunicationChannelType arcct = agreementRoleCommunicationChannelTypeRepository.findByTitle(addressType);
                lease.findRoleWithType(art, lease.getStartDate()).addCommunicationChannel(arcct, comm, lease.getStartDate());
            }
        }
    }
    // Phone
    if (phoneNumber != null) {
        CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, phoneNumber);
        if (comm == null) {
            comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
            comm.setReference(leaseReference);
        }
    }
    // Fax
    if (faxNumber != null) {
        CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, faxNumber);
        if (comm == null) {
            comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
            comm.setReference(leaseReference);
        }
    }
    // Email
    if (emailAddress != null) {
        CommunicationChannel comm = emailAddressRepository.findByEmailAddress(party, emailAddress);
        if (comm == null) {
            comm = communicationChannelRepository.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
            comm.setReference(leaseReference);
        }
    }
    return results;
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) ApplicationException(org.apache.isis.applib.ApplicationException) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Lease(org.estatio.module.lease.dom.Lease) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ArrayList(java.util.ArrayList) Country(org.incode.module.country.dom.impl.Country) DomainObject(org.apache.isis.applib.annotation.DomainObject) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 45 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class LeaseImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Party tenant = fetchParty(tenantReference);
    final Party landlord = fetchParty(landlordReference);
    Lease lease = leaseRepository.findLeaseByReferenceElseNull(reference);
    final LeaseType leaseType = leaseTypeRepository.findByReference(type);
    final Property property = fetchProperty(propertyReference, null, false);
    if (lease == null) {
        lease = leaseRepository.newLease(property.getApplicationTenancy(), reference, name, leaseType, startDate, endDate, tenancyStartDate, tenancyEndDate, landlord, tenant);
    }
    lease.setTenancyStartDate(tenancyStartDate);
    lease.setTenancyEndDate(tenancyEndDate);
    lease.setExternalReference(externalReference);
    lease.setComments(getComments());
    if (getProlongationPeriod() != null) {
        prolongationOptionRepository.newProlongationOption(lease, getProlongationPeriod(), getNotificationPeriod(), null);
    }
    if (getPreviousLeaseReference() != null) {
        Lease previous = leaseRepository.findLeaseByReference(getPreviousLeaseReference());
        if (previous == null) {
            // oops, not found?
            System.out.println(String.format("On lease [%s] the previous lease [%s] was not found", getReference(), getPreviousLeaseReference()));
        } else {
            lease.setPrevious(previous);
            // Huh? Two sided
            previous.setNext(lease);
        }
    }
    return Lists.newArrayList(lease);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) LeaseType(org.estatio.module.lease.dom.LeaseType) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Party (org.estatio.module.party.dom.Party)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)22 Test (org.junit.Test)15 Property (org.estatio.module.asset.dom.Property)13 BankAccount (org.estatio.module.financial.dom.BankAccount)13 Organisation (org.estatio.module.party.dom.Organisation)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)10 Expectations (org.jmock.Expectations)10 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)8 ArrayList (java.util.ArrayList)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Lease (org.estatio.module.lease.dom.Lease)6 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)6 List (java.util.List)5 Inject (javax.inject.Inject)4 Action (org.apache.isis.applib.annotation.Action)4 Country (org.incode.module.country.dom.impl.Country)4 LocalDate (org.joda.time.LocalDate)4 Optional (java.util.Optional)3 SortedSet (java.util.SortedSet)3