(SnTT) NaSS Installation Toolkit, Part II: The Generate Design Element Docs agent
Category Show-n-Tell Thursday
Bookmark :
(Note: This is Part II of a series. Part I can be found here.)
In Part I I introduced you to the Notes access for SAP solutions (NaSS) Installation Toolkit, which is a part of the upcoming Notes 7.0.2 release. In this second part I am going to explore the Design Element Doc feature, and how the Design Element Docs are automatically generated.
Overview
The Installation Toolkit contains a set of documents known as Design Element Docs. These documents represent every design element that is a part of the various featuresets contained in NaSS. This is very useful to quickly determine what elements are contained in each featureset, and also what elements are contained in each template. Both modified elements (i.e. elements that are modified from an original template design element) and elements that are brand new are documented as Design Element Docs.
There are multiple views that are used to categorize and sort NaSS design elements, such as the By Featureset view displayed below:
Additional views include By NaSS Name, By Template, and By Type.
The Design Element Docs contained in these views are displayed as below:
The information catalogued in the Design Element Doc includes:
- Element type - the design element type, such as Form, View, etc.
- Template name - the filename of the template containing the element
- Element name - the name of the design element
- Alias(es) - list of alias(es) for the design element
- Featureset(s) - the featureset(s) that use this element; this can also be "All Featuresets" or "Original Design Element"
- Modified date - the date the design element was last updated
- New/Modified - whether this is an original design element for NaSS, or it is a modified element from the template
- NaSS name - the special designation for the element that is used to identify and catalogue it in NaSS; this is stored in the Comments for the element
NaSS.ElementName.NotesVersion.FeaturesetDesignator
- NaSS - indicates it is a NaSS element
- ElementName - a name to easily identify what the element is; usually based on the element name, but not always
- NotesVersion - the version of Notes this element is for; for instance for Notes 7.0.2 this would be 702
- FeaturesetDesignator - indicates the featureset(s) that use this element; one character for each featureset, such as T for Time Reporting, V for Vacation/Leave Request, and so on
Now that you understand how we catalogue and identify a design element, let's take a look at the code used to generate these documents...
The Generate Design Element Docs agent
I am going to review the important points of the Generate Design Element Docs agent, instead of posting all of it. Before this first bit of code I simply prompt the user to choose one or more Notes Templates or Databases for processing.
The next bit loops through all of the targeted design elements as NotesDocuments to generate the base Design Element Docs.
Forall tp In targetdbpath Set targetdb = New NotesDatabase("", "") Call targetdb.Open("", Cstr(tp)) If targetdb.IsOpen = False Then Error 1000, "Unable to open database: " &_ Cstr(tp) & " - aborting..." Set dnotecol = getNaSSDesignElements(targetdb) ' from NaSS.TPLmgmt.utilities.6 If dnotecol.Count = 0 Then Error 1000, "Unable to locate design elements in target database: " &_ Cstr(targetdbpath(0)) & " - aborting..." REM we have the design elements - now cycle through all elements and find our doc nid = dnotecol.GetFirstNoteId For i = 1 To dnotecol.Count commentval = 0 Set eldoc = targetdb.GetDocumentByID(nid) If Not(eldoc Is Nothing) Then comments = eldoc.GetItemValue("$COMMENT")(0) titles = Fulltrim(eldoc.GetItemValue("$TITLE")) ' this is an array of name and aliases, maybe aliases = "" Call buildTitleArray(titles, elementname, aliases) ' from LS.DXL.BE.6 If Instr(Lcase(comments), "nass") > 0 Then Redim Preserve titles(Ubound(titles) + 1) titles(Ubound(titles)) = comments commentval = -1 End If Forall t In titles If Lcase(Strleft(t, ".")) = "nass" Then Set desdoc = thisdb.CreateDocument With desdoc .Form = "NaSSDesignElement" .Categories = "Design Element Doc" .Comment = comments ' .Subject = titles(Ubound(titles) + commentval) .Subject = elementname .ElementType = getElementType(eldoc) ' from NaSS.TPLmgmt.utilities.6 .TemplateName = Lcase(targetdb.FileName) .ElementName = elementname .ElementAlias = aliases .ElementModifiedDate = eldoc.LastModified .UseCases = getUseCases(Cstr(t)) ' from NaSS.TPLmgmt.utilities.6 End With Call desdoc.ComputeWithForm(False, False) Call desdoc.Save(True, False, True) Exit Forall End If End Forall End If nid = dnotecol.GetNextNoteId(nid) Next End Forall
The Forall loop is used to loop through all of the databases chosen in the OpenFileDialog. First thing I do is open the database, and verify that I actually was able to open it. After that I run my getNaSSDesignElements function against the database. This function is a nice little piece I have that creates a NotesNoteCollection containing the design notes of the element types I want. See, I don't need ALL element types - I know I didn't use certain elements so I try to be more efficient by only pulling through the element types I need. This function returns Agents, Forms, Folders, Framesets, Image Resources, Outlines, Pages, Script Libraries, Subforms, and Views.
After gathering the desired element notes I loop through them and check the Comments to see if it is a NaSS element by parsing the comment to see if it begins with NaSS. If it does begin with NaSS then I know it is one of the elements I need to process further, so I get a handle to the element as a NotesDocument by using the NoteID.
I need to get the name and alias(es) of the element - but this can be tricky because in some element types the alias is stored in the $Title item as an array, and in some other elements the name and alias(es) are stored in a concatenated string. Therefore I wrapped the code that determines all of this and acts accordingly in a function called buildTitleArray, which simply checks the $Titles item for a pipe symbol ("|") - if it finds one it splits it and builds the arrays accordingly.
In the loop that builds the beginning of the Design Element Doc there are two important function calls that you may find interesting - getElementType and getUseCases. These will be covered in next week's SnTT installment. For now, let's finish out the agent.
REM we have created all the docs - now cycle through them and tag the modified elements vs the new ones Set dview = thisdb.GetView("Design.Elements.by.NaSSName") If dview Is Nothing Then Error 1000, "Unable to find view: Design.Elements.by.NaSSName" Set desdoc = dview.getFirstDocument Do While Not(desdoc Is Nothing) Set desdoc2 = dview.getNextDocument(desdoc) If Not(desdoc2 Is Nothing) Then REM compare the next doc to the current doc - see if they are the same comment/name desname = desdoc.GetItemValue("Comment")(0) desname2 = desdoc2.GetItemValue("Comment")(0) destypes = Strrightback(desname, ".") & Strrightback(desname2, ".") desname = Strleftback(desname, ".") desname2 = Strleftback(desname2, ".") If desname = desname2 Then If Instr(Ucase(destypes), "X") > 0 Then desdoc.NewModified = "Modified" desdoc2.NewModified = "Modified" Call desdoc.Save(True, False, True) Call desdoc2.Save(True, False, True) End If End If End If Set desdoc = desdoc2 Loop
This last loop goes back through the documents and determines which ones are modified design elements, and which ones are new design elements. Since the original and modified versions of an element have the same comments except for the FeaturesetIndicator, I simply walk the Design.Elements.by.NaSSName view and look for elements whose NaSS Name is the same except for the FeaturesetIndicator. I do a StrRightback on the period ( "." ) so that I get the part that is the same, and compare them. If they match, then I have a modified/original pair; if they don't, then it is a new element and I don't need to do anything, since the default value for the NewModified field is "New".
Conclusion
This is just the beginning of this feature in the Installation Toolkit. You now understand the upper level of the Generate Design Element Docs agent; next week we'll dive into the new functions getElementType and getUseCases, which should provide you with some interesting code that you can use in other projects.
See you then.
Rock
**I used to be a professional singer. I had to quit on account of my throat. Audiences were threatening to cut it.







Blog Roll








