@SuppressWarnings("unchecked") @Override public List<String> listPrimaryKeyFieldNames(Class<?> type) { List<String> keys = new ArrayList<String>(); if (type == null) { return keys; } if (isPersistable(type)) { keys = persistenceStructureService.listPrimaryKeyFieldNames(type); } else { ModuleService responsibleModuleService = kualiModuleService.getResponsibleModuleService(type); if (responsibleModuleService != null && responsibleModuleService.isExternalizable(type)) { keys = responsibleModuleService.listPrimaryKeyFieldNames(type); } else { // check the Data Dictionary for PK's of non PBO/EBO DataObjectEntry dataObjectEntry = dataDictionaryService.getDataDictionary().getDataObjectEntry(type.getName()); if (dataObjectEntry != null) { List<String> pks = dataObjectEntry.getPrimaryKeys(); if (pks != null) { keys = pks; } } else { LOG.warn( "Unable to retrieve data object entry for non-persistable KNS-managed class: " + type.getName()); } } } return keys; }
/** * @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; }
@SuppressWarnings("unchecked") protected void addCollectionSectionsToInquiryView( InquiryView view, DataObjectEntry dataObjectEntry) { for (CollectionDefinition coll : dataObjectEntry.getCollections()) { // Create a new section DataObjectEntry collectionEntry = dataDictionaryService.getDataDictionary().getDataObjectEntry(coll.getDataObjectClass()); // Extract the key fields on the collection which are linked to the parent. // When auto-generating the Inquiry Collection table, we want to exclude those. Collection<String> collectionFieldsLinkedToParent = new HashSet<String>(); if (coll.getDataObjectCollection() != null) { for (DataObjectAttributeRelationship rel : coll.getDataObjectCollection().getAttributeRelationships()) { collectionFieldsLinkedToParent.add(rel.getChildAttributeName()); } } if (collectionEntry == null) { LOG.warn( "Unable to find DataObjectEntry for collection class: " + coll.getDataObjectClass()); continue; } CollectionGroup section = createCollectionInquirySection(coll.getName(), coll.getLabel()); try { section.setCollectionObjectClass(Class.forName(coll.getDataObjectClass())); } catch (ClassNotFoundException e) { LOG.warn( "Unable to set class on collection section - class not found: " + coll.getDataObjectClass()); } section.setPropertyName(coll.getName()); // summary title : collection object label // Summary fields : PK fields? // add the attributes to the section for (AttributeDefinition attr : collectionEntry.getAttributes()) { boolean dontDisplay = hasHintOfType(attr.getDataObjectAttribute(), UifDisplayHintType.NO_INQUIRY); dontDisplay |= (attr.getControlField() instanceof HiddenControl); // Auto-exclude fields linked to the parent object dontDisplay |= collectionFieldsLinkedToParent.contains(attr.getName()); if (dontDisplay) { continue; } DataField dataField = ComponentFactory.getDataField(); dataField.setPropertyName(attr.getName()); ((List<Component>) section.getItems()).add(dataField); } ((List<Group>) view.getItems()).add(section); } }
@Override public boolean accept(Field field) { if (BusinessObject.class.isAssignableFrom(field.getType())) { return false; } DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class); AttributeSecurity attributeSecurity = dataDictionaryService.getAttributeSecurity( PayeeACHAccount.class.getName(), field.getName()); if ((ObjectUtils.isNotNull(attributeSecurity) && (attributeSecurity.isHide() || attributeSecurity.isMask() || attributeSecurity.isPartialMask()))) { return false; } return super.accept(field); }
@Override public ValidCharactersConstraint deriveValidCharactersConstraint(AttributeDefinition attrDef) { ValidCharactersConstraint validCharactersConstraint = null; // First - see if one was defined in the metadata (provided by krad-data module annotations) if (attrDef.getDataObjectAttribute() != null) { if (StringUtils.isNotBlank( attrDef.getDataObjectAttribute().getValidCharactersConstraintBeanName())) { Object consObj = dataDictionaryService.getDictionaryBean( attrDef.getDataObjectAttribute().getValidCharactersConstraintBeanName()); if (consObj != null && consObj instanceof ValidCharactersConstraint) { validCharactersConstraint = (ValidCharactersConstraint) consObj; } } } // if not, make an intelligent guess from the data type if (validCharactersConstraint == null) { if (attrDef.getDataType() != null) { if (attrDef.getDataType() == DataType.CURRENCY) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(CURRENCY_PATTERN_CONSTRAINT); } else if (attrDef.getDataType() == DataType.PRECISE_DECIMAL) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(BIG_DECIMAL_PATTERN_CONSTRAINT); } else if (attrDef.getDataType().isNumeric()) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(FLOATING_POINT_PATTERN_CONSTRAINT); } else if (attrDef.getDataType().isTemporal()) { if (attrDef.getDataType() == DataType.DATE) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(DATE_PATTERN_CONSTRAINT); } else if (attrDef.getDataType() == DataType.TIMESTAMP) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(TIMESTAMP_PATTERN_CONSTRAINT); } } } } // default to UTF8 if (validCharactersConstraint == null) { validCharactersConstraint = (ValidCharactersConstraint) dataDictionaryService.getDictionaryBean(ANY_CHARACTER_PATTERN_CONSTRAINT); } return validCharactersConstraint; }