Skip to content
This repository was archived by the owner on Jul 30, 2019. It is now read-only.

Commit 08d81e6

Browse files
author
Laszlo Hordos
committed
OPENICF-329 Align the OpenICF Filter and CREST QueryFilter
1 parent d4eab4e commit 08d81e6

File tree

9 files changed

+405
-52
lines changed

9 files changed

+405
-52
lines changed

Framework/CommonObjects.cs

100644100755
+139-3
Original file line numberDiff line numberDiff line change
@@ -2993,6 +2993,12 @@ public sealed class OperationOptions
29932993
/// </summary>
29942994
public static readonly string OP_PAGED_RESULTS_COOKIE = "PAGED_RESULTS_COOKIE";
29952995

2996+
/// <summary>
2997+
/// An option to use with <seealso cref="SearchApiOp"/> that specifies the policy used for calculating
2998+
/// the total number of paged results.
2999+
/// </summary>
3000+
public const string OP_TOTAL_PAGED_RESULTS_POLICY = "TOTAL_PAGED_RESULTS_POLICY";
3001+
29963002
/// <summary>
29973003
/// An option to use with <seealso cref="SearchApiOp"/> that specifies the index within
29983004
/// the result set of the first result which should be returned.
@@ -3137,6 +3143,22 @@ public string PagedResultsCookie
31373143
}
31383144
}
31393145

3146+
/// <summary>
3147+
/// Returns the <seealso cref="SearchResult.CountPolicy"/> used to calculate
3148+
/// <seealso cref="SearchResult#getTotalPagedResults()"/>.
3149+
/// </summary>
3150+
/// <returns> The count policy. </returns>
3151+
/// <seealso cref= SearchResult#getTotalPagedResults()</seealso>
3152+
/// <remarks>Since 1.5</remarks>
3153+
public SearchResult.CountPolicy TotalPagedResultsPolicy
3154+
{
3155+
get
3156+
{
3157+
return (SearchResult.CountPolicy)CollectionUtil.GetValue(
3158+
_operationOptions, OP_TOTAL_PAGED_RESULTS_POLICY, SearchResult.CountPolicy.NONE);
3159+
}
3160+
}
3161+
31403162
/// <summary>
31413163
/// Returns the index within the result set of the first result which should
31423164
/// be returned. Paged results will be enabled if and only if the page size
@@ -3372,6 +3394,22 @@ public string PagedResultsCookie
33723394
}
33733395
}
33743396

3397+
/// <summary>
3398+
/// Sets the policy for calculating the total number of paged results. If no
3399+
/// count policy is supplied or paged results are not requested a default of
3400+
/// <seealso cref="SearchResult.CountPolicy#NONE"/> will be used. This will result in no count being
3401+
/// performed and no overhead incurred.
3402+
/// </summary>
3403+
/// <remarks>Since 1.5</remarks>
3404+
public SearchResult.CountPolicy TotalPagedResultsPolicy
3405+
{
3406+
set
3407+
{
3408+
Assertions.NullCheck(value, "totalPagedResultsPolicy");
3409+
_options[OperationOptions.OP_TOTAL_PAGED_RESULTS_POLICY] = value;
3410+
}
3411+
}
3412+
33753413
/// <summary>
33763414
/// Convenience method to set
33773415
/// <seealso cref="OperationOptions#OP_PAGED_RESULTS_OFFSET"/>
@@ -4834,15 +4872,48 @@ public ScriptContext Build()
48344872
public sealed class SearchResult
48354873
{
48364874

4875+
/// <summary>
4876+
/// An enum of count policy types.
4877+
/// </summary>
4878+
/// <seealso cref= OperationOptionsBuilder#setTotalPagedResultsPolicy(CountPolicy) </seealso>
4879+
/// <seealso cref= SearchResult#getTotalPagedResultsPolicy() </seealso>
4880+
public enum CountPolicy
4881+
{
4882+
/// <summary>
4883+
/// There should be no count returned. No overhead should be incurred.
4884+
/// </summary>
4885+
NONE,
4886+
4887+
/// <summary>
4888+
/// Estimated count may be used. If no estimation is available it is up
4889+
/// to the implementor whether to return an <seealso cref="#EXACT"/> count or
4890+
/// <seealso cref="#NONE"/>. It should be known to the client which was used as in
4891+
/// <seealso cref="SearchResult#getTotalPagedResultsPolicy()"/>
4892+
/// </summary>
4893+
ESTIMATE,
4894+
4895+
/// <summary>
4896+
/// Exact count is required.
4897+
/// </summary>
4898+
EXACT
4899+
}
4900+
4901+
/// <summary>
4902+
/// The value provided when no count is known or can reasonably be supplied.
4903+
/// </summary>
4904+
public const int NoCount = -1;
4905+
48374906
private readonly string _pagedResultsCookie;
4907+
private readonly CountPolicy _totalPagedResultsPolicy;
4908+
private readonly int _totalPagedResults;
48384909
private readonly int _remainingPagedResults;
48394910

48404911
/// <summary>
48414912
/// Creates a new search result with a {@code null} paged results cookie and
48424913
/// no estimate of the total number of remaining results.
48434914
/// </summary>
48444915
public SearchResult()
4845-
: this(null, -1)
4916+
: this(null, CountPolicy.NONE, NoCount, NoCount)
48464917
{
48474918
}
48484919

@@ -4860,9 +4931,41 @@ public SearchResult()
48604931
/// {@code -1} if paged results were not requested, or if the
48614932
/// total number of remaining results is unknown. </param>
48624933
public SearchResult(string pagedResultsCookie, int remainingPagedResults)
4934+
: this(pagedResultsCookie, CountPolicy.NONE, NoCount, remainingPagedResults)
48634935
{
4864-
this._pagedResultsCookie = pagedResultsCookie;
4865-
this._remainingPagedResults = remainingPagedResults;
4936+
}
4937+
4938+
/// <summary>
4939+
/// Creates a new query response with the provided paged results cookie and a
4940+
/// count of the total number of resources according to
4941+
/// <seealso cref="#totalPagedResultsPolicy"/>.
4942+
/// </summary>
4943+
/// <param name="pagedResultsCookie">
4944+
/// The opaque cookie which should be used with the next paged
4945+
/// results query request, or {@code null} if paged results were
4946+
/// not requested, or if there are not more pages to be returned. </param>
4947+
/// <param name="totalPagedResultsPolicy">
4948+
/// The policy that was used to calculate
4949+
/// <seealso cref="#totalPagedResults"/>. If none is specified ({@code null}
4950+
/// ), then <seealso cref="CountPolicy#NONE"/> is assumed. </param>
4951+
/// <param name="totalPagedResults">
4952+
/// The total number of paged results requested in adherence to
4953+
/// the <seealso cref="OperationOptions#getTotalPagedResultsPolicy()"/> in
4954+
/// the request, or <seealso cref="#NO_COUNT"/> if paged results were not
4955+
/// requested, the count policy is {@code NONE}, or if the total
4956+
/// number of results is unknown. </param>
4957+
/// <param name="remainingPagedResults">
4958+
/// An estimate of the total number of remaining results to be
4959+
/// returned in subsequent paged results query requests, or
4960+
/// {@code -1} if paged results were not requested, or if the
4961+
/// total number of remaining results is unknown.</param>
4962+
/// <remarks>Since 1.5</remarks>
4963+
public SearchResult(string pagedResultsCookie, CountPolicy totalPagedResultsPolicy, int totalPagedResults, int remainingPagedResults)
4964+
{
4965+
_pagedResultsCookie = pagedResultsCookie;
4966+
_totalPagedResultsPolicy = totalPagedResultsPolicy;
4967+
_totalPagedResults = totalPagedResults;
4968+
_remainingPagedResults = remainingPagedResults;
48664969
}
48674970

48684971
/// <summary>
@@ -4880,6 +4983,39 @@ public string PagedResultsCookie
48804983
}
48814984
}
48824985

4986+
/// <summary>
4987+
/// Returns the policy that was used to calculate the
4988+
/// {@literal totalPagedResults}.
4989+
/// </summary>
4990+
/// <returns> The count policy. </returns></seealso>
4991+
/// <remarks>Since 1.5</remarks>
4992+
public CountPolicy TotalPagedResultsPolicy
4993+
{
4994+
get
4995+
{
4996+
return _totalPagedResultsPolicy;
4997+
}
4998+
}
4999+
5000+
/// <summary>
5001+
/// Returns the total number of paged results in adherence with the
5002+
/// <seealso cref="OperationOptions#getTotalPagedResultsPolicy()"/> in the request or
5003+
/// <seealso cref="#NO_COUNT"/> if paged results were not requested, the count policy
5004+
/// is {@code NONE}, or the total number of paged results is unknown.
5005+
/// </summary>
5006+
/// <returns> A count of the total number of paged results to be returned in
5007+
/// subsequent paged results query requests, or <seealso cref="#NO_COUNT"/> if
5008+
/// paged results were not requested, or if the total number of paged
5009+
/// results is unknown. </returns>
5010+
/// <remarks>Since 1.5</remarks>
5011+
public int TotalPagedResults
5012+
{
5013+
get
5014+
{
5015+
return _totalPagedResults;
5016+
}
5017+
}
5018+
48835019
/// <summary>
48845020
/// Returns an estimate of the total number of remaining results to be
48855021
/// returned in subsequent paged results search requests.

Framework/CommonObjectsFilter.cs

100644100755
+59
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,50 @@ public override string ToString()
11041104
}
11051105
#endregion
11061106

1107+
#region ExtendedMatchFilter
1108+
public sealed class ExtendedMatchFilter : AttributeFilter
1109+
{
1110+
1111+
/// <summary>
1112+
/// Creates a new {@code extended match} filter using the provided operator
1113+
/// and attribute assertion.
1114+
/// </summary>
1115+
/// <param name="operator">
1116+
/// The operator. </param>
1117+
/// <param name="attribute">
1118+
/// The assertion value. </param>
1119+
public ExtendedMatchFilter(string @operator, ConnectorAttribute attribute)
1120+
: base(attribute)
1121+
{
1122+
if (StringUtil.IsBlank(@operator))
1123+
{
1124+
throw new ArgumentException("Operator not be null!");
1125+
}
1126+
Operator = @operator;
1127+
}
1128+
1129+
public string Operator
1130+
{
1131+
get;
1132+
internal set;
1133+
}
1134+
1135+
/// <summary>
1136+
/// Framework can not understand this filter, always return true.
1137+
/// <seealso cref="ConnectorObject"/>.
1138+
/// </summary>
1139+
public override bool Accept(ConnectorObject obj)
1140+
{
1141+
return true;
1142+
}
1143+
1144+
public override TR Accept<TR, TP>(FilterVisitor<TR, TP> v, TP p)
1145+
{
1146+
return v.VisitExtendedFilter(p, this);
1147+
}
1148+
}
1149+
#endregion
1150+
11071151
#region Filter
11081152
public interface Filter
11091153
{
@@ -1415,6 +1459,20 @@ public static Filter EqualTo(ConnectorAttribute attr)
14151459
return new EqualsFilter(attr);
14161460
}
14171461

1462+
/// <summary>
1463+
/// Creates a new {@code extended match} filter using the provided operator
1464+
/// and attribute assertion.
1465+
/// </summary>
1466+
/// <param name="operator">
1467+
/// The operator. </param>
1468+
/// <param name="attribute">
1469+
/// The assertion value.</param>
1470+
/// <remarks>Since 1.5</remarks>
1471+
public static Filter ExtendedMatch(string @operator, ConnectorAttribute attribute)
1472+
{
1473+
return new ExtendedMatchFilter(@operator, attribute);
1474+
}
1475+
14181476
/// <summary>
14191477
/// Ands the two <see cref="Filter" />.
14201478
/// </summary>
@@ -1502,6 +1560,7 @@ public static Filter Not(Filter filter)
15021560
/// The name of field within the <seealso cref="Org.IdentityConnectors.Framework.Common.Objects.ConnectorObject"/> which must be
15031561
/// present. </param>
15041562
/// <returns> The newly created {@code presence} filter. </returns>
1563+
/// <remarks>Since 1.5</remarks>
15051564
public static Filter Present(string attributeName)
15061565
{
15071566
return new PresenceFilter(attributeName);

FrameworkInternal/Resources.resx

100644100755
+21-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
</resheader>
120120
<data name="connectors.dtd" xml:space="preserve">
121121
<value>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
122-
123122
&lt;!--=======================================================--&gt;
124123
&lt;!--= =--&gt;
125124
&lt;!--= DTD for Connector Objects =--&gt;
@@ -149,9 +148,9 @@
149148
"&gt;
150149

151150
&lt;!ENTITY % filterTypes
152-
"AndFilter | ContainsFilter | EndsWithFilter | EqualsFilter |
151+
"AndFilter | ContainsFilter | EndsWithFilter | EqualsFilter | ExtendedMatchFilter |
153152
GreaterThanFilter | GreaterThanOrEqualFilter | LessThanFilter |
154-
LessThanOrEqualFilter | NotFilter | OrFilter | StartsWithFilter |
153+
LessThanOrEqualFilter | NotFilter | OrFilter | PresenceFilter | StartsWithFilter |
155154
ContainsAllValuesFilter
156155
"&gt;
157156

@@ -172,7 +171,7 @@ ObjectPoolConfiguration | ResultsHandlerConfiguration | ConfigurationProperty |
172171
APIConfiguration | ConnectorMessages | ConnectorKey | ConnectorInfo |
173172
UpdateApiOpType | AttributeInfo | ConnectorObject | ObjectClass |
174173
ObjectClassInfo | Schema | Script | ScriptContext | OperationOptions |
175-
OperationOptionInfo | SyncDeltaType | SyncToken | SyncDelta | QualifiedUid
174+
OperationOptionInfo | SearchResult | SyncDeltaType | SyncToken | SyncDelta | QualifiedUid
176175
"&gt;
177176

178177

@@ -486,6 +485,16 @@ OperationOptionInfo | SyncDeltaType | SyncToken | SyncDelta | QualifiedUid
486485

487486
&lt;!ELEMENT QualifiedUid (ObjectClass,Uid)&gt;
488487

488+
&lt;!ELEMENT CountPolicy EMPTY&gt;
489+
&lt;!ATTLIST CountPolicy
490+
value ( NONE | ESTIMATE | EXACT ) #REQUIRED
491+
&gt;
492+
&lt;!ELEMENT SearchResult (CountPolicy?)&gt;
493+
&lt;!ATTLIST SearchResult
494+
pagedResultsCookie CDATA #REQUIRED
495+
remainingPagedResults CDATA #REQUIRED
496+
totalPagedResults CDATA #REQUIRED
497+
&gt;
489498

490499
&lt;!--=======================================================--&gt;
491500
&lt;!--= =--&gt;
@@ -499,12 +508,20 @@ OperationOptionInfo | SyncDeltaType | SyncToken | SyncDelta | QualifiedUid
499508
&lt;!ELEMENT ContainsFilter (attribute)&gt;
500509
&lt;!ELEMENT EndsWithFilter (attribute)&gt;
501510
&lt;!ELEMENT EqualsFilter (attribute)&gt;
511+
&lt;!ELEMENT ExtendedMatchFilter (attribute)&gt;
512+
&lt;!ATTLIST ExtendedMatchFilter
513+
operator CDATA #IMPLIED
514+
&gt;
502515
&lt;!ELEMENT GreaterThanFilter (attribute)&gt;
503516
&lt;!ELEMENT GreaterThanOrEqualFilter (attribute)&gt;
504517
&lt;!ELEMENT LessThanFilter (attribute)&gt;
505518
&lt;!ELEMENT LessThanOrEqualFilter (attribute)&gt;
506519
&lt;!ELEMENT NotFilter (%filterTypes;)&gt;
507520
&lt;!ELEMENT OrFilter ((%filterTypes;),(%filterTypes;))&gt;
521+
&lt;!ELEMENT PresenceFilter (#PCDATA)&gt;
522+
&lt;!ATTLIST PresenceFilter
523+
name CDATA #IMPLIED
524+
&gt;
508525
&lt;!ELEMENT StartsWithFilter (attribute)&gt;
509526
&lt;!ELEMENT ContainsAllValuesFilter (attribute)&gt;
510527

0 commit comments

Comments
 (0)