/// <summary> /// This function Generates List from the CQL Script Provided decided after it is checked in previuos Function. /// </summary> /// <param name="namespaceName"></param> /// <param name="script"></param> /// <param name="errorMessage"></param> /// <param name="isCqlScript"></param> /// <param name="columnsAndDataType"></param> /// <returns>Generates List<POCOObjectListForExport/> Retained As Global Variable</returns> private static void GenerateListForScriptCql(string namespaceName, ref string script, ref string errorMessage, ref bool isCqlScript, ref Dictionary<string, string> columnsAndDataType) { if (columnsAndDataType == null) throw new ArgumentNullException("columnsAndDataType"); var fetchdatafromScript = new FetchDataFromScript(); if (script.Contains("with")) script = script.Remove(script.IndexOf("with", StringComparison.Ordinal)); isCqlScript = true; columnsAndDataType = new Dictionary<string, string>(); string createColumnFamilyCql = "create table if not exists"; const string createColumnFamilyTableCql = "create table"; bool isValidColumnFamily = Validator.ValidateCqlScript(script, ref errorMessage, ref createColumnFamilyCql, createColumnFamilyTableCql); if (isValidColumnFamily) { // Fetch Column family(Table) name _columnFamilyName = fetchdatafromScript.FetchData(script, createColumnFamilyCql, "("); _columnFamilyName = _columnFamilyName.Substring(_columnFamilyName.IndexOf(".", StringComparison.Ordinal) + 1); _columnFamilyName = _columnFamilyName.Trim('(', ')'); // Fetch Column family(Table) Details _columnDetails = fetchdatafromScript.FetchData(script, "(", ")"); if (_columnDetails.Contains("primary key")) { var index = _columnDetails.IndexOf("primary key", StringComparison.Ordinal); _columnDetails = _columnDetails.Remove(index, 11); var getindex = _columnDetails.IndexOfAny(new[] { '(' }, index); if (getindex > 0) { if (_columnDetails.ElementAt(getindex).Equals('(')) { var lastindex = _columnDetails.LastIndexOf('('); _columnDetails = _columnDetails.Remove(lastindex); } } } _columnDetails = _columnDetails.Trim(')'); isValidColumnFamily = Validator.ValidateCqlScriptsColumnDetails(ref errorMessage, _columnFamilyName, _columnDetails); if (!isValidColumnFamily) return; columnsAndDataType = fetchdatafromScript.ParseColumnNameAndDataType(_columnDetails, false, ref errorMessage, ref isValidColumnFamily); _exportPocoList.Add(Parser.ConvertGeneratedMetaDataToListFormat(namespaceName, _columnFamilyName, _keyDataType, columnsAndDataType, isCqlScript)); } }
/// <summary> /// This function Generates List from the CLI Script Provided decided after it is checked in previuos Function. /// </summary> /// <param name="namespaceName"></param> /// <param name="script"></param> /// <param name="errorMessage"></param> /// <param name="isCqlScript"></param> /// <param name="columnsAndDataType"></param> /// <returns>Generates List<POCOObjectListForExport/> Retained As Global Variable</returns> private static void GenerateListForScriptCli(string namespaceName, string script, ref string errorMessage, bool isCqlScript, ref Dictionary<string, string> columnsAndDataType) { var fetchdatafromScript = new FetchDataFromScript(); const string createColumnFamilyCli = "create column family"; const string keyValidationClass = "key_validation_class"; const string withCompartor = "with comparator"; const string columnMetaData = "and column_metadata"; var isValidColumnFamily = Validator.ValidateCliScript(script,ref errorMessage, createColumnFamilyCli); if (!isValidColumnFamily) return; // Fetch Column family name _columnFamilyName = fetchdatafromScript.FetchData(script, createColumnFamilyCli, withCompartor); // Identify the key data type _keyDataType = fetchdatafromScript.FetchData(script, keyValidationClass, columnMetaData); // Identify the Column Details _columnDetails = fetchdatafromScript.FetchData(script, "[", "]"); isValidColumnFamily = Validator.ValidateCliScriptsColumnDetails(ref errorMessage, _columnFamilyName, _keyDataType); if (!isValidColumnFamily) return; columnsAndDataType = fetchdatafromScript.ParseColumnNameAndDataType(_columnDetails, true, ref errorMessage, ref isValidColumnFamily); _exportPocoList.Add(Parser.ConvertGeneratedMetaDataToListFormat(namespaceName, _columnFamilyName, _keyDataType, columnsAndDataType, isCqlScript)); }