-
Notifications
You must be signed in to change notification settings - Fork 1
/
DBSoap.h
207 lines (149 loc) · 7.3 KB
/
DBSoap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* -*- mode: objc -*-
Project: DataBasin
Copyright (C) 2008-2021 Free Software Foundation
Author: Riccardo Mottola
Created: 2008-11-13 22:44:45 +0100 by Riccardo Mottola
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#import <Foundation/Foundation.h>
#import <WebServices/WebServices.h>
#if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
#ifndef NSUInteger
#define NSUInteger unsigned int
#endif
#ifndef NSInteger
#define NSInteger int
#endif
#endif
/* some Salesforce limits */
#define MAX_SOQL_LENGTH 20000
#define MAX_SOQL WHERE_LENGTH 4000
#define MAX_BATCH_SIZE 200
#define RETRIEVE_BATCH_SIZE 2000
#define CLIENT_NAME @"DataBasin"
@class DBSObject;
@protocol DBProgressProtocol;
@protocol DBLoggerProtocol;
@interface DBSoap : NSObject
{
id<DBLoggerProtocol> logger;
/* salesforce.com session variables */
NSString *sessionId;
NSURL *serverURL;
BOOL passwordExpired;
NSDictionary *userInfo;
/* list of all objects, custom and not */
NSArray *sObjectList;
/* list of all object names, custom and not */
NSMutableArray *sObjectNamesList;
/* Map of described objects, for which details are present */
NSMutableDictionary *sObjectDetailsDict;
/** should run assignment rules on create, update, upsert */
BOOL runAssignmentRules;
/** create, update, upsert batch size */
unsigned upBatchSize;
/** query batch size */
unsigned downBatchSize;
/** actually used SOQL length, must be inferior to MAX_SOQL_LENGTH */
unsigned maxSOQLLength;
/** Timeout in seconds, for generic methods */
unsigned standardTimeoutSec;
/** Timeout in seconds, for query methods */
unsigned queryTimeoutSec;
/** is executing */
NSUInteger *busyCount;
NSRecursiveLock *lockBusy;
/** describe each object in a query to get field types */
BOOL enableFieldTypesDescribeForQuery;
/** return positive results */
BOOL returnSuccessResults;
/** return multiple errors per object, else only the first is retrieved */
BOOL returnMultipleErrors;
}
+ (NSArray *)fieldsByParsingQuery:(NSString *)query;
+ (NSURL *)loginURLProduction;
+ (NSURL *)loginURLTest;
+ (GWSService *)gwserviceForDBSoap;
- (void)login :(NSURL *)url :(NSString *)userName :(NSString *)password;
- (void)setLogger: (id<DBLoggerProtocol>)l;
- (id<DBLoggerProtocol>)logger;
- (void)setRunAssignmentRules :(BOOL)flag;
- (BOOL)runAssignmentRules;
- (unsigned)upBatchSize;
- (void)setUpBatchSize:(unsigned)size;
- (unsigned)downBatchSize;
- (void)setDownBatchSize:(unsigned)size;
- (unsigned)maxSOQLLength;
- (void)setMaxSOQLLength:(unsigned)size;
- (NSMutableArray *)queryFull :(NSString *)queryString queryAll:(BOOL)all progressMonitor:(id<DBProgressProtocol>)p;
- (NSString *)query :(NSString *)queryString queryAll:(BOOL)all toArray:(NSMutableArray *)objects progressMonitor:(id<DBProgressProtocol>)p;
- (NSString *)queryMore :(NSString *)locator toArray:(NSMutableArray *)objects;
- (void)queryIdentify :(NSString *)queryString with: (NSArray *)identifiers queryAll:(BOOL)all fromArray:(NSArray *)fromArray toArray:(NSMutableArray *)outArray withBatchSize:(int)batchSize progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)create :(NSString *)objectName fromArray:(NSMutableArray *)objects progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)update :(NSString *)objectName fromArray:(NSMutableArray *)objects progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)delete :(NSArray *)array progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)undelete :(NSArray *)array progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)retrieveWithQuery:(NSString *)queryString andObjects:(NSArray *)objectList;
- (NSMutableArray *)retrieveFields:(NSArray *)fieldList ofObject:(NSString *)objectType fromArray:(NSArray *)objectList;
- (NSMutableDictionary *)getUpdated :(NSString *)objectType :(NSDate *)startDate :(NSDate *)endDate;
- (NSMutableDictionary *)getDeleted :(NSString *)objectType :(NSDate *)startDate :(NSDate *)endDate;
- (NSArray *)describeGlobal;
- (NSArray *)sObjects;
- (NSArray *)sObjectNames;
- (void)updateObjects;
- (DBSObject *)describeSObject: (NSString *)objectType;
- (NSString *)identifyObjectById:(NSString *)sfId;
- (void)flushObjectDetails;
- (BOOL)enableFieldTypesDescribeForQuery;
- (void)setEnableFieldTypesDescribeForQuery:(BOOL)flag;
- (NSMutableDictionary *)sObjectDetailsDict;
- (void)setSObjectDetailsDict:(NSMutableDictionary *)md;
- (NSString *) sessionId;
- (void) setSessionId:(NSString *)session;
- (NSURL *) serverURL;
- (void) setServerURL:(NSURL *)url;
- (BOOL) passwordExpired;
- (NSDictionary *) userInfo;
- (void)setStandardTimeout:(unsigned)sec;
- (void)setQueryTimeout:(unsigned)sec;
- (unsigned)standardTimeout;
- (unsigned)queryTimeout;
- (BOOL)isBusy;
@end
@interface DBSoap (Selecting)
- (NSString *)_query :(NSString *)queryString queryAll:(BOOL)all toArray:(NSMutableArray *)objects declaredSize:(NSUInteger *)ds progressMonitor:(id<DBProgressProtocol>)p;
- (NSString *)_queryMore :(NSString *)locator toArray:(NSMutableArray *)objects;
- (NSMutableArray *)_queryFull :(NSString *)queryString queryAll:(BOOL)all progressMonitor:(id<DBProgressProtocol>)p;
- (void)_queryIdentify :(NSString *)queryString with: (NSArray *)identifiers queryAll:(BOOL)all fromArray:(NSArray *)fromArray toArray:(NSMutableArray *)outArray withBatchSize:(int)batchSize progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)_retrieveFields:(NSArray *)fieldList ofObject:(NSString*)objectType fromObjects:(NSArray *)objectList;
@end
@interface DBSoap (Updating)
- (NSMutableArray *)_update :(NSString *)objectName fromArray:(NSMutableArray *)objects progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableDictionary *)_getUpdated :(NSString *)objectType :(NSDate *)startDate :(NSDate *)endDate;
@end
@interface DBSoap (Creating)
- (NSMutableArray *)_create :(NSString *)objectName fromArray:(NSMutableArray *)objects progressMonitor:(id<DBProgressProtocol>)p;
@end
@interface DBSoap (Deleting)
- (NSMutableArray *)_delete :(NSArray *)array progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableArray *)_undelete :(NSArray *)array progressMonitor:(id<DBProgressProtocol>)p;
- (NSMutableDictionary *)_getDeleted :(NSString *)objectType :(NSDate *)startDate :(NSDate *)endDate;
@end
@interface DBSoap (PrivateMethods)
- (DBSObject *)_describeSObject: (NSString *)objectType;
- (NSArray *)_describeGlobal;
- (id)adjustFormatForField:(NSString *)key forValue:(id)value inObject:(DBSObject *)sObj;
- (NSString *)interpretString:(NSString *)valueStr forField:(NSString *)fieldName forObject:(NSString *)objectName;
- (void)extractQueryRecords:(NSArray *)records toObjects:(NSMutableArray *)objects;
@end