예제 #1
0
 private bool IsTrait(FieldDescriptor f, out string traitID, out string catID, out string tableName)
 {
     return IsOneToMany("trait", f, out traitID, out catID, out tableName);
 }
예제 #2
0
 public ConvertingValidatorResult(FieldDescriptor field, string originalValue)
 {
     this.Field = field;
     this.OriginalValue = originalValue;
 }
예제 #3
0
        private bool IsOneToMany(string oneToManyType, FieldDescriptor f, out string ID, out string catID, out string tableName)
        {
            var s = f.TableName.Split('.');
            if (s.Length == 4 && s[0].Equals(oneToManyType)) {
                ID = s[2];
                catID = s[3];
                tableName = s[1];
                return true;
            }

            ID = null;
            catID = null;
            tableName = null;

            return false;
        }
예제 #4
0
 private bool IsNote(FieldDescriptor f, out string noteID, out string catID, out string tableName)
 {
     return IsOneToMany("note", f, out noteID, out catID, out tableName);
 }
예제 #5
0
        public ConvertingValidatorResult ValidateImportValue(FieldDescriptor targetField, string value, bool throwOnFailure = false)
        {
            if (targetField.Validate == null || string.IsNullOrWhiteSpace(value)) {
                var result = new ConvertingValidatorResult(targetField, value);
                result.Success(value);
                return result;
            } else {
                var result = new ConvertingValidatorResult(targetField, value);
                targetField.Validate(value, result);
                if (throwOnFailure && !result.IsValid) {
                    throw new Exception(result.Message);
                }

                return result;
            }
        }
예제 #6
0
        public List<FieldDescriptor> GetImportFields()
        {
            // Start off with the base list of static fields...
            var list = new List<FieldDescriptor>(ImportFieldDescriptors);

            var kingdomField = list.Find((fld) => {
                return fld.DisplayName == "KingdomType";
            });

            // The old code put the ranks after the kingdomtype field, but before the other taxon fields...
            int index = -1;
            if (kingdomField != null) {
                index = list.IndexOf(kingdomField) + 1;
            }

            // Add taxon ranks...
            StoredProcReaderForEach("spBiotaRankList", (reader) => {
                string rank = reader[1].ToString();
                if (!string.IsNullOrWhiteSpace(rank)) {
                    var field = new FieldDescriptor { DisplayName = rank, Category = "Taxon", Description = "The taxonamic rank " + rank };
                    if (index > 0) {
                        list.Insert(index++, field);
                    } else {
                        list.Add(field);
                    }
                }
            });

            return list;
        }
 public ConvertingValidatorResult(FieldDescriptor field, string originalValue)
 {
     this.Field         = field;
     this.OriginalValue = originalValue;
 }