зеркало из https://github.com/microsoft/Power-Fx.git
Capabilities update (#2700)
This commit is contained in:
Родитель
6c9855ebd2
Коммит
089043b341
|
@ -132,11 +132,14 @@ namespace Microsoft.PowerFx.Connectors
|
|||
|
||||
public static TableDelegationInfo ToDelegationInfo(ServiceCapabilities serviceCapabilities, string tableName, bool isReadOnly, ConnectorType connectorType, string datasetName)
|
||||
{
|
||||
SortRestrictions sortRestriction = new SortRestrictions()
|
||||
{
|
||||
AscendingOnlyProperties = serviceCapabilities?.SortRestriction?.AscendingOnlyProperties,
|
||||
UnsortableProperties = serviceCapabilities?.SortRestriction?.UnsortableProperties
|
||||
};
|
||||
// sortRestriction == null means sortable = false
|
||||
SortRestrictions sortRestriction = serviceCapabilities?.SortRestriction != null
|
||||
? new SortRestrictions()
|
||||
{
|
||||
AscendingOnlyProperties = serviceCapabilities.SortRestriction.AscendingOnlyProperties,
|
||||
UnsortableProperties = serviceCapabilities.SortRestriction.UnsortableProperties
|
||||
}
|
||||
: null;
|
||||
|
||||
FilterRestrictions filterRestriction = new FilterRestrictions()
|
||||
{
|
||||
|
@ -144,10 +147,13 @@ namespace Microsoft.PowerFx.Connectors
|
|||
NonFilterableProperties = serviceCapabilities?.FilterRestriction?.NonFilterableProperties
|
||||
};
|
||||
|
||||
SelectionRestrictions selectionRestriction = new SelectionRestrictions()
|
||||
{
|
||||
IsSelectable = serviceCapabilities?.SelectionRestriction?.IsSelectable ?? false
|
||||
};
|
||||
// selectionRestriction == null means selectable = false
|
||||
SelectionRestrictions selectionRestriction = serviceCapabilities?.SelectionRestriction != null
|
||||
? new SelectionRestrictions()
|
||||
{
|
||||
IsSelectable = serviceCapabilities.SelectionRestriction.IsSelectable
|
||||
}
|
||||
: null;
|
||||
|
||||
GroupRestrictions groupRestriction = new GroupRestrictions()
|
||||
{
|
||||
|
@ -255,6 +261,8 @@ namespace Microsoft.PowerFx.Connectors
|
|||
private static SortRestriction ParseSortRestriction(IDictionary<string, IOpenApiAny> capabilitiesMetaData)
|
||||
{
|
||||
IDictionary<string, IOpenApiAny> sortRestrictionMetaData = capabilitiesMetaData.GetObject(CapabilityConstants.SortRestrictions);
|
||||
|
||||
// When "sortable" = false (or not defined), SortRestriction is null
|
||||
return sortRestrictionMetaData?.GetBool(CapabilityConstants.Sortable) == true
|
||||
? new SortRestriction(sortRestrictionMetaData.GetList(CapabilityConstants.UnsortableProperties), sortRestrictionMetaData.GetList(CapabilityConstants.AscendingOnlyProperties))
|
||||
: null;
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
|
||||
public DName EntityName { get; }
|
||||
|
||||
public bool IsSelectable => _delegationInfo.SelectionRestriction == null ? false : _delegationInfo.SelectionRestriction.IsSelectable;
|
||||
public bool IsSelectable => _delegationInfo.IsSelectable;
|
||||
|
||||
public bool IsDelegatable => _delegationInfo.IsDelegable;
|
||||
|
||||
|
@ -109,17 +109,17 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
|
||||
bool IExternalTabularDataSource.CanIncludeSelect(IExpandInfo expandInfo, string selectColumnName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IExternalTabularDataSource.CanIncludeExpand(IExpandInfo expandToAdd)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IExternalTabularDataSource.CanIncludeExpand(IExpandInfo parentExpandInfo, IExpandInfo expandToAdd)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static List<OperationCapabilityMetadata> GetCapabilityMetadata(AggregateType recordType, TableDelegationInfo delegationInfo)
|
||||
|
@ -152,38 +152,45 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
}
|
||||
}
|
||||
|
||||
Dictionary<DPath, DelegationCapability> sortRestrictions = new Dictionary<DPath, DelegationCapability>();
|
||||
|
||||
if (delegationInfo?.SortRestriction?.UnsortableProperties != null)
|
||||
{
|
||||
foreach (string unsortableProperty in delegationInfo.SortRestriction.UnsortableProperties)
|
||||
{
|
||||
AddOrUpdate(sortRestrictions, unsortableProperty, DelegationCapability.Sort);
|
||||
}
|
||||
}
|
||||
|
||||
if (delegationInfo?.SortRestriction?.AscendingOnlyProperties != null)
|
||||
{
|
||||
foreach (string ascendingOnlyProperty in delegationInfo.SortRestriction.AscendingOnlyProperties)
|
||||
{
|
||||
AddOrUpdate(sortRestrictions, ascendingOnlyProperty, DelegationCapability.SortAscendingOnly);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<DPath, DPath> oDataReplacements = new Dictionary<DPath, DPath>();
|
||||
|
||||
FilterOpMetadata filterOpMetadata = new CdpFilterOpMetadata(recordType, delegationInfo);
|
||||
GroupOpMetadata groupOpMetadata = new GroupOpMetadata(type, groupByRestrictions);
|
||||
ODataOpMetadata oDataOpMetadata = new ODataOpMetadata(type, oDataReplacements);
|
||||
SortOpMetadata sortOpMetadata = new SortOpMetadata(type, sortRestrictions);
|
||||
|
||||
return new List<OperationCapabilityMetadata>()
|
||||
List<OperationCapabilityMetadata> metadataList = new List<OperationCapabilityMetadata>()
|
||||
{
|
||||
filterOpMetadata,
|
||||
groupOpMetadata,
|
||||
oDataOpMetadata,
|
||||
sortOpMetadata
|
||||
oDataOpMetadata
|
||||
};
|
||||
|
||||
if (delegationInfo?.SortRestriction != null)
|
||||
{
|
||||
Dictionary<DPath, DelegationCapability> sortRestrictions = new Dictionary<DPath, DelegationCapability>();
|
||||
|
||||
if (delegationInfo?.SortRestriction?.UnsortableProperties != null)
|
||||
{
|
||||
foreach (string unsortableProperty in delegationInfo.SortRestriction.UnsortableProperties)
|
||||
{
|
||||
AddOrUpdate(sortRestrictions, unsortableProperty, DelegationCapability.Sort);
|
||||
}
|
||||
}
|
||||
|
||||
if (delegationInfo?.SortRestriction?.AscendingOnlyProperties != null)
|
||||
{
|
||||
foreach (string ascendingOnlyProperty in delegationInfo.SortRestriction.AscendingOnlyProperties)
|
||||
{
|
||||
AddOrUpdate(sortRestrictions, ascendingOnlyProperty, DelegationCapability.SortAscendingOnly);
|
||||
}
|
||||
}
|
||||
|
||||
SortOpMetadata sortOpMetadata = new SortOpMetadata(type, sortRestrictions);
|
||||
|
||||
metadataList.Add(sortOpMetadata);
|
||||
}
|
||||
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
internal static DPath GetReplacementPath(string alias, DPath currentColumnPath)
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
public abstract class TableDelegationInfo
|
||||
{
|
||||
// Defines unsortable columns or columns only supporting ascending ordering
|
||||
// If set to null, the table is not sortable
|
||||
public SortRestrictions SortRestriction { get; init; }
|
||||
|
||||
// Defines columns that cannot be sorted and required properties
|
||||
|
@ -45,6 +46,12 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
// Read-Only table
|
||||
public bool IsReadOnly { get; init; }
|
||||
|
||||
// Defines when the table is sortable
|
||||
public bool IsSortable => SortRestriction != null;
|
||||
|
||||
// Defines when columns can be selected
|
||||
public bool IsSelectable => SelectionRestriction != null && SelectionRestriction.IsSelectable;
|
||||
|
||||
// Dataset name
|
||||
public string DatasetName { get; init; }
|
||||
|
||||
|
@ -52,7 +59,7 @@ namespace Microsoft.PowerFx.Core.Entities
|
|||
// Key = field logical name, Value = foreign table logical name
|
||||
internal Dictionary<string, string> ColumnsWithRelationships { get; init; }
|
||||
|
||||
public virtual bool IsDelegable => (SortRestriction != null) || (FilterRestriction != null) || (FilterFunctions != null);
|
||||
public virtual bool IsDelegable => IsSortable || (FilterRestriction != null) || (FilterFunctions != null);
|
||||
|
||||
public TableDelegationInfo()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче