use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class LeaseBuilder method execute.
@Override
protected void execute(final ExecutionContext executionContext) {
checkParam("reference", executionContext, String.class);
checkParam("name", executionContext, String.class);
checkParam("property", executionContext, Unit.class);
checkParam("landlord", executionContext, Party.class);
checkParam("tenant", executionContext, Party.class);
checkParam("startDate", executionContext, LocalDate.class);
checkParam("endDate", executionContext, LocalDate.class);
defaultParam("invoiceAddressCreationPolicy", executionContext, InvoiceAddressCreationPolicy.DONT_CREATE);
defaultParam("addressesCreationPolicy", executionContext, AddressesCreationPolicy.DONT_CREATE);
landlord.addRole(LeaseRoleTypeEnum.LANDLORD);
tenant.addRole(LeaseRoleTypeEnum.TENANT);
final ApplicationTenancy atPath = ApplicationTenancy_enum.Global.findUsing(serviceRegistry);
final LeaseType leaseType = leaseTypeRepository.findOrCreate("STD", "Standard", atPath);
Lease lease = leaseRepository.newLease(property.getApplicationTenancy(), reference, name, leaseType, startDate, null, endDate, landlord, tenant);
executionContext.addResult(this, lease.getReference(), lease);
if (manager != null) {
final AgreementRole role = lease.createRole(agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.MANAGER), manager, null, null);
executionContext.addResult(this, role);
}
for (final OccupancySpec spec : occupancySpecs) {
Occupancy occupancy = occupancyRepository.newOccupancy(lease, spec.unit, spec.startDate);
occupancy.setEndDate(spec.endDate);
occupancy.setBrandName(spec.brand, spec.brandCoverage, spec.countryOfOrigin);
occupancy.setSectorName(spec.sector);
occupancy.setActivityName(spec.activity);
executionContext.addResult(this, occupancy);
}
if (invoiceAddressCreationPolicy == InvoiceAddressCreationPolicy.CREATE) {
addInvoiceAddressForTenant(lease, tenant, CommunicationChannelType.EMAIL_ADDRESS);
}
if (addressesCreationPolicy == AddressesCreationPolicy.CREATE) {
createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.ADMINISTRATION_ADDRESS);
createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
}
if (leaseRepository.findLeaseByReference(reference) == null) {
throw new RuntimeException("could not find lease reference='" + reference + "'");
}
object = lease;
}
use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class AgreementCommunicationChannelLocator method onFile.
@Programmatic
public List<CommunicationChannel> onFile(final Agreement agreement, final String art, final List<CommunicationChannelType> communicationChannelTypes) {
final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
for (final AgreementRole role : agreementRoles) {
if (role.getType() == partyInRoleOf) {
final Party party = role.getParty();
final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwner(party);
for (CommunicationChannel channel : channels) {
if (communicationChannelTypes.contains(channel.getType())) {
communicationChannels.add(channel);
}
}
break;
}
}
return communicationChannels;
}
Aggregations