Ejemplo n.º 1
0
        /// <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));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This function creates List from VB Script Provided.
        /// </summary>
        /// <param name="pocoScript"></param>
        /// <param name="isValidScript"></param>
        /// <param name="errorMessage"></param>
        /// <returns>Returns List</returns>
        private static List<PocoObjectListForExport> GenerateListFromVbScript(string pocoScript, ref string errorMessage, out bool isValidScript)
        {
            const string startOfScript = "imports system";
            isValidScript = LangValidator.ValidateScriptsOfSelectedLanguageType(pocoScript, ref errorMessage, startOfScript);

            if (isValidScript)
            {
                var fetchdatafromScript = new FetchDataFromScript();
                //Fetch KeyspaceName(Table) name
                _keyspaceName = fetchdatafromScript.FetchData(pocoScript, "namespace", "public");
                // Fetch Column family(Table) name
                _columnFamilyName = fetchdatafromScript.FetchData(pocoScript, "public class", "public");
                _columnDetails = fetchdatafromScript.FetchData(pocoScript, _columnFamilyName, "end class");

                isValidScript = LangValidator.ValidateColumnDetailsForSelectedLanguageType(_keyspaceName, _columnFamilyName, ref errorMessage, _columnDetails);

                if (isValidScript)
                {
                    var columnsAndDataType = fetchdatafromScript.ParseColumnNameAndDataTypeForVbScript(_columnDetails, ref errorMessage, ref isValidScript);
                    var pocoChildList = Parser.PocoObjectListMetadata(columnsAndDataType);
                    _exportPocoList.Add(LangParser.ConvertFetchedDataToExportFormatInPocoToDb(_keyspaceName, _columnFamilyName, pocoChildList));

                }
            }

            return _exportPocoList;
        }
Ejemplo n.º 3
0
        /// <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));
        }