在Domino的数据库中有数据文档和设计文档两种文档。设计文档包括单,视图,代理等,这些组成了
一个数据库设计。标准的Notes类库能够很容易的访问数据文档,但是却没有提供任何方法来访问设计
文档。下面的这个DatabaseDesign类可以让我们使用LotusScript来访问设计文档,返回的是NotesDocument
对象。
要使用这个类,我们把DBDesign这个script库拷贝到数据库中。
下面是这个类的代码:
DatabaseDesign类代码
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->%REM
****************************************************************************************************************
This library was originally created by Damien Katz of Iris Associates, Aug. 1999
This library may be freely distributed, modified and used only if this header is kept intact,
unchanged and is distributed with the contents of the library.
Please share any fixes or enhancements and send them to Damien_katz@iris.com so I can add
it the library.
If you find this library useful, send me a mail message and let me know what you're using it for.
Thanks.
****************************************************************************************************************
NOTE:
To instantiate a new DatabaseDesign object, do not attempt to instantiate it directly,
instead call the createDatabaseDesign method, it will return a new instantiated object.
%END REM
'Set this flag to true to always use the platform independent method
Const FLAG_NEVER_USE_NATIVE_API_CALLS =False
Const DESIGN_NOTE_NAME_ITEM = "$TITLE"
Const NOTE_CLASS_DOCUMENT = &H0001 ' document note
Const NOTE_CLASS_DATA = NOTE_CLASS_DOCUMENT ' old name for document note
Const NOTE_CLASS_INFO = &H0002 ' notefile info (help-about) note
Const NOTE_CLASS_FORM = &H0004 ' form note
Const NOTE_CLASS_VIEW = &H0008 ' view note
Const NOTE_CLASS_ICON = &H0010 ' icon note
Const NOTE_CLASS_DESIGN = &H0020 ' design note collection
Const NOTE_CLASS_ACL = &H0040 ' acl note
Const NOTE_CLASS_HELP_INDEX = &H0080 ' Notes product help index note
Const NOTE_CLASS_HELP = &H0100 ' designer's help note
Const NOTE_CLASS_FILTER = &H0200 ' filter note
Const NOTE_CLASS_FIELD = &H0400 ' field note
Const NOTE_CLASS_REPLFORMULA = &H0800 ' replication formula
Const NOTE_CLASS_PRIVATE = &H1000
Const NOTE_CLASS_ALLNONDATA = &H7FFE
Const DESIGN_FLAG_ADD = "A"
Const DESIGN_FLAG_ANTIFOLDER = "a" ' VIEW: Indicates that a view is an antifolder view
Const DESIGN_FLAG_BACKGROUND_FILTER = "B" ' FILTER: Indicates FILTER_TYPE_BACKGROUND is asserted
Const DESIGN_FLAG_INITBYDESIGNONLY="b" ' VIEW: Indicates view can be initially built only by designer and above
Const DESIGN_FLAG_NO_COMPOSE = "C" ' FORM: Indicates a form that is used only for
' query by form (not on compose menu).
Const DESIGN_FLAG_CALENDAR_VIEW = "c" ' VIEW: Indicates a form is a calendar style view.
Const DESIGN_FLAG_NO_QUERY = "D" ' FORM: Indicates a form that should not be used in query by form
Const DESIGN_FLAG_DEFAULT_DESIGN = "d" ' ALL: Indicates the default design note for it"s class (used for VIEW)
Const DESIGN_FLAG_MAIL_FILTER = "E" ' FILTER: Indicates FILTER_TYPE_MAIL is asserted
Const DESIGN_FLAG_PUBLICANTIFOLDER = "e" ' VIEW: Indicates that a view is a public antifolder view
Const DESIGN_FLAG_FOLDER_VIEW = "F" ' VIEW: This is a V4 folder view.
Const DESIGN_FLAG_V4AGENT = "f" ' FILTER: This is a V4 agent
Const DESIGN_FLAG_VIEWMAP = "G" ' VIEW: This is ViewMap/GraphicView/Navigator
Const DESIGN_FLAG_OTHER_DLG = "H" ' ALL: Indicates a form that is placed in Other dialog
Const DESIGN_FLAG_V4PASTE_AGENT = "I" ' FILTER: This is a V4 paste agent
Const DESIGN_FLAG_IMAGE_RESOURCE = "i" ' FORM: Note is a shared image resource
Const DESIGN_FLAG_JAVA_AGENT = "J" ' FILTER: If its Java
Const DESIGN_FLAG_JAVA_AGENT_WITH_SOURCE = "j" ' FILTER: If it is a java agent with java source code.
Const DESIGN_FLAG_LOTUSSCRIPT_AGENT = "L" ' FILTER: If its LOTUSSCRIPT
Const DESIGN_FLAG_DELETED_DOCS = "l" ' VIEW: Indicates that a view is a deleted documents view
Const DESIGN_FLAG_QUERY_MACRO_FILTER = "M" ' FILTER: Stored FT query AND macro
Const DESIGN_FLAG_SITEMAP = "m" ' FILTER: This is a site(m)ap.
Const DESIGN_FLAG_NEW = "N" ' FORM: Indicates that a subform is listed when making a new form.
Const DESIGN_FLAG_HIDE_FROM_NOTES = "n" ' ALL: notes stamped with this flag
'will be hidden from Notes clients
'We need a separate value here
'because it Is possible To be
'hidden from V4 AND to be hidden
'from Notes, and clearing one
'should not clear the other
Const DESIGN_FLAG_QUERY_V4_OBJECT = "O" ' FILTER: Indicates V4 search bar query object - used in addition to "Q"
Const DESIGN_FLAG_PRIVATE_STOREDESK = "o" ' VIEW: If Private_1stUse, store the private view in desktop
Const DESIGN_FLAG_PRESERVE = "P" ' ALL: related to data dictionary
Const DESIGN_FLAG_PRIVATE_1STUSE = "p" ' VIEW: This is a private copy of a private on first use view.
Const DESIGN_FLAG_QUERY_FILTER = "Q" ' FILTER: Indicates full text query ONLY, no filter macro
Const DESIGN_FLAG_AGENT_SHOWINSEARCH = "q" ' FILTER: Search part of this agent should be shown in search bar
Const DESIGN_FLAG_REPLACE_SPECIAL = "R" ' SPECIAL: this flag is the opposite of DESIGN_FLAG_PRESERVE, used
'only for the "About" and "Using" notes + the icon bitmap in the icon note
Const DESIGN_FLAG_PROPAGATE_NOCHANGE = "r" ' DESIGN: this flag is used to propagate the prohibition of design change
Const DESIGN_FLAG_V4BACKGROUND_MACRO = "S" ' FILTER: This is a V4 background agent
Const DESIGN_FLAG_SCRIPTLIB = "s" ' FILTER: A database global script library note
Const DESIGN_FLAG_VIEW_CATEGORIZED = "T" ' VIEW: Indicates a view that is categorized on the categories field
Const DESIGN_FLAG_DATABASESCRIPT = "t" ' FILTER: A database script note
Const DESIGN_FLAG_SUBFORM = "U" ' FORM: Indicates that a form is a subform.
Const DESIGN_FLAG_AGENT_RUNASWEBUSER = "u" ' FILTER: Indicates agent should run as effective user on web
Const DESIGN_FLAG_PRIVATE_IN_DB = "V" ' ALL: This is a private element stored in the database
Const DESIGN_FLAG_WEBPAGE = "W" ' FORM: Note is a WEBPAGE
Const DESIGN_FLAG_HIDE_FROM_WEB = "w" ' ALL: notes stamped with this flag
'will be hidden from WEB clients
' WARNING: A formula that build Design Collecion relies on the fact that Agent Data"s
'$Flags is the only Desing Collection element whose $Flags="X"
Const DESIGN_FLAG_V4AGENT_DATA = "X" ' FILTER: This is a V4 agent data note
Const DESIGN_FLAG_SUBFORM_NORENDER = "x" ' SUBFORM: indicates whether
'we should render a subform in
'the parent form
Const DESIGN_FLAG_NO_MENU = "Y" ' ALL: Indicates that folder/view/etc. should be hidden from menu.
Const DESIGN_FLAG_SACTIONS = "y" ' Shared actions note
Const DESIGN_FLAG_MULTILINGUAL_PRESERVE_HIDDEN = "Z" ' ALL: Used to indicate design element was hidden
' before the "Notes Global Designer" modified it.
' (used with the "!" flag)
Const DESIGN_FLAG_FRAMESET = "#" ' FORM: Indicates that this is a frameset note
Const DESIGN_FLAG_MULTILINGUAL_ELEMENT = "!"' ALL: Indicates this design element supports the
' "Notes Global Designer" multilingual addin
Const DESIGN_FLAG_JAVA_RESOURCE = "@" ' FORM: Note is a shared Java resource
Const DESIGN_FLAG_HIDE_FROM_V3 = "3" ' ALL: notes stamped with this flag
' will be hidden from V3 client
Const DESIGN_FLAG_HIDE_FROM_V4 = "4" ' ALL: notes stamped with this flag
' will be hidden from V4 client
Const DESIGN_FLAG_HIDE_FROM_V5 = "5" ' FILTER: "Q5"= hide from V4.5 search list
' ALL OTHER: notes stamped with this flag
' will be hidden from V5 client
Const DESIGN_FLAG_HIDE_FROM_V6 = "6" ' ALL: notes stamped with this flag
'will be hidden from V6 client
Const DESIGN_FLAG_HIDE_FROM_V7 = "7" ' ALL: notes stamped with this flag
'will be hidden from V7 client
Const DESIGN_FLAG_HIDE_FROM_V8 = "8" ' ALL: notes stamped with this flag
'will be hidden from V8 client
Const DESIGN_FLAG_HIDE_FROM_V9 = "9" ' ALL: notes stamped with this flag
'will be hidden from V9 client
Const DESIGN_FLAG_MUTILINGUAL_HIDE = "0" ' ALL: notes stamped with this flag
'will be hidden from the client
'usage is for different language
'versions of the design list to be
'hidden completely
' These are the flags that help determine the type of a design element.
' These flags are used to sub-class the note classes, and cannot be
' changed once they are created (for example, there is no way to change
' a form into a subform).
Const DESIGN_FLAGS_SUBCLASS = "UW#yi@GFXstm"
' These are the flags that can be used to distinguish between two
' design elements that have the same class, subclass (see DESIGN_FLAGS_SUBCLASS),
' and name.
Const DESIGN_FLAGS_DISTINGUISH = "nw3456789"
Const ERR_BASE_CLASS_INSTANTIATED = 10452
Const ERR_BASE_CLASS_INSTANTIATED_MESSAGE = "You cannot instantiate this class directly"
Public Class DatabaseDesignClass DatabaseDesign
'PUBLIC MEMBERS
Public cacheDocuments As Integer
'PRIVATE MEMBERS
Private db As NotesDatabase
Private forms As Variant
Private views As Variant
Private filters As Variant
Private fields As Variant
Sub new()Sub new( database As NotesDatabase)
If isAbstractClass Then
'this prevents the base class from being instantiated directly
Error ERR_BASE_CLASS_INSTANTIATED, ERR_BASE_CLASS_INSTANTIATED_MESSAGE
End If
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->%REM
****************************************************************************************************************
This library was originally created by Damien Katz of Iris Associates, Aug. 1999
This library may be freely distributed, modified and used only if this header is kept intact,
unchanged and is distributed with the contents of the library.
Please share any fixes or enhancements and send them to Damien_katz@iris.com so I can add
it the library.
If you find this library useful, send me a mail message and let me know what you're using it for.
Thanks.
****************************************************************************************************************
NOTE:
To instantiate a new DatabaseDesign object, do not attempt to instantiate it directly,
instead call the createDatabaseDesign method, it will return a new instantiated object.
%END REM
'Set this flag to true to always use the platform independent method
Const FLAG_NEVER_USE_NATIVE_API_CALLS =False
Const DESIGN_NOTE_NAME_ITEM = "$TITLE"
Const NOTE_CLASS_DOCUMENT = &H0001 ' document note
Const NOTE_CLASS_DATA = NOTE_CLASS_DOCUMENT ' old name for document note
Const NOTE_CLASS_INFO = &H0002 ' notefile info (help-about) note
Const NOTE_CLASS_FORM = &H0004 ' form note
Const NOTE_CLASS_VIEW = &H0008 ' view note
Const NOTE_CLASS_ICON = &H0010 ' icon note
Const NOTE_CLASS_DESIGN = &H0020 ' design note collection
Const NOTE_CLASS_ACL = &H0040 ' acl note
Const NOTE_CLASS_HELP_INDEX = &H0080 ' Notes product help index note
Const NOTE_CLASS_HELP = &H0100 ' designer's help note
Const NOTE_CLASS_FILTER = &H0200 ' filter note
Const NOTE_CLASS_FIELD = &H0400 ' field note
Const NOTE_CLASS_REPLFORMULA = &H0800 ' replication formula
Const NOTE_CLASS_PRIVATE = &H1000
Const NOTE_CLASS_ALLNONDATA = &H7FFE
Const DESIGN_FLAG_ADD = "A"
Const DESIGN_FLAG_ANTIFOLDER = "a" ' VIEW: Indicates that a view is an antifolder view
Const DESIGN_FLAG_BACKGROUND_FILTER = "B" ' FILTER: Indicates FILTER_TYPE_BACKGROUND is asserted
Const DESIGN_FLAG_INITBYDESIGNONLY="b" ' VIEW: Indicates view can be initially built only by designer and above
Const DESIGN_FLAG_NO_COMPOSE = "C" ' FORM: Indicates a form that is used only for
' query by form (not on compose menu).
Const DESIGN_FLAG_CALENDAR_VIEW = "c" ' VIEW: Indicates a form is a calendar style view.
Const DESIGN_FLAG_NO_QUERY = "D" ' FORM: Indicates a form that should not be used in query by form
Const DESIGN_FLAG_DEFAULT_DESIGN = "d" ' ALL: Indicates the default design note for it"s class (used for VIEW)
Const DESIGN_FLAG_MAIL_FILTER = "E" ' FILTER: Indicates FILTER_TYPE_MAIL is asserted
Const DESIGN_FLAG_PUBLICANTIFOLDER = "e" ' VIEW: Indicates that a view is a public antifolder view
Const DESIGN_FLAG_FOLDER_VIEW = "F" ' VIEW: This is a V4 folder view.
Const DESIGN_FLAG_V4AGENT = "f" ' FILTER: This is a V4 agent
Const DESIGN_FLAG_VIEWMAP = "G" ' VIEW: This is ViewMap/GraphicView/Navigator
Const DESIGN_FLAG_OTHER_DLG = "H" ' ALL: Indicates a form that is placed in Other dialog
Const DESIGN_FLAG_V4PASTE_AGENT = "I" ' FILTER: This is a V4 paste agent
Const DESIGN_FLAG_IMAGE_RESOURCE = "i" ' FORM: Note is a shared image resource
Const DESIGN_FLAG_JAVA_AGENT = "J" ' FILTER: If its Java
Const DESIGN_FLAG_JAVA_AGENT_WITH_SOURCE = "j" ' FILTER: If it is a java agent with java source code.
Const DESIGN_FLAG_LOTUSSCRIPT_AGENT = "L" ' FILTER: If its LOTUSSCRIPT
Const DESIGN_FLAG_DELETED_DOCS = "l" ' VIEW: Indicates that a view is a deleted documents view
Const DESIGN_FLAG_QUERY_MACRO_FILTER = "M" ' FILTER: Stored FT query AND macro
Const DESIGN_FLAG_SITEMAP = "m" ' FILTER: This is a site(m)ap.
Const DESIGN_FLAG_NEW = "N" ' FORM: Indicates that a subform is listed when making a new form.
Const DESIGN_FLAG_HIDE_FROM_NOTES = "n" ' ALL: notes stamped with this flag
'will be hidden from Notes clients
'We need a separate value here
'because it Is possible To be
'hidden from V4 AND to be hidden
'from Notes, and clearing one
'should not clear the other
Const DESIGN_FLAG_QUERY_V4_OBJECT = "O" ' FILTER: Indicates V4 search bar query object - used in addition to "Q"
Const DESIGN_FLAG_PRIVATE_STOREDESK = "o" ' VIEW: If Private_1stUse, store the private view in desktop
Const DESIGN_FLAG_PRESERVE = "P" ' ALL: related to data dictionary
Const DESIGN_FLAG_PRIVATE_1STUSE = "p" ' VIEW: This is a private copy of a private on first use view.
Const DESIGN_FLAG_QUERY_FILTER = "Q" ' FILTER: Indicates full text query ONLY, no filter macro
Const DESIGN_FLAG_AGENT_SHOWINSEARCH = "q" ' FILTER: Search part of this agent should be shown in search bar
Const DESIGN_FLAG_REPLACE_SPECIAL = "R" ' SPECIAL: this flag is the opposite of DESIGN_FLAG_PRESERVE, used
'only for the "About" and "Using" notes + the icon bitmap in the icon note
Const DESIGN_FLAG_PROPAGATE_NOCHANGE = "r" ' DESIGN: this flag is used to propagate the prohibition of design change
Const DESIGN_FLAG_V4BACKGROUND_MACRO = "S" ' FILTER: This is a V4 background agent
Const DESIGN_FLAG_SCRIPTLIB = "s" ' FILTER: A database global script library note
Const DESIGN_FLAG_VIEW_CATEGORIZED = "T" ' VIEW: Indicates a view that is categorized on the categories field
Const DESIGN_FLAG_DATABASESCRIPT = "t" ' FILTER: A database script note
Const DESIGN_FLAG_SUBFORM = "U" ' FORM: Indicates that a form is a subform.
Const DESIGN_FLAG_AGENT_RUNASWEBUSER = "u" ' FILTER: Indicates agent should run as effective user on web
Const DESIGN_FLAG_PRIVATE_IN_DB = "V" ' ALL: This is a private element stored in the database
Const DESIGN_FLAG_WEBPAGE = "W" ' FORM: Note is a WEBPAGE
Const DESIGN_FLAG_HIDE_FROM_WEB = "w" ' ALL: notes stamped with this flag
'will be hidden from WEB clients
' WARNING: A formula that build Design Collecion relies on the fact that Agent Data"s
'$Flags is the only Desing Collection element whose $Flags="X"
Const DESIGN_FLAG_V4AGENT_DATA = "X" ' FILTER: This is a V4 agent data note
Const DESIGN_FLAG_SUBFORM_NORENDER = "x" ' SUBFORM: indicates whether
'we should render a subform in
'the parent form
Const DESIGN_FLAG_NO_MENU = "Y" ' ALL: Indicates that folder/view/etc. should be hidden from menu.
Const DESIGN_FLAG_SACTIONS = "y" ' Shared actions note
Const DESIGN_FLAG_MULTILINGUAL_PRESERVE_HIDDEN = "Z" ' ALL: Used to indicate design element was hidden
' before the "Notes Global Designer" modified it.
' (used with the "!" flag)
Const DESIGN_FLAG_FRAMESET = "#" ' FORM: Indicates that this is a frameset note
Const DESIGN_FLAG_MULTILINGUAL_ELEMENT = "!"' ALL: Indicates this design element supports the
' "Notes Global Designer" multilingual addin
Const DESIGN_FLAG_JAVA_RESOURCE = "@" ' FORM: Note is a shared Java resource
Const DESIGN_FLAG_HIDE_FROM_V3 = "3" ' ALL: notes stamped with this flag
' will be hidden from V3 client
Const DESIGN_FLAG_HIDE_FROM_V4 = "4" ' ALL: notes stamped with this flag
' will be hidden from V4 client
Const DESIGN_FLAG_HIDE_FROM_V5 = "5" ' FILTER: "Q5"= hide from V4.5 search list
' ALL OTHER: notes stamped with this flag
' will be hidden from V5 client
Const DESIGN_FLAG_HIDE_FROM_V6 = "6" ' ALL: notes stamped with this flag
'will be hidden from V6 client
Const DESIGN_FLAG_HIDE_FROM_V7 = "7" ' ALL: notes stamped with this flag
'will be hidden from V7 client
Const DESIGN_FLAG_HIDE_FROM_V8 = "8" ' ALL: notes stamped with this flag
'will be hidden from V8 client
Const DESIGN_FLAG_HIDE_FROM_V9 = "9" ' ALL: notes stamped with this flag
'will be hidden from V9 client
Const DESIGN_FLAG_MUTILINGUAL_HIDE = "0" ' ALL: notes stamped with this flag
'will be hidden from the client
'usage is for different language
'versions of the design list to be
'hidden completely
' These are the flags that help determine the type of a design element.
' These flags are used to sub-class the note classes, and cannot be
' changed once they are created (for example, there is no way to change
' a form into a subform).
Const DESIGN_FLAGS_SUBCLASS = "UW#yi@GFXstm"
' These are the flags that can be used to distinguish between two
' design elements that have the same class, subclass (see DESIGN_FLAGS_SUBCLASS),
' and name.
Const DESIGN_FLAGS_DISTINGUISH = "nw3456789"
Const ERR_BASE_CLASS_INSTANTIATED = 10452
Const ERR_BASE_CLASS_INSTANTIATED_MESSAGE = "You cannot instantiate this class directly"
Public Class DatabaseDesignClass DatabaseDesign
'PUBLIC MEMBERS
Public cacheDocuments As Integer
'PRIVATE MEMBERS
Private db As NotesDatabase
Private forms As Variant
Private views As Variant
Private filters As Variant
Private fields As Variant
Sub new()Sub new( database As NotesDatabase)
If isAbstractClass Then
'this prevents the base class from being instantiated directly
Error ERR_BASE_CLASS_INSTANTIATED, ERR_BASE_CLASS_INSTANTIATED_MESSAGE
End If