public class OAObject extends Object implements Serializable, Comparable
OAObjects have built-in functionality to allow it to work with other Classes. This includes other OAObjects, Hub Collections, any datasource/database, JFC component, JSP component, XML, other applications (distributed) and any other Class.
Subclasses of OAObject can be created that add properties and methods for building customized software applications.
OAObject then supplies the capability for these subclasses to automatically work with any OA Enabled Class.
This is a summary of some of the features included in OAObject.
This is a listing of the types of relationships that an OAObject can have with another OAObject. This information
is built into the object information. Relationships between objects are "two-way", meaning that both
objects are related to each other.
Managing Relationships
OAObject manages the relationships between objects, and is responsible for retrieving and populating reference
objects and for managing changes. An OAObject subclass does not have to have any code to handle retrieving or
storing reference objects, OAObject does it completely. If a reference property is changed, then OAObject manages
the change so that other objects are updated correctly.
For example, if a Department has many Employees, and an Employee has one Department: if an Employee's Department
is changed, then the Employee object is removed from the original Department collection and added to the new
assigned Department collection. This also works when an Employee is added to a different Departments Employee
collection - the Employee's Department property is changed to the newly assigned Department.
Working with DataSources
OAObjects work directly with OADataSource for initializing properties, saving, deleting. This is all
done so that the OAObjects are independent from datasource/database.
For more information about this package, see documentation.
Modifier and Type | Field and Description |
---|---|
static int |
CASCADE_ALL_LINKS
Cascade rule where all reference objects are followed, even if cascade rule is false.
|
static int |
CASCADE_LINK_RULES
Cascade rule where all defined rules for references will be included.
|
static int |
CASCADE_NONE
Cascade rule where no reference objects will be included.
|
static int |
CASCADE_OWNED_LINKS
Cascade rule where all only the owned references will be included.
|
protected boolean |
changedFlag |
static int |
cntFinal |
static int |
cntNew |
protected boolean |
deletedFlag |
protected int |
guid |
protected boolean |
newFlag |
protected byte[] |
nulls |
static Logger |
OALOG |
protected OAObjectKey |
objectKey |
protected Object[] |
properties
managed by OAObjectPropertyDelegate.java
|
protected WeakReference<Hub<?>>[] |
weakhubs |
Constructor and Description |
---|
OAObject()
Creates new OAObject and calls OAObjectDelegate.initialize()
|
Modifier and Type | Method and Description |
---|---|
void |
afterDelete()
called after an object is deleted.
|
void |
afterLoad()
Called after an object has been loaded from a datasource.
|
void |
afterSave()
called after an object is saved
|
boolean |
beginServerOnly()
Makes sure that the following code is only ran on the server.
|
static Object |
callRemote(Hub hub,
Object... args) |
boolean |
canDelete() |
boolean |
canSave() |
int |
compareTo(Object obj) |
void |
copyInto(OAObject toObject) |
OAObject |
createCopy()
Copies the properties and some of the links from a source object (this) to a new object.
|
Object |
createCopy(String[] excludePropertyNames) |
void |
delete()
Remove this object from all hubs and deletes object from OADataSource.
|
void |
endServerOnly() |
boolean |
equals(Object obj)
OAObjects are equal if:
the objects are the same address.
|
protected void |
finalize()
Removes object from HubController and calls super.finalize().
|
Object |
find(String propertyPath,
Object value)
Using a propertyPath from this object, find the first matching object.
|
Object[] |
findAll(String propertyPath,
Object value)
Using a propertyPath from this object, find all of the matching objects.
|
protected void |
fireBeforePropertyChange(String property,
boolean oldObj,
boolean newObj) |
protected void |
fireBeforePropertyChange(String property,
double oldObj,
double newObj) |
protected void |
fireBeforePropertyChange(String property,
int oldObj,
int newObj) |
protected void |
fireBeforePropertyChange(String property,
long oldObj,
long newObj) |
protected void |
fireBeforePropertyChange(String propertyName,
Object oldObj,
Object newObj) |
protected void |
fireBeforePropertyChange(String propertyName,
Object oldObj,
Object newObj,
boolean bLocalOnly)
Used to manage property changes.
|
protected void |
fireLocalPropertyChange(String property) |
protected void |
fireLocalPropertyChange(String property,
int oldObj,
int newObj) |
protected void |
fireLocalPropertyChange(String property,
Object oldObj,
Object newObj) |
protected void |
firePropertyChange(String propertyName) |
protected void |
firePropertyChange(String property,
boolean oldObj,
boolean newObj) |
protected void |
firePropertyChange(String property,
double oldObj,
double newObj) |
protected void |
firePropertyChange(String property,
int oldObj,
int newObj) |
protected void |
firePropertyChange(String property,
long oldObj,
long newObj) |
protected void |
firePropertyChange(String propertyName,
Object oldObj,
Object newObj) |
protected void |
firePropertyChange(String propertyName,
Object oldObj,
Object newObj,
boolean bLocalOnly) |
boolean |
getAutoAdd() |
protected byte[] |
getBlob(String linkPropertyName)
DataSource independent method to retrieve a blob/byte[] property.
|
boolean |
getChanged()
Returns true if this object is new or any changes have been made to this object or
any objects in Links that are CASCADE=true
|
boolean |
getChanged(boolean bIncludeLinks) |
boolean |
getChanged(int relationshipType)
Returns true if this object is new or any changes have been made to this object or
any objects in Links that are TYPE=MANY and CASCADE=true that match the relationshipType parameter.
|
static boolean |
getDebugMode() |
boolean |
getDeleted()
Flag to know if object was deleted.
|
static boolean |
getFinalizeSave() |
int |
getGuid() |
protected Hub |
getHub(String linkPropertyName) |
protected Hub |
getHub(String linkPropertyName,
Hub hubMatch) |
protected Hub |
getHub(String linkPropertyName,
String sortOrder)
DataSource independent method to retrieve a reference property that is a Hub Collection.
|
protected Hub |
getHub(String linkPropertyName,
String sortOrder,
boolean bSequence) |
protected Hub |
getHub(String linkPropertyName,
String sortOrder,
boolean bSequence,
Hub hubMatch) |
protected Hub |
getHub(String linkPropertyName,
String sortOrder,
Hub hubMatch) |
boolean |
getNew()
Flag to know if object is new and has not been saved.
|
static String |
getOAVersion() |
protected Object |
getObject(String linkPropertyName)
DataSource independent method to retrieve a reference property.
|
OAObjectKey |
getObjectKey() |
Object |
getProperty(String propName)
Generic way for getting any property or value.
|
String |
getPropertyAsString(String propName)
Generic way for getting any property or value as a String value.
|
String |
getPropertyAsString(String propName,
boolean bUseDefaultFormatting) |
String |
getPropertyAsString(String propName,
String fmt)
Generic way for getting any property or value as a String value.
|
String |
getPropertyAsString(String propName,
String fmt,
String nullValue) |
static OAObject |
getUniqueInstance(Class<? extends OAObject> clazz,
String propertyName,
Object uniqueKey,
boolean bAutoCreate) |
int |
hashCode() |
Object |
hierFind(String propertyName,
String heirarchyPropertyPath) |
boolean |
isChanged() |
boolean |
isChanged(boolean bIncludeLinks) |
boolean |
isClient() |
boolean |
isDeleted() |
boolean |
isEmpty(Object obj) |
boolean |
isEnabled() |
boolean |
isEnabled(String propertyName) |
boolean |
isHubLoaded(String name) |
boolean |
isLoaded(String prop) |
boolean |
isLoading()
True if this object is in process of being loaded.
|
boolean |
isLocked()
Checks to see if object is locked.
|
boolean |
isNew() |
boolean |
isNull(String prop) |
boolean |
isPropertyLoaded(String prop) |
boolean |
isPropertyLocked(String prop) |
boolean |
isReferenceNull(String prop) |
boolean |
isReferenceObjectNull(String name) |
boolean |
isRemoteAvailable()
returns true if this is a oaclient and is not a remoteThread.
|
static boolean |
isRemoteAvailable(Hub hub) |
boolean |
isRemoteThread()
All OASync messages will be processed by an OARemoteThread.
|
boolean |
isServer()
This is used so that code will only be ran on the server.
|
boolean |
isUnique(String property,
Object value) |
boolean |
isValidPropertyChange(String propertyName,
Object oldValue,
Object newValue) |
boolean |
isVisible() |
boolean |
isVisible(String propertyName) |
void |
loadReferences(boolean bIncludeCalc) |
void |
loadReferences(boolean bOne,
boolean bMany,
boolean bIncludeCalc) |
void |
loadReferences(int maxLevelsToLoad,
int additionalOwnedLevelsToLoad,
boolean bIncludeCalc) |
void |
loadReferences(int maxLevelsToLoad,
int additionalOwnedLevelsToLoad,
boolean bIncludeCalc,
int maxRefsToLoad) |
void |
lock()
Creates a lock on this object.
|
protected Object |
readResolve() |
Object |
remote(Object... args) |
void |
removeProperty(String name)
removing property.
|
void |
save()
This is used to save object to OADataSource and flag object as
being saved and no longer new.
|
void |
save(int iCascadeRule) |
void |
saveAll()
Cascade save all links.
|
boolean |
sendMessages() |
boolean |
sendMessages(boolean b)
This is used to send out OASync messages, even if the currentThread is a OARemoteThread.
|
void |
setAutoAdd(boolean b)
Used to determine if an object should be added to a reference/master hub when one
of it's OAObject properties is set.
|
void |
setChanged(boolean tf)
Flag to know if object has been changed.
|
static void |
setDebugMode(boolean b) |
void |
setDeleted(boolean tf) |
static void |
setFinalizeSave(boolean b)
Option to have finalized objects automatically saved to datasource.
|
void |
setHub(String linkPropertyName,
Hub hub) |
void |
setNew(boolean b) |
void |
setNull(String propName) |
void |
setProperty(String propName,
boolean value) |
void |
setProperty(String propName,
double value) |
void |
setProperty(String propName,
int value)
calls setProperty()
|
void |
setProperty(String propName,
long value) |
void |
setProperty(String propName,
Object value) |
void |
setProperty(String propName,
Object value,
String fmt)
Generic way for setting any property and storing name/value pairs.
If propertyName is a valid property, then the setX method will be called, where X is the name of property. If propertyName is a valid property and obj is a String, obj will be converted to the correct obj that the method needs. |
boolean |
startServerOnly() |
void |
unlock()
Unlocks this object.
|
boolean |
verifyCommand(String methodName) |
boolean |
wasDeleted() |
public static final Logger OALOG
protected int guid
protected volatile OAObjectKey objectKey
protected volatile boolean changedFlag
protected volatile boolean newFlag
protected byte[] nulls
protected volatile boolean deletedFlag
protected transient volatile WeakReference<Hub<?>>[] weakhubs
protected transient volatile Object[] properties
public static final int CASCADE_NONE
public static final int CASCADE_LINK_RULES
public static final int CASCADE_OWNED_LINKS
public static final int CASCADE_ALL_LINKS
public static volatile int cntNew
public static volatile int cntFinal
public OAObject()
public static String getOAVersion()
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
public void setProperty(String propName, boolean value)
public void setProperty(String propName, int value)
setProperty(String, Object, String)
public void setProperty(String propName, long value)
public void setProperty(String propName, double value)
public void setNull(String propName)
public void setProperty(String propName, Object value, String fmt)
propName
- name of propertyvalue
- new valuefmt
- format to convert fromOAObjectReflectDelegate.setProperty(com.viaoa.object.OAObject, java.lang.String, java.lang.Object, java.lang.String)
public Object getProperty(String propName)
propName
- can be a property path. If a Hub property is in the path and is not the last property, then the ActiveObject will be used.public String getPropertyAsString(String propName)
public String getPropertyAsString(String propName, boolean bUseDefaultFormatting)
public String getPropertyAsString(String propName, String fmt)
propName
- fmt
- public String getPropertyAsString(String propName, String fmt, String nullValue)
public void removeProperty(String name)
name
- of property to remove. (case insensitive)public boolean isValidPropertyChange(String propertyName, Object oldValue, Object newValue)
public boolean isEnabled(String propertyName)
public boolean isEnabled()
public boolean isVisible(String propertyName)
public boolean isVisible()
public boolean verifyCommand(String methodName)
public boolean getNew()
public boolean isNew()
public void setNew(boolean b)
public boolean getDeleted()
public boolean wasDeleted()
public boolean isDeleted()
public void setDeleted(boolean tf)
public final boolean equals(Object obj)
public int compareTo(Object obj)
compareTo
in interface Comparable
public boolean getChanged()
public boolean isChanged()
public boolean getChanged(boolean bIncludeLinks)
public boolean isChanged(boolean bIncludeLinks)
public boolean getChanged(int relationshipType)
public void setChanged(boolean tf)
This is automatically set to true whenever firePropertyChange. It is set to false when save() is called.
tf
- if false then all original values of changed properties will be removed.public OAObject createCopy()
public void copyInto(OAObject toObject)
public static void setFinalizeSave(boolean b)
b
- to set valuepublic static boolean getFinalizeSave()
protected void finalize() throws Throwable
public boolean isLoading()
protected void fireBeforePropertyChange(String propertyName, Object oldObj, Object newObj, boolean bLocalOnly)
propertyName
- is not case sensitiveprotected void fireBeforePropertyChange(String propertyName, Object oldObj, Object newObj)
protected void fireBeforePropertyChange(String property, boolean oldObj, boolean newObj)
protected void fireBeforePropertyChange(String property, int oldObj, int newObj)
protected void fireBeforePropertyChange(String property, long oldObj, long newObj)
protected void fireBeforePropertyChange(String property, double oldObj, double newObj)
protected void firePropertyChange(String propertyName, Object oldObj, Object newObj, boolean bLocalOnly)
protected void firePropertyChange(String propertyName, Object oldObj, Object newObj)
protected void firePropertyChange(String propertyName)
protected void firePropertyChange(String property, boolean oldObj, boolean newObj)
protected void firePropertyChange(String property, int oldObj, int newObj)
protected void firePropertyChange(String property, long oldObj, long newObj)
protected void firePropertyChange(String property, double oldObj, double newObj)
protected void fireLocalPropertyChange(String property, Object oldObj, Object newObj)
protected void fireLocalPropertyChange(String property)
protected void fireLocalPropertyChange(String property, int oldObj, int newObj)
protected Hub getHub(String linkPropertyName, String sortOrder)
linkPropertyName
- name of property to retrieve. (case insensitive)protected Hub getHub(String linkPropertyName, String sortOrder, boolean bSequence)
bSequence
- if true, then a setAutoSequence will be called on the hubprotected Hub getHub(String linkPropertyName, String sortOrder, boolean bSequence, Hub hubMatch)
bSequence
- if true, then a setAutoSequence will be called on the hubprotected Object getObject(String linkPropertyName)
If reference object is not already loaded, then OADataSource will be used to retreive object.
public boolean isReferenceObjectNull(String name)
protected byte[] getBlob(String linkPropertyName)
If reference object is not already loaded, then OADataSource will be used to retreive object.
public void save()
It does the following:
isChanged()
public void save(int iCascadeRule)
iCascadeRule
- OR combination of CASCADE, ALL, FORCE, NOCHECKsave()
public boolean canSave()
public void saveAll()
public void afterSave()
public void delete()
public boolean canDelete()
public void afterDelete()
public void lock()
public void unlock()
public boolean isLocked()
public Object find(String propertyPath, Object value)
Example: find a SectionItem from a SectionItem
SectionItem si = (SectionItem) secItem.find("section.templateRow.template.templateRows.sections.sectionItems.item", item);
findAll(String,Object)
public Object[] findAll(String propertyPath, Object value)
Example: find a SectionItem from a SectionItem
SectionItem si = (SectionItem) secItem.find("section.templateRow.template.templateRows.sections.sectionItems.item", item);
find(String,Object)
public boolean isNull(String prop)
public boolean isServer()
public boolean isClient()
public boolean isRemoteThread()
public boolean sendMessages(boolean b)
public boolean sendMessages()
public void afterLoad()
public OAObjectKey getObjectKey()
public int getGuid()
public void setAutoAdd(boolean b)
b
- (default is true)public boolean getAutoAdd()
public boolean isEmpty(Object obj)
public boolean isHubLoaded(String name)
public void loadReferences(boolean bIncludeCalc)
public void loadReferences(boolean bOne, boolean bMany, boolean bIncludeCalc)
public void loadReferences(int maxLevelsToLoad, int additionalOwnedLevelsToLoad, boolean bIncludeCalc)
public void loadReferences(int maxLevelsToLoad, int additionalOwnedLevelsToLoad, boolean bIncludeCalc, int maxRefsToLoad)
public static OAObject getUniqueInstance(Class<? extends OAObject> clazz, String propertyName, Object uniqueKey, boolean bAutoCreate)
public boolean isRemoteAvailable()
public static boolean isRemoteAvailable(Hub hub)
public boolean isLoaded(String prop)
public boolean isPropertyLoaded(String prop)
public boolean isReferenceNull(String prop)
public boolean beginServerOnly()
endServerOnly()
public boolean startServerOnly()
public void endServerOnly()
public static void setDebugMode(boolean b)
public static boolean getDebugMode()
public boolean isPropertyLocked(String prop)
Copyright © 1999–2019 ViaOA. All rights reserved.