Search in sources :

Example 6 with LeaseType

use of org.estatio.module.lease.dom.LeaseType 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

LeaseType (org.estatio.module.lease.dom.LeaseType)6 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 Lease (org.estatio.module.lease.dom.Lease)2 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)1 Property (org.estatio.module.asset.dom.Property)1 ApplicationTenancyLevel (org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel)1 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)1 LeaseTypeForItalyRefData (org.estatio.module.lease.fixtures.LeaseTypeForItalyRefData)1 Party (org.estatio.module.party.dom.Party)1