notesgrip 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,468 @@
1
+ module Notesgrip
2
+ # ====================================================
3
+ # ================= NotesDatabase Class ===============
4
+ # ====================================================
5
+ class NotesDatabase < GripWrapper
6
+ def initialize(raw_object)
7
+ super(raw_object)
8
+ # auto open Database
9
+ unless @raw_object.isOpen
10
+ begin
11
+ @raw_object.Open("","")
12
+ rescue WIN32OLERuntimeError
13
+ # unable access DataBase
14
+ end
15
+ end
16
+ end
17
+
18
+ def ACL
19
+ NotesACL.new(@raw_object.ACL)
20
+ end
21
+
22
+ def ACLActivityLog
23
+ @raw_object.ACLActivityLog()
24
+ end
25
+
26
+ def Agents
27
+ agent_arr = @raw_object.Agents
28
+ return [] unless agent_arr # Case of No Agent in database
29
+ ret_list = []
30
+ agent_arr.each {|raw_agent|
31
+ ret_list.push NotesAgent.new(raw_agent)
32
+ }
33
+ ret_list
34
+ end
35
+
36
+ def AllDocuments
37
+ NotesDocumentCollection.new(@raw_object.AllDocuments)
38
+ end
39
+
40
+ ACLLEVEL_NOACCESS = 0
41
+ ACLLEVEL_DEPOSITOR = 1
42
+ ACLLEVEL_READER = 2
43
+ ACLLEVEL_AUTHOR = 3
44
+ ACLLEVEL_EDITOR = 4
45
+ ACLLEVEL_DESIGNER = 5
46
+ ACLLEVEL_MANAGER = 6
47
+
48
+ def Forms
49
+ ret_list = []
50
+ @raw_object.Forms.each {|raw_form|
51
+ ret_list.push NotesForm.new(raw_form)
52
+ }
53
+ ret_list
54
+ end
55
+
56
+ def Parent()
57
+ NotesSession.new()
58
+ end
59
+
60
+ def ReplicationInfo
61
+ NotesReplication.new(@raw_object.NotesReplication)
62
+ end
63
+
64
+ def Views
65
+ ret_list = []
66
+ raw_views = @raw_object.Views
67
+ return [] unless raw_views
68
+ raw_views.each {|raw_view|
69
+ ret_list.push NotesView.new(raw_view)
70
+ }
71
+ ret_list
72
+ end
73
+
74
+ CMPC_ARCHIVE_DELETE_COMPACT = 1 # archive and delete, then compact
75
+ CMPC_ARCHIVE_DELETE_ONLY = 2 # archive and delete with no compact; supersedes a
76
+ CMPC_CHK_OVERLAP = 32768 # check overlap
77
+ CMPC_COPYSTYLE = 16 # copy style; supersedes b and B
78
+ CMPC_DISABLE_DOCTBLBIT_OPTMZN = 128 # disable document table bit map optimization
79
+ CMPC_DISABLE_LARGE_UNKTBL = 4096 # disable large unknown table
80
+ CMPC_DISABLE_RESPONSE_INFO = 512 # disable "Don't support specialized response hierarchy"
81
+ CMPC_DISABLE_TRANSACTIONLOGGING = 262144 # disable transaction logging
82
+ CMPC_DISABLE_UNREAD_MARKS = 1048576 # disable "Don't maintain unread marks"
83
+ CMPC_DISCARD_VIEW_INDICES = 32 # discard view indexes
84
+ CMPC_ENABLE_DOCTBLBIT_OPTMZN = 64 # enable document table bit map optimization; supersedes f
85
+ CMPC_ENABLE_LARGE_UNKTBL = 2048 # enable large unknown table; supersedes k
86
+ CMPC_ENABLE_RESPONSE_INFO = 256 # enable "Don't support specialized response hierarchy"; supersedes H
87
+ CMPC_ENABLE_TRANSACTIONLOGGING = 131072 # enable transaction logging; supersedes t
88
+ CMPC_ENABLE_UNREAD_MARKS = 524288 # enable "Don't maintain unread marks"; supersedes U
89
+ CMPC_IGNORE_COPYSTYLE_ERRORS = 1024 # ignore copy-style errors
90
+ CMPC_MAX_4GB = 16384 # set maximum database size at 4 gigabytes
91
+ CMPC_NO_LOCKOUT = 8192 # do not lock out users
92
+ CMPC_RECOVER_INPLACE = 8 # recover unused space in-place and reduce file size; supersedes b
93
+ CMPC_RECOVER_REDUCE_INPLACE = 4 # recover unused space in-place without reducing file size
94
+ CMPC_REVERT_FILEFORMAT = 65536 # do not convert old file format
95
+ def CompactWithOptions( options )
96
+ @raw_object.CompactWithOptions( options )
97
+ end
98
+
99
+ def CreateCopy( newServer, newDbFile , maxsize=4 )
100
+ db = @raw_object.CreateCopy( newServer, newDbFile , maxsize )
101
+ NotesDatabase.new(db)
102
+ end
103
+
104
+ def CreateDocument(formName=nil)
105
+ raw_doc = @raw_object.CreateDocument()
106
+ new_doc = raw_doc ? NotesDocument.new(raw_doc) : nil
107
+ if new_doc and formName
108
+ new_doc.AppendItemValue('Form', formName)
109
+ #new_doc['Form'].Values = formName
110
+ end
111
+ new_doc
112
+ end
113
+
114
+ def CreateFromTemplate( newServer, newDbFile, inheritFlag, maxsize=4 )
115
+ db = @raw_object.CreateFromTemplate( newServer, newDbFile, inheritFlag, maxsize )
116
+ NotesDatabase.new(db)
117
+ end
118
+
119
+
120
+ FTINDEX_ALL_BREAKS = 4 # index sentence and paragraph breaks
121
+ FTINDEX_ATTACHED_BIN_FILES = 16 # index attached files (binary)
122
+ FTINDEX_ATTACHED_FILES = 1 # index attached files (raw text)
123
+ FTINDEX_CASE_SENSITIVE = 8 # enable case-sensitive searches
124
+ FTINDEX_ENCRYPTED_FIELDS = 2 # index encrypted fields
125
+ def CreateFTIndex( options , recreate=false )
126
+ @raw_object.CreateFTIndex( options , recreate )
127
+ end
128
+
129
+ def CreateNoteCollection( selectAllFlag = false)
130
+ raw_notesNotesCollection = @raw_object.CreateNoteCollection( selectAllFlag)
131
+ NotesNoteCollection.new(raw_notesNotesCollection)
132
+ end
133
+
134
+ def CreateOutline( outlinename, defaultOutline=false )
135
+ raw_outline = @raw_object.CreateOutline( outlinename, defaultOutline)
136
+ NotesOutline.new(raw_outline)
137
+ end
138
+
139
+ def CreateReplica( newServer, newDbFile )
140
+ raw_db = @raw_object.CreateReplica( newServer, newDbFile )
141
+ raw_doc ? NotesDocument.new(raw_doc) : nil
142
+ end
143
+
144
+ def CreateView( viewName=nil, viewSelectionFormula=nil, templateView=nil, prohibitDesignRefreshModifications=false )
145
+ raw_view = @raw_object.CreateView( viewName, viewSelectionFormula, templateView, prohibitDesignRefreshModifications )
146
+ NotesView.new(raw_view)
147
+ end
148
+
149
+
150
+ FIXUP_INCREMENTAL = 4 # checks only documents since last Fixup
151
+ FIXUP_NODELETE = 16 # prevents Fixup from deleting corrupted documents
152
+ FIXUP_NOVIEWS = 64 # does not check views
153
+ FIXUP_QUICK = 2 # checks documents more quickly but less thoroughly
154
+ FIXUP_REVERT = 32 # reverts ID tables to the previous release format
155
+ FIXUP_TXLOGGED = 8 # includes databases enabled for transaction logging
156
+ FIXUP_VERIFY = 1 # makes no modifications
157
+ def Fixup(options)
158
+ @raw_object.Fixup(options)
159
+ end
160
+
161
+
162
+ # Constant for FTSearch
163
+ FT_DATE_ASC = 64 # sorts by document creation date in ascending order.
164
+ FT_DATE_DES = 32 # sorts by document creation date in descending order.
165
+ FT_SCORES = 8 # sorts by relevance score (default).
166
+ FT_DATABASE = 8192 # includes Domino databases.
167
+ FT_FUZZY = 16384 # searches for related words. Need not be an exact match.
168
+ FT_FILESYSTEM = 4096 # includes files that are not Domino databases.
169
+ FT_STEMS = 512 # uses stem words as the basis of the search.
170
+ FT_THESAURUS = 1024 # uses thesaurus synonyms.
171
+ def FTDomainSearch( query, maxDocs=0, sortoptions=FT_SCORES, otheroptions=0, start=0, count=1, entryform="" )
172
+ #raw_doc = @raw_object.FTDomainSearch( query, maxDocs, sortoptions, otheroptions, start, count, entryform )
173
+ #raw_doc ? NotesDocument.new(raw_doc) : nil
174
+ raise "FTDomainSearch() is not work."
175
+ end
176
+
177
+ def FTSearch( query, maxdocs=0, sortoptions=FT_SCORES, otheroptions=0 )
178
+ raw_docCollection = @raw_object.FTSearch( query, maxdocs, sortoptions, otheroptions)
179
+ NotesDocumentCollection.new(raw_docCollection)
180
+ end
181
+
182
+ def FTSearchRange( query, maxdocs=0, sortoptions=FT_SCORES, otheroptions=0, start=0 )
183
+ raw_docCollection = @raw_object.FTSearchRange( query, maxdocs, sortoptions, otheroptions, start)
184
+ NotesDocumentCollection.new(raw_docCollection)
185
+ end
186
+
187
+ def GetAgent( agentName )
188
+ raw_agent = @raw_object.GetAgent(agentName)
189
+ NotesAgent.new(raw_agent)
190
+ end
191
+
192
+ def GetAllReadDocuments( username=nil )
193
+ raw_docCollection = @raw_object.GetAllReadDocuments(username)
194
+ NotesDocumentCollection.new(raw_docCollection)
195
+ end
196
+
197
+ def GetAllUnreadDocuments( username=nil )
198
+ raw_docCollection = @raw_object.GetAllUnreadDocuments(username)
199
+ NotesDocumentCollection.new(raw_docCollection)
200
+ end
201
+
202
+ def GetDocumentByID( noteID )
203
+ raw_doc = @raw_object.GetDocumentByID( noteID )
204
+ raw_doc ? NotesDocument.new(raw_doc) : nil
205
+ end
206
+
207
+ def GetDocumentByUNID(unid)
208
+ raw_doc = @raw_object.GetDocumentByUNID(unid)
209
+ raw_doc ? NotesDocument.new(raw_doc) : nil
210
+ end
211
+
212
+ def GetDocumentByURL( url, reload=0, urllist=0, charset="", webusername="", webpassword=nil, proxywebusername=nil, proxywebpassword=nil, returnimmediately=false )
213
+ #raw_doc = @raw_object.GetDocumentByURL( url, reload, urllist, charset, webusername, webpassword, proxywebusername, proxywebpassword, returnimmediately )
214
+ #raw_doc ? NotesDocument.new(raw_doc) : nil
215
+ raise "GetDocumentByURL() is not Work"
216
+ end
217
+
218
+ def GetForm( name )
219
+ raw_form = @raw_object.GetForm(name)
220
+ raw_form ? NotesForm.new(raw_form) : nil
221
+ end
222
+
223
+
224
+ DBMOD_DOC_ACL = 64
225
+ DBMOD_DOC_AGENT = 512
226
+ DBMOD_DOC_ALL = 32767
227
+ DBMOD_DOC_DATA = 1
228
+ DBMOD_DOC_FORM = 4
229
+ DBMOD_DOC_HELP = 256
230
+ DBMOD_DOC_ICON = 16
231
+ DBMOD_DOC_REPLFORMULA = 2048
232
+ DBMOD_DOC_SHAREDFIELD = 1024
233
+ DBMOD_DOC_VIEW = 8
234
+ def GetModifiedDocuments( since=nil , noteClass=DBMOD_DOC_DATA )
235
+ #raw_docCollection = @raw_object.GetModifiedDocuments( since, noteClass)
236
+ #NotesDocumentCollection.new(raw_docCollection)
237
+ raise "GetModifiedDocuments() is not work."
238
+ end
239
+
240
+
241
+ DBOPT_LZCOMPRESSION = 65 # uses LZ1 compression for attachments
242
+ DBOPT_MAINTAINLASTACCESSED = 44 # maintains LastAccessed property
243
+ DBOPT_MOREFIELDS = 54 # allows more fields in database
244
+ DBOPT_NOHEADLINEMONITORS = 46 # doesn't allow headline monitoring
245
+ DBOPT_NOOVERWRITE = 36 # doesn't overwrite free space
246
+ DBOPT_NORESPONSEINFO = 38 # doesn't support specialized response hierarchy
247
+ DBOPT_NOTRANSACTIONLOGGING = 45 # disables transaction logging
248
+ DBOPT_NOUNREAD = 37 # doesn't maintain unread marks
249
+ DBOPT_OPTIMIZATION = 41 # enables document table bitmap optimization
250
+ DBOPT_REPLICATEUNREADMARKSTOANY = 71 # replicates unread marks to all servers
251
+ DBOPT_REPLICATEUNREADMARKSTOCLUSTER = 70 # replicates unread marks to clustered servers only
252
+ DBOPT_SOFTDELETE = 49 # allows soft deletions
253
+ def GetOption(optionName)
254
+ @raw_object.GetOption(optionName)
255
+ end
256
+
257
+ def SetOption( optionName, flag )
258
+ @raw_object.SetOption(optionName, flag)
259
+ end
260
+
261
+ def GetOutline( outlinename )
262
+ #raw_outline = @raw_object.GetOutline( outlinename )
263
+ #NotesOutline.new(raw_outline)
264
+ raise "GetOutline is not work."
265
+ end
266
+
267
+ def GetProfileDocCollection( profilename=nil )
268
+ raw_docCollection = @raw_object.GetProfileDocCollection( profilename )
269
+ NotesDocumentCollection.new(raw_docCollection)
270
+ end
271
+
272
+ def GetProfileDocument( profilename, uniqueKey=nil )
273
+ raw_document = @raw_object.GetProfileDocument( profilename, uniqueKey)
274
+ raw_document ? NotesDocument.new(raw_document) : nil
275
+ end
276
+
277
+ def GetView( viewName )
278
+ raw_view = @raw_object.GetView( viewName )
279
+ raw_view ? NotesView.new(raw_view) : nil
280
+ end
281
+ alias view GetView
282
+
283
+ def Search( formula, notesDateTime=nil, maxDocs=0 )
284
+ #raw_docCollection = @raw_object.Search( formula, notesDateTime, maxDocs )
285
+ #NotesDocumentCollection.new(raw_docCollection)
286
+ raise "Search() is not work."
287
+ end
288
+
289
+ def UnprocessedFTSearch(query, maxdocs=0, sortoptions=nil, otheroptions=nil )
290
+ #raw_docCollection = @raw_object.UnprocessedFTSearch(query, maxdocs, sortoptions, otheroptions )
291
+ #NotesDocumentCollection.new(raw_docCollection)
292
+ raise "UnprocessedFTSearch() is not work."
293
+ end
294
+
295
+ # ---- Additional Methods ------
296
+ def name
297
+ @raw_object.Title
298
+ end
299
+
300
+ def open?()
301
+ @raw_object.IsOpen()
302
+ end
303
+
304
+ def each_document
305
+ doc_collection = self.AllDocuments
306
+ doc_collection.each {|doc|
307
+ yield doc
308
+ }
309
+ end
310
+
311
+ def each_view
312
+ view_collection = self.Views
313
+ view_collection.each {|view|
314
+ yield view
315
+ }
316
+ end
317
+
318
+ def each_form
319
+ form_collection = self.Forms
320
+ form_collection.each {|form|
321
+ yield form
322
+ }
323
+ end
324
+
325
+ def each_agent
326
+ self.Agents.each {|agent|
327
+ yield agent
328
+ }
329
+ end
330
+
331
+ def each_profile
332
+ self.GetProfileDocCollection.each {|profileDoc|
333
+ yield profileDoc
334
+ }
335
+ end
336
+
337
+ def inspect
338
+ "<#{self.class}, Name:#{self.name.inspect}, FilePath:#{self.FilePath.inspect}>"
339
+ end
340
+ end
341
+
342
+ # ====================================================
343
+ # ================= NotesForm Class ===============
344
+ # ====================================================
345
+ class NotesForm < GripWrapper
346
+ # ------ Additional Methods -----
347
+ def inspect
348
+ "<#{self.class} Name:#{self.Name.inspect}>"
349
+ end
350
+ end
351
+
352
+ # ====================================================
353
+ # ================= NotesAgent Class ===============
354
+ # ====================================================
355
+ class NotesAgent < GripWrapper
356
+ # ------ Additional Methods -----
357
+ def inspect
358
+ "<#{self.class} Name:#{self.Name.inspect}>"
359
+ end
360
+ end
361
+
362
+ # ====================================================
363
+ # ================= NotesACL Class ===============
364
+ # ====================================================
365
+ class NotesACL < GripWrapper
366
+ def Parent
367
+ NotesDatabase.new(@raw_object.Parent)
368
+ end
369
+
370
+ def CreateACLEntry( name, level )
371
+ raw_ACLEntry = @raw_object.CreateACLEntry( name, level )
372
+ raw_ACLEntry ? NotesACLEntry.new(raw_ACLEntry) : nil
373
+ end
374
+
375
+ def GetEntry( name )
376
+ raw_ACLEntry = @raw_object.GetEntry( name )
377
+ raw_ACLEntry ? NotesACLEntry.new(raw_ACLEntry) : nil
378
+ end
379
+
380
+ def GetFirstEntry
381
+ raw_ACLEntry = @raw_object.GetFirstEntry()
382
+ raw_ACLEntry ? NotesACLEntry.new(raw_ACLEntry) : nil
383
+ end
384
+
385
+ def GetNextEntry( entry )
386
+ raw_ACLEntry = @raw_object.GetNextEntry(toRaw(entry))
387
+ raw_ACLEntry ? NotesACLEntry.new(raw_ACLEntry) : nil
388
+ end
389
+
390
+ def RemoveACLEntry( name )
391
+ @raw_entry.RemoveACLEntry( name )
392
+ end
393
+
394
+ def RenameRole( oldName, newName )
395
+ @raw_object.RenameRole( oldName, newName )
396
+ end
397
+
398
+ # ----- Additional Methods ----
399
+ def each_entry
400
+ raw_entry = @raw_object.GetFirstEntry
401
+ while raw_entry
402
+ next_entry = @raw_object.GetNextEntry(raw_entry)
403
+ yield NotesACLEntry.new(raw_entry)
404
+ raw_entry = next_entry
405
+ end
406
+ end
407
+ alias each each_entry
408
+ end
409
+
410
+ # ====================================================
411
+ # ============= NotesACLEntry Class ==================
412
+ # ====================================================
413
+ class NotesACLEntry < GripWrapper
414
+ def NameObject()
415
+ raw_nameObject = @raw_object.NameObject
416
+ NotesName.new(raw_nameObject)
417
+ end
418
+
419
+ def Parent
420
+ raw_aclEntry = @raw_object.Parent
421
+ NotesACL.new(raw_aclEntry)
422
+ end
423
+
424
+ ACLTYPE_UNSPECIFIED = 0
425
+ ACLTYPE_PERSON = 1
426
+ ACLTYPE_SERVER = 2
427
+ ACLTYPE_MIXED_GROUP = 3
428
+ ACLTYPE_PERSON_GROUP = 4
429
+ ACLTYPE_SERVER_GROUP = 5
430
+ def UserType
431
+ @raw_object.UserType
432
+ end
433
+ # ----- Additional Methods ----
434
+ def inspect
435
+ "<#{self.class} Name:#{self.Name}>"
436
+ end
437
+ end
438
+
439
+ # ====================================================
440
+ # ============= NotesOutline Class ==================
441
+ # ====================================================
442
+ class NotesOutline < GripWrapper
443
+ end
444
+
445
+ # ====================================================
446
+ # ============= NotesOutlineEntry Class ==================
447
+ # ====================================================
448
+ class NotesOutlineEntry < GripWrapper
449
+ end
450
+
451
+ # ====================================================
452
+ # ============= NotesReplication Class ==================
453
+ # ====================================================
454
+ class NotesReplication < GripWrapper
455
+ end
456
+
457
+ # ====================================================
458
+ # ============= NotesReplicationEntry Class ==================
459
+ # ====================================================
460
+ class NotesReplicationEntry < GripWrapper
461
+ end
462
+
463
+ # ====================================================
464
+ # ======== NotesNoteCollection Class ===============
465
+ # ====================================================
466
+ class NotesNoteCollection < GripWrapper
467
+ end
468
+ end