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);
}
Aggregations