private static IEnumerable <SchemaAttribute> GetAttributesFromDefinition(IDictionary <string, object> definitions, string definitionName) { if (!definitions.ContainsKey(definitionName)) { logger.Error($"The definition for type {definitionName} was not found in the response"); yield break; } if (!(definitions[definitionName] is IDictionary <string, object> definitionObject)) { logger.Info($"The definition for type {definitionName} was null"); yield break; } if (!definitionObject.ContainsKey("properties")) { logger.Error($"The definition for type {definitionName} was did not contain any properties"); yield break; } if (!(definitionObject["properties"] is IDictionary <string, object> properties)) { logger.Info($"The properties definition for {definitionName} were missing"); yield break; } foreach (KeyValuePair <string, object> property in properties) { string name = property.Key; if (!(property.Value is IDictionary <string, object> values)) { logger.Warn($"Missing value set for property {name}"); continue; } AttributeOperation operation = SchemaProvider.GetAttributeOperationFromMutability(values["mutability"].ToString()); bool ismultivalued = SchemaProvider.IsMultivalued(values); AttributeType type = SchemaProvider.GetTypeForAttribute(values, ismultivalued); if (name == "managerId") { type = AttributeType.Reference; } logger.Info($"Got attribute {name} of type {type} and is mv {ismultivalued}"); if (ismultivalued) { yield return(SchemaAttribute.CreateMultiValuedAttribute(name, type, operation)); } else { yield return(SchemaAttribute.CreateSingleValuedAttribute(name, type, operation)); } } }
private List <AttributeOperation> GetAttributeOperations(AttributeValue attributeValue) { List <AttributeOperation> operations = new List <AttributeOperation>(); foreach (string val in attributeValue.ValuesAsString) { AttributeOperation op = new AttributeOperation { Operation = (attributeValue.Attribute.IsMultivalued) ? AttributeOperationType.Add : AttributeOperationType.Replace, Name = attributeValue.AttributeName, Value = (attributeValue.IsFilter()) ? GetFilterValue(val) : val, ValueType = (attributeValue.IsFilter()) ? AttributeValueType.XPathFilter : AttributeValueType.Value }; operations.Add(op); } return(operations); }
public AttributeDefinition(string Name, string DataTypeName) { this.Name = Name; AttributeOperation = AttributeOperation.ImportExport; switch (DataTypeName) { case "int": this.AttributeType = AttributeType.Integer; break; case "bigint": this.AttributeType = AttributeType.Integer; break; case "tinyint": this.AttributeType = AttributeType.Integer; break; case "smallint": this.AttributeType = AttributeType.Integer; break; case "bit": this.AttributeType = AttributeType.Boolean; break; case "binary": this.AttributeType = AttributeType.Binary; break; case "varbinary": this.AttributeType = AttributeType.Binary; break; case "image": this.AttributeType = AttributeType.Binary; break; case "uniqueidentifier": this.AttributeType = AttributeType.Binary; break; case "date": this.AttributeType = AttributeType.String; break; case "datetime": this.AttributeType = AttributeType.String; break; case "smalldatetime": this.AttributeType = AttributeType.String; break; case "datetime2": this.AttributeType = AttributeType.String;; break; case "datetimeoffset": this.AttributeType = AttributeType.String; break; case "time": this.AttributeType = AttributeType.String; break; case "timestamp": this.AttributeType = AttributeType.String; AttributeOperation = AttributeOperation.ImportOnly; break; case "nvarchar": this.AttributeType = AttributeType.String; break; case "char": this.AttributeType = AttributeType.String; break; case "varchar": this.AttributeType = AttributeType.String; break; case "text": this.AttributeType = AttributeType.String; break; case "nchar": this.AttributeType = AttributeType.String; break; case "ntext": this.AttributeType = AttributeType.String; break; case "decimal": this.AttributeType = AttributeType.String; break; case "float": this.AttributeType = AttributeType.String; break; case "money": this.AttributeType = AttributeType.String; break; case "smallmoney": this.AttributeType = AttributeType.String; break; case "real": this.AttributeType = AttributeType.String; break; case "xml": this.AttributeType = AttributeType.String; break; default: Tracer.TraceWarning("non-supported-type name: {0}, sql-type: {1}", Name, DataTypeName); this.AttributeType = AttributeType.String; break; } Tracer.TraceInformation("name: {0}, sql-type: {1}, selected-schematype: {2}", Name, DataTypeName, AttributeType); }