use of org.jaffa.soa.domain.SOAEvent in project jaffa-framework by jaffa-projects.
the class SOAEventParam method validate.
// .//GEN-END:performPreDeleteReferentialIntegrity_1_be
// .//GEN-BEGIN:3_be
/**
* @clientCardinality 0..*
* @supplierCardinality 1
* @clientQualifier eventId
* @supplierQualifier eventId
* @link association
*/
/*#SOAEvent lnkSOAEvent;*/
// .//GEN-END:3_be
// All the custom code goes here//GEN-FIRST:custom
/**
* {@inheritDoc}
*/
@Override
public void validate() throws ApplicationExceptions, FrameworkException {
// Ensure that the eventId is specified
if (getEventId() == null)
throw new ApplicationExceptions(new MandatoryFieldException(SOAEventParamMeta.META_EVENT_ID.getLabelToken()));
// Log a WARNing message if the paramter is not documented in soa-events.xml
if (getName() != null && isModified(SOAEventParamMeta.NAME)) {
try {
SOAEvent soaEvent = getSOAEventObject();
SoaEventInfo soaEventInfo = ConfigurationService.getInstance().getSoaEventInfo(soaEvent.getEventName());
if (soaEventInfo != null) {
boolean foundParam = false;
for (Param param : soaEventInfo.getParam()) {
if (getName().equals(param.getName())) {
foundParam = true;
break;
}
}
if (!foundParam)
log.warn("SOA Event Parameter'" + soaEvent.getEventName() + ": " + getName() + "' should be documented in soa-events.xml");
}
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
super.validate();
}
use of org.jaffa.soa.domain.SOAEvent in project jaffa-framework by jaffa-projects.
the class SOAEventParam method findSOAEventObject.
/**
* Finds the related foreign SOAEvent object.
* If checkExistenceOnly is false, then the foreign object will be fetched and assigned to the corresponding member variable of this class.
* If checkExistenceOnly is true, then a mere existence check is performed for the foreign object, as oppposed to fetching all the values for that object.
*/
private void findSOAEventObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_sOAEventObject == null && getEventId() != null) {
Criteria criteria = new Criteria();
criteria.setTable(SOAEventMeta.getName());
criteria.addCriteria(SOAEventMeta.EVENT_ID, getEventId());
if (checkExistenceOnly)
criteria.addFunction(Criteria.FUNCTION_COUNT, null, Criteria.ID_FUNCTION_COUNT);
Number count = null;
if (uow == null || !uow.isActive()) {
uow = new UOW();
localUow = true;
}
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext()) {
if (checkExistenceOnly)
count = (Number) ((Map) itr.next()).get(Criteria.ID_FUNCTION_COUNT);
else
m_sOAEventObject = (SOAEvent) itr.next();
}
if (m_sOAEventObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(SOAEventParamMeta.META_EVENT_ID.getLabelToken(), new Object[] { SOAEventMeta.getLabelToken(), SOAEventMeta.META_EVENT_ID.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
Aggregations