use of org.jaffa.datatypes.exceptions.MandatoryFieldException 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.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class PersistentHelper method checkMandatoryFields.
/**
* This will check all the mandatory fields of the persistent object.
* It utilises the corresponding Meta class for determining the mandatory fields.
* @param object The persistent object.
* @throws ApplicationExceptions Will contain a collection of MandatoryFieldExceptions for the all the mandatory fields which do not have values.
* @throws FrameworkException If any framework error occurs.
*/
public static void checkMandatoryFields(IPersistent object) throws ApplicationExceptions, FrameworkException {
try {
FieldMetaData[] fields = getMandatoryFields(object.getClass().getName());
if (fields != null && fields.length > 0) {
ApplicationExceptions appExps = new ApplicationExceptions();
for (int i = 0; i < fields.length; i++) {
FieldMetaData fieldMetaData = fields[i];
Object fieldValue = BeanHelper.getField(object, fieldMetaData.getName());
if (fieldValue == null || (fieldValue instanceof String && ((String) fieldValue).length() == 0)) {
if (log.isDebugEnabled())
log.debug("Mandatory validation failed for the field " + fieldMetaData.getName());
appExps.add(new MandatoryFieldException(fieldMetaData.getLabelToken()));
}
}
if (appExps.size() > 0)
throw appExps;
}
} catch (ClassNotFoundException e) {
String str = "Exception thrown while validating the domain object " + object;
log.error(str, e);
throw new DomainObjectValidationException(null, e);
} catch (NoSuchMethodException e) {
String str = "Exception thrown while validating the domain object " + object;
log.error(str, e);
throw new DomainObjectValidationException(null, e);
} catch (IllegalAccessException e) {
String str = "Exception thrown while validating the domain object " + object;
log.error(str, e);
throw new DomainObjectValidationException(null, e);
} catch (InvocationTargetException e) {
String str = "Exception thrown while validating the domain object " + object;
log.error(str, e);
throw new DomainObjectValidationException(null, e);
}
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class AttachmentViewerComponent method display.
// .//GEN-END:_AttachmentViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
* This retrieves the details for the Attachment.
* @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
* @throws FrameworkException Indicates some system error.
* @return The FormKey for the View screen.
*/
public FormKey display() throws ApplicationExceptions, FrameworkException {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_display_2_be
if (getAttachmentId() == null) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new MandatoryFieldException(AttachmentMeta.META_ATTACHMENT_ID.getLabelToken()));
}
if (appExps != null && appExps.size() > 0)
throw appExps;
doInquiry();
return getViewerFormKey();
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class MandatoryFieldValidator method validate.
/**
* The RulesEngine will invoke this method to perform the field validation.
* @throws ValidationException if any validation rule fails.
* @throws FrameworkException if any framework error occurs.
*/
public void validate() throws ValidationException, FrameworkException {
Object value = getValue();
if (value == null || (value instanceof String && ((String) value).trim().length() == 0)) {
MandatoryFieldException e = new MandatoryFieldException(getLabelToken());
log.error(null, e);
throw e;
}
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class FormGroupMaintenanceComponent method doCreate.
// .//GEN-END:_retrieveFormUsage_1_be
// .//GEN-BEGIN:_doCreate_1_be
/**
* This will invoke the create method on the transaction to create a new domain object.
* @throws ApplicationExceptions Indicates some functional error.
* @throws FrameworkException Indicates some system error.
*/
protected void doCreate() throws ApplicationExceptions, FrameworkException {
FormGroupMaintenanceCreateInDto input = new FormGroupMaintenanceCreateInDto();
if (getFormType() == null || getFormType().trim().equals("")) {
throw new ApplicationExceptions(new MandatoryFieldException(FormGroupMeta.META_FORM_TYPE.getLabelToken()));
}
// .//GEN-LAST:_doCreate_1
// .//GEN-BEGIN:_doCreate_2_be
input.setHeaderDto(getHeaderDto());
input.setFormName(getFormName());
input.setDescription(getDescription());
input.setFormType(getFormType());
FormGroupMaintenanceRetrieveOutDto output = createTx().create(input);
loadRetrieveOutDto(output);
// .//GEN-END:_doCreate_2_be
// Add custom code//GEN-FIRST:_doCreate_2
// .//GEN-LAST:_doCreate_2
// .//GEN-BEGIN:_doCreate_3_be
}
Aggregations