/** * Is the cmp attribute also a field in the key class? */ protected boolean isAttributeKeyClassField(String attributeName) { // ensure key class is not null JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return false; // see if the attribute name matchs any of the reflected key class public field names List keyFields = keyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { if (field.getName().equals(attributeName)) return true; } } return false; }
protected void initializeForCompoundKey() { List keys = getKeyAttributes(); // clear key list keys.clear(); //ensure the key class is not null JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return; keyClass.eAdapters().add(this); // reflect key fields into key attributes list List keyFields = keyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { //only public fields CMPAttribute keyAttribute = cmp.getPersistentAttribute(field.getName()); if (keyAttribute != null) keys.add(keyAttribute); } } }
/** * Sort the list of the key attributes to match the order of the key class */ private void sortKeyAttributeList() { List result = new ArrayList(); JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return; List keyFields = keyClass.getFieldsExtended(); List currentKeys = getKeyAttributes(); // create a new list of the attributes in order of key class fields. for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { //only public fields for (int j=0; j<currentKeys.size(); j++) { CMPAttribute attribute = (CMPAttribute) currentKeys.get(j); if (field.getName().equals(attribute.getName())) result.add(attribute); } } } //clear list and set the new key attribute order on the cmp getKeyAttributes().clear(); getKeyAttributes().addAll(result); }
/** * For CMP 1.1 beans, the list is simply the fields, extended, * on the bean class * * @return java.util.List of {@link CMPFieldDescriptor} */ public static List getAvailableCMP11FieldDescriptors(JavaClass beanClass, CMPHelper.CMPFieldExistTester fieldTester) { if (beanClass == null) return Collections.EMPTY_LIST; List fields = beanClass.getFieldsExtended(); List result = new ArrayList(); for (int i = 0; i < fields.size(); i++) { Field aField = (Field) fields.get(i); if (!isPublic(aField) || aField.isStatic() || aField.isTransient() || (fieldTester != null && !fieldTester.isExisting(aField))) continue; String name = aField.getName(); String typeName = getTypeName(aField); if (typeName != null && name != null) result.add(createFieldDescriptor(name, typeName)); } return result; }
boolean modFlag = getCurrentModificationFlag(); try { List keyFields = primaryKeyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i);
List fields = clazz.getFieldsExtended(); Iterator iterator = fields.iterator(); Field field = null;
List primKeyFields = cmp.getPrimaryKey().getFieldsExtended();
List primKeyFields = cmp.getPrimaryKey().getFieldsExtended();