ipp_quickbase_devkit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +87 -0
- data/README.rdoc +112 -0
- data/doc/QuickBaseClient.rb.htm +1896 -0
- data/doc/ReleaseNotes.txt +43 -0
- data/doc/qbc.makeCSVFile.qbc +4 -0
- data/doc/qbc.makeCSVFile.rb +4 -0
- data/doc/quickbase_adapter.rb.htm +399 -0
- data/examples/cookbookfiles/QuickBaseAPICookbook.html +2590 -0
- data/examples/cookbookfiles/addChangeRemoveUserRole.rb +21 -0
- data/examples/cookbookfiles/addOrEditRecord.rb +10 -0
- data/examples/cookbookfiles/application_object.rb +55 -0
- data/examples/cookbookfiles/applyRubyFormulas.rb +10 -0
- data/examples/cookbookfiles/average.rb +27 -0
- data/examples/cookbookfiles/backupApplication.rb +8 -0
- data/examples/cookbookfiles/cacheSchemas.rb +53 -0
- data/examples/cookbookfiles/calculateRunningTotals.rb +11 -0
- data/examples/cookbookfiles/copyrecords.rb +73 -0
- data/examples/cookbookfiles/count.rb +26 -0
- data/examples/cookbookfiles/createRecordNavigatorHTML.rb +42 -0
- data/examples/cookbookfiles/createReportDashboard.rb +35 -0
- data/examples/cookbookfiles/createTable.rb +12 -0
- data/examples/cookbookfiles/deviation.rb +25 -0
- data/examples/cookbookfiles/downloadCookbook.rb +97 -0
- data/examples/cookbookfiles/downloadFile.rb +10 -0
- data/examples/cookbookfiles/downloadFilesToFolder.rb +81 -0
- data/examples/cookbookfiles/downloadToTextFile.rb +64 -0
- data/examples/cookbookfiles/dumpSchema.rb +11 -0
- data/examples/cookbookfiles/duplicateRecord.rb +8 -0
- data/examples/cookbookfiles/dynamicMethods.rb +33 -0
- data/examples/cookbookfiles/editRecords.rb +15 -0
- data/examples/cookbookfiles/findJohnsLast10Records.rb +17 -0
- data/examples/cookbookfiles/findRubyRecords.rb +17 -0
- data/examples/cookbookfiles/formatCurrency.rb +24 -0
- data/examples/cookbookfiles/formatDate.rb +10 -0
- data/examples/cookbookfiles/formatDuration.rb +27 -0
- data/examples/cookbookfiles/formatPercent.rb +24 -0
- data/examples/cookbookfiles/getAllValuesForFields.rb +18 -0
- data/examples/cookbookfiles/getAppDTMInfo.rb +29 -0
- data/examples/cookbookfiles/getApplicationVariable.rb +5 -0
- data/examples/cookbookfiles/getChildTableDBID.rb +11 -0
- data/examples/cookbookfiles/getColumnListForReport.rb +6 -0
- data/examples/cookbookfiles/getFieldChoices.rb +13 -0
- data/examples/cookbookfiles/getFieldIDs.rb +6 -0
- data/examples/cookbookfiles/getFieldNames.rb +6 -0
- data/examples/cookbookfiles/getLastModTime.rb +8 -0
- data/examples/cookbookfiles/getLastRecModTime.rb +8 -0
- data/examples/cookbookfiles/getNumRecords.rb +8 -0
- data/examples/cookbookfiles/getNumTables.rb +4 -0
- data/examples/cookbookfiles/getRecord.rb +5 -0
- data/examples/cookbookfiles/getRecordDisplayURL.rb +13 -0
- data/examples/cookbookfiles/getRecordsAddedToday.rb +20 -0
- data/examples/cookbookfiles/getRecordsAsJSON.rb +6 -0
- data/examples/cookbookfiles/getReportNames.rb +25 -0
- data/examples/cookbookfiles/getRoleInfo.rb +48 -0
- data/examples/cookbookfiles/getServerStatus.rb +11 -0
- data/examples/cookbookfiles/getSortListForReport.rb +6 -0
- data/examples/cookbookfiles/getTableIDs.rb +6 -0
- data/examples/cookbookfiles/getTableName.rb +8 -0
- data/examples/cookbookfiles/getTableNames.rb +25 -0
- data/examples/cookbookfiles/getTimeCreated.rb +8 -0
- data/examples/cookbookfiles/getTimeInMilliseconds.rb +5 -0
- data/examples/cookbookfiles/getUserInfo.rb +26 -0
- data/examples/cookbookfiles/getUserRole.rb +15 -0
- data/examples/cookbookfiles/intranet.rb +101 -0
- data/examples/cookbookfiles/isAverageField.rb +17 -0
- data/examples/cookbookfiles/isDbidString.rb +8 -0
- data/examples/cookbookfiles/isTotalField.rb +16 -0
- data/examples/cookbookfiles/iterateDBPages.rb +8 -0
- data/examples/cookbookfiles/iterateFilteredRecords.rb +12 -0
- data/examples/cookbookfiles/iterateJoinRecords.rb +68 -0
- data/examples/cookbookfiles/iterateRecordInfos.rb +8 -0
- data/examples/cookbookfiles/iterateRecords.rb +23 -0
- data/examples/cookbookfiles/iterateSummaryRecords.rb +13 -0
- data/examples/cookbookfiles/iterateUnionRecords.rb +38 -0
- data/examples/cookbookfiles/listAccessibleApplications.rb +6 -0
- data/examples/cookbookfiles/logRequestAndResponseXML.rb +8 -0
- data/examples/cookbookfiles/lookupFieldPropertyByName.rb +62 -0
- data/examples/cookbookfiles/lookupFieldTypeByName.rb +10 -0
- data/examples/cookbookfiles/makeCSVFile.rb +4 -0
- data/examples/cookbookfiles/makeSlideShow.rb +42 -0
- data/examples/cookbookfiles/makerecs.rb +64 -0
- data/examples/cookbookfiles/max.rb +26 -0
- data/examples/cookbookfiles/min.rb +26 -0
- data/examples/cookbookfiles/percent.rb +29 -0
- data/examples/cookbookfiles/printChildElements.rb +54 -0
- data/examples/cookbookfiles/printNewRecords.rb +12 -0
- data/examples/cookbookfiles/processRESTRequest.rb +21 -0
- data/examples/cookbookfiles/provisionAndInviteNewUser.rb +13 -0
- data/examples/cookbookfiles/purgeRecords.rb +15 -0
- data/examples/cookbookfiles/quickbase_adapter.rb.htm +397 -0
- data/examples/cookbookfiles/quickbase_record_finder.zip +0 -0
- data/examples/cookbookfiles/recordAndFieldIterator.rb +24 -0
- data/examples/cookbookfiles/runImport.rb +9 -0
- data/examples/cookbookfiles/runQuickBaseTwitterConnector.rb +41 -0
- data/examples/cookbookfiles/sendToQuickBase.rb +33 -0
- data/examples/cookbookfiles/setDBvar.rb +6 -0
- data/examples/cookbookfiles/showRequestAndResponseXML.rb +8 -0
- data/examples/cookbookfiles/sqlQuery.rb +11 -0
- data/examples/cookbookfiles/stopOnError.rb +10 -0
- data/examples/cookbookfiles/sum.rb +26 -0
- data/examples/cookbookfiles/twitterFromQuickBase.rb +42 -0
- data/examples/cookbookfiles/twitterWithQuickBase.rb +36 -0
- data/examples/cookbookfiles/uploadCSVData.rb +20 -0
- data/examples/cookbookfiles/uploadExcelData.rb +22 -0
- data/examples/cookbookfiles/uploadFileEveryHour.rb +18 -0
- data/examples/cookbookfiles/uploadFileIntoNewRecord.rb +8 -0
- data/examples/cookbookfiles/uploadFilesFromFolder.exe +0 -0
- data/examples/cookbookfiles/uploadFilesFromFolder.rb +69 -0
- data/examples/cookbookfiles/useCompanyURL.rb +12 -0
- data/examples/cookbookfiles/userRoles.rb +49 -0
- data/examples/cookbookfiles/watchCommunityForum.rb +5 -0
- data/examples/cookbookfiles/wikifyTable.rb +29 -0
- data/examples/cookbookfiles/xmlShortcuts.rb +33 -0
- data/examples/pmp/app/controllers/application.rb +7 -0
- data/examples/pmp/app/controllers/contacts_controller.rb +8 -0
- data/examples/pmp/app/controllers/document_library_controller.rb +2 -0
- data/examples/pmp/app/controllers/issues_controller.rb +5 -0
- data/examples/pmp/app/controllers/projects_controller.rb +22 -0
- data/examples/pmp/app/controllers/resources_controller.rb +2 -0
- data/examples/pmp/app/controllers/tasks_controller.rb +13 -0
- data/examples/pmp/app/controllers/time_cards_controller.rb +5 -0
- data/examples/pmp/app/helpers/application_helper.rb +3 -0
- data/examples/pmp/app/helpers/contacts_helper.rb +2 -0
- data/examples/pmp/app/helpers/document_library_helper.rb +2 -0
- data/examples/pmp/app/helpers/issues_helper.rb +2 -0
- data/examples/pmp/app/helpers/projects_helper.rb +2 -0
- data/examples/pmp/app/helpers/resources_helper.rb +2 -0
- data/examples/pmp/app/helpers/tasks_helper.rb +2 -0
- data/examples/pmp/app/helpers/time_cards_helper.rb +2 -0
- data/examples/pmp/app/models/contacts.rb +26 -0
- data/examples/pmp/app/models/document_library.rb +2 -0
- data/examples/pmp/app/models/issues.rb +6 -0
- data/examples/pmp/app/models/projects.rb +26 -0
- data/examples/pmp/app/models/resources.rb +2 -0
- data/examples/pmp/app/models/tasks.rb +12 -0
- data/examples/pmp/app/models/time_cards.rb +7 -0
- data/examples/pmp/app/schemas/contacts.xml +1 -0
- data/examples/pmp/app/schemas/document_library.xml +1 -0
- data/examples/pmp/app/schemas/issues.xml +1 -0
- data/examples/pmp/app/schemas/pmp.xml +1 -0
- data/examples/pmp/app/schemas/projects.xml +1 -0
- data/examples/pmp/app/schemas/readme.txt +8 -0
- data/examples/pmp/app/schemas/resources.xml +1 -0
- data/examples/pmp/app/schemas/tasks.xml +1 -0
- data/examples/pmp/app/schemas/time_cards.xml +1 -0
- data/examples/pmp/app/views/contacts/companies.rhtml +31 -0
- data/examples/pmp/app/views/contacts/project_contacts.rhtml +31 -0
- data/examples/pmp/app/views/issues/filter_issues.rhtml +26 -0
- data/examples/pmp/app/views/layouts/application.rhtml +56 -0
- data/examples/pmp/app/views/projects/all_projects.rhtml +33 -0
- data/examples/pmp/app/views/projects/home.rhtml +11 -0
- data/examples/pmp/app/views/projects/my_open_projects.rhtml +27 -0
- data/examples/pmp/app/views/projects/open_projects.rhtml +44 -0
- data/examples/pmp/app/views/projects/project_sorted_by_company.rhtml +40 -0
- data/examples/pmp/app/views/projects/projects_sorted_by_priority.rhtml +30 -0
- data/examples/pmp/app/views/projects/updated_projects.rhtml +0 -0
- data/examples/pmp/app/views/tasks/all_tasks.rhtml +27 -0
- data/examples/pmp/app/views/tasks/search.rhtml +23 -0
- data/examples/pmp/app/views/tasks/search2.rhtml +23 -0
- data/examples/pmp/app/views/tasks/search3.rhtml +23 -0
- data/examples/pmp/app/views/time_cards/summary.rhtml +38 -0
- data/examples/pmp/config/boot.rb +45 -0
- data/examples/pmp/config/database.yml +30 -0
- data/examples/pmp/config/environment.rb +60 -0
- data/examples/pmp/config/environments/development.rb +21 -0
- data/examples/pmp/config/environments/production.rb +18 -0
- data/examples/pmp/config/environments/test.rb +19 -0
- data/examples/pmp/config/routes.rb +23 -0
- data/examples/pmp/db/migrate/001_create_projects.rb +10 -0
- data/examples/pmp/db/migrate/002_create_tasks.rb +10 -0
- data/examples/pmp/db/migrate/003_create_issues.rb +10 -0
- data/examples/pmp/db/migrate/004_create_document_libraries.rb +10 -0
- data/examples/pmp/db/migrate/005_create_resources.rb +10 -0
- data/examples/pmp/db/migrate/006_create_time_cards.rb +10 -0
- data/examples/pmp/db/migrate/007_create_contacts.rb +10 -0
- data/examples/pmp/public/404.html +30 -0
- data/examples/pmp/public/500.html +30 -0
- data/examples/pmp/public/app.index.html +277 -0
- data/examples/pmp/public/dispatch.cgi +10 -0
- data/examples/pmp/public/dispatch.fcgi +24 -0
- data/examples/pmp/public/dispatch.rb +10 -0
- data/examples/pmp/public/favicon.ico +0 -0
- data/examples/pmp/public/images/rails.png +0 -0
- data/examples/pmp/public/javascripts/application.js +2 -0
- data/examples/pmp/public/javascripts/controls.js +833 -0
- data/examples/pmp/public/javascripts/dragdrop.js +942 -0
- data/examples/pmp/public/javascripts/effects.js +1088 -0
- data/examples/pmp/public/javascripts/prototype.js +2515 -0
- data/examples/pmp/public/robots.txt +1 -0
- data/examples/pmp/test/fixtures/contacts.yml +5 -0
- data/examples/pmp/test/fixtures/document_libraries.yml +5 -0
- data/examples/pmp/test/fixtures/issues.yml +5 -0
- data/examples/pmp/test/fixtures/projects.yml +5 -0
- data/examples/pmp/test/fixtures/resources.yml +5 -0
- data/examples/pmp/test/fixtures/tasks.yml +5 -0
- data/examples/pmp/test/fixtures/time_cards.yml +5 -0
- data/examples/pmp/test/functional/contacts_controller_test.rb +18 -0
- data/examples/pmp/test/functional/document_library_controller_test.rb +18 -0
- data/examples/pmp/test/functional/issues_controller_test.rb +18 -0
- data/examples/pmp/test/functional/projects_controller_test.rb +18 -0
- data/examples/pmp/test/functional/resources_controller_test.rb +18 -0
- data/examples/pmp/test/functional/tasks_controller_test.rb +18 -0
- data/examples/pmp/test/functional/time_cards_controller_test.rb +18 -0
- data/examples/pmp/test/test_helper.rb +28 -0
- data/examples/pmp/test/unit/contacts_test.rb +10 -0
- data/examples/pmp/test/unit/document_library_test.rb +10 -0
- data/examples/pmp/test/unit/issues_test.rb +10 -0
- data/examples/pmp/test/unit/projects_test.rb +10 -0
- data/examples/pmp/test/unit/resources_test.rb +10 -0
- data/examples/pmp/test/unit/tasks_test.rb +10 -0
- data/examples/pmp/test/unit/time_cards_test.rb +10 -0
- data/lib/QuickBaseClient.rb +5054 -0
- data/lib/QuickBaseCommandLineClient.rb +401 -0
- data/lib/QuickBaseContactsAppBuilder.rb +419 -0
- data/lib/QuickBaseEmailer.rb +334 -0
- data/lib/QuickBaseEventNotifier.rb +592 -0
- data/lib/QuickBaseMisc.rb +96 -0
- data/lib/QuickBaseObjects.rb +566 -0
- data/lib/QuickBaseRSSGenerator.rb +286 -0
- data/lib/QuickBaseTextData.rb +545 -0
- data/lib/QuickBaseTwitterConnector.rb +300 -0
- data/lib/QuickBaseWebClient.rb +126 -0
- data/lib/WorkPlaceClient.rb +45 -0
- data/lib/qbc.makeCSVFile.qbc +4 -0
- data/lib/qbc.makeCSVFile.rb +17 -0
- data/lib/quickbase_adapter.rb +320 -0
- data/lib/runFieldEntryDialog.rb +151 -0
- data/lib/runOfflineFieldEntryDialog.rb +203 -0
- data/rakefile +100 -0
- data/test/run_tests.bat +7 -0
- data/test/spec_all_tests.rb +13 -0
- data/test/spec_smoke_tests.rb +58 -0
- data/test/spec_workplace_addrecord_test.rb +46 -0
- data/test/spec_workplace_base_test.rb +57 -0
- data/test/spec_workplace_editrecord_test.rb +38 -0
- data/test/spec_workplace_json_test.rb +38 -0
- data/test/spec_workplace_objects_test.rb +39 -0
- data/test/spec_workplace_smoke_tests.rb +45 -0
- metadata +353 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
#--#####################################################################
|
2
|
+
# Copyright (c) 2009 Gareth Lewis and Intuit, Inc.
|
3
|
+
#
|
4
|
+
# All rights reserved. This program and the accompanying materials
|
5
|
+
# are made available under the terms of the Eclipse Public License v1.0
|
6
|
+
# which accompanies this distribution, and is available at
|
7
|
+
# http://www.opensource.org/licenses/eclipse-1.0.php
|
8
|
+
#
|
9
|
+
# Contributors:
|
10
|
+
# Gareth Lewis - Initial contribution.
|
11
|
+
# Intuit Partner Platform.
|
12
|
+
#++#####################################################################
|
13
|
+
|
14
|
+
require 'QuickBaseTextData'
|
15
|
+
require 'tk'
|
16
|
+
|
17
|
+
# Display a dialog with one text entry field, and buttons to send the text to a
|
18
|
+
# field in a new record in QuickBase, go to QuickBase, and to close the dialog.
|
19
|
+
# * 'dbid' must be a valid table id.
|
20
|
+
# * 'field' must be the name or id of a text field in the 'dbid' table.
|
21
|
+
# If you can't connect to QuickBase, data will be written to a file in your
|
22
|
+
# current working directory then sent to QuickBase next time you are
|
23
|
+
# able to connect. Note that you must have connected to QuickBase at least
|
24
|
+
# once before you can enter data offline.
|
25
|
+
def runOfflineFieldEntryDialog(username,password,dbid,field)
|
26
|
+
|
27
|
+
connected = false
|
28
|
+
appendToOfflineFile = false
|
29
|
+
|
30
|
+
numTextLines = 1
|
31
|
+
tableName = ""
|
32
|
+
fieldID = ""
|
33
|
+
fieldName = ""
|
34
|
+
|
35
|
+
offlineDataFileName = "#{dbid}.offline.txt"
|
36
|
+
offlineConfigFileName = "#{dbid}.offline.cfg"
|
37
|
+
|
38
|
+
if FileTest.exist?(offlineConfigFileName)
|
39
|
+
File.open(offlineConfigFileName,"r"){|f|
|
40
|
+
cfg = f.gets
|
41
|
+
tableName, numTextLines, fieldID, fieldName = cfg.split(":::")
|
42
|
+
numTextLines = numTextLines.to_i
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
@qbc = QuickBase::Client.new(username,password)
|
47
|
+
if @qbc and @qbc.requestSucceeded
|
48
|
+
connected = true
|
49
|
+
if FileTest.exist?(offlineDataFileName)
|
50
|
+
QuickBase::TextData.uploadData(username,password,offlineDataFileName)
|
51
|
+
File.delete(offlineDataFileName)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
appendToOfflineFile = true if FileTest.exist?(offlineDataFileName)
|
55
|
+
end
|
56
|
+
|
57
|
+
@offlineDataFile = nil
|
58
|
+
if connected
|
59
|
+
@qbc.getSchema(dbid)
|
60
|
+
if @qbc.requestSucceeded
|
61
|
+
field = field.join(' ')
|
62
|
+
field.strip!
|
63
|
+
fieldID = @qbc.lookupFieldIDByName(field)
|
64
|
+
if fieldID
|
65
|
+
fieldName = field
|
66
|
+
else
|
67
|
+
fieldName = lookupFieldNameFromID(field)
|
68
|
+
fieldID = field if fieldName
|
69
|
+
end
|
70
|
+
tableName = @qbc.getResponseElement( "table/name" ).text
|
71
|
+
if fieldID and fieldName
|
72
|
+
fieldElement = @qbc.lookupField(fieldID)
|
73
|
+
numLinesProc = proc { |element|
|
74
|
+
if element.is_a?(REXML::Element) and element.name == "num_lines" and element.has_text?
|
75
|
+
numTextLines = element.text.to_i
|
76
|
+
end
|
77
|
+
}
|
78
|
+
@qbc.processChildElements(fieldElement, true, numLinesProc)
|
79
|
+
File.open(offlineConfigFileName,"w"){|f|f.write("#{tableName}:::#{numTextLines}:::#{fieldID}:::#{fieldName}")}
|
80
|
+
else
|
81
|
+
Tk.messageBox({"icon"=>"error","title"=>"Oops!", "message" => "Error finding the QuickBase field '#{fieldName}' in the '#{tableName}' table."})
|
82
|
+
end
|
83
|
+
else
|
84
|
+
Tk.messageBox({"icon"=>"error","title"=>"Oops!", "message" => "Error finding the QuickBase table with the '#{dbid}' id."})
|
85
|
+
end
|
86
|
+
elsif appendToOfflineFile
|
87
|
+
@offlineDataFile = File.open(offlineDataFileName, "a")
|
88
|
+
else
|
89
|
+
@offlineDataFile = File.open(offlineDataFileName, "w")
|
90
|
+
@offlineDataFile.puts("dbid:#{dbid}")
|
91
|
+
end
|
92
|
+
|
93
|
+
root = TkRoot.new{ title tableName }
|
94
|
+
frame = TkFrame.new(root){
|
95
|
+
borderwidth 4
|
96
|
+
width 60
|
97
|
+
pack "side" => "top"
|
98
|
+
}
|
99
|
+
if numTextLines == 1
|
100
|
+
labelText = "Enter '#{fieldName}' and press Enter or click 'Send to QuickBase':"
|
101
|
+
else
|
102
|
+
labelText = "Enter '#{fieldName}' and click 'Send to QuickBase':"
|
103
|
+
end
|
104
|
+
fieldLabel = TkLabel.new(frame){
|
105
|
+
text labelText
|
106
|
+
font "Arial 10 bold"
|
107
|
+
pack "side"=>"top", "expand" => true
|
108
|
+
}
|
109
|
+
|
110
|
+
entryField = nil
|
111
|
+
if numTextLines == 1
|
112
|
+
entryField = TkEntry.new(frame){
|
113
|
+
font "Arial 10 bold"
|
114
|
+
pack "fill" => "x", "expand" => true, "side" => "top", "padx" =>5, "pady"=>5
|
115
|
+
}
|
116
|
+
entryField.bind('Key-Return') {|e|
|
117
|
+
value = entryField.get
|
118
|
+
if connected
|
119
|
+
@qbc.clearFieldValuePairList
|
120
|
+
@qbc.addFieldValuePair(nil,fieldID,nil,value)
|
121
|
+
@qbc.addRecord(dbid,@qbc.fvlist)
|
122
|
+
else
|
123
|
+
@offlineDataFile.puts("record:\n#{fieldName}:#{value}")
|
124
|
+
end
|
125
|
+
entryField.value = ""
|
126
|
+
}
|
127
|
+
elsif numTextLines > 1
|
128
|
+
entryField = TkText.new(frame){
|
129
|
+
height numTextLines
|
130
|
+
width 60
|
131
|
+
font "Arial 10 bold"
|
132
|
+
pack "fill" => "both", "expand" => true, "side" => "top", "padx" =>5, "pady"=>5
|
133
|
+
wrap "word"
|
134
|
+
}
|
135
|
+
end
|
136
|
+
entryField.focus
|
137
|
+
|
138
|
+
buttonFrame = TkFrame.new(frame){
|
139
|
+
pack "side" => "bottom"
|
140
|
+
width 50
|
141
|
+
}
|
142
|
+
sendButton = TkButton.new(buttonFrame){
|
143
|
+
text "Send To QuickBase"
|
144
|
+
underline 0
|
145
|
+
font "Arial 10 bold"
|
146
|
+
pack "side"=>"left", "padx"=>5, "pady"=>5
|
147
|
+
}
|
148
|
+
sendButton.command {
|
149
|
+
if numTextLines > 1
|
150
|
+
value = entryField.get("1.0","end")
|
151
|
+
else
|
152
|
+
value = entryField.get
|
153
|
+
end
|
154
|
+
if connected
|
155
|
+
@qbc.clearFieldValuePairList
|
156
|
+
@qbc.addFieldValuePair(nil,fieldID,nil,value)
|
157
|
+
@qbc.addRecord(dbid,@qbc.fvlist)
|
158
|
+
else
|
159
|
+
@offlineDataFile.puts("record:\n#{fieldName}:#{value}")
|
160
|
+
end
|
161
|
+
entryField.value = ""
|
162
|
+
}
|
163
|
+
|
164
|
+
if connected
|
165
|
+
launchButton = TkButton.new(buttonFrame){
|
166
|
+
text "Go to QuickBase..."
|
167
|
+
underline 0
|
168
|
+
font "Arial 10 bold"
|
169
|
+
pack "side"=>"left","padx"=>5, "pady"=>5
|
170
|
+
}
|
171
|
+
launchButton.command {
|
172
|
+
url = "http://www.quickbase.com/db/#{dbid}"
|
173
|
+
url = "start #{url}" if RUBY_PLATFORM.split("-")[1].include?("mswin")
|
174
|
+
system(url)
|
175
|
+
}
|
176
|
+
end
|
177
|
+
closeButton = TkButton.new(buttonFrame){
|
178
|
+
text "Close"
|
179
|
+
underline 0
|
180
|
+
font "Arial 10 bold"
|
181
|
+
pack "side"=>"right","padx"=>5, "pady"=>5
|
182
|
+
}
|
183
|
+
closeButton.command { Tk.exit }
|
184
|
+
|
185
|
+
root.bind('Alt-KeyRelease-s') {|e| sendButton.invoke }
|
186
|
+
root.bind('Alt-KeyRelease-l') {|e| launchButton.invoke }
|
187
|
+
root.bind('Alt-KeyRelease-c') {|e| closeButton.invoke }
|
188
|
+
|
189
|
+
Tk.mainloop
|
190
|
+
end
|
191
|
+
|
192
|
+
if ARGV[3]
|
193
|
+
runOfflineFieldEntryDialog(ARGV[0],ARGV[1],ARGV[2],ARGV[3..-1])
|
194
|
+
else
|
195
|
+
puts "\nusage: ruby runOfflineFieldEntryDialog.rb username password dbid field"
|
196
|
+
puts "\n'dbid' must be a valid table id."
|
197
|
+
puts "'field' must be the name or id of a text field in the 'dbid' table."
|
198
|
+
puts "'field' can be more than one word, e.g. 'To-Do Item'."
|
199
|
+
puts "If you can't connect to QuickBase, data will be written to a file in"
|
200
|
+
puts "your current working directory then sent to QuickBase next time you"
|
201
|
+
puts "are able to connect. Note that you must have connected to QuickBase"
|
202
|
+
puts "at least once before you can enter data offline.\n"
|
203
|
+
end
|
data/rakefile
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.rubyforge_project = "orphans" # prevents WARNING
|
8
|
+
|
9
|
+
if RUBY_PLATFORM == "java" # jruby
|
10
|
+
s.name = "ipp_quickbase_devkit_jruby" # saves people having to download additional jruby-specific gems
|
11
|
+
s.description = "The ipp_quickbase_devkit_jruby wraps the QuickBase HTTP API and adds a lot of classes and methods to minimize the amount of code need to get useful things done."
|
12
|
+
s.add_dependency("json-jruby")
|
13
|
+
s.add_dependency("jruby-openssl")
|
14
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc", "--title", "ipp_quickbase_devkit_jruby: JRuby client for database applications on www.quickbase.com and workplace.intuit.com"]
|
15
|
+
s.post_install_message = %q{**************************************************
|
16
|
+
|
17
|
+
Thank you for installing ipp_quickbase_devkit_jruby.
|
18
|
+
Distributed under the Eclipse Public License Version 1.0.
|
19
|
+
|
20
|
+
**************************************************
|
21
|
+
}
|
22
|
+
else
|
23
|
+
s.name = "ipp_quickbase_devkit"
|
24
|
+
s.description = "The ipp_quickbase_devkit wraps the QuickBase HTTP API and adds a lot of classes and methods to minimize the amount of code need to get useful things done."
|
25
|
+
s.add_dependency("json") if RUBY_VERSION.include?("1.8.")
|
26
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc", "--title", "ipp_quickbase_devkit: Ruby client for database applications on www.quickbase.com and workplace.intuit.com"]
|
27
|
+
s.post_install_message = %q{**************************************************
|
28
|
+
|
29
|
+
Thank you for installing ipp_quickbase_devkit.
|
30
|
+
Distributed under the Eclipse Public License Version 1.0.
|
31
|
+
|
32
|
+
**************************************************
|
33
|
+
}
|
34
|
+
|
35
|
+
end
|
36
|
+
s.version = "0.0.1"
|
37
|
+
s.date = "2009-07-01"
|
38
|
+
s.authors = ["Gareth Lewis"]
|
39
|
+
s.email = "dev-ipp_dev_kits@code.intuit.com"
|
40
|
+
s.summary = "The ipp_quickbase_devkit is a Ruby wrapper for the QuickBase HTTP API."
|
41
|
+
s.homepage = "https://code.intuit.com/sf/projects/ipp_dev_kits"
|
42
|
+
s.has_rdoc = true
|
43
|
+
s.extra_rdoc_files = ["LICENSE","README.rdoc"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.add_dependency("rspec", [">= 1.2.7"])
|
46
|
+
s.add_development_dependency("rspec", [">= 1.2.7"])
|
47
|
+
s.required_ruby_version = ">=1.8.6"
|
48
|
+
s.platform = Gem::Platform::RUBY
|
49
|
+
s.files = FileList["LICENSE","README.rdoc","rakefile","examples/**/*.","examples/**/*.*","doc/*.*","lib/*.rb","lib/*.qbc","test/*.rb","test/*.bat"].exclude(".svn").to_a
|
50
|
+
end
|
51
|
+
|
52
|
+
Rake::GemPackageTask.new(spec).define
|
53
|
+
|
54
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
55
|
+
t.spec_files = FileList['spec_all_tests.rb']
|
56
|
+
t.ruby_opts = ['-C test']
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'Uninstall dev gem'
|
60
|
+
task :uninstall_gem do
|
61
|
+
if RUBY_PLATFORM == "java"
|
62
|
+
sh 'jruby -S gem uninstall ipp_quickbase_devkit_jruby'
|
63
|
+
else
|
64
|
+
sh 'gem uninstall ipp_quickbase_devkit'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Build dev gem'
|
69
|
+
task :build_gem do
|
70
|
+
Rake::Task[:repackage].invoke
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'Install dev gem'
|
74
|
+
task :install_gem do
|
75
|
+
if RUBY_PLATFORM == "java"
|
76
|
+
sh 'jruby -S gem install pkg/ipp_quickbase_devkit_jruby'
|
77
|
+
else
|
78
|
+
sh 'gem install pkg/ipp_quickbase_devkit'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc '(Default task) Uninstalls, rebuilds & installs gem from source'
|
83
|
+
task :full_rebuild do
|
84
|
+
Rake::Task[:uninstall_gem].invoke
|
85
|
+
Rake::Task[:repackage].invoke
|
86
|
+
Rake::Task[:install_gem].invoke
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'Full rebuild, then run tests'
|
90
|
+
task :full_rebuild_and_test do
|
91
|
+
Rake::Task[:full_rebuild].invoke
|
92
|
+
puts "**************************************************"
|
93
|
+
puts ""
|
94
|
+
puts " Running unit tests"
|
95
|
+
puts ""
|
96
|
+
puts "**************************************************"
|
97
|
+
Rake::Task[:spec].invoke
|
98
|
+
end
|
99
|
+
|
100
|
+
task :default => :full_rebuild
|
data/test/run_tests.bat
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
def ruby19?
|
4
|
+
RUBY_VERSION >= "1.9"
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'spec_smoke_tests'
|
9
|
+
require 'spec_workplace_smoke_tests'
|
10
|
+
require 'spec_workplace_objects_test'
|
11
|
+
require 'spec_workplace_addrecord_test'
|
12
|
+
require 'spec_workplace_editrecord_test'
|
13
|
+
require 'spec_workplace_json_test'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
describe "Smoke Test" do
|
5
|
+
|
6
|
+
it "should show that the basic ruby files are in the regular ruby paths" do
|
7
|
+
found = false
|
8
|
+
$:.each{|path| found = true if File.exist?("#{path}/date.rb") }
|
9
|
+
found.should == true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should show that the main ipp_quickbase_devkit src file is not in the regular ruby paths" do
|
13
|
+
found = false
|
14
|
+
$:.each{|path| found = true if File.exist?("#{path}/QuickBaseClient.rb") } unless ruby19?
|
15
|
+
found.should == false
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should show that the main ipp_quickbase_devkit src file is not loaded by default" do
|
19
|
+
found = false
|
20
|
+
$".each{|path| found = true if path.include? "QuickBaseClient.rb" }
|
21
|
+
found.should == false
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should find ipp_quickbase_devkit" do
|
25
|
+
found = require 'QuickBaseClient'
|
26
|
+
found.should == true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create a QuickBase::Client" do
|
30
|
+
qbc_required = require 'QuickBaseClient'
|
31
|
+
qbc = QuickBase::Client.new
|
32
|
+
qbc.should_not == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should create a QuickBase::CommandLineClient" do
|
36
|
+
require 'QuickBaseCommandLineClient'
|
37
|
+
qbc = QuickBase::CommandLineClient.new
|
38
|
+
qbc.should_not == nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should create a QuickBase::WebClient" do
|
42
|
+
require 'QuickBaseWebClient'
|
43
|
+
qbc = QuickBase::WebClient.new(false)
|
44
|
+
qbc.should_not == nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should show that the gem searching is turned on" do
|
48
|
+
gemSearching = ENV["RUBYOPT"].include? "-rubygems"
|
49
|
+
gemSearching.should == true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should NOT find ipp_quickbase_devkit when -rubygems option is off" do
|
53
|
+
ENV["RUBYOPT"]=""
|
54
|
+
found = require 'QuickBaseClient'
|
55
|
+
found.should == false
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
require 'spec_workplace_base_test'
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
describe "Workplace Add Record test" do
|
6
|
+
|
7
|
+
it "should add a Person" do
|
8
|
+
|
9
|
+
require 'WorkPlaceClient'
|
10
|
+
class WorkPlaceAddRecordTest
|
11
|
+
include WorkPlaceBaseTest
|
12
|
+
end
|
13
|
+
wpart = WorkPlaceAddRecordTest.new
|
14
|
+
workPlaceClient = wpart.setup
|
15
|
+
workPlaceClient.should_not == nil
|
16
|
+
|
17
|
+
personFieldValues = Hash["First Name", "FirstName", "Last Name", "LastName", "Email", "FirstNameLastName@email.com","Web Page","http://www.FirstNameLastName.com","Opt In","1","DOB","12-12-1978","Attention Span","1","Favorite Number","7","Amount Owed", "34.87","Rating", "4","PhoneNumber", "454-323-3456","Bedtime", "23","Address", "10 Downing Street"]
|
18
|
+
workPlaceClient.setFieldValues(personFieldValues)
|
19
|
+
rid, update_id = workPlaceClient.addRecord(wpart.personTableDBID,workPlaceClient.fvlist)
|
20
|
+
rid.should_not == nil
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should add a Person with an Image file attachment" do
|
25
|
+
|
26
|
+
require 'WorkPlaceClient'
|
27
|
+
class WorkPlaceAddRecordTest
|
28
|
+
include WorkPlaceBaseTest
|
29
|
+
end
|
30
|
+
wpart = WorkPlaceAddRecordTest.new
|
31
|
+
workPlaceClient = wpart.setup
|
32
|
+
workPlaceClient.should_not == nil
|
33
|
+
|
34
|
+
workPlaceClient.addFieldValuePair("First Name",nil,nil,"Whatever")
|
35
|
+
workPlaceClient.addFieldValuePair("Last Name",nil,nil,"Works")
|
36
|
+
workPlaceClient.addFieldValuePair("Image",nil,"FileName","File Contents") # contents from memory
|
37
|
+
rid, update_id = workPlaceClient.addRecord(wpart.personTableDBID,workPlaceClient.fvlist)
|
38
|
+
rid.should_not == nil
|
39
|
+
|
40
|
+
fid = workPlaceClient.lookupFieldIDByName("Image", wpart.personTableDBID)
|
41
|
+
response, filecontents = workPlaceClient._downLoadFile(rid,fid)
|
42
|
+
filecontents.should == "File Contents"
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
module WorkPlaceBaseTest
|
3
|
+
|
4
|
+
attr_reader :workPlaceClient, :testAppDBID, :testAppName, :personTableDBID, :personFields
|
5
|
+
|
6
|
+
def setup
|
7
|
+
|
8
|
+
if not File.exist?("test.config")
|
9
|
+
File.open("test.config","w"){|f|
|
10
|
+
f.puts("username:<enter your workplace username>")
|
11
|
+
f.puts("password:<enter your workplace password>")
|
12
|
+
f.puts("appname:<enter the name of an existing test application, e.g. MyTestApp>")
|
13
|
+
f.puts("apptoken:<enter a valid application token for your test application>")
|
14
|
+
raise "***Please fill out the fields in test.config***"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
@options = {}
|
19
|
+
#@options["printRequestsAndResponses"]=true
|
20
|
+
@options["stopOnError"]=true
|
21
|
+
IO.foreach("test.config"){|line|
|
22
|
+
key,value = line.split(/:/)
|
23
|
+
@options[key]=value.strip if key and value
|
24
|
+
}
|
25
|
+
|
26
|
+
raise "'username' missing from test.config" if !@options["username"]
|
27
|
+
raise "'password' missing from test.config" if !@options["password"]
|
28
|
+
raise "'appname' missing from test.config" if !@options["appname"]
|
29
|
+
raise "'apptoken' missing from test.config" if !@options["apptoken"]
|
30
|
+
|
31
|
+
@workPlaceClient = QuickBase::WorkPlaceClient.init(@options)
|
32
|
+
|
33
|
+
#@workPlaceClient.printRequestsAndResponses=true
|
34
|
+
|
35
|
+
@workPlaceClient.grantedDBs().each{|dbinfo| @testAppDBID = dbinfo.dbid if dbinfo.dbname == @options["appname"] }
|
36
|
+
|
37
|
+
@testAppName = "Test copy of #{@options['appname']}"
|
38
|
+
@workPlaceClient.grantedDBs().each{|dbinfo| @workPlaceClient.deleteDatabase(dbinfo.dbid) if dbinfo.dbname == @testAppName }
|
39
|
+
@testAppDBID = @workPlaceClient.cloneDatabase(@testAppDBID, @testAppName, @testAppName, true) if @testAppDBID
|
40
|
+
|
41
|
+
@testAppName = @options['appname'] unless @testAppDBID
|
42
|
+
@testAppDBID = @workPlaceClient.createDatabase(@options["appname"],@options["appname"]) unless @testAppDBID
|
43
|
+
|
44
|
+
raise "Unable to clone or create an application with the name #{@options['appname']}" unless @testAppDBID
|
45
|
+
|
46
|
+
@personsTableName = "Persons"
|
47
|
+
@personTableDBID = @workPlaceClient.createTable(@personsTableName, @testAppDBID)
|
48
|
+
@personFields = Hash["First Name", "text", "Last Name", "text", "Email", "email","Image","file","Web Page","url","Opt In","checkbox","DOB","date","Attention Span","duration","Favorite Number","float","Favorite Number Squared","float","Amount Owed", "currency","Rating", "rating","PhoneNumber", "phone","Bedtime", "timeofday","Address", "text"]
|
49
|
+
@personFields.each{|name,type|
|
50
|
+
fid,label = @workPlaceClient.addField(@personTableDBID,name,type)
|
51
|
+
@workPlaceClient.setFieldProperties(@personTableDBID,{"formula" => "[Favorite Number] * [Favorite Number]"},fid) if name == "Favorite Number Squared"
|
52
|
+
@workPlaceClient.setFieldProperties(@personTableDBID,{"num_lines" => "3"},fid) if name == "Address"
|
53
|
+
}
|
54
|
+
@workPlaceClient
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|