/** * @param parameter * @return * @throws DynamicExtensionsApplicationException * @throws DynamicExtensionsSystemException */ private List<NameValueBean> getAttributesForForm(String formId) throws DynamicExtensionsSystemException, DynamicExtensionsApplicationException { ArrayList<NameValueBean> formAttributesList = new ArrayList<NameValueBean>(); if (formId != null) { Logger.out.debug("Fetching attributes for [" + formId + "]"); ContainerInterface container = DynamicExtensionsUtility.getContainerByIdentifier(formId); if (container != null) { // Collection<ControlInterface> controlCollection = container.getControlCollection(); Collection<ControlInterface> controlCollection = container.getAllControls(); if (controlCollection != null) { NameValueBean controlName = null; AbstractAttributeInterface abstractAttribute = null; AttributeInterface attribute = null; for (ControlInterface control : controlCollection) { if (control != null) { // if control contains Attribute interface object then only show on UI. // If control contains association objects do not show in attribute list abstractAttribute = control.getAbstractAttribute(); if (abstractAttribute != null && (abstractAttribute instanceof AttributeInterface)) { attribute = (AttributeInterface) abstractAttribute; if (!(attribute.getAttributeTypeInformation() instanceof FileAttributeTypeInformation)) { controlName = new NameValueBean(control.getCaption(), control.getId()); formAttributesList.add(controlName); } } } } } } } return formAttributesList; }
/** * @see * edu.common.dynamicextensions.validation.ValidatorRuleInterface#validate(edu.common.dynamicextensions.domaininterface.AttributeInterface, * java.lang.Object, java.util.Map) * @throws DynamicExtensionsValidationException */ public boolean validate( AttributeInterface attribute, Object valueObject, Map<String, String> parameterMap) throws DynamicExtensionsValidationException { boolean valid = false; String attributeName = attribute.getName(); AttributeTypeInformationInterface attributeTypeInformation = attribute.getAttributeTypeInformation(); if (((valueObject != null) && (!((String) valueObject).trim().equals(""))) && ((attributeTypeInformation != null) && (attributeTypeInformation instanceof DateAttributeTypeInformation))) { DateAttributeTypeInformation dateAttributeTypeInformation = (DateAttributeTypeInformation) attributeTypeInformation; String dateFormat = dateAttributeTypeInformation.getFormat(); String value = (String) valueObject; if (dateFormat.equals(ProcessorConstants.MONTH_YEAR_FORMAT)) { value = DynamicExtensionsUtility.formatMonthAndYearDate(value); value = value.substring(0, value.length() - 4); } if (dateFormat.equals(ProcessorConstants.YEAR_ONLY_FORMAT)) { value = DynamicExtensionsUtility.formatYearDate(value); value = value.substring(0, value.length() - 4); } try { Date date = null; date = Utility.parseDate(value, "MM-dd-yyyy"); if (date != null) { valid = true; } } catch (ParseException parseException) { List<String> placeHolders = new ArrayList<String>(); placeHolders.add(attributeName); placeHolders.add(dateFormat); throw new DynamicExtensionsValidationException( "Validation failed", null, "dynExtn.validation.Date", placeHolders); } } return valid; }