Skip to main content

%Studio.AbstractDocument

Class %Studio.AbstractDocument Extends %AbstractStream [ Abstract, System = 3 ]

To implement a new routine type to be used by Studio you subclass from this abstract routine class and fill in the methods to perform your own Load/Save/Compile/Delete/Lock functions.

Parameters

Delimiter

Parameter Delimiter = ".";

Delimiter to use when constructing directories for this document type. This only applies if you write the List query. If you override the ItemList then you must insert this into ^IRIS.Temp structure yourself. Note do not use '/' or '\' as a delimiter as these are reserved for CSP files.

Properties

Code

Property Code As %GlobalCharacterStream;

The extension name, this can be a comma separated list of extensions if this class supports more than one. For details on the projection parameters see %Projection.StudioDocument. The body of the routine is held in this stream

Name

Property Name As %String;

The name of this routine, this includes the routine extension

TimeStamp

Property TimeStamp As %TimeStamp [ Calculated ];

Timestamp of the current document

CompileTime

Property CompileTime As %TimeStamp [ Calculated ];

Timestamp of the last compile of this document

Generated

Property Generated As %Boolean;

True if this routine is generated from something else

Locked

Property Locked As %Integer [ InitialExpression = 0 ];

Used to hold the number of times this document is locked. It happens to be used by the default lock implementation but you may ignore this in your subclass if you wish.

UpToDate

Property UpToDate As %Boolean [ Calculated ];

Return true if the document is up to date with respect to the compiled version, i.e. if you recompiled this document then the generated compiled code would be the same. Return false if the source document is modified but not compiled or the generated code has been modified manually.

Methods

UpToDateGet

Method UpToDateGet() As %Boolean

%Load

Method %Load(sid As %String) As %Status [ Private, ProcedureBlock = 1 ]

%DeleteData

ClassMethod %DeleteData(soid As %String, concurrency As %Integer) As %Status [ Private, ProcedureBlock = 1 ]

%SaveData

Method %SaveData(ByRef sid As %String) As %Status [ Private, ProcedureBlock = 1 ]

%OnNew

Method %OnNew(name As %String) As %Status [ Private ]

Set the name property

SaveStream

Method SaveStream(SupressBackup As %Boolean = 0, Output Refresh As %Boolean) As %Status

TimeStampGet

Method TimeStampGet() As %TimeStamp [ CodeMode = expression, Final ]

CompileTimeGet

Method CompileTimeGet() As %TimeStamp [ CodeMode = expression, Final ]

Load

Method Load() As %Status

Load the routine in Name into the stream Code

Save

Method Save() As %Status

Save the routine stored in Code

SaveAs

Method SaveAs(name As %String) As %Status

Save this document with a new name. You may want to modify this depending on how this implementation will work for your class.

Compile

Method Compile(flags As %String) As %Status

Compile the document, with source control hooks

CompileDocument

Method CompileDocument(ByRef qstruct As %String) As %Status

CompileDocument is called when the document is to be compiled. It has already called the source control hooks at this point.

Delete

ClassMethod Delete(name As %String) As %Status

Delete the routine 'name' which includes the routine extension

Lock

Method Lock(flags As %String) As %Status

Lock the current routine. The default method just locks the ^ROUTINE global with the name of the routine. If it fails then return a status code of the error, otherise return $$$OK

LockName

ClassMethod LockName(name As %String) As %Status

Lock a document by name. The default method just locks the ^ROUTINE global with the name of the document.

Unlock

Method Unlock(flags As %String) As %Status

Unlock the current routine. The default method just unlocks the ^ROUTINE global with the name of the routine.

UnlockName

ClassMethod UnlockName(name As %String) As %Status

Unlock a document by name. The default method just unlocks the ^ROUTINE global with the name of the document.

TimeStamp

ClassMethod TimeStamp(name As %String) As %TimeStamp

Return the timestamp of routine 'name' in %TimeStamp format. This is used to determine if the routine has been updated on the server and so needs reloading from Studio. So the format should be $zdatetime($horolog,3), or "" if the routine does not exist.

CompileTime

ClassMethod CompileTime(name As %String) As %TimeStamp

Return the compile time of routine 'name' in %TimeStamp format. The format should be $zdatetime($horolog,3), or "" if the routine does not exist.

IsUpToDate

ClassMethod IsUpToDate(name As %String) As %Boolean

Return true if the document is up to date with respect to the compiled version, i.e. if you recompiled this document then the generated compiled code would be the same. Return false if the source document is modified but not compiled or the generated code has been modified manually.

Exists

ClassMethod Exists(name As %String) As %Boolean

Return 1 if the routine 'name' exists and 0 if it does not.

ItemList

ClassMethod ItemList(Idx As %Integer, Ext As %String, ByRef Work As %String, Start As %String, End As %String, Directory As %String, Sort As %Integer, System As %Boolean, Flat As %Boolean, ShowGenerated As %Boolean, ByRef NewFormat As %Boolean) As %Status

This method ties into the open dialog in Studio. It is passed a list of information based on the search criteria from the user and it should populate the ^||%RoutineList(Idx) global with the items it wishes to show in the following format:

^||%RoutineList(Idx,dirtype,order_$char(0)_index)=$listbuild(name,dirsymbol,type,size,date/time,description)

  • Idx - The index provided in the 'Idx' parameter
  • dirtype - This is 1 if this is a regular openable item and 0 if this is a directory so that directories show up before the other items in the open dialog
  • order - The value based on the sorting order of items, e.g. size or date/time last modified, more information on this below
  • index - An integer index to prevent multiple items with for example the same size from over writing each other.
  • name - The name to display in the open dialog
  • dirsymbol - The symbol to use to navigate directories, for regular items this is "" but for directories this should be the character to append to the directory in order to browse into this directory. Do not use '/' or '\' as these are reserved for CSP files
  • type - This is an integer version of the type of the item, see the list below for details
  • size - The size of this item as an integer
  • date/time - The date/time this item was last modified in %TimeStamp format, or "" if not known

The type of the item which can be one of:

  • 0 - MAC file, a routine containing macros
  • 1 - INT file, a standard routine
  • 2 - INC file, an include file
  • 3 - BAS file, a Cache Basic routine
  • 4 - CLS, a class
  • 5 - CSP, a Cache Server Page or another file in this directory
  • 7 - GBL, a Global
  • 8 - PRJ, a Project
  • 9 - a Package
  • 10 - a CSP application Further numbers are reserved for future use. User defined items should start at 100.

order is one of:

  • 1 - Name of the file non case sensitive (the default)
  • 2 - Date/Time the file was saved
  • 3 - Size of the file
  • 4 - Type of the file i.e. the number from the 'type' list
  • 5 - Name of the file case sensitive .

The arguments to this method are:

  • Idx - Index into ^||%RoutineList to write data
  • Ext - Extension name we are processing
  • Work - Array of pattern match information that we test each item against, root node is $listbuild(mapped) so you can see if we want to return mapped items
  • Start - First possible match, can be used to optimise the query
  • End - Last possible match, can be used to optimise the query
  • Directory - The directory name we are searching
  • Sort - The entry to sort by, same as the list for 'order'
  • System - If true then include the '%' routines/classes
  • Flat - If true then flatten directories to return items inside them, this is used by the 'Namespace' tab in Studio to display all items in the system
  • ShowGenerated - If false then do not show items generated from something else, e.g. do not show TEST.INT if this is compiled from TEST.MAC
  • NewFormat - Returned by reference, if set to true use the new ^||%RoutineList format, else caller will convert output to the new format

GetOther

ClassMethod GetOther(Name As %String) As %String

Return other document types that this is related to. Passed a name and you return a comma separated list of the other documents it is related to or "" if it is not related to anything. Note that this can be passed a document of another type for example if your 'test.XXX' document creates a 'test.INT' routine then it will also be called with 'test.INT' so you can return 'test.XXX' to complete the cycle.

GetPrevious

ClassMethod GetPrevious(Name As %String) As %String

Return other document types that this is related to. Passed a name and you return a comma separated list of the other documents it is related to or "" if it is not related to anything. This goes in opposite direction to GetOther function. It can be called with documents that are not of this document type as with GetOther.

ExportToXML

Method ExportToXML(flags As %String) As %Status

Export this document to the current device in XML format

ImportFromXML

Method ImportFromXML(stream As %RegisteredObject, flags As %String) As %Status

Passed a stream containing the XML document, this method should insert this into the current document. Once this is done the importer will call Save on the document. This default handler in assumes the export ExportToXML just wrote the data in a CDATA structure

escapeCData

ClassMethod escapeCData(data As %String) As %String [ Private ]

Utility method to quote any ']]>' inside the code as these end the CDATA section

unescapeCData

ClassMethod unescapeCData(data As %String) As %String [ Private ]

Utility method to quote any ']]>' inside the code as these end the CDATA section

escapeCDataStream

ClassMethod escapeCDataStream(stream As %Stream.Object) [ Private ]

Utility method to escape any ']]>' inside a CDATA section

AtEndGet

Method AtEndGet() As %Boolean [ CodeMode = expression, Final ]

AtEndSet

Method AtEndSet(val As %Boolean) As %Status [ Final ]

Read

Method Read(ByRef len As %Integer = 32000, ByRef sc As %Status) As %String [ CodeMode = expression, Final ]

ReadLine

Method ReadLine(ByRef len As %Integer = 32000, ByRef sc As %Status, ByRef eol As %Boolean) As %String [ CodeMode = expression, Final ]

Write

Method Write(data As %String) As %Status [ CodeMode = expression, Final ]

WriteLine

Method WriteLine(data As %String) As %Status [ CodeMode = expression, Final ]

Flush

Method Flush() As %Status [ CodeMode = expression, Final ]

Rewind

Method Rewind() As %Status [ CodeMode = expression, Final ]

SizeGet

Method SizeGet() As %Integer [ CodeMode = expression, Final ]

Clear

Method Clear() As %Status [ CodeMode = expression, Final ]

Clear the contents of this Stream from permanent storage. This will remove the permanent stream storage and any temporary stream and initialise the stream to its initial state, including removing all the stream attributes.

Returns a %Status value indicating success or failure.

MoveToEnd

Method MoveToEnd() As %Status [ CodeMode = expression, Final ]

Move to the end of the stream so the next Write will be appended to the end. This allows you to read from a stream, then MoveToEnd() and append new data, where just calling Write after a read will clear the stream before writing new data.

Returns a %Status value indicating success or failure.

ListExecute

ClassMethod ListExecute(ByRef qHandle As %Binary, Directory As %String, Flat As %Boolean, System As %Boolean) As %Status

This query scans over the documents for the Studio open dialog. The arguments are defined in ItemList.

This should return a row formed by:
$listbuild(name,date/time modified,size,directory delimiter)

  • name - The name to display in the open dialog
  • date/time modified - In %TimeStamp format the date/time this item was last modified
  • size - The size of this item
  • directory delimiter - If this is not a directory then return "" here, if it is a directory then return the type of delimiter to use when they double click on this directory

ListFetch

ClassMethod ListFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = ListExecute ]

ListClose

ClassMethod ListClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = ListExecute ]
ClassMethod Search(Name As %String, Pattern As %String, WholeWords As %Boolean, CaseSensitive As %Boolean, Max As %Integer, ByRef Found As %Integer)

Override this to support searching inside your document type. By default it will open the document and search the Code.

  • Name - Name of document to search
  • Pattern - String to search for
  • WholeWords - True if we only want to find whole words, false otherwise
  • CaseSensitive - True if this is a case sensitive search
  • Max - The maximum number of items to find, if we get to this limit stop outputting results and return
  • Found - Passed by reference, contains a count of the number of matches we find. Increment by one for each match When a match is found write out the match to the current device using the format

():

checkMatch

ClassMethod checkMatch(value As %String, Pattern As %String, WholeWords As %Boolean, CaseSensitive As %Boolean) As %Boolean [ Private ]

Helper method for Search. Check if this really matches the item we are searching for.

SearchRegex

ClassMethod SearchRegex(Name As %String, Matcher As %Regex.Matcher, Max As %Integer, ByRef Found As %Integer)

Override this to support searching inside your document type with a regular expression. By default it will open the document and search the Code.

  • Name - Name of document to search
  • Matcher - A %Regex.Matcher object initialised with the search expression
  • Max - The maximum number of items to find, if we get to this limit stop outputting results and return
  • Found - Passed by reference, contains a count of the number of matches we find. Increment by one for each match When a match is found write out the match to the current device using the format

():

IsEnabled

ClassMethod IsEnabled() As %Boolean

Returns true if this document type is enabled, and false to disable it

LocalizeDescription

ClassMethod LocalizeDescription(ext As %String, ByRef Description As %String(MAXLEN=500)) As %Status

IsGenerated

ClassMethod IsGenerated(name As %String) As %Boolean

Return true if this is generated and zero otherwise. Default implementation opens instance to find the property value, it is much more efficient to override this to provide a better implementation.

IsMapped

ClassMethod IsMapped(name As %String, ByRef sourcedb As %String) As %Boolean

Return true if this is mapped from a database other than the default routine database and zero otherwise. Also set the source database in sourcedb.

TranslateExportName

ClassMethod TranslateExportName(name As %String, ByRef items As %String) As %Status

Can be used to translate the type of document to be exported to XML. For example if asked to export 'abc.tst' it can: Set items("User.abc.cls")="" Which will cause the XML export to export the class User.abc instead of this abc.tst document. Default behavior is to export the regular document.