persistent class %ExtentMgr.GUID
extends %Persistent
GUID,OID value pairs are recorded in ^OBJ.GUID. %ExtentMgr.GUID is a persistent class that
models ^OBJ.GUID. This class can be queried using SQL. It is also a fully functioning persistent
class with the GUID as the ID value. The OID property is swizzle-able. Instances of this class
can be deleted and updated. New instances can be created.
This class defines two indexes.
idxGUID is the IDKEY for the class and indexes the GUID
value.
idxOID is a unique index on OID and indexes the OID value. The GUID value is stored
in the
idxOID as data. Index methods Open and Exists can be used for various purposes. For example,
to see if an OID is defined in the GUID registry, simply call the idxOIDExists() method, passing in the requested
OID value. All index Exists() methods will return the ID corresponding to the requested key value in an option pass by reference
argument. For example:
SAMPLES>set person = ##class(Sample.Person).%OpenId(5)
SAMPLES>write "Exists: ",##class(%ExtentMgr.GUID).idxOIDExists(person.%Oid(),.id),", GUID: ",id
Exists: 1, GUID: A7413A9A-F73C-11DF-BF93-23DF9B6F8200
SAMPLES>
Remember, OIDs are meant to be opaque values and simply constructing an OID value using $ListBuild
is breaking encapsulation and it might not produce the desired results. For example:
SAMPLES>write "Exists: ",##class(%ExtentMgr.GUID).idxOIDExists($ListBuild(5,"Sample.Person"),.id),", GUID: ",id
Exists: 0, GUID:
SAMPLES>
classmethod GetGUID(pOID As %Library.Binary = "")
as %Library.Binary
[ SQLProc ]
GetGUID returns a GUID value registered to the object whose OID is pOID. If no
GUID is currently assigned to that object or if pOID is NULL then NULL is returned.
classmethod idxOIDExists(pOID As %Library.Binary = "", ByRef id As %String = "")
as %Boolean
idxOIDExists()
This method returns true if a GUID exists whose OID matches the pOID value passed
in by the caller. The optional byref id parameter will contain the id matching the object that
was found to match the index key value upon a successful return.
index (idxGUID on GUID) [IdKey];
index (idxOID on OID) [Data = GUID,Type = key,Unique];