NOTEID DES DOCUMENTS ''SPECIAUX'' COMME ''ABOUT DOCUMENT''

NOTEID DES DOCUMENTS ''SPECIAUX'' COMME ''ABOUT DOCUMENT''

Messagepar Michael DELIQUE » 04 Mars 2005 à 17:39

Qui n'a jamais voulu employer les objets spéciaux d'une base comme le document "About Database" en LotusScript ? c'est possible chaque objet est un document avec une NoteID constante (identique pour toutes les bases) :

Note ID Document

FFFF0002 “About Database” document

FFFF0004 Default Form

FFFF0008 Default View

FFFF0010 Icon and design info

FFFF0020 Design document

FFFF0040 ACL info

FFFF0100 “Using Database” document

FFFF0800 Default Replication
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy

Classe pour exploiter ces documents spéciaux

Messagepar oguruma » 08 Mars 2005 à 10:15

Je me suis permis de reprendre les infos postées pour en faire une classe "à la va vite"...
Son code évoluera au fil du temps et de mon temps.
Voici la v0.1

Code : Tout sélectionner
Private Const ABOUT="FFFF0002"
Private Const DEFAULTFORM="FFFF0004"
Private Const DEFAULTVIEW="FFFF0008"
Private Const DATABASEICON="FFFF0010"
Private Const DBDESIGN="FFFF0020"
Private Const ACL="FFFF0040"
Private Const USINGDB="FFFF0100"
Private Const REPLICA="FFFF0800"
Public Class DocSpeciaux
%REM
Cette classe permet de récupérer le contenu des documents spéciaux
FFFF0002 : "About This Database" document
FFFF0004 : Default form
FFFF0008 : Default view
FFFF0010 : Database icon
FFFF0020 : Database Design Collection (view)
FFFF0040 : Database ACL
FFFF0100 : "Using This Database" document
FFFF0800 : Replication Formula
%END REM   
   
   Private m_session As NotesSession
   Private m_db As NotesDatabase
   Private m_docAbout As NotesDocument
   Private m_docDefaultView As NotesDocument
   Private m_docDefaultForm As NotesDocument
   Private m_docIcon As NotesDocument
   Private m_docDatabaseDesign As NotesDocument
   Private m_docACL As NotesDocument
   Private m_docReplicaFormula As NotesDocument
   Private m_docUsingDB As NotesDocument
   Private m_doc As NotesDocument
   
   Sub new
      Call init   
   End Sub
   
   Private Function init
      Set m_session=New NotesSession
      Set m_db=m_session.CurrentDatabase            
   End Function
   
   Private Function addElementToArray(a As Variant, element As Variant) As Integer
      If Isempty(a) Then
         Redim a(0)
      Else
         Redim Preserve a(Ubound(a)+1)   
      End If
      a(Ubound(a))=element      
   End Function
   
   Public Function getDocAbout() As Notesdocument
      Set m_docAbout=m_db.GetDocumentByID( ABOUT )
      Set getDocAbout=m_docAbout
   End Function
   
   Public Function getDocDefaultView() As NotesDocument
      Set m_docDefaultView=m_db.GetDocumentByID( DEFAULTVIEW )   
      Set getDocDefaultView=m_docDefaultView
   End Function
   
   Public Function getDocDefaultForm() As NotesDocument
      Set m_docDefaultForm=m_db.GetDocumentByID( DEFAULTFORM )   
      Set getDocDefaultForm=m_docDefaultForm
   End Function
   
   Public Function getDocIcon() As NotesDocument
      Set m_docIcon=m_db.GetDocumentByID( DATABASEICON )   
      Set getDocIcon=m_docIcon
      
   End Function
   
   Public Function getDocDatabaseDesign() As NotesDocument
      Set m_docDatabaseDesign=m_db.GetDocumentByID( DBDESIGN )   
      Set getDocDatabaseDesign=m_docDatabaseDesign
      
   End Function
   
   Public Function getDocAcl() As NotesDocument
      Set m_docACL=m_db.GetDocumentByID( ACL )   
      Set getDocAcl=m_docACL
      
   End Function
   
   Public Function getDocReplicaFormula()  As NotesDocument
      Set m_docReplicaFormula=m_db.GetDocumentByID( REPLICA )   
      Set getDocReplicaFormula=m_docReplicaFormula
      
   End Function
   
   Public Function getDocUsingDB() As NotesDocument
      Set m_docUsingDB=m_db.GetDocumentByID( USINGDB )   
      Set getDocUsingDB=m_docUsingDB      
   End Function
   
   Public Function getItems(d As NotesDocument) As Variant
      getItems=d.items
   End Function   
   
   Public Function getFieldsNames(items As Variant) As Variant
      Dim v As Variant
      Forall f In items
         Call addElementToArray(v,f.name)         
      End Forall      
      getFieldsNames=v
   End Function   
   
End Class


Un petit exemple permettant de l'exploiter et connaître quels sont les champs de ces documents

Code : Tout sélectionner
Sub Initialize
   Dim ds As DocSpeciaux
   Dim d As notesdocument
   Dim items As Variant
   Dim names As Variant
   Close
   Open "c:\FieldsSpec.txt" For Output As 1
   
   Set ds=New DocSpeciaux
   
   Set d=ds.getDocDefaultView
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DefaultView"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Set d=ds.getDocIcon
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocIcon"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Set d=ds.getDocDatabaseDesign
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocDesign"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Set d=ds.getDocAcl
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocACL"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Set d=ds.getDocReplicaFormula
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocReplica"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Set d=ds.getDocReplicaFormula
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocReplica"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   
   Set d=ds.getDocDefaultForm
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DocDefaultForm"
      Forall n In names
         Print #1,n
      End Forall
   End If
   
   Close   
   
End Sub


voici le résultat obtenu dans le fichier

Code : Tout sélectionner
=== Liste des champs pour DefaultView
$TITLE
$Index
$UpdatedBy
$Formula
$FormulaClass
$Collation
$VIEWFORMAT
$Comment
$Flags
$DesignerVersion
$Signature
$Collection
=== Liste des champs pour DocIcon
$Flags
$TITLE
$UpdatedBy
IconBitmap
=== Liste des champs pour DocDesign
$DesignVersion
$Version
$Formula
$FormulaClass
$Collation
$UpdatedBy
$Collection
=== Liste des champs pour DocACL
$ACLDigest
$Signature
$UpdatedBy
=== Liste des champs pour DocDefaultForm
$TITLE
$Info
$UpdatedBy
$Flags
$DesignerVersion
$$ScriptName
membres
$Fields
$Body
$Signature


Il me reste à travailler sur le contenu des champs et offrir des méthodes permettant d'obtenir le contenu d'un de ceux-ci et aussi pourvoir les modifier quand cela est possible (enfin si Notes veut bien)
Bien à vous

http://www.dominoarea.org/oguruma/

Les téléphones PORTABLES dans les TGV y en a MARRRE de ces voyageurs qui ne respectent pas les autres ! ARRET DES PORTABLES SVP - Merci

Fumeurs ! respectez les non fumeurs !!!
Fumeurs ! respectez la loi de février 2007 et les lieux publics !!! (ie. hall de gares)
Avatar de l’utilisateur
oguruma
Super V.I.P.
Super V.I.P.
 
Message(s) : 4086
Inscrit(e) le : 16 Déc 2004 à 08:50
Localisation : LILLE

Version 0.2

Messagepar oguruma » 08 Mars 2005 à 14:11

Code : Tout sélectionner
%REM
Cette classe permet de récupérer le contenu des documents spéciaux
FFFF0002 : "About This Database" document
FFFF0004 : Default form
FFFF0008 : Default view
FFFF0010 : Database icon
FFFF0020 : Database Design Collection (view)
FFFF0040 : Database ACL
FFFF0100 : "Using This Database" document
FFFF0800 : Replication Formula
%END REM   

Private Const ABOUT="FFFF0002"
Private Const DEFAULTFORM="FFFF0004"
Private Const DEFAULTVIEW="FFFF0008"
Private Const DATABASEICON="FFFF0010"
Private Const DBDESIGN="FFFF0020"
Private Const ACL="FFFF0040"
Private Const USINGDB="FFFF0100"
Private Const REPLICA="FFFF0800"

Class ObjectDocSpec
   Private Function atImplode(s As Variant, div As String) As String
      Dim i As Integer
      If Isarray(s) Then      
         atImplode = s(Lbound(s))
         For i = Lbound(s)+1 To Ubound(s)
            atImplode = atImplode & div & s(i)
         Next
      Else
         atImplode = Cstr(s)
      End If
   End Function
   
   Public Function toString(v As Variant) As String
      toString=atImplode(v,",")   
   End Function   
   
End Class

Public Class DocSpeciaux As ObjectDocSpec   
   Private m_session As NotesSession
   Private m_db As NotesDatabase
   Private m_docAbout As NotesDocument
   Private m_docDefaultView As NotesDocument
   Private m_docDefaultForm As NotesDocument
   Private m_docIcon As NotesDocument
   Private m_docDatabaseDesign As NotesDocument
   Private m_docACL As NotesDocument
   Private m_docReplicaFormula As NotesDocument
   Private m_docUsingDB As NotesDocument
   Private m_doc As NotesDocument
   
   Sub new
      Call init   
   End Sub
   
   Private Function init
      Set m_session=New NotesSession
      Set m_db=m_session.CurrentDatabase            
   End Function
   
   Private Function addElementToArray(a As Variant, element As Variant) As Integer
      If Isempty(a) Then
         Redim a(0)
      Else
         Redim Preserve a(Ubound(a)+1)   
      End If
      a(Ubound(a))=element      
   End Function
   
   
   Public Function getDocAbout() As Notesdocument
      Set m_docAbout=m_db.GetDocumentByID( ABOUT )
      Set getDocAbout=m_docAbout
   End Function
   
   Public Function getDocDefaultView() As NotesDocument
      Set m_docDefaultView=m_db.GetDocumentByID( DEFAULTVIEW )   
      Set getDocDefaultView=m_docDefaultView
   End Function
   
   Public Function getDocDefaultForm() As NotesDocument
      Set m_docDefaultForm=m_db.GetDocumentByID( DEFAULTFORM )   
      Set getDocDefaultForm=m_docDefaultForm
   End Function
   
   Public Function getDocIcon() As NotesDocument
      Set m_docIcon=m_db.GetDocumentByID( DATABASEICON )   
      Set getDocIcon=m_docIcon
      
   End Function
   
   Public Function getDocDatabaseDesign() As NotesDocument
      Set m_docDatabaseDesign=m_db.GetDocumentByID( DBDESIGN )   
      Set getDocDatabaseDesign=m_docDatabaseDesign
      
   End Function
   
   Public Function getDocAcl() As NotesDocument
      Set m_docACL=m_db.GetDocumentByID( ACL )   
      Set getDocAcl=m_docACL
      
   End Function
   
   Public Function getDocReplicaFormula()  As NotesDocument
      Set m_docReplicaFormula=m_db.GetDocumentByID( REPLICA )   
      Set getDocReplicaFormula=m_docReplicaFormula
      
   End Function
   
   Public Function getDocUsingDB() As NotesDocument
      Set m_docUsingDB=m_db.GetDocumentByID( USINGDB )   
      Set getDocUsingDB=m_docUsingDB      
   End Function
   
   Public Function getItems(d As NotesDocument) As Variant
      getItems=d.items
   End Function   
   
   Public Function getFieldsNames(items As Variant) As Variant
      Dim v As Variant
      Forall f In items
         Call addElementToArray(v,f.name)         
      End Forall      
      getFieldsNames=v
   End Function   
   
   Public Function getUpdatedBy(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$UpdatedBy")
      getUpdatedBy=v
   End Function
   
   Public Function getFlags(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Flags")
      getFlags=v
   End Function
   
   Public Function getTittle(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$TITLE")
      getTittle=v
   End Function
   
   Public Function getFields(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Fields")
      getFields=v
   End Function
   
   Public Function getCollection(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Collection")
      getCollection=v
   End Function
   
   Public Function getFormula(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Formula")
      getFormula=v
   End Function
   
   Public Function getComment(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Comment")
      getComment=v
   End Function
   
   Public Function getSignature(d As NotesDocument) As Variant
      Dim v As Variant
      v=d.GetItemvalue("$Signature")
      getSignature=v
   End Function
   
   
End Class


exemple

Code : Tout sélectionner
Set ds=New DocSpeciaux
   
   Set d=ds.getDocDefaultView
   If Not (d Is Nothing) Then
      items=ds.getItems(d)
      names=ds.getFieldsNames(items)
      Print #1,"=== Liste des champs pour DefaultView"
      Forall n In names
         Print #1,n
      End Forall
      Print #1, ds.toString(ds.getUpdatedBy(d))
      Print #1, ds.toString(ds.getComment(d))
      Print #1, ds.toString(ds.getSignature(d))
      Print #1, ds.toString(ds.getFormula(d))
   End If


allez une piste pour ceux et celles qui souhaitent enrichir cette classe...
Bien à vous

http://www.dominoarea.org/oguruma/

Les téléphones PORTABLES dans les TGV y en a MARRRE de ces voyageurs qui ne respectent pas les autres ! ARRET DES PORTABLES SVP - Merci

Fumeurs ! respectez les non fumeurs !!!
Fumeurs ! respectez la loi de février 2007 et les lieux publics !!! (ie. hall de gares)
Avatar de l’utilisateur
oguruma
Super V.I.P.
Super V.I.P.
 
Message(s) : 4086
Inscrit(e) le : 16 Déc 2004 à 08:50
Localisation : LILLE


Retour vers Structure des base Lotus Notes