Exemplo n.º 1
0
        }         // WriteIndividualSpotfireDataFilesForEachQueryTable

        /// <summary>
        /// Build and add the metadata for a column
        /// </summary>
        /// <param name="qc"></param>
        /// <param name="nameSuffix"></param>
        /// <param name="extraColNameSuffix"></param>
        /// <param name="mdb"></param>
        /// <param name="nValueMetaColumns"></param>

        void AddMetadataForColumn(
            QueryColumn qc,
            string colName,
            string extraColNameSuffix,
            SpotfireDataFileMetadataBuilder mdb,
            ExportParms ep,
            HashSet <MetaColumn> nValueMetaColumns)
        {
            QueryTable qt = qc.QueryTable;
            MetaTable  mt = qt.MetaTable;
            MetaColumn mc = qc.MetaColumn;

            SpotfireDataFileValueType sdfType = GetSpotfireDataFileType(mc);

            qc.SpotfireExportType = sdfType;

            // Structures get added as string type columns but the ContentType property for the DataTable Columns should be set to
            // chemical/x-mdl-molfile, chemical/x-mdl-chime  or chemical/x-daylight-smiles
            // Also for visualizations columns that display structures the renderer must be set to a structure renderer
            // if the structure format is chime (molfile and smiles autodetect)

            if (mc.DataType == MetaColumnType.Structure)
            {
                mdb.AddColumn(colName + extraColNameSuffix, sdfType);
            }

            // qualified number -> 1 to 3 Spotfire columns

            else if (mc.DataType == MetaColumnType.QualifiedNo)
            {
                if (QnSubcolumns.IsSplitFormat(ep.QualifiedNumberSplit))
                {
                    mdb.AddColumn(colName + "_PRFX_TXT" + extraColNameSuffix, SpotfireDataFileValueType.String);       // qualifier

                    mdb.AddColumn(colName + extraColNameSuffix, SpotfireDataFileValueType.Double);                     // main value, use basic colname

                    if (mt.SummarizedExists && mt.UseSummarizedData)
                    {
                        mdb.AddColumn(colName + "_NBR_VALS_CNSDRD" + extraColNameSuffix, SpotfireDataFileValueType.Int);                         // number of values included if summary value
                        nValueMetaColumns.Add(mc);
                    }
                }

                else                                                                               // combined QNs
                {
                    mdb.AddColumn(colName + extraColNameSuffix, SpotfireDataFileValueType.String); // combined value
                }
            }

            // Other column types use single column in Spotfire of the specified type

            else
            {
                mdb.AddColumn(colName + extraColNameSuffix, sdfType);
            }

            return;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write out the values for a data row
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="qtMap"></param>
        /// <param name="tw"></param>
        /// <param name="ep"></param>
        /// <param name="outputNValues"></param>
        /// <param name="nValueMetaColumns"></param>
        /// <param name="noDataForTable"></param>
        /// <param name="ti"></param>
        /// <param name="keyValueForRow"></param>

        void WriteRowValues(
            object[] dr,
            QueryTableVoMap qtMap,
            SpotfireDataFileTableWriter tw,
            ExportParms ep,
            bool outputNValues,
            HashSet <MetaColumn> nValueMetaColumns,
            bool noDataForTable = false,
            int ti = 0,
            string keyValueForRow = "")
        {
            QueryColumn qc;
            MetaColumn  mc;
            SpotfireDataFileValueType sdfType;
            QualifiedNumber           qn;
            object vo, vo2;
            double dVal;
            string txt;

            for (int fi = 0; fi < qtMap.SelectedColumns.Count; fi++)
            {
                qc = qtMap.SelectedColumns[fi];
                mc = qc.MetaColumn;

                sdfType = (SpotfireDataFileValueType)qc.SpotfireExportType;

                if (noDataForTable && ti == 0 && qc.IsKey)                 // if this is the root table and no data then supply the row key value
                {
                    vo             = keyValueForRow;
                    noDataForTable = false;                     // now have data
                }

                if (noDataForTable)
                {
                    vo = null;
                }
                else
                {
                    vo = dr[qc.VoPosition];
                }

                bool isNull = NullValue.IsNull(vo);

                if (isNull && (mc.DataType != MetaColumnType.QualifiedNo))                 // write null value (unless QN which may require multiple value writes)
                {
                    WriteValue(tw, sdfType, null);
                }

                else if (mc.DataType == MetaColumnType.Structure)
                {
                    if (vo is MoleculeMx)
                    {
                        string molString = GetMoleculeString(vo, ep.ExportStructureFormat);
                        WriteValue(tw, sdfType, molString);
                    }

                    else
                    {
                        vo2 = MobiusDataType.ConvertToPrimitiveValue(vo, mc);
                        WriteValue(tw, sdfType, vo2);
                    }
                }


                else if (mc.DataType == MetaColumnType.QualifiedNo)                 // write 1-3 values for Qualified number
                {
                    // Output a split QN

                    if (QnSubcolumns.IsSplitFormat(ep.QualifiedNumberSplit))
                    {
                        if (vo is QualifiedNumber && !isNull)                         // regular QN
                        {
                            qn = (QualifiedNumber)vo;
                            WriteValue(tw, SpotfireDataFileValueType.String, qn.Qualifier);                             // qualifier
                            WriteValue(tw, SpotfireDataFileValueType.Double, qn.NumberValue);

                            if (outputNValues && nValueMetaColumns.Contains(mc))
                            {
                                if (NullValue.IsNull(qn.NValueTested))
                                {
                                    WriteValue(tw, SpotfireDataFileValueType.Int, null);                                     // number in calc
                                }
                                else
                                {
                                    WriteValue(tw, SpotfireDataFileValueType.Int, qn.NValueTested);
                                }
                            }
                        }

                        else if (!isNull)                                           // non-qn
                        {
                            WriteValue(tw, SpotfireDataFileValueType.String, null); // qualifier

                            if (QualifiedNumber.TryConvertToDouble(vo, out dVal))
                            {
                                WriteValue(tw, SpotfireDataFileValueType.Double, dVal);
                            }
                            else
                            {
                                WriteValue(tw, SpotfireDataFileValueType.Double, null);
                            }

                            if (outputNValues && nValueMetaColumns.Contains(mc))
                            {
                                WriteValue(tw, SpotfireDataFileValueType.Int, null);                                 // N value
                            }
                        }

                        else                                                        // null value
                        {
                            WriteValue(tw, SpotfireDataFileValueType.String, null); // qualifier
                            WriteValue(tw, SpotfireDataFileValueType.Double, null); // value

                            if (outputNValues && nValueMetaColumns.Contains(mc))
                            {
                                WriteValue(tw, SpotfireDataFileValueType.Int, null);                                 // N value
                            }
                        }
                    }

                    // Output a non-split (combined) QN

                    else                     // combined
                    {
                        if (isNull)
                        {
                            WriteValue(tw, SpotfireDataFileValueType.String, null);
                        }

                        else if (vo is QualifiedNumber && !isNull)                         // regular QN
                        {
                            qn  = (QualifiedNumber)vo;
                            txt = qn.Format(qc, false, mc.Format, mc.Decimals, ep.QualifiedNumberSplit, false);
                            WriteValue(tw, SpotfireDataFileValueType.String, txt);
                        }

                        else if (!isNull)                         // non-qn
                        {
                            txt = vo.ToString();
                            WriteValue(tw, SpotfireDataFileValueType.String, txt);
                        }

                        else                         // null value
                        {
                            WriteValue(tw, SpotfireDataFileValueType.String, null);
                        }
                    }
                }

                else                 // write other types as primitive value for now
                {
                    vo2 = MobiusDataType.ConvertToPrimitiveValue(vo, mc);
                    WriteValue(tw, sdfType, vo2);
                }
            }             // col loop

            return;
        }