Index

dkEntityDef

Purpose:

A dkEntityDef defines an interface to access and manipulate entities defined in the datastore. An entity corresponds to a table in Relational Databases, an index-class in DL, and so forth. A dkEntityDef may contains a set of dkAttrDef, defining attributes in this entity.

The interface has methods to access entity information as well as to:

dkEntityDef should be subclassed to provide a specific implementation for the target datastore. For example:

All methods related to sub-entity operations should throw a DKUsageError exception since most datastores do not support sub-entities by default. If the datastore supports multiple-level entities, for example, QBIC or Domino.Doc, the concrete class should provide the correct implementation for the specific datastore to override the exception.

Class summary:

class dkEntityDef
 {
   public:
      virtual ~dkEntityDef();
      dkDatastore* getDatastore();
      void setDatastore(dkDatastore* ds);
      DKString  datastoreName() const;
      DKString  datastoreType() const;
      DKString  getName();
      void setName(const char* name);
      short getType();
      void setType(short entityType);
      DKString  getDescription();
      void setDescription(const char* desc);
      virtual DKBoolean isSearchable();
      virtual DKBoolean hasSubEntities();
      virtual dkEntityDef* createSubEntity();
      virtual dkEntityDef* getSubEntity(const char* subEntityName);
 
      virtual dkEntityDef* retrieveSubEntity(const char* subEntityName);
 
      virtual dkCollection* listSubEntities();
      virtual DKString* listSubEntityNames(long& arraySize);
      // persistent functions 
      virtual void add(dkEntityDef* subEntityDef);
      virtual void del(dkEntityDef* subEntityDef);
 
      virtual void deleteSubEntity(const char* subEntityName);
      // memory functions
      virtual void addSubEntity(dkEntityDef* subEntityDef);
      virtual void removeSubEntity(const char* subEntityName);
 
      virtual dkAttrDef* createAttr();
      virtual dkAttrDef* getAttr(const char* attrName);
 
      virtual dkAttrDef* retrieveAttr(const char* attrName);
 
      virtual dkCollection* listAttrs();
      virtual DKString* listAttrNames(long& arraySize);
      virtual void add();
      virtual void del();
      // persistent functions 
      virtual void add(dkAttrDef* attrDef);
      virtual void del(dkAttrDef* attrDef);
 
      virtual void deleteAttr(const char* attrName);
      // memory functions 
      virtual void addAttr(dkAttrDef* attrDef);
      virtual void removeAttr(const char* attrName);
      virtual DKString getParentEntityName();
      virtual void setParentEntityName(const char* parentEntityName);
      virtual DKBoolean isTextSearchable();
      virtual void setTextSearchable(DKBoolean textSearchable);
      virtual void clearCache();
 
 };

Members:

Member functions

setDatastore
Sets the reference to the owner datastore object.
void setDatastore(dkDatastore* ds);

datastoreName
Gets the name of the owner datastore object.
DKString  datastoreName() const;

getDatastore
Gets the reference to the owner datastore object. Returns a dkDatastore object.
 dkDatastore* getDatastore();

datastoreType
Gets the type of the owner datastore object.
DKString  datastoreType() const;

getName
Returns the name of this entity.
DKString  getName();

setName
Sets the entity name.
void setName(const char* name);

getType
Gets the entity type.
short getType();

setType
Sets the entity type.
void setType(short entityType);

getDescription
Gets the entity description.
DKString  getDescription();

setDescription
Sets the description of this entity.
void setDescription(const char* desc);

isSearchable
Returns TRUE if this entity is searchable.
virtual DKBoolean isSearchable();

hasSubEntities
Returns TRUE if this entity has sub-entity objects.
virtual DKBoolean hasSubEntities();

createSubEntity
Creates a new sub-entity object (dkEntityDef) and returns it to caller.

Exceptions
DKException -- If the datastore does not support multiple-level entities.

virtual dkEntityDef* createSubEntity();

Note:
DKUsageError exception thrown if method is not implemented.

getSubEntity
Gets the sub entity object with the given name. This method is provided to support multiple-level document model.

Exceptions

DKException
If the datastore does not support multiple-level entities.
 virtual dkEntityDef* getSubEntity(const char* subEntityName);

Note:
DKUsageError exception thrown if method is not implemented.

retrieveSubEntity
Retrieve the sub entity object with the given name. This method is provided to support multiple-level document model.

Exceptions

DKException
If the datastore does not support multiple-level entities.

virtual dkEntityDef* retrieveSubEntity(const char* subEntityName);

Note:
DKUsageError exception thrown if method is not implemented.

listSubEntities
Gets the list of sub-entities in this object.

Exceptions

DKException
If the datastore does not support multiple-level entities.
virtual dkCollection* listSubEntities();

Note:
DKUsageError exception thrown if method is not implemented.

listSubEntityNames
Gets the list of sub-entity names in this object.

Exceptions

DKException
If the datastore does not support multiple-level entities.
 virtual DKString* listSubEntityNames(long& arraySize);

Note:
DKUsageError exception thrown if method is not implemented.

add
The first form adds the given sub-entity definition to this entity in the persistent datastore. The second form adds this entity definition to the persistent datastore, that is, make this entity definition persistent. The third form adds the given attribute definition to this entity in the persistent datastore, that is, make this attribute definition persistent.

Exceptions

DKException
If one of the following occurs:
  • The datastore does not support multiple-level entities (that is: the entity object does not have sub-entities.)
  • An error occurs in the server.
  • The subclass does not implement this feature.
virtual void add(dkEntityDef* subEntityDef);
virtual void add();
virtual void add(dkAttrDef* attrDef);

Note:
DKUsageError exception thrown if method is not implemented.

del
The first form deletes the given sub-entity definition from this entity in the persistent datastore. The second form deletes this entity definition from the persistent datastore, such as a drop table for RDB. The in-memory copy is not affected, until the datastore definition is refreshed. The third form deletes the given attribute definition from this entity in the persistent datastore. The in-memory copy is not affected, until this entity is refreshed.

Exceptions

DKException
If one of the following occurs:
  • The datastore does not support multiple-level entities (that is: the entity object does not have sub-entities.)
  • An error occurs in the server.
  • The subclass does not implement this feature.
virtual void del(dkEntityDef* subEntityDef);
virtual void del();
virtual void del(dkAttrDef* attrDef);

Note:
DKUsageError exception thrown if method is not implemented.

deleteSubEntity
Delete the sub entity definition object from this entity in the persistent store.
virtual void deleteSubEntity(const char* subEntityName);

Note:
DKUsageError exception thrown if method is not implemented.

addSubEntity
Add the sub entity definition object to this entity in memory.
virtual void addSubEntity(dkEntityDef* subEntityDef);

Note:
DKUsageError exception thrown if method is not implemented.

removeSubEntity
Remove the sub entity definition object from this entity in memory.

virtual void removeSubEntity(const char* subEntityName);

Note:
DKUsageError exception thrown if method is not implemented.

createAttr
Creates a new dkAttrDef object and returns it.
virtual dkAttrDef* createAttr();

Note:
DKUsageError exception thrown if method is not implemented.

getAttr
Gets the attribute object with a given name.

Exceptions

DKException
If The datastore does not support multiple-level entities (that is: the entity object does not have sub-entities.)


--

virtual dkAttrDef* getAttr(const char* attrName);

Note:
DKUsageError exception thrown if method is not implemented.

retrieveAttr
Retrieve the attribute object with a given name.

Exceptions

DKException
If The datastore does not support multiple-level entities (that is: the entity object does not have sub-entities.)


--

virtual dkAttrDef* retrieveAttr(const char* attrName);

Note:
DKUsageError exception thrown if method is not implemented.

deleteAttr
Deletes the given attribute from this entity in the persistent store.
virtual void deleteAttr(const char* attrName);

Note:
DKUsageError exception thrown if method is not implemented.

addAttr
Adds the given attribute to this entity in memory.
virtual void addAttr(dkAttrDef* attrDef);

Note:
DKUsageError exception thrown if method is not implemented.

removeAttr
Remove the given attribute from this entity in memory.
virtual void removeAttr(const char* attrName);

Note:
DKUsageError exception thrown if method is not implemented.

listAttrs
Gets the list of attributes defined in this entity.
 virtual dkCollection* listAttrs();

listAttrNames
Gets the list of attribute names defined in this entity.
virtual DKString* listAttrNames(long& arraySize);

getParentEntityName
Gets the parent entity name.
virtual DKString getParentEntityName();

setParentEntityName
Sets the parent entity name.
virtual void setParentEntityName(const char* parentEntityName);

isTextSearchable
Returns TRUE if this entity is text searchable.
virtual DKBoolean isTextSearchable();

setTextSearchable
Sets the text searchability of this entity to either TRUE or FALSE.

vvirtual void setTextSearchable(DKBoolean textSearchable);

clearCache
Clears the cache.
virtual void clearCache();

Note:
DKUsageError exception thrown if method is not implemented.

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.