use of org.apache.isis.applib.ApplicationException in project estatio by estatio.
the class GuaranteeImport method fetchLease.
private Lease fetchLease(final String leaseReference) {
final Lease lease;
lease = leaseRepository.findLeaseByReference(leaseReference.trim().replaceAll("~", "+"));
if (lease == null) {
throw new ApplicationException(String.format("Lease with reference %s not found.", leaseReference));
}
return lease;
}
use of org.apache.isis.applib.ApplicationException in project estatio by estatio.
the class Communication method sendByEmail.
// so can invoke via BackgroundService
@Action(hidden = Where.EVERYWHERE)
public Communication sendByEmail() {
// body...
final Document coverNoteDoc = findDocument(DocumentConstants.PAPERCLIP_ROLE_COVER);
final String emailBody = coverNoteDoc.asChars();
// (email) attachments..
// this corresponds to the primary document and any attachments
final List<DataSource> attachments = Lists.newArrayList();
final Document primaryDocument = getPrimaryDocument();
if (primaryDocument != null) {
// should be the case
attachments.add(primaryDocument.asDataSource());
}
attachments.addAll(findDocumentsInRoleAsStream(DocumentConstants.PAPERCLIP_ROLE_ATTACHMENT).map(DocumentAbstract::asDataSource).collect(Collectors.toList()));
// cc..
final List<String> toList = findCorrespondents(CommChannelRoleType.TO);
final List<String> ccList = findCorrespondents(CommChannelRoleType.CC);
final List<String> bccList = findCorrespondents(CommChannelRoleType.BCC);
// subject ...
final String subject = getSubject();
// finally, we send
final boolean send = emailService.send(toList, ccList, bccList, subject, emailBody, attachments.toArray(new DataSource[] {}));
if (!send) {
throw new ApplicationException("Failed to send email; see system logs for details.");
}
// mark this comm as having been sent.
sent();
return this;
}
use of org.apache.isis.applib.ApplicationException in project estatio by estatio.
the class PartitionItemImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
Property property = propertyRepository.findPropertyByReference(propertyReference);
if (property == null)
throw new ApplicationException(String.format("Property with reference [%s] not found.", propertyReference));
final Budget budget = budgetRepository.findOrCreateBudget(property, startDate, endDate);
final KeyTable keyTable = keyTableRepository.findOrCreateBudgetKeyTable(budget, keyTableName, FoundationValueType.MANUAL, KeyValueMethod.PERCENT, 6);
findOrCreateBudgetKeyItem(keyTable, unitRepository.findUnitByReference(unitReference), keyValue, sourceValue);
final Charge charge = fetchCharge(budgetChargeReference);
final BudgetItem butgetItem = findOrCreateBudgetItem(budget, charge, budgetValue);
final Charge scheduleCharge = fetchCharge(invoiceChargeReference);
final Partitioning partitioning = findOrCreatePartitioning(budget);
findOrCreatePartitionItem(partitioning, scheduleCharge, butgetItem, keyTable, percentage);
return Lists.newArrayList();
}
use of org.apache.isis.applib.ApplicationException in project estatio by estatio.
the class Api method putPartyCommunicationChannels.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putPartyCommunicationChannels(@Named("reference") final String partyReference, @Named("reference") @Optional final String reference, @Named("address1") @Optional final String address1, @Named("address2") @Optional final String address2, @Named("address3") @Optional final String address3, @Named("city") @Optional final String city, @Named("postalCode") @Optional final String postalCode, @Named("stateCode") @Optional final String stateCode, @Named("countryCode") @Optional final String countryCode, @Named("phoneNumber") @Optional final String phoneNumber, @Named("faxNumber") @Optional final String faxNumber, @Named("emailAddress") @Optional final String emailAddress, @Named("legal") @Optional final Boolean legal) {
final Party party = fetchParty(partyReference);
if (party == null)
throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
// Address
if (address1 != null) {
final Country country = fetchCountry(countryCode);
PostalAddress comm = (PostalAddress) postalAddresses.findByAddress(party, address1, postalCode, city, country);
if (comm == null) {
comm = communicationChannels.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, null, postalCode, city, states.findState(stateCode), countries.findCountry(countryCode));
comm.setReference(reference);
}
if (legal) {
comm.setLegal(true);
}
}
// Phone
if (phoneNumber != null) {
CommunicationChannel comm = phoneOrFaxNumbers.findByPhoneOrFaxNumber(party, phoneNumber);
if (comm == null) {
comm = communicationChannels.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
comm.setReference(reference);
}
}
// Fax
if (faxNumber != null) {
CommunicationChannel comm = phoneOrFaxNumbers.findByPhoneOrFaxNumber(party, faxNumber);
if (comm == null) {
comm = communicationChannels.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
comm.setReference(reference);
}
}
// Email
if (emailAddress != null) {
CommunicationChannel comm = emailAddresses.findByEmailAddress(party, emailAddress);
if (comm == null) {
comm = communicationChannels.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
comm.setReference(reference);
}
}
}
use of org.apache.isis.applib.ApplicationException in project estatio by estatio.
the class Api method putBankMandate.
@ActionSemantics(Of.IDEMPOTENT)
public void putBankMandate(@Named("reference") final String reference, @Named("sepaMandateIdentifier") @Optional final String sepaMandateIdentifier, @Named("name") @Optional final String name, @Named("leaseReference") final String leaseReference, @Named("debtorReference") final String debtorReference, @Named("creditorReference") final String creditorReference, @Named("bankAccountReference") final String bankAccountReference, @Named("startDate") final LocalDate startDate, @Named("endDate") @Optional final LocalDate endDate) {
BankMandate bankMandate = (BankMandate) agreements.findAgreementByReference(reference);
final BankAccount bankAccount = (BankAccount) financialAccounts.findAccountByReference(bankAccountReference);
if (bankAccount == null)
throw new ApplicationException(String.format("BankAccount with reference %1$s not found", bankAccountReference));
final Lease lease = fetchLease(leaseReference);
final Party debtor = fetchParty(debtorReference);
final Party creditor = fetchParty(creditorReference);
if (bankMandate == null) {
lease.newMandate(bankAccount, reference, startDate, endDate);
bankMandate = lease.getPaidBy();
bankMandate.setName(name);
// EST-467, previously was:
// bankMandate = bankMandates.newBankMandate(reference, name,
// startDate, endDate, debtor, creditor, bankAccount);
}
// upsert
bankMandate.setBankAccount(bankAccount);
bankMandate.setName(name);
bankMandate.setStartDate(startDate);
bankMandate.setEndDate(endDate);
bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
lease.paidBy(bankMandate);
}
Aggregations