/** * @param dataObjectClass * @return DataObjectEntry for the given dataObjectClass, or null if * there is none * @throws IllegalArgumentException if the given Class is null */ protected DataObjectEntry getDataObjectEntry(Class<?> dataObjectClass) { if (dataObjectClass == null) { throw new IllegalArgumentException("invalid (null) dataObjectClass"); } DataObjectEntry entry = dataDictionaryService.getDataDictionary().getDataObjectEntry(dataObjectClass.getName()); return entry; }
/** * @param dataObjectClass * @return DataObjectEntry for the given dataObjectClass, or null if * there is none * @throws IllegalArgumentException if the given Class is null */ protected DataObjectEntry getDataObjectEntry(Class<?> dataObjectClass) { if (dataObjectClass == null) { throw new IllegalArgumentException("invalid (null) dataObjectClass"); } DataObjectEntry entry = getDataDictionaryService().getDataDictionary().getDataObjectEntry( dataObjectClass.getName()); return entry; }
/** * Convenience method for accessing <code>{@link DataDictionaryEntry}</code> for the given business object * * @param businessObjectClassName * @return DataDictionaryEntry */ private DataDictionaryEntry getDataDictionaryEntry(String businessObjectClassName) { return getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry(businessObjectClassName); }
/** * @param businessObjectClass - class of business object to return entry for * @return BusinessObjectEntry for the given dataObjectClass, or null if * there is none */ protected BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass) { validateBusinessObjectClass(businessObjectClass); BusinessObjectEntry entry = getDataDictionaryService().getDataDictionary().getBusinessObjectEntry( businessObjectClass.getName()); return entry; }
/** * Locates the <code>DictionaryService</code> to discover the type name of the document. * * @return */ protected String discoverDocumentTypeName() { return ((DataDictionaryService) KRADServiceLocatorWeb.getDataDictionaryService()).getDataDictionary().getDocumentEntry(getDocument().getClass().getName()).getDocumentTypeName(); }
/**initializes the header tabs from what is defined in the datadictionary if {@link KualiDocumentFormBase#getDefaultDocumentTypeName()} is overriden to return a valid value. */ protected void initializeHeaderNavigationTabs() { if (StringUtils.isNotBlank(getDefaultDocumentTypeName())) { final KNSDocumentEntry docEntry = (KNSDocumentEntry) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(getDocumentClass().getName()); final List<HeaderNavigation> navList = docEntry.getHeaderNavigationList(); final HeaderNavigation[] list = new HeaderNavigation[navList.size()]; super.setHeaderNavigationTabs(navList.toArray(list)); } }
@Override public void setDerivedValuesOnForm(HttpServletRequest request) { super.setDerivedValuesOnForm(request); String docTypeName = getDocTypeName(); if (StringUtils.isNotBlank(docTypeName)) { DataDictionary dataDictionary = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); Class<? extends DerivedValuesSetter> derivedValuesSetterClass = null; KNSDocumentEntry documentEntry = (KNSDocumentEntry) dataDictionary.getDocumentEntry(docTypeName); derivedValuesSetterClass = (documentEntry).getDerivedValuesSetterClass(); if (derivedValuesSetterClass != null) { DerivedValuesSetter derivedValuesSetter = null; try { derivedValuesSetter = derivedValuesSetterClass.newInstance(); } catch (Exception e) { LOG.error("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); throw new RuntimeException("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); } derivedValuesSetter.setDerivedValues(this, request); } } }
/** * Gets text to prepend to the inquiry link title * * @param dataObjectClass * - data object class being inquired into * @return String title prepend text */ @Deprecated protected String createTitleText(Class<?> dataObjectClass) { String titleText = ""; String titlePrefixProp = getKualiConfigurationService().getPropertyValueAsString(INQUIRY_TITLE_PREFIX); if (StringUtils.isNotBlank(titlePrefixProp)) { titleText += titlePrefixProp + " "; } String objectLabel = getDataDictionaryService().getDataDictionary() .getBusinessObjectEntry(dataObjectClass.getName()).getObjectLabel(); if (StringUtils.isNotBlank(objectLabel)) { titleText += objectLabel + " "; } return titleText; }
protected Inquirable getInquirable(String boClassName) { try { Class customInquirableClass = null; try { BusinessObjectEntry entry = (BusinessObjectEntry) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(boClassName); customInquirableClass = entry.getInquiryDefinition().getInquirableClass(); } catch (Exception e) { LOG.error("Unable to correlate business object class with maintenance document entry"); } Inquirable kualiInquirable = KNSServiceLocator.getKualiInquirable(); // get inquirable impl from Spring if (customInquirableClass != null) { Class[] defaultConstructor = new Class[] {}; Constructor cons = customInquirableClass.getConstructor(defaultConstructor); kualiInquirable = (Inquirable) cons.newInstance(); } kualiInquirable.setBusinessObjectClass(Class.forName(boClassName)); return kualiInquirable; } catch (Exception e) { LOG.error("Error attempting to retrieve inquirable.", e); throw new RuntimeException("Error attempting to retrieve inquirable."); } }
protected BusinessObjectEntry loadBusinessObjectEntry() { KualiForm kualiForm = KNSGlobalVariables.getKualiForm(); if (kualiForm instanceof LookupForm) { LookupForm lookupForm = (LookupForm) kualiForm; if (!StringUtils.isBlank(lookupForm.getBusinessObjectClassName())) { return KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(lookupForm.getBusinessObjectClassName()); } } return null; }
/** * Examines the BusinessObject's data dictionary entry to determine if it supports * XML export or not and set's canExport appropriately. */ protected void populateExportCapabilities(HttpServletRequest request, String boClassName) { setCanExport(false); BusinessObjectEntry businessObjectEntry = (BusinessObjectEntry) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(boClassName); Class<? extends Exporter> exporterClass = businessObjectEntry.getExporterClass(); if (exporterClass != null) { try { Exporter exporter = exporterClass.newInstance(); if (exporter.getSupportedFormats(businessObjectEntry.getBusinessObjectClass()).contains(KRADConstants.XML_FORMAT)) { setCanExport(true); } } catch (Exception e) { LOG.error("Failed to locate or create exporter class: " + exporterClass, e); throw new RuntimeException("Failed to locate or create exporter class: " + exporterClass); } } }
@Deprecated protected AnchorHtmlData getHyperLink(Class inquiryClass, Map<String, String> fieldList, String inquiryUrl, String displayText) { AnchorHtmlData a = new AnchorHtmlData(inquiryUrl, KRADConstants.EMPTY_STRING, displayText); a.setTitle(AnchorHtmlData.getTitleText(getKualiConfigurationService().getPropertyValueAsString( INQUIRY_TITLE_PREFIX) + " " + getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(inquiryClass.getName()) .getObjectLabel() + " ", inquiryClass, fieldList)); return a; }
@Override public List<String> listPrimaryKeyFieldNames(Class<?> clazz) { if (persistenceStructureService.isPersistable(clazz)) { return persistenceStructureService.listPrimaryKeyFieldNames(clazz); } ModuleService responsibleModuleService = getKualiModuleService().getResponsibleModuleService(clazz); if (responsibleModuleService != null && responsibleModuleService.isExternalizable(clazz)) { return responsibleModuleService.listPrimaryKeyFieldNames(clazz); } // check the Data Dictionary for PK's of non PBO/EBO List<String> pks = dataDictionaryService.getDataDictionary().getDataObjectEntry(clazz.getName()) .getPrimaryKeys(); if (pks != null && !pks.isEmpty()) { return pks; } return new ArrayList<String>(); }
/** * This method modifies the passed in field so that it may be used to render a multiple values lookup button * * @param field this object will be modified by this method * @param parents * @param definition */ static final public void modifyFieldToSupportMultipleValueLookups(Field field, String parents, MaintainableCollectionDefinition definition) { field.setMultipleValueLookedUpCollectionName(parents + definition.getName()); field.setMultipleValueLookupClassName(definition.getSourceClassName().getName()); field.setMultipleValueLookupClassLabel(getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(definition.getSourceClassName().getName()).getObjectLabel()); }
/** * Reads the data dictionary to determine which properties of the document should be serialized. * * @see org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator#initializeEvaluator(org.kuali.rice.krad.document.Document) */ @Override public void initializeEvaluatorForDataObject(Object businessObject){ DataDictionary dictionary = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); MaintenanceDocumentEntry maintenanceDocumentEntry = (MaintenanceDocumentEntry) dictionary.getMaintenanceDocumentEntryForBusinessObjectClass(businessObject.getClass()); serializableProperties = new PropertySerializerTrie(); populateSerializableProperties(maintenanceDocumentEntry.getMaintainableSections()); serializableProperties.addSerializablePropertyName("boNotes", true); serializableProperties.addSerializablePropertyName("boNotes.attachment", true); }
/** * Handles exporting the BusinessObject for this Inquiry to XML if it has a custom XML exporter available. */ public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { InquiryForm inquiryForm = (InquiryForm) form; if (inquiryForm.isCanExport()) { BusinessObject bo = retrieveBOFromInquirable(inquiryForm); checkBO(bo); if (bo != null) { BusinessObjectEntry businessObjectEntry = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(inquiryForm.getBusinessObjectClassName()); Class<? extends Exporter> exporterClass = businessObjectEntry.getExporterClass(); if (exporterClass != null) { Exporter exporter = exporterClass.newInstance(); response.setContentType(KRADConstants.XML_MIME_TYPE); response.setHeader("Content-disposition", "attachment; filename=export.xml"); exporter.export(businessObjectEntry.getBusinessObjectClass(), Collections.singletonList(bo), KRADConstants.XML_FORMAT, response.getOutputStream()); } } else { //show the empty section with error populateSections(mapping, request, inquiryForm, bo); return mapping.findForward(RiceConstants.MAPPING_BASIC); } } return null; }
public static boolean isDocumentSession(Document document, PojoFormBase docForm) { boolean sessionDoc = document instanceof org.kuali.rice.krad.document.SessionDocument; boolean dataDictionarySessionDoc = false; if (!sessionDoc) { DataDictionary dataDictionary = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); if (docForm instanceof KualiMaintenanceForm) { KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) docForm; if (dataDictionary != null) { if (maintenanceForm.getDocTypeName() != null) { MaintenanceDocumentEntry maintenanceDocumentEntry = (MaintenanceDocumentEntry) dataDictionary.getDocumentEntry(maintenanceForm.getDocTypeName()); dataDictionarySessionDoc = maintenanceDocumentEntry.isSessionDocument(); } } } else { if (document != null && dataDictionary != null) { KNSDocumentEntry documentEntry = (KNSDocumentEntry) dataDictionary.getDocumentEntry(document.getClass().getName()); dataDictionarySessionDoc = documentEntry.isSessionDocument(); } } } return sessionDoc || dataDictionarySessionDoc; }
/** * This method generates and returns title text for action urls. * Child classes can override this if they want to generate the title text differently. * For example, refer to BatchJobStatusLookupableHelperServiceImpl * * @param businessObject * @param displayText * @param pkNames * @return */ protected String getActionUrlTitleText(BusinessObject businessObject, String displayText, List pkNames, BusinessObjectRestrictions businessObjectRestrictions) { String prependTitleText = displayText + " " + getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(getBusinessObjectClass().getName()).getObjectLabel() + " " + this.getKualiConfigurationService().getPropertyValueAsString(TITLE_ACTION_URL_PREPENDTEXT_PROPERTY); return HtmlData.getTitleText(prependTitleText, businessObject, pkNames, businessObjectRestrictions); }
public static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName) { String displayMaskValue = null; Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName); DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService() .getDataDictionary().getDictionaryObjectEntry(className); AttributeDefinition a = entry.getAttributeDefinition(fieldName); AttributeSecurity attributeSecurity = a.getAttributeSecurity(); if (attributeSecurity != null && attributeSecurity.isMask()) { MaskFormatter maskFormatter = attributeSecurity.getMaskFormatter(); displayMaskValue = maskFormatter.maskValue(propertyValue); } return displayMaskValue; }
public static String getPartiallyMaskedValue(String className, String fieldName, Object formObject, String propertyName) { String displayMaskValue = null; Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName); DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService() .getDataDictionary().getDictionaryObjectEntry(className); AttributeDefinition a = entry.getAttributeDefinition(fieldName); AttributeSecurity attributeSecurity = a.getAttributeSecurity(); if (attributeSecurity != null && attributeSecurity.isPartialMask()) { MaskFormatter partialMaskFormatter = attributeSecurity.getPartialMaskFormatter(); displayMaskValue = partialMaskFormatter.maskValue(propertyValue); } return displayMaskValue; }