Package org.openbravo.dal.xml
Class PrimitiveReferenceHandler
- java.lang.Object
-
- org.openbravo.dal.xml.PrimitiveReferenceHandler
-
- All Implemented Interfaces:
OBProvidable
,OBSingleton
public class PrimitiveReferenceHandler extends Object implements OBSingleton
Handles primitive reference values. These are references which are not modeled as foreign keys to a specific table but as string/table combinations stored in different fields. Sometimes the table is stored in a separate field, sometimes it needs to be computed (seeTree.PROPERTY_TYPEAREA
). This class provides utility methods to find these references and resolve them.
-
-
Constructor Summary
Constructors Constructor Description PrimitiveReferenceHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PrimitiveReferenceHandler
getInstance()
Entity
getPrimitiveReferencedEntity(BaseOBObject obObject, Property property)
In case of a primitive reference (isPrimitiveReference(Property)
) then this method returns the Entity to which the property value refers.List<Property>
getPrimitiveReferences(Entity entity)
boolean
hasObjectPrimitiveReference(BaseOBObject obObject)
Returns true if the passed object has so-called primitive references (isPrimitiveReference(Property)
).boolean
isPrimitiveReference(Property property)
Code which handles so-called primitive references, These are references which are modeled as primitive types and which do not have a foreign key constraint defined in the database.static void
setInstance(PrimitiveReferenceHandler instance)
-
-
-
Method Detail
-
getInstance
public static PrimitiveReferenceHandler getInstance()
-
setInstance
public static void setInstance(PrimitiveReferenceHandler instance)
-
getPrimitiveReferences
public List<Property> getPrimitiveReferences(Entity entity)
- Parameters:
entity
- the Entity for which to get the primitive reference properties- Returns:
- list of properties of the entity which are primitive references
isPrimitiveReference(Property)
).
-
isPrimitiveReference
public boolean isPrimitiveReference(Property property)
Code which handles so-called primitive references, These are references which are modeled as primitive types and which do not have a foreign key constraint defined in the database. The reference is defined using 2 columns: one holding the id, the other holding the table- Parameters:
property
- the property to check if it is a primitive reference- Returns:
- true if this property is a primitive reference, false otherwise
-
hasObjectPrimitiveReference
public boolean hasObjectPrimitiveReference(BaseOBObject obObject)
Returns true if the passed object has so-called primitive references (isPrimitiveReference(Property)
).- Parameters:
obObject
- the object having a primitive reference property (or not)- Returns:
- true if this entity holds a primitive reference
-
getPrimitiveReferencedEntity
public Entity getPrimitiveReferencedEntity(BaseOBObject obObject, Property property)
In case of a primitive reference (isPrimitiveReference(Property)
) then this method returns the Entity to which the property value refers. This method may only be called if the primitive reference is unequal to null.- Parameters:
obObject
- the object refering to an instance of an Entityproperty
- the primitive reference property- Returns:
- the Entity to which the property value refers, can not be null
- Throws:
OBException
- if no Entity can be found
-
-