/// <summary> /// Adds the given client-query to the list of queries /// </summary> /// <param parameterName="parameterExternalName">The parameterName to show to the end user</param> /// <param parameterName="table">The table descriptor that the query belongs to</param> /// <param parameterName="predicate">The predicate that defines the filter for the query</param> /// <param parameterName="parameterDefinitions">The parameter definitions defining the functionParameters to be used</param> private LiteQueryViewModel NewUserQuery(string externalName, FeatureTableDescriptor table, System.Linq.Expressions.Expression predicate, ParameterDefinitionCollection parameterDefinitions, bool addToQueries) { LiteQueryViewModel clientQuery = null; if (IsAuthenticated && Queries != null) { var predicateText = predicate != null?predicate.GeoLinqText(useInternalParameterNames : true) : null; var queryDefinition = new FeatureCollectionQueryDefinition() { ServiceProviderGroup = table.ServiceProviderGroup, Context = ServiceProviderDatumContext.User, Name = externalName.ToLower(), ExternalName = externalName, TableDescriptor = table, ParameterDefinitions = parameterDefinitions }; clientQuery = new LiteQueryViewModel(this.Messenger, queryDefinition, predicateText); if (addToQueries) { Queries.Add(clientQuery); SaveUserQueries(); } } return(clientQuery); }
/// <summary> /// Returns the cached table descriptor /// </summary> private async Task <FeatureTableDescriptor> EnsureTableDescriptorAsync() { if (_tableDescriptor == null && !_triedRetrievingTables && TableName != null && FieldName != null) { // Get the table descriptor, since it was not received before var tables = await GetService <ICollectionService>().GetTableDescriptorsAsync(TableName); // We've tried receiving it (in case it's not there; don't keep on trying) _triedRetrievingTables = true; if (tables.Count > 0) { // Get the appropriate table, but only in case there is a corresponding field var table = tables[0]; var field = table.FieldDescriptors[FieldName]; if (field != null && field.IsGeometry) { // The table descriptor is fine _tableDescriptor = tables[0]; } } } return(_tableDescriptor); }
/// <summary> /// Creates a default table descriptor for one geometry of the specified geometry type /// </summary> private static FeatureTableDescriptor GeometryTableDescriptor(FeatureGeometryType type) { var table = new FeatureTableDescriptor("", ""); var field = table.FieldDescriptors.Add("", "", type); return(table); }
/// <summary> /// Set up the modes for the specified table descriptor /// </summary> /// <param parameterName="table"></param> private async void SetupForTable(FeatureTableDescriptor table) { // Make sure the table has its field descriptors await table.EvaluateAsync(); // Indicate table descriptor change foreach (var mode in Modes) { mode.TableDescriptor = table; } if (SelectedMode != null && SelectedMode.IsEnabled) { // The active mode is still enabled } else { LiteNewUserQueryViewModelMode newSelectedMode = null; foreach (var mode in Modes) { if (mode.IsEnabled) { newSelectedMode = mode; break; } } // Set the new mode SelectedMode = newSelectedMode; } }
/// <summary> /// Called whenever authentication changes; make sure we stop caching /// </summary> protected override void OnAuthenticationChanged(SpatialEye.Framework.Authentication.AuthenticationContext context, bool isAuthenticated) { // Reset the table _triedRetrievingTables = false; _tableDescriptor = null; // Get base behavior happening base.OnAuthenticationChanged(context, isAuthenticated); }
/// <summary> /// Constructs the insert item /// </summary> /// <param name="tableDescriptor">The table descriptor for the item</param> /// <param name="isAttachPossible">Indicates whether attach is possible</param> /// <param name="isAttachRequired">Indicates whether attaching to an asset is required</param> public FeatureInsertItemViewModel(FeatureTableDescriptor tableDescriptor, bool isAttachRequired, bool isAttachPossible) { TableDescriptor = tableDescriptor; Category = tableDescriptor.EditabilityProperties.Category; IsAttachRequired = isAttachRequired; IsAttachPossible = isAttachPossible; var ignored = RetrieveTableDetails(); CalculateState(); }
/// <summary> /// Constructs the request /// </summary> /// <param name="sender">The originator of the request</param> /// <param name="feature">The feature (recipe-holder) to show details for</param> public LiteNewFeatureRequestMessage(Object sender, FeatureTableDescriptor tableDescriptor, FeatureGeometryFieldDescriptor geomDescriptor, IFeatureGeometry startWithGeometry = null, Feature attachToFeature = null) : base(sender) { this.TableDescriptor = tableDescriptor; this.GeometryDescriptor = geomDescriptor; if (tableDescriptor.EditabilityProperties.AllowInsert) { var newFeature = tableDescriptor.NewTemplateFeature(); if (geomDescriptor != null && startWithGeometry != null) { StartedWithTrail = true; newFeature[geomDescriptor.Name] = startWithGeometry; } Feature = new EditableFeature(newFeature, false, attachToFeature); } }
/// <summary> /// Can we attach to the specified table descriptor /// </summary> internal bool CanAttachTo(FeatureTableDescriptor table) { bool canAttach = false; if (IsAttachPossible) { var candidateTables = TableDescriptor.CandidateTableDescriptorsForAttach(); if (candidateTables != null) { foreach (var attach in candidateTables) { if (table.Name == attach.Name) { canAttach = true; break; } } } } return(canAttach); }
/// <summary> /// Returns the queryable geometry fields for the specified table /// </summary> public static IList <FeatureGeometryFieldDescriptor> GeometryFieldsFor(FeatureTableDescriptor table) { var result = new List <FeatureGeometryFieldDescriptor>(); if (table != null) { foreach (FeatureGeometryFieldDescriptor geometryField in table.FieldDescriptors.Descriptors(FeatureFieldDescriptorType.Geometry, false, false)) { switch (geometryField.FieldType.PhysicalType) { case FeaturePhysicalFieldType.Point: case FeaturePhysicalFieldType.MultiPoint: case FeaturePhysicalFieldType.Curve: case FeaturePhysicalFieldType.MultiCurve: case FeaturePhysicalFieldType.Polygon: case FeaturePhysicalFieldType.MultiPolygon: result.Add(geometryField); break; } } } return(result); }
/// <summary> /// Constructor for the request /// </summary> public LiteGetAttachCandidatesRequestMessage(object sender, FeatureTableDescriptor table) : base(sender) { TableDescriptor = table; }
/// <summary> /// Returns a geometry target expression for the specified table /// </summary> public static Expression GeometryTargetExpressionFor(FeatureTableDescriptor table) { var fields = GeometryFieldsFor(table); return((fields.Count == 1) ? (Expression)GeoLinqExpressionFactory.Data.Field(fields[0]) : (Expression)GeoLinqExpressionFactory.Data.Table(table)); }
/// <summary> /// Returns a flag indicating whether there are geometry fields in the specified table /// </summary> public static bool HasGeometryFieldsFor(FeatureTableDescriptor table) { var fields = GeometryFieldsFor(table); return(fields.Count > 0); }