Ejemplo n.º 1
0
        public void Schema_Drop_Should_Contain_SQL(string dbType)
        {
            // Arrange
            SchemaBase    schema    = SchemaLookup.FromName(dbType);
            DbCommandStub dbCommand = new DbCommandStub();

            // Act
            schema.Drop(dbCommand);

            // Assert
            Assert.That(dbCommand.CommandText, Is.StringContaining("DROP"));
        }
Ejemplo n.º 2
0
        public void Schema_Create_Should_Contain_SQL(string dbType)
        {
            // Arrange
            SchemaBase    schema    = SchemaLookup.FromName(dbType);
            DbCommandStub dbCommand = new DbCommandStub();

            // Act
            schema.Create(dbCommand);

            // Assert
            Assert.That(dbCommand.CommandText, Is.StringContaining("CREATE TABLE"));
        }
Ejemplo n.º 3
0
        public static void MultiTask_TaskCompute(int id, Object task_data)
        {
            MultiTask_DataObj thisDataObj = (MultiTask_DataObj)task_data;

            try
            {
                SchemaLookup lookup = new SchemaLookup(thisDataObj.mParts[0], thisDataObj.mParts[1]);
                lookup.setInput(TnmStagingData.SSF25_KEY, thisDataObj.mParts[2]);
                lookup.setInput(TnmStagingData.SEX_KEY, thisDataObj.mParts[2]);

                List <StagingSchema> lookups = mMultiTask_Staging.lookupSchema(lookup);
                if (lookups == null)
                {
                    IntegrationUtils.WritelineToLog("Line #" + thisDataObj.miLineNum + " [" + thisDataObj.msFullLine + "] --> mStaging.lookupSchema returned NULL.");
                    Interlocked.Increment(ref miMultiTask_FailedCases);
                }
                else if (thisDataObj.mParts[3].Length == 0)
                {
                    if (lookups.Count == 1)
                    {
                        IntegrationUtils.WritelineToLog("Line #" + thisDataObj.miLineNum + " [" + thisDataObj.msFullLine + "] --> The schema selection should not have found any schema but did: " + lookups[0].getId());
                        Interlocked.Increment(ref miMultiTask_FailedCases);
                    }
                }
                else
                {
                    if (lookups.Count != 1)
                    {
                        IntegrationUtils.WritelineToLog("Line #" + thisDataObj.miLineNum + " [" + thisDataObj.msFullLine + "] --> The schema selection should have found a schema, " + thisDataObj.mParts[3] + ", but did not.");
                        Interlocked.Increment(ref miMultiTask_FailedCases);
                    }
                    else if (lookups[0].getId() != thisDataObj.mParts[3])
                    {
                        IntegrationUtils.WritelineToLog("Line #" + thisDataObj.miLineNum + " [" + thisDataObj.msFullLine + "] --> The schema selection found schema " + lookups[0].getId() + " but it should have been " + thisDataObj.mParts[3] + ".");
                        Interlocked.Increment(ref miMultiTask_FailedCases);
                    }
                }
            }
            catch (Exception e)
            {
                if (miMultiTask_FailedCases == 0)
                {
                    IntegrationUtils.WritelineToLog("Line #" + thisDataObj.miLineNum + " --> Exception processing schema selection: " + e.Message);
                    IntegrationUtils.WritelineToLog("  StackTrace: " + e.StackTrace);
                }
                Interlocked.Increment(ref miMultiTask_FailedCases);
            }

            Interlocked.Increment(ref miMultiTask_ThreadProcessedCases);
        }
        public static void MultiTask_TaskCompute(int id, Object task_data)
        {
            MultiTask_DataObj thisDataObj = (MultiTask_DataObj)task_data;

            //IntegrationUtils.WritelineToLog("Task " + id + " - Executing Line " + thisDataObj.miLineNum + " - " + DateTime.Now.ToString("HH:mm:ss.ffff"));

            // load up inputs
            CsStagingData data = new CsStagingData();

            data.setInput(CsInput.PRIMARY_SITE, thisDataObj.mValues[0]);
            data.setInput(CsInput.HISTOLOGY, thisDataObj.mValues[1]);
            data.setInput(CsInput.DX_YEAR, thisDataObj.mValues[2]);
            data.setInput(CsInput.CS_VERSION_ORIGINAL, thisDataObj.mValues[3]);
            data.setInput(CsInput.BEHAVIOR, thisDataObj.mValues[4]);
            data.setInput(CsInput.GRADE, thisDataObj.mValues[5]);
            data.setInput(CsInput.AGE_AT_DX, thisDataObj.mValues[6]);
            data.setInput(CsInput.LVI, thisDataObj.mValues[7]);
            data.setInput(CsInput.TUMOR_SIZE, thisDataObj.mValues[8]);
            data.setInput(CsInput.EXTENSION, thisDataObj.mValues[9]);
            data.setInput(CsInput.EXTENSION_EVAL, thisDataObj.mValues[10]);
            data.setInput(CsInput.LYMPH_NODES, thisDataObj.mValues[11]);
            data.setInput(CsInput.LYMPH_NODES_EVAL, thisDataObj.mValues[12]);
            data.setInput(CsInput.REGIONAL_NODES_POSITIVE, thisDataObj.mValues[13]);
            data.setInput(CsInput.REGIONAL_NODES_EXAMINED, thisDataObj.mValues[14]);
            data.setInput(CsInput.METS_AT_DX, thisDataObj.mValues[15]);
            data.setInput(CsInput.METS_EVAL, thisDataObj.mValues[16]);
            data.setInput(CsInput.SSF1, thisDataObj.mValues[17]);
            data.setInput(CsInput.SSF2, thisDataObj.mValues[18]);
            data.setInput(CsInput.SSF3, thisDataObj.mValues[19]);
            data.setInput(CsInput.SSF4, thisDataObj.mValues[20]);
            data.setInput(CsInput.SSF5, thisDataObj.mValues[21]);
            data.setInput(CsInput.SSF6, thisDataObj.mValues[22]);
            data.setInput(CsInput.SSF7, thisDataObj.mValues[23]);
            data.setInput(CsInput.SSF8, thisDataObj.mValues[24]);
            data.setInput(CsInput.SSF9, thisDataObj.mValues[25]);
            data.setInput(CsInput.SSF10, thisDataObj.mValues[26]);
            data.setInput(CsInput.SSF11, thisDataObj.mValues[27]);
            data.setInput(CsInput.SSF12, thisDataObj.mValues[28]);
            data.setInput(CsInput.SSF13, thisDataObj.mValues[29]);
            data.setInput(CsInput.SSF14, thisDataObj.mValues[30]);
            data.setInput(CsInput.SSF15, thisDataObj.mValues[31]);
            data.setInput(CsInput.SSF16, thisDataObj.mValues[32]);
            data.setInput(CsInput.SSF17, thisDataObj.mValues[33]);
            data.setInput(CsInput.SSF18, thisDataObj.mValues[34]);
            data.setInput(CsInput.SSF19, thisDataObj.mValues[35]);
            data.setInput(CsInput.SSF20, thisDataObj.mValues[36]);
            data.setInput(CsInput.SSF21, thisDataObj.mValues[37]);
            data.setInput(CsInput.SSF22, thisDataObj.mValues[38]);
            data.setInput(CsInput.SSF23, thisDataObj.mValues[39]);
            data.setInput(CsInput.SSF24, thisDataObj.mValues[40]);
            data.setInput(CsInput.SSF25, thisDataObj.mValues[41]);

            try
            {
                // save the expected outputs
                Dictionary <String, String> output = new Dictionary <String, String>(100, StringComparer.Ordinal);
                String sKeyValue = "";
                foreach (KeyValuePair <CsOutput, int> entry in thisDataObj.mMappings)
                {
                    sKeyValue         = entry.Key.toString();
                    output[sKeyValue] = thisDataObj.mValues[entry.Value];
                }

                // run collaborative stage; if no schema found, set the output to empty
                SchemaLookup lookup = new SchemaLookup(data.getInput(CsInput.PRIMARY_SITE), data.getInput(CsInput.HISTOLOGY));
                lookup.setInput(CsStagingData.SSF25_KEY, data.getInput(CsInput.SSF25));
                List <StagingSchema> schemas = mMultiTask_Staging.lookupSchema(lookup);

                if (schemas.Count == 1)
                {
                    mMultiTask_Staging.stage(data);
                }
                else
                {
                    Dictionary <String, String> outResult = new Dictionary <String, String>(2, StringComparer.Ordinal);
                    outResult["schema_id"] = "<invalid>";

                    data.setOutput(outResult);
                }

                List <String> mismatches = new List <String>();

                // compare results
                foreach (KeyValuePair <String, String> entry in output)
                {
                    String expected = "";
                    output.TryGetValue(entry.Key, out expected);
                    if (expected == null)
                    {
                        expected = "";
                    }
                    expected = expected.Trim();

                    String actual = "";
                    data.getOutput().TryGetValue(entry.Key, out actual);
                    if (actual == null)
                    {
                        actual = "";
                    }
                    actual = actual.Trim();

                    if (expected != actual)
                    {
                        mismatches.Add("   " + thisDataObj.miLineNum + " --> " + entry.Key + ": EXPECTED '" + expected + "' ACTUAL: '" + actual + "'");
                    }
                }

                if (mismatches.Count != 0)
                {
                    String sSchemaIDValue = data.getSchemaId();

                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> [" + sSchemaIDValue + "] Mismatches in " + thisDataObj.msFileName);
                    foreach (String mismatch in mismatches)
                    {
                        IntegrationUtils.WritelineToLog(mismatch);
                    }
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " *** RESULT: " + data.getResult());
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> " + IntegrationUtils.convertInputMap(data.getInput()));
                    if (data.getErrors().Count > 0)
                    {
                        IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> ERRORS: ");
                        foreach (Error e in data.getErrors())
                        {
                            IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> (" + e.getTable() + ": " + e.getMessage() + ") ");
                        }
                    }

                    Interlocked.Increment(ref miMultiTask_FailedCases);
                }
            }
            catch (Exception e)
            {
                IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Exception processing " + thisDataObj.msFileName + " : " + e.Message);
                Interlocked.Increment(ref miMultiTask_FailedCases);
            }

            Interlocked.Increment(ref miMultiTask_ThreadProcessedCases);
        }
Ejemplo n.º 5
0
        public static void MultiTask_TaskCompute(int id, Object task_data)
        {
            MultiTask_DataObj thisDataObj = (MultiTask_DataObj)task_data;

            try
            {
                // load up inputs
                TnmStagingData data = new TnmStagingData();
                foreach (KeyValuePair <TnmInput, String> kp in thisDataObj.mInputValues)
                {
                    data.setInput(kp.Key, kp.Value);
                }

                // save the expected outputs
                Dictionary <String, String> output = new Dictionary <String, String>(100, StringComparer.Ordinal);
                String sKeyValue = "";
                foreach (KeyValuePair <TnmOutput, String> entry in thisDataObj.mOutputValues)
                {
                    sKeyValue         = entry.Key.toString();
                    output[sKeyValue] = entry.Value;
                }


                // run collaborative stage; if no schema found, set the output to empty
                SchemaLookup lookup = new SchemaLookup(data.getInput(TnmInput.PRIMARY_SITE), data.getInput(TnmInput.HISTOLOGY));
                lookup.setInput(TnmStagingData.SEX_KEY, data.getInput(TnmInput.SEX));
                lookup.setInput(TnmStagingData.SSF25_KEY, data.getInput(TnmInput.SSF25));
                List <StagingSchema> schemas = mMultiTask_Staging.lookupSchema(lookup);

                if (schemas.Count == 1)
                {
                    mMultiTask_Staging.stage(data);
                }
                else
                {
                    Dictionary <String, String> outResult = new Dictionary <String, String>(2, StringComparer.Ordinal);
                    outResult["schema_id"] = "<invalid>";

                    data.setOutput(outResult);
                }

                List <String> mismatches = new List <String>();

                // compare results
                if (!thisDataObj.mbJSONFormat)
                {
                    String sNewResultStr = "";
                    String sOldResultStr = thisDataObj.msExpectedResult.Trim();
                    if (data.getResult() == StagingData.Result.STAGED)
                    {
                        sNewResultStr = "STAGED";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_MISSING_SITE_OR_HISTOLOGY)
                    {
                        sNewResultStr = "FAILED_MISSING_SITE_OR_HISTOLOGY";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_NO_MATCHING_SCHEMA)
                    {
                        sNewResultStr = "FAILED_NO_MATCHING_SCHEMA";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_MULITPLE_MATCHING_SCHEMAS)
                    {
                        sNewResultStr = "FAILED_MULITPLE_MATCHING_SCHEMAS";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_INVALID_YEAR_DX)
                    {
                        sNewResultStr = "FAILED_INVALID_YEAR_DX";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_INVALID_INPUT)
                    {
                        sNewResultStr = "FAILED_INVALID_INPUT";
                    }

                    if (sNewResultStr != sOldResultStr)
                    {
                        mismatches.Add("   " + thisDataObj.miLineNum + " --> Result: EXPECTED '" + sOldResultStr + "' ACTUAL: '" + sNewResultStr + "'");
                    }
                }

                // compare output
                foreach (KeyValuePair <String, String> entry in output)
                {
                    String expected = "";
                    output.TryGetValue(entry.Key, out expected);
                    if (expected == null)
                    {
                        expected = "";
                    }
                    expected = expected.Trim();

                    String actual = "";
                    data.getOutput().TryGetValue(entry.Key, out actual);
                    if (actual == null)
                    {
                        actual = "";
                    }
                    actual = actual.Trim();

                    if (expected != actual)
                    {
                        mismatches.Add("   " + thisDataObj.miLineNum + " --> " + entry.Key + ": EXPECTED '" + expected + "' ACTUAL: '" + actual + "'");
                    }
                }

                if (mismatches.Count != 0)
                {
                    String sSchemaIDValue = data.getSchemaId();


                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> [" + sSchemaIDValue + "] Mismatches in " + thisDataObj.msFileName);
                    foreach (String mismatch in mismatches)
                    {
                        IntegrationUtils.WritelineToLog(mismatch);
                    }
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " *** RESULT: " + data.getResult());
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Input: " + IntegrationUtils.convertInputMap(data.getInput()));
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Output: " + IntegrationUtils.convertInputMap(data.getOutput()));
                    if (data.getErrors().Count > 0)
                    {
                        IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> ERRORS: ");
                        foreach (Error e in data.getErrors())
                        {
                            IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> (" + e.getTable() + ": " + e.getMessage() + ") ");
                        }
                    }

                    Interlocked.Increment(ref miMultiTask_FailedCases);
                }
            }
            catch (Exception e)
            {
                IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Exception processing " + thisDataObj.msFileName + " : " + e.Message);
                Interlocked.Increment(ref miMultiTask_FailedCases);
            }

            Interlocked.Increment(ref miMultiTask_ThreadProcessedCases);
        }