use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class PartySubscriptions method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
Party sourceParty = (Party) ev.getSource();
Party replacementParty = ev.getReplacement();
List<AgreementRole> agreementRoles;
switch(ev.getEventPhase()) {
case VALIDATE:
agreementRoles = agreementRoleRepository.findByParty(sourceParty);
if (replacementParty == null && agreementRoles.size() > 0) {
ev.invalidate("Party is being used in an agreement role: remove roles or provide a replacement");
} else {
scratchpad.put(onPartyRemoveScratchpadKey = UUID.randomUUID(), agreementRoles);
}
break;
case EXECUTING:
agreementRoles = (List<AgreementRole>) scratchpad.get(onPartyRemoveScratchpadKey);
for (AgreementRole agreementRole : agreementRoles) {
agreementRole.setParty(replacementParty);
}
break;
default:
break;
}
}
use of org.apache.isis.applib.annotation.Programmatic 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 CommunicationChannel.RemoveEvent ev) {
CommunicationChannel sourceCommunicationChannel = ev.getSource();
CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
List<AgreementRoleCommunicationChannel> communicationChannels;
switch(ev.getEventPhase()) {
case VALIDATE:
communicationChannels = agreementRoleCommunicationChannelRepository.findByCommunicationChannel(sourceCommunicationChannel);
if (communicationChannels.size() > 0 && replacementCommunicationChannel == null) {
ev.invalidate("Communication channel is being used: provide a replacement");
} else {
scratchpad.put(onCommunicationChannelRemoveScratchpadKey = UUID.randomUUID(), communicationChannels);
}
break;
case EXECUTING:
communicationChannels = (List<AgreementRoleCommunicationChannel>) scratchpad.get(onCommunicationChannelRemoveScratchpadKey);
for (AgreementRoleCommunicationChannel arcc : communicationChannels) {
arcc.setCommunicationChannel(replacementCommunicationChannel);
}
break;
default:
break;
}
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class PostalAddressDtoFactory method newDto.
@Programmatic
public PostalAddressDto newDto(final PostalAddress postalAddress) {
PostalAddressDto dto = new PostalAddressDto();
dto.setSelf(mappingHelper.oidDtoFor(postalAddress));
dto.setAddress1(postalAddress.getAddress1());
dto.setAddress2(postalAddress.getAddress2());
dto.setAddress3(postalAddress.getAddress3());
dto.setCity(postalAddress.getCity());
final State postalAddressState = postalAddress.getState();
if (postalAddressState != null) {
dto.setStateReference(postalAddressState.getReference());
dto.setStateName(postalAddressState.getName());
}
final Country postalAddressCountry = postalAddress.getCountry();
if (postalAddressCountry != null) {
dto.setCountryReference(postalAddressCountry.getReference());
dto.setCountryAlpha2Code(postalAddressCountry.getAlpha2Code());
dto.setCountryName(postalAddressCountry.getName());
}
return dto;
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class IncomingInvoice method reasonItemsIncomplete.
@Programmatic
public String reasonItemsIncomplete() {
StringBuffer buffer = new StringBuffer();
for (InvoiceItem item : getItems()) {
IncomingInvoiceItem incomingInvoiceItem = (IncomingInvoiceItem) item;
if (incomingInvoiceItem.reasonIncomplete() != null) {
buffer.append("(on item ");
buffer.append(incomingInvoiceItem.getSequence().toString());
buffer.append(") ");
buffer.append(incomingInvoiceItem.reasonIncomplete());
}
}
return buffer.length() == 0 ? null : buffer.toString();
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class IncomingInvoice method getPropertySummary.
@Programmatic
public String getPropertySummary() {
List<Property> distinctProperties = new ArrayList<>();
for (InvoiceItem item : getItems()) {
IncomingInvoiceItem iitem = (IncomingInvoiceItem) item;
if (iitem.getFixedAsset() != null && !distinctProperties.contains(iitem.getFixedAsset())) {
distinctProperties.add((Property) iitem.getFixedAsset());
}
}
StringBuffer summary = new StringBuffer();
for (Property property : distinctProperties) {
if (summary.length() > 0) {
summary.append(" | ");
}
summary.append(property.getName());
}
return summary.toString();
}
Aggregations