NutOps.mesa
useful database utilities
Implemented by: NutOpsImpl
Created by: Donahue on: January 20, 1983 3:48 pm
last edited by: Donahue, July 12, 1983 9:21 am
Last Edited by: Willie-sue, February 22, 1983 3:44 pm
Last Edited by: Cattell, July 22, 1983 2:59 pm
Last Edited by: Widom, June 15, 1984 8:45:05 am PDT
Last Edited by: Butler, June 26, 1984 4:30:56 pm PDT
DIRECTORY
DB,
ViewerClasses USING[ Viewer ],
Rope USING [ROPE];
NutOps: CEDAR DEFINITIONS =
BEGIN
OPEN DB, Rope;
**********************************************
Handy DB routines, implemented by NutOpsImpl.mesa
**********************************************
IsSystemDomain:PROC[d: Domain] RETURNS[BOOLEAN];
IsSystemRelation: PROC[r: Relation] RETURNS[BOOLEAN];
IsSystemEntity:PROC[e: Entity] RETURNS[BOOLEAN];
AttributesOf: PROC[r: Relation] RETURNS[AttributeList];
Returns list of r's attributes
FirstAttributeOf: PROC[r: Relation] RETURNS[Attribute];
returns AttributesOf[r].first
EntityValued: PROC [a: Attribute] RETURNS[BOOL];
returns TRUE iff the value stored in attribute a should be an entity
GetUniquenessString: PROC[a: Attribute] RETURNS[ROPE];
returns the uniqueness of a: Key, OptionalKey, etc., as a printable string
RSetSize: PROC[rs: RelshipSet] RETURNS[INT];
returns the length of rs, and does a ReleaseRelshipSet
GetTuples: PROC[e: Entity, a: Attribute] RETURNS [tl: LIST OF Relship];
returns all the tuples that reference e via attribute a
GetRelation: PROC[a: Attribute] RETURNS[r: Relation];
finds a's relation
GetRefAttributes: PROC[d: Domain] RETURNS[al: LIST OF Attribute];
returns all the attributes that can reference an entity from domain d
RemoveAttribute: PROC[a: Attribute, al: AttributeList] RETURNS[AttributeList];
destructively removes a from al
AppendAttributes: PROC [al1, al2: AttributeList] RETURNS [al: AttributeList];
destructively appends al1 and al2 and returns the result
***********************************************
Opening segments and transactions for them
***********************************************
SetUpSegment: PROC[segmentFile: ROPE, seg: DB.Segment, number: NAT← 0, makeReadOnly: BOOLFALSE] RETURNS [success: BOOL, readOnly: BOOL];
Do: PROC[proc: PROC[ REF ANY ], clientData: REF ANYNIL, reTry: BOOLFALSE, msgViewer: ViewerClasses.Viewer ← NIL ] RETURNS [succeeded: BOOL];
Evaluates the procedure supplied in an environment where the Aborted and Failed signals
that may be raised from DB will be caught; the procedure will be retried after a restart
if reTry is TRUE (otherwise a restart will be performed on failure without retrying the proc.
Any messages produced will be printed in the msgViewer if one is supplied.
We return succeeded=TRUE iff no errors occured in executing proc.
TryRestart: PROC[trans: DB.Transaction];
Attempts to re-open an aborted transaction if user confirms.
AtomFromSegment: PROC[ segR: ROPE ] RETURNS[ ATOM ];
IsLocalName: PROC[ segR: ROPE ] RETURNS[ BOOL ];
SafeNameOf: PROC[e: Entity] RETURNS [s: ROPE];
Returns DB.NameOf iff e is not NIL, else returns NIL
SafeSegmentOf: PROC[e: EntityOrRelship] RETURNS [s: Segment];
Returns DB.SegmentOf iff e is not NIL, else returns NIL
SafeDomainOf: PROC[e: Entity] RETURNS [s: Domain];
Returns DB.DomainOf iff e is not NIL, else returns NIL
********************************************
-- Routines moved from DBNames...
some may be deleted later...
********************************************
EntityToName: PROC[ e: Entity, seg: Segment ← NIL ] RETURNS[ name: ROPE ];
MakeName: PROC[seg: DB.Segment, d: Domain, eName: ROPE] RETURNS[ name: ROPE ];
MakeName is useful when the entity might not exist yet
NameToEntity: PROC[ name: ROPE, create: BOOLFALSE ] RETURNS[ e: Entity ];
SegmentOf: PROC[ name: ROPE ] RETURNS[ segment: Segment ];
DecomposeName: PROC[ name: ROPE ] RETURNS[ segment, domain, entity: ROPE ];
Separator: CHAR;
END.