Changes between Version 43 and Version 44 of FDORfc50


Ignore:
Timestamp:
07/19/10 09:34:17 (14 years ago)
Author:
romicadascalescu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc50

    v43 v44  
    4343          * '''Cons''': We need to change all the providers leading to a big effort from everyone.
    4444
    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.
    4646         * '''Pros''': this solution will not add more complexity to the API, we do not need to change any provider.[[BR]]
    4747         * '''Cons''': None.
     
    5151The 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.
    5252
    53 The new method added on FdoISelect will have a default implementation throwing an exception:
     53The new methods added on FdoISelect will have a default implementation throwing an exception or empty implementation:
    5454
    5555{{{
    5656  class FdoISelect : public FdoIBaseSelect
    5757  {
    58      /// new added method
     58     /// new added methods
    5959
    6060     /// \brief
     
    6868          throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_3_NOTIMPLEMENTED)));
    6969     }
     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     }
    7088  }
    7189}}}
     
    89107         
    90108          /// 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);
    92110
    93111          /// 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);
    95113
    96114      public:
     
    99117
    100118          /// Constructs a full defined instance of a join criteria.
    101           /// In this case Name = joinClass->GetName().
     119          /// In this case Alias = joinClass->GetName().
    102120          FDO_API static FdoJoinCriteria* Create(FdoIdentifier* joinClass,
    103121                                                 FdoJoinType joinType);
    104122
    105123          /// Constructs a full defined instance of a join criteria.
    106           /// In this case Name = joinClass->GetName().
     124          /// In this case Alias = joinClass->GetName().
    107125          FDO_API static FdoJoinCriteria* Create(FdoIdentifier* joinClass,
    108126                                                 FdoJoinType joinType,
     
    110128
    111129          /// 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,
    113131                                                 FdoIdentifier* joinClass,
    114132                                                 FdoJoinType joinType);
    115133
    116134          /// 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,
    118136                                                 FdoIdentifier* joinClass,
    119137                                                 FdoJoinType joinType,
     
    121139
    122140          /// Returns the alias name for the join criteria class
    123           FDO_API FdoString* GetName();
     141          FDO_API FdoString* GetAlias();
    124142
    125143          /// Sets the alias name for the join criteria class
    126           FDO_API void SetName(FdoString* value);
     144          FDO_API void SetAlias(FdoString* value);
    127145
    128146          /// Returns the identifier of the right join class
     
    173191
    174192Default 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.
     193An 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.
    175194
    176195{{{
     
    194213          /// Returns FdoJoinCriteria in case if found (based on name search).
    195214          /// 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);
    197216       
    198217          /// 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);
    200219
    201220          /// Returns FdoJoinCriteria having the index.
     
    220239
    221240      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);
    224241      sel->SetFeatureClassName(fcpoint); // set the main class
    225242
     
    244261=== Selecting from Multiple Classes ===
    245262
    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.
     263We 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.
    249264
    250265The 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.
    251266
    252     ''SELECT * FROM class1 AS p1, class2 AS p2 WHERE p1.ID=p2.!FeatId AND SPATIAL_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);''
    253268
    254269Below we added some C++ code on how caller can use this new improvement to achieve above select statement:
     
    258273
    259274      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 fcname1
    261       FdoPtr<FdoComputedIdentifier> fcp1 = FdoComputedIdentifier::Create(L"p1", fcname1);
    262275      sel->SetFeatureClassName(fcpoint); // set the main class
     276      sel->SetAlias(L"p1");
    263277
    264278      FdoPtr<FdoJoinCriteriaCollection> jcrit = sel->GetJoinCriteria();
    265279
    266280      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");
    268282      jcrits->Add(jc1);
    269283
    270       FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"p1.ID=p2.FeatId AND Geometry INTERSECTS GeomFromText('CURVESTRING(...)')");
     284      FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Geometry INTERSECTS GeomFromText('CURVESTRING(...)')");
    271285      sel->SetFilter(filter);
    272286