Example #1
0
        public Resource ConvertElementToResource(EAAPI.Element eaElement)
        {
            Resource result;

            result = new Resource();

            if (eaElement != null)
            {
                result.ID = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(eaElement.ElementGUID);

                result.Revision = "1";

                result.ChangedAt = eaElement.Modified;

                result.ChangedBy = eaElement.Author;

                result.Class = new Key("RC-Requirement", "1");

                result.Properties = new List <Property>();

                string name = eaElement.Name;

                string classifierName = eaElement.GetClassifierName(_repository);

                if (!string.IsNullOrEmpty(classifierName))
                {
                    if (name == "")
                    {
                        name = classifierName;
                    }
                    else
                    {
                        name += " : " + classifierName;
                    }
                }

                result.Title = new Value(name);

                Property nameProperty = new Property
                {
                    Title         = new Value("dcterms:title"),
                    PropertyClass = new Key("AT-Req-Name", "1"),
                    Value         = new Value
                    {
                        LanguageValues = new List <LanguageValue>
                        {
                            new LanguageValue
                            {
                                Text = name
                            }
                        }
                    },
                    ID        = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(eaElement.ElementGUID + "_NAME"),
                    ChangedAt = eaElement.Modified,
                    ChangedBy = eaElement.Author
                };

                result.Properties.Add(nameProperty);

                Property notesProperty = new Property
                {
                    Title         = new Value("dcterms:description"),
                    PropertyClass = new Key("PC-Text", "1"),
                    Value         = new Value
                    {
                        LanguageValues = new List <LanguageValue>
                        {
                            new LanguageValue
                            {
                                Text = eaElement.Notes
                            }
                        }
                    },
                    ID        = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(eaElement.ElementGUID + "_NOTES"),
                    ChangedAt = eaElement.Modified,
                    ChangedBy = eaElement.Author
                };



                result.Properties.Add(notesProperty);


                string stereotype = eaElement.Stereotype;

                if (eaElement.Type == "Requirement")
                {
                    result.Class = new Key("RC-Requirement", "1");

                    string identifier = eaElement.GetTaggedValueString("Identifier");

                    if (!string.IsNullOrEmpty(identifier))
                    {
                        Property identifierProperty = new Property
                        {
                            Title         = new Value("dcterms:identifier"),
                            PropertyClass = new Key("PC-VisibleId", "1"),
                            Value         = new Value
                            {
                                LanguageValues = new List <LanguageValue>
                                {
                                    new LanguageValue
                                    {
                                        Text = identifier
                                    }
                                }
                            },
                            ID        = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(eaElement.ElementGUID + "_IDENTIFIER"),
                            ChangedAt = eaElement.Modified,
                            ChangedBy = eaElement.Author
                        };

                        result.Properties.Add(identifierProperty);
                    }

                    string status = eaElement.Status;

                    string statusID = "";

                    switch (status)
                    {
                    case "00_rejected":
                        statusID = "V-Status-1";
                        break;

                    case "10_initial":
                        statusID = "V-Status-2";
                        break;

                    case "20_drafted":
                        statusID = "V-Status-3";
                        break;

                    case "30_submitted":
                        statusID = "V-Status-4";
                        break;

                    case "40_approved":
                        statusID = "V-Req-Status-3";
                        break;
                    }

                    if (!string.IsNullOrEmpty(statusID))
                    {
                        Property statusProperty = new Property
                        {
                            Title         = new Value("SpecIF:Status"),
                            PropertyClass = new Key("PC-Status", "1"),
                            Value         = new Value
                            {
                                LanguageValues = new List <LanguageValue>
                                {
                                    new LanguageValue
                                    {
                                        Text = statusID
                                    }
                                }
                            },
                            ID        = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(eaElement.ElementGUID + "_STATUS"),
                            ChangedAt = eaElement.Modified,
                            ChangedBy = eaElement.Author
                        };

                        result.Properties.Add(statusProperty);
                    }
                }
                else if (eaElement.Type == "Package")
                {
                    result.Class = new Key("RC-Folder", "1");
                }
                else if (eaElement.Type == "Object")
                {
                    if (stereotype == "agent" || stereotype == "human agent")
                    {
                        result.Class = new Key("RC-Actor", "1");
                    }
                    else if (stereotype == "storage")
                    {
                        result.Class = new Key("RC-State", "1");
                    }
                    else if (stereotype == "heading")
                    {
                        result.Class = new Key("RC-Folder", "1");
                    }
                }
                else if (eaElement.Type == "Actor")
                {
                    result.Class = new Key("RC-Actor", "1");
                }
                else if (eaElement.Type == "Port")
                {
                    if (stereotype == "channel")
                    {
                        //result.ResourceClass = "OT-Channel";
                    }
                }
            }

            return(result);
        }