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