|
Determining If View Attribute Is From Primary Entity
A customer asked if there is a way to determine whether a view object attribute is from the primary entity for its view object, or not. The three methods in this framework extension class illustrate a method that can get the job done:
package demo.fwkext; import oracle.jbo.AttributeDef; import oracle.jbo.server.EntityDefImpl; import oracle.jbo.server.ViewAttributeDefImpl; import oracle.jbo.server.ViewObjectImpl; public class CustomViewObjectImpl extends ViewObjectImpl { private boolean isAttributeFromPrimaryEntity(AttributeDef attrDef) { EntityDefImpl[] defs = getEntityDefs(); return ((defs != null) && (defs.length > 0)) ? (((ViewAttributeDefImpl) attrDef).getEntityDef() == defs[0]) : false; } public boolean isAttributeFromPrimaryEntity(int attrSlot) { return isAttributeFromPrimaryEntity(getAttributeDef(attrSlot)); } public boolean isAttributeFromPrimaryEntity(String attrName) { return isAttributeFromPrimaryEntity(findAttributeDef(attrName)); } }
You can use this method by passing it either an attribute name as a string, or an attribute integer index "slot number". It works by comparing the view attribute definitions EntityDefImpl object with the first EntityDefImpl object in the ViewObject definition (if there is one).
|