public string Line(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetLegacySymbol symbol, LegacyEntityType entity, LegacyFunctionCodeType code)
        {
            string result = "";
            string graphic = "";

            _notes = "";

            string graphicPath = _configHelper.GetPath("JMSML_2525C", FindEnum.Find2525C);

            if (entity.Graphic != "" && entity.Icon != IconType.FULL_FRAME)
                graphic = entity.Graphic;
            else
                graphic = GrabGraphic(entity.CloverGraphic, entity.RectangleGraphic, entity.SquareGraphic, entity.DiamondGraphic, sig.GraphicSuffix);

            string id = graphic.Substring(0, graphic.Length - 4); ;

            IconType iType = entity.Icon;
            string geometryType = GeometryIs(entity.GeometryType);

            string itemRootedPath = _configHelper.BuildRootedPath(graphicPath, graphic);
            string itemOriginalPath = _configHelper.BuildOriginalPath(graphicPath, graphic);

            if (!File.Exists(itemOriginalPath))
                _notes = _notes + "image file does not exist;";

            result = result + itemRootedPath;
            result = result + "," + Convert.ToString(_configHelper.PointSize);
            result = result + "," + id;
            result = result + "," + BuildEntityItemCategory(ss, iType, geometryType);
            result = result + "," + BuildEntityItemTags(sig, ss, symbol, entity, code);
            result = result + "," + id;
            result = result + "," + geometryType;
            result = result + "," + _notes;

            return result;
        }
        private void _UpdateFromLegacy()
        {
            // Search for the appropriate JMSML Library elements, given the older/legacy (2525C, 2525B, etc.)
            // SIDC for this Symbol.

            _librarian.ResetStatusCode();

            _version = _librarian.Version(1, 0);

            _legacySymbol = _librarian.LegacySymbol(_legacySIDC, ref _dimension, ref _symbolSet);

            if (_legacySymbol != null)
            {
                _affiliation = _librarian.AffiliationByLegacyCode(_legacySIDC.Substring(1, 1), _dimension.ID);

                if (_affiliation != null)
                {
                    _context = _librarian.Context(_affiliation.ContextID);
                    _standardIdentity = _librarian.StandardIdentity(_affiliation.StandardIdentityID);
                    _sig = _librarian.StandardIdentityGroup(_standardIdentity);
                }

                _status = _librarian.Status(_legacySIDC.Substring(3, 1), _legacySIDC.Substring(0, 1));
                _hqTFDummy = _librarian.HQTFDummy(_legacySIDC.Substring(10, 1));

                _amplifier = _librarian.Amplifier(_legacySIDC.Substring(11, 1), _legacySIDC.Substring(0, 1));

                if (_amplifier != null)
                {
                    _amplifierGroup = _librarian.AmplifierGroup(_amplifier);
                }

                _entity = _librarian.Entity(_symbolSet, _legacySymbol.EntityID);
                _entityType = _librarian.EntityType(_entity, _legacySymbol.EntityTypeID);
                _entitySubType = _librarian.EntitySubType(_symbolSet, _entityType, _legacySymbol.EntitySubTypeID);
                _modifierOne = _librarian.ModifierOne(_symbolSet, _legacySymbol.ModifierOneID);
                _modifierTwo = _librarian.ModifierTwo(_symbolSet, _legacySymbol.ModifierTwoID);
            }

            _librarian.LogConversionResult(_legacySIDC);

            _ValidateStatus();
        }
        private void _UpdateFromCurrent()
        {
            // Search for the appropriate JMSML Library elements, given the current (2525D)
            // SIDC for this Symbol.

            string first10 = _sidc.PartAString;
            string second10 = _sidc.PartBString;

            _librarian.ResetStatusCode();

            _version = _librarian.Version(Convert.ToUInt16(first10.Substring(0, 1)),
                                          Convert.ToUInt16(first10.Substring(1, 1)));

            _context = _librarian.Context(Convert.ToUInt16(first10.Substring(2, 1)));
            _standardIdentity = _librarian.StandardIdentity(Convert.ToUInt16(first10.Substring(3, 1)));
            _sig = _librarian.StandardIdentityGroup(_standardIdentity);
            _symbolSet = _librarian.SymbolSet(Convert.ToUInt16(first10.Substring(4, 1)), Convert.ToUInt16(first10.Substring(5, 1)));

            if (_symbolSet != null)
            {
                _dimension = _librarian.DimensionBySymbolSet(_symbolSet.ID);
            }

            if (_context != null && _dimension != null && _standardIdentity != null)
            {
                _affiliation = _librarian.Affiliation(_context.ID, _dimension.ID, _standardIdentity.ID);
            }

            _status = _librarian.Status(Convert.ToUInt16(first10.Substring(6, 1)));
            _hqTFDummy = _librarian.HQTFDummy(Convert.ToUInt16(first10.Substring(7, 1)));
            _amplifierGroup = _librarian.AmplifierGroup(Convert.ToUInt16(first10.Substring(8, 1)));

            if (_amplifierGroup != null)
            {
                _amplifier = _librarian.Amplifier(_amplifierGroup, Convert.ToUInt16(first10.Substring(9, 1)));
            }

            if (_symbolSet != null)
            {
                _entity = _librarian.Entity(_symbolSet, Convert.ToUInt16(second10.Substring(0, 1)), Convert.ToUInt16(second10.Substring(1, 1)));

                if (_entity != null)
                {
                    _entityType = _librarian.EntityType(_entity, Convert.ToUInt16(second10.Substring(2, 1)), Convert.ToUInt16(second10.Substring(3, 1)));
                }

                if (_entityType != null)
                {
                    _entitySubType = _librarian.EntitySubType(_entityType, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));

                    if (_entitySubType == null)
                    {
                        _entitySubType = _librarian.EntitySubType(_symbolSet, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));
                    }
                }

                _modifierOne = _librarian.ModifierOne(_symbolSet, Convert.ToUInt16(second10.Substring(6, 1)), Convert.ToUInt16(second10.Substring(7, 1)));
                _modifierTwo = _librarian.ModifierTwo(_symbolSet, Convert.ToUInt16(second10.Substring(8, 1)), Convert.ToUInt16(second10.Substring(9, 1)));

                _legacySymbol = _librarian.LegacySymbol(_symbolSet, _entity, _entityType, _entitySubType, _modifierOne, _modifierTwo);
            }

            _librarian.LogConversionResult(_sidc.PartAString + ", " + _sidc.PartBString);

            _ValidateStatus();
        }
Example #4
0
        private void _importLegacyData(string source, string destination)
        {
            if (File.Exists(destination))
            {
                SymbolSet ss = _deserializeSymbolSet(destination);
                LibraryDimension dimension = _librarian.Dimension(ss.DimensionID);

                if (ss != null)
                {
                    string code = Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);

                    if (code != "")
                    {
                        // Open the source file for read.

                        if (File.Exists(source))
                        {
                            // Lets build a list of legacy symbols to hold the results

                            List<SymbolSetLegacySymbol> legacySymbols = new List<SymbolSetLegacySymbol>();

                            // Now process the input

                            string line = "";

                            using (StreamReader r = new StreamReader(source))
                            {
                                while (!r.EndOfStream)
                                {
                                    line = r.ReadLine();

                                    string[] tokens = line.Split(',');
                                    string ssCode = tokens[2];
                                    string legacyCode = tokens[0];
                                    string fullLegacyCode = tokens[1];

                                    string mod1Code = tokens[4];
                                    string mod2Code = tokens[5];

                                    string status = tokens[6];
                                    string remarks = tokens[7];

                                    // Skip over all rows in the source file that don't match the symbol set code
                                    // or where the 2525C SIDC field is blank.

                                    if (ssCode == code && legacyCode != "")
                                    {
                                        // Extract the six character function code from the current 2525C SIDC.

                                        string functionCode = legacyCode.Substring(legacyCode.Length - 6);
                                        //string schemaCode = legacyCode.Substring(0, 1);
                                        //string dimensionCode = legacyCode.Substring(2, 1);

                                        string entityCode = tokens[3];

                                        if (entityCode.Length == 6)
                                        {
                                            string eCode = entityCode.Substring(0, 2);
                                            string etCode = entityCode.Substring(2, 2);
                                            string estCode = entityCode.Substring(4, 2);

                                            // Now that we have everything, let's find the pieces in the open symbol set

                                            SymbolSetLegacySymbol ls = new SymbolSetLegacySymbol();

                                            // Find the entity, entity type, and entity subtype for the specified SIDC.

                                            SymbolSetEntity entity = _librarian.Entity(ss, Convert.ToUInt16(eCode.Substring(0, 1)), Convert.ToUInt16(eCode.Substring(1, 1)));

                                            if (entity != null)
                                            {
                                                ls.EntityID = entity.ID;
                                                ls.ID = entity.ID;

                                                if (etCode != "00")
                                                {
                                                    SymbolSetEntityEntityType eType = _librarian.EntityType(entity, Convert.ToUInt16(etCode.Substring(0, 1)), Convert.ToUInt16(etCode.Substring(1, 1)));

                                                    if (eType != null)
                                                    {
                                                        ls.EntityTypeID = eType.ID;
                                                        ls.ID = ls.ID + "_" + eType.ID;

                                                        if (estCode != "00")
                                                        {
                                                            EntitySubTypeType eSubType = _librarian.EntitySubType(eType, Convert.ToUInt16(estCode.Substring(0, 1)), Convert.ToUInt16(estCode.Substring(1, 1)));

                                                            if (eSubType != null)
                                                            {
                                                                ls.EntitySubTypeID = eSubType.ID;
                                                                ls.ID = ls.ID + "_" + eSubType.ID;
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            // No entities were found, so mark it as retired.

                                            if (ls.ID == null)
                                            {
                                                ls.ID = "RETIRED";
                                                ls.Remarks = "Retired";
                                            }

                                            // Find the modifier 1 and modifier 2 for the specified SIDC.

                                            if (mod1Code != "" && mod1Code != "00" && mod1Code != "0")
                                            {
                                                if (mod1Code.Length == 2)
                                                {
                                                    ModifiersTypeModifier mod = _librarian.ModifierOne(ss, Convert.ToUInt16(mod1Code.Substring(0, 1)), Convert.ToUInt16(mod1Code.Substring(1, 1)));

                                                    if (mod != null)
                                                    {
                                                        ls.ModifierOneID = mod.ID;
                                                        ls.ID = ls.ID + "_" + mod.ID;
                                                    }
                                                }
                                            }

                                            if (mod2Code != "" && mod2Code != "00" && mod2Code != "0")
                                            {
                                                if (mod2Code.Length == 2)
                                                {
                                                    ModifiersTypeModifier mod = _librarian.ModifierTwo(ss, Convert.ToUInt16(mod2Code.Substring(0, 1)), Convert.ToUInt16(mod2Code.Substring(1, 1)));

                                                    if (mod != null)
                                                    {
                                                        ls.ModifierTwoID = mod.ID;
                                                        ls.ID = ls.ID + "_" + mod.ID;
                                                    }
                                                }
                                            }

                                            ls.ID = ls.ID + "_SYM";
                                            ls.Label = fullLegacyCode;

                                            // Add the legacy function code

                                            LegacyFunctionCodeType lfCode = new LegacyFunctionCodeType();
                                            lfCode.Name = "2525C";

                                            if (fullLegacyCode.Substring(0, 1) != ss.LegacyCodingSchemeCode[0].Value)
                                                lfCode.SchemaOverride = fullLegacyCode.Substring(0, 1);

                                            if (fullLegacyCode.Substring(2, 1) != dimension.LegacyDimensionCode[0].Value)
                                                lfCode.DimensionOverride = fullLegacyCode.Substring(2, 1);

                                            lfCode.Value = functionCode;

                                            if (status != "")
                                                lfCode.Description = status;

                                            if (remarks != "")
                                                lfCode.Remarks = remarks;

                                            ls.LegacyFunctionCode = new LegacyFunctionCodeType[] { lfCode };

                                            // Add it to the current legacy symbol set

                                            legacySymbols.Add(ls);
                                        }
                                    }
                                }

                                r.Close();
                            }

                            // Done processing the input.  If there is anything in our list then add it to the
                            // symbol set and re-serialize it.  Remove the existing values if they exist.

                            if (legacySymbols.Count > 0)
                            {
                                ss.LegacySymbols = legacySymbols.ToArray();

                                // Serialize the symbol set

                                _serializeSymbolSet(ss, destination);
                            }
                        }
                    }
                }
            }
        }
        public string Line(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyFunctionCodeType functionCode)
        {
            string result = "";

            string name = _buildName(ss, legacySymbol);
            string entityCode = "";
            string extraIcon = "";

            // Special care is needed with special entity subtypes

            bool isEntitySubTypeSpecial = false;

            if (_entitySubType != null)
            {
                if (_configHelper.IsSpecialEntitySubtype(ss, _entitySubType))
                {
                    entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, null);
                    extraIcon = _entityExport.CodeIt(null, ss, null, null, _entitySubType);
                    isEntitySubTypeSpecial = true;
                }
                else
                    entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, _entitySubType);
            }
            else
                entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, _entitySubType);

            string mod1Code = "";
            string mod2Code = "";

            if (_modifier1 != null && _modifier1.Label != "Unspecified" && _modifier1.Label != "Not Applicable")
                mod1Code = _modifierExport.CodeIt(ss, "1", _modifier1);

            if (_modifier2 != null && _modifier2.Label != "Unspecified" && _modifier2.Label != "Not Applicable")
                mod2Code = _modifierExport.CodeIt(ss, "2", _modifier2);

            bool fullFrame = false;
            string geometry = _entityExport.GeometryIt(_entity, _entityType, _entitySubType);

            if (_entitySubType != null && !isEntitySubTypeSpecial)
            {
                fullFrame = _entitySubType.Icon == IconType.FULL_FRAME;
            }
            else if (_entityType != null)
            {
                fullFrame = _entityType.Icon == IconType.FULL_FRAME;
            }
            else if (_entity != null)
            {
                fullFrame = _entity.Icon == IconType.FULL_FRAME;
            }

            string fullFrameOutput = fullFrame ? "TRUE" : "";

            result = name;
            result = result + "," + _buildSIDCKey(ss, legacySymbol, functionCode); // + "LegacyKey";
            result = result + "," + entityCode; // + "MainIcon";
            result = result + "," + mod1Code;  // + "Modifier1";
            result = result + "," + mod2Code; // + "Modifier2";
            result = result + "," + extraIcon; // + "ExtraIcon";
            result = result + "," + fullFrameOutput; // + "FullFrame";
            result = result + "," + geometry; // + "GeometryType";
            result = result + ","; // + "Standard";
            result = result + ","; // + "Status";
            result = result + ","; // + "Notes";

            return result;
        }
        private string _buildSIDCKey(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyFunctionCodeType functionCode)
        {
            // Builds a unique key from a select number of characters from an SIDC.
            // The pattern for this is:
            //
            // S-D-FFFFFF
            //
            // Where:
            //
            // S = Schema code
            // D = Dimension code
            // FFFFFF = Function code

            string result = "";

            if (functionCode != null)
            {
                if (functionCode.SchemaOverride == "")
                {
                    LegacyLetterCodeType letterCode = _configHelper.LegacyLetter(ss.LegacyCodingSchemeCode, _standard);
                    if(letterCode != null)
                        result = letterCode.Value;
                }
                else
                    result = functionCode.SchemaOverride;

                result = result + "-";

                Librarian lib = _configHelper.Librarian;
                LibraryDimension dimension = lib.Dimension(ss.DimensionID);

                if (functionCode.DimensionOverride == "")
                {
                    LegacyLetterCodeType letterCode = _configHelper.LegacyLetter(dimension.LegacyDimensionCode, _standard);
                    if (letterCode != null)
                        result = result + letterCode.Value;
                }
                else
                    result = result + functionCode.DimensionOverride;

                result = result + "-";
                result = result + functionCode.Value;
            }

            return result;
        }
        private string _buildName(SymbolSet ss, SymbolSetLegacySymbol legacySymbol)
        {
            // Builds a seperated string of components names for all the 2525D elements
            // used to make this legacy symbol

            string result = "";

            Librarian lib = _configHelper.Librarian;

            if (legacySymbol.EntityID != "")
                _entity = lib.Entity(ss, legacySymbol.EntityID);
            else
                _entity = null;

            if (_entity != null && legacySymbol.EntityTypeID != "")
                _entityType = lib.EntityType(_entity, legacySymbol.EntityTypeID);
            else
                _entityType = null;

            if (_entityType != null && legacySymbol.EntitySubTypeID != "")
                _entitySubType = lib.EntitySubType(ss, _entityType, legacySymbol.EntitySubTypeID);
            else
                _entitySubType = null;

            if (legacySymbol.ModifierOneID != "")
                _modifier1 = lib.ModifierOne(ss, legacySymbol.ModifierOneID);
            else
                _modifier1 = null;

            if (legacySymbol.ModifierTwoID != "")
                _modifier2 = lib.ModifierTwo(ss, legacySymbol.ModifierTwoID);
            else
                _modifier2 = null;

            result = _entityExport.NameIt(null, ss, _entity, _entityType, _entitySubType);

            if (_modifier1 != null && _modifier1.Label != "Unspecified" && _modifier1.Label != "Not Applicable")
                result = result + _configHelper.DomainSeparator + _modifierExport.NameIt(ss, "1", _modifier1);

            if (_modifier2 != null && _modifier2.Label != "Unspecified" && _modifier2.Label != "Not Applicable")
                result = result + _configHelper.DomainSeparator + _modifierExport.NameIt(ss, "2", _modifier2);

            return result;
        }
        public string Line(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyEntityType legacyEntity, LegacyFunctionCodeType functionCode)
        {
            string result = "";

            string sidcKey = _buildSIDCKey(ss, legacySymbol, functionCode);

            bool fullFrame = (legacyEntity.Icon == IconType.FULL_FRAME);
            string fullFrameOutput = fullFrame ? "TRUE" : "";

            result = legacyEntity.Label;
            result = result + "," + sidcKey;
            result = result + "," + sidcKey;
            result = result + ",";
            result = result + ",";
            result = result + ",";
            result = result + "," + fullFrameOutput;
            result = result + "," + "Point"; // TODO : Handle this through a modernized form of GeometryIt
            result = result + ",";
            result = result + ",";
            result = result + ",";

            return result;
        }
        protected string BuildEntityItemTags(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetLegacySymbol symbol, LegacyEntityType entity, LegacyFunctionCodeType code)
        {
            // Builds a list of seperated tag strings from information derived from the specified objects.
            // TODO: Normalize with similar code found in the preceding function.

            string result = "";
            string graphic = "";

            string name = entity.Label.Replace(',', '-');

            // Add the type of geometry

            string geometry = _geometryList[(int)entity.GeometryType];

            if (entity.Icon == IconType.FULL_FRAME)
            {
                if (sig != null)
                {
                    graphic = GrabGraphic(entity.CloverGraphic, entity.RectangleGraphic, entity.SquareGraphic, entity.DiamondGraphic, sig.GraphicSuffix);
                }

                _notes = _notes + "icon touches frame;";
            }
            else
                graphic = entity.Graphic;

            // Create the unique ID

            string id = graphic.Substring(0, graphic.Length - 4);

            // Grab any custom XML tags that might exist

            string[] xmlTags = entity.Tags;

            // Now build the string

            result = ss.Label.Replace(',', '-');
            result = result + ";" + name;

            // If there is a standard identity group, add it

            if (sig != null)
            {
                result = result + ";" + sig.Label;
            }

            // Add any custom XML or export tags that might exist

            result = _configHelper.AddCustomTags(result, id, xmlTags);

            // Add the 15 character SIDC for the symbol

            result = result + ";" + symbol.Label;

            // Add the entity's type

            result = result + ";" + Convert.ToString(entity.Icon);

            // Add the three most important pieces of information

            result = result + ";" + geometry;
            result = result + ";" + name;
            result = result + ";" + id;

            if (result.Length > 255)
            {
                // Can't have a tag string greater than 255 in length.
                // Human interaction will be required to resolve these on a case by case basis.

                _notes = _notes + "styleItemTags > 255;";
            }

            return result;
        }