Changes between Version 43 and Version 44 of FDORfc50
- Timestamp:
- 07/19/10 09:34:17 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FDORfc50
v43 v44 43 43 * '''Cons''': We need to change all the providers leading to a big effort from everyone. 44 44 45 * Enhance FdoISelect, add a new method ''!GetJoinCriteria()'' with the default implementation of the method throwing an exception . Providers which want to implement this new method must override it and provide a detailed implementation. Even though FdoISelect is declared as ''interface'' we do not have real interfaces in the FDO C++ API, and abstract methods can co-exist with those that have a default implementation. A good example here are the locking methods on the select command. Most providers do not support locking and have to provide an empty implementation (usually to throw an exception), creating more code on provider side. A better plan would have provided a default implementation in the FdoISelect base class. Following this idea, this alternative will just modify the FdoISelect base class, allowing providers that that will not support joins to remain unchanged. These providers will inherit the default implementation. Looking at FdoISelect there are already two methods which provide default implementation: !AddRef() and Release(), so adding default implementation for the new method will not be something totally new. As with option 2 above: Two new capability functions will be added to the FDO FdoIConnectionCapabilities Interface so that applications can determine if a provider supports the join criteria, supported join types and sub-selects. These new capabilities would be named: !SupportsJoins(), !GetJoinTypes() & !SupportsSubSelects(). A few other changes must be done in order to handle sub-selects.45 * Enhance FdoISelect, add a new method ''!GetJoinCriteria()'' with the default implementation of the method throwing an exception, also add two new methods used to set alias for the main class: !SetAlias() & !GetAlias() having empty implementation (no exception will be thrown here). Providers which want to implement this new method must override it and provide a detailed implementation. Even though FdoISelect is declared as ''interface'' we do not have real interfaces in the FDO C++ API, and abstract methods can co-exist with those that have a default implementation. A good example here are the locking methods on the select command. Most providers do not support locking and have to provide an empty implementation (usually to throw an exception), creating more code on provider side. A better plan would have provided a default implementation in the FdoISelect base class. Following this idea, this alternative will just modify the FdoISelect base class, allowing providers that that will not support joins to remain unchanged. These providers will inherit the default implementation. Looking at FdoISelect there are already two methods which provide default implementation: !AddRef() and Release(), so adding default implementation for the new method will not be something totally new. As with option 2 above: Two new capability functions will be added to the FDO FdoIConnectionCapabilities Interface so that applications can determine if a provider supports the join criteria, supported join types and sub-selects. These new capabilities would be named: !SupportsJoins(), !GetJoinTypes() & !SupportsSubSelects(). A few other changes must be done in order to handle sub-selects. 46 46 * '''Pros''': this solution will not add more complexity to the API, we do not need to change any provider.[[BR]] 47 47 * '''Cons''': None. … … 51 51 The last option seems to be the best solution since will not enforce other providers to add a blank implementation for the new method and also will not add a new command. We avoid having two select commands one "extended" and one "join" this way we also eliminate a confusion which might show-up in commands naming. Also it opens a different approach to update a base class without changing all providers to add a blank implementation. 52 52 53 The new method added on FdoISelect will have a default implementation throwing an exception:53 The new methods added on FdoISelect will have a default implementation throwing an exception or empty implementation: 54 54 55 55 {{{ 56 56 class FdoISelect : public FdoIBaseSelect 57 57 { 58 /// new added method 58 /// new added methods 59 59 60 60 /// \brief … … 68 68 throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_3_NOTIMPLEMENTED))); 69 69 } 70 /// \brief 71 /// Gets the alias used for the main feature class. 72 /// 73 /// \return 74 /// Returns the identifier. 75 /// 76 FDO_API virtual FdoString* GetAlias() 77 { 78 return NULL; 79 } 80 /// \brief 81 /// Sets the alias used for the main feature class. 82 /// 83 /// \return 84 /// 85 FDO_API virtual void SetAlias(FdoString* alias) 86 { 87 } 70 88 } 71 89 }}} … … 89 107 90 108 /// Constructs an instance of a parameter using the specified arguments. 91 FdoJoinCriteria(FdoString* name, FdoIdentifier* joinClass, FdoJoinType joinType);109 FdoJoinCriteria(FdoString* alias, FdoIdentifier* joinClass, FdoJoinType joinType); 92 110 93 111 /// Constructs an instance of a parameter using the specified arguments. 94 FdoJoinCriteria(FdoString* name, FdoIdentifier* joinClass, FdoJoinType joinType, FdoFilter* filter);112 FdoJoinCriteria(FdoString* alias, FdoIdentifier* joinClass, FdoJoinType joinType, FdoFilter* filter); 95 113 96 114 public: … … 99 117 100 118 /// Constructs a full defined instance of a join criteria. 101 /// In this case Name= joinClass->GetName().119 /// In this case Alias = joinClass->GetName(). 102 120 FDO_API static FdoJoinCriteria* Create(FdoIdentifier* joinClass, 103 121 FdoJoinType joinType); 104 122 105 123 /// Constructs a full defined instance of a join criteria. 106 /// In this case Name= joinClass->GetName().124 /// In this case Alias = joinClass->GetName(). 107 125 FDO_API static FdoJoinCriteria* Create(FdoIdentifier* joinClass, 108 126 FdoJoinType joinType, … … 110 128 111 129 /// Constructs a full defined instance of a join criteria. 112 FDO_API static FdoJoinCriteria* Create(FdoString* name,130 FDO_API static FdoJoinCriteria* Create(FdoString* alias, 113 131 FdoIdentifier* joinClass, 114 132 FdoJoinType joinType); 115 133 116 134 /// Constructs a full defined instance of a join criteria. 117 FDO_API static FdoJoinCriteria* Create(FdoString* name,135 FDO_API static FdoJoinCriteria* Create(FdoString* alias, 118 136 FdoIdentifier* joinClass, 119 137 FdoJoinType joinType, … … 121 139 122 140 /// Returns the alias name for the join criteria class 123 FDO_API FdoString* Get Name();141 FDO_API FdoString* GetAlias(); 124 142 125 143 /// Sets the alias name for the join criteria class 126 FDO_API void Set Name(FdoString* value);144 FDO_API void SetAlias(FdoString* value); 127 145 128 146 /// Returns the identifier of the right join class … … 173 191 174 192 Default implementation for !GetJoinTypes() will return !FdoJoinType_None and !SupportsJoins() will return false, since is not normal to throw exceptions when caller wants to get capabilities. 193 An exception will be thrown in case caller is passing a filter to a cross join criteria (FdoJoinType_Cross) and also an exception will be thrown in case caller is passing a NULL filter to all join criteria types except None and Cross. 175 194 176 195 {{{ … … 194 213 /// Returns FdoJoinCriteria in case if found (based on name search). 195 214 /// This will throw an exception in case item is not found 196 FDO_API FdoJoinCriteria* GetItem(FdoString* name);215 FDO_API FdoJoinCriteria* GetItem(FdoString* alias); 197 216 198 217 /// Returns NULL in case FdoJoinCriteria was not found or FdoJoinCriteria found (based on name search). 199 FDO_API FdoJoinCriteria* FindItem(FdoString* name);218 FDO_API FdoJoinCriteria* FindItem(FdoString* alias); 200 219 201 220 /// Returns FdoJoinCriteria having the index. … … 220 239 221 240 FdoPtr<FdoIdentifier> fcpoint = FdoIdentifier::Create(L"p"); 222 /// In case we need an alias we can do:223 /// FdoPtr<FdoComputedIdentifier> pAlias = FdoComputedIdentifier::Create(L"pAlias", fcpoint);224 241 sel->SetFeatureClassName(fcpoint); // set the main class 225 242 … … 244 261 === Selecting from Multiple Classes === 245 262 246 We should be able to select from multiple classes and have filters applied on any class attributes. In order to be able to achieve that objective, we can use FdoISelect::!GetJoinCriteria() and add all classes we want to select from. The filter must be based on properties from the selected classes and filter can be validated at run time when the whole select is built. In this collection we can have: 247 * !FdoIdentifier’s in case we just need to pass a class name. 248 * !FdoComputedIdentifier’s having a name and as expression value an !FdoIdentifier, this way we can get aliases, e.g. !ClassName AS !NewClassName. We already use computed identifiers in our API for expressions and we provide a name and an expression value. In this case it will be the same, since an alias is actually an expression: we provide an alias (name) and the real name of the class. 263 We should be able to select from multiple classes and have filters applied on any class attributes. In order to be able to achieve that objective, we can use FdoISelect::!GetJoinCriteria() and add all classes we want to select from. The filter must be based on properties from the selected classes and filter can be validated at run time when the whole select is built. Aliases can be used by calling SetAlias()/GetAlias() on the select interface, e.g. !ClassName AS !NewClassName. 249 264 250 265 The following sections will use some SQL examples just to illustrate things we are trying to achieve, each RBDMS-based provider will translate FDO selects in server side SQL depending of the server capabilities. 251 266 252 ''SELECT * FROM class1 AS p1 , class2 AS p2 WHERE p1.ID=p2.!FeatId ANDSPATIAL_COND(p1.GEOM, GEOM_VAL);''267 ''SELECT * FROM class1 AS p1 INNER JOIN class2 AS p2 ON(p1.ID=p2.!FeatId) WHERE SPATIAL_COND(p1.GEOM, GEOM_VAL);'' 253 268 254 269 Below we added some C++ code on how caller can use this new improvement to achieve above select statement: … … 258 273 259 274 FdoPtr<FdoIdentifier> fcname1 = FdoIdentifier::Create(L"class1"); 260 // we need this only in case we want to create an alias for the class, otherwise we can pass fcname1261 FdoPtr<FdoComputedIdentifier> fcp1 = FdoComputedIdentifier::Create(L"p1", fcname1);262 275 sel->SetFeatureClassName(fcpoint); // set the main class 276 sel->SetAlias(L"p1"); 263 277 264 278 FdoPtr<FdoJoinCriteriaCollection> jcrit = sel->GetJoinCriteria(); 265 279 266 280 FdoPtr<FdoIdentifier> fcname2 = FdoIdentifier::Create(L"class2"); 267 FdoPtr<FdoJoinCriteria> jc1 = FdoJoinCriteria::Create(L"p2", fcname2, FdoJoinType_ Cross);281 FdoPtr<FdoJoinCriteria> jc1 = FdoJoinCriteria::Create(L"p2", fcname2, FdoJoinType_Inner, L"p1.ID=p2.FeatId"); 268 282 jcrits->Add(jc1); 269 283 270 FdoPtr<FdoFilter> filter = FdoFilter::Parse(L" p1.ID=p2.FeatId ANDGeometry INTERSECTS GeomFromText('CURVESTRING(...)')");284 FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Geometry INTERSECTS GeomFromText('CURVESTRING(...)')"); 271 285 sel->SetFilter(filter); 272 286