EARecordset

EARecordset is a script library I’ve created to simplify working with the XML structures Sparx EA uses to encapsulate the results from SQL queries.

EARecordset class diagram

I’m still in the process of final testing, but plan to release this sometime early 2019

newRecordset(inSQLString)inSQLString (optional): provide an SQL select statement that will be used to query your Sparx EA repository. The _Recordset Object will be populated with the returned column(s), row(s) and value(s).

Returns: a new instance of a _Recordset Object.
newExcel() Returns: a new instance of an _Excel Object
newIndex(bCaseSensitive)bCaseSensitive (optional): set before you start using the index to indicate if the index keys are case sensitive or not. E.g. is “Steve” the same as “steve”.

Returns: a new instance of an _Index Object.
newNVP(inListString, inDeliminator)inListString (optional): set the initial list of name value pairs that you want to work with.
inDeliminator (optional): set the deliminator for the name value pairs. (defaults to a semi-colon “;”)

Returns: a new instance of a _NVP Object
newXML(inXMLString)Returns: a new instance of the _XML Object
inXMLString (optional): set the initial XML
getHierarchy(inTypeID, inID, bUP,inReturnTypeIDs)inTypeID: the numeric object type ID for the object type you want to get the parent/child hierarchy for.
inID: the numeric ID or GUID for the starting object, or an Array of these.
bUP (optional): the direction to traverse the hierarchy.
inReturnTypeID: the numeric object type ID for the parent/child objects you’d like to return, or an Array of these.

Returns: a new instance of a _Recordset Object with the following columns defined:
EAID: the ID of each object in the hierarchy
EAGUID: the GUID of each object in the hierarchy.
EATypeID: the numeric Object Type ID of each object in the hierarchy.
Name: the name of each object in the hierarchy.
Stereotype: the stereotype of each object in the hierarchy.
Path_ID: a comma separated list of the hierarchy of Parent or Child ID’s leading up, or from to the starting object’s ID.
Path_GUID: same as Path_ID, but with GUIDs.
Path_Position: sort order location in the project browser
insertTaggedValue(inTypeID, inParentID, inName, inValue, inNote)inTypeID: the numeric object type ID for the parent object for the tagged value.
inParentID: the ID or GUID of the parent object for the tagged value.
inName: the name of the tagged value
inValue: the value for the tagged value (max 255 chars)
inNote (optional): the note for the tagged value
insertTaggedValues(inTypeID, inRecordset)inTypeID: the numeric object type ID for the parent object for the tagged values.
inRecordset: a recordset object containing the information for the 1 or more tagged values you want to insert, containing the following columns:
ParentID: the ID or GUID of the parent object for the tagged value.
Name: the name of the tagged value
Value: the value for the tagged value (max 255 chars)
Note (optional): the note for the tagged value

This function does a direct write to the Database containing your Sparx EA. It uses an undocumented API function Repository.Execute to write multiple inserts with a single commit… drastically improves performance. Currently limited to tagged values due to their simple nature.
updateTaggedValueByID(inTypeID, inTagID, inName, inValue, inNote)
inTypeID: the numeric object type ID for the parent object for the tagged values.
inTagID: the ID or GUID of the tagged value you want to update
inName (optional): the name of the tagged value (if you want to change the name)
inValue: the value for the tagged value (max 255 chars)
inNote (optional): the note for the tagged value
updateTaggedValueByName(inTypeID, inName, inValue, inNote) inTypeID: the numeric object type ID for the parent object for the tagged values.
inName: the name of the tagged value (if you want to change the name)
inValue: the value for the tagged value (max 255 chars)
inNote (optional): the note for the tagged value