private void BtnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateManifest())
            {
                Manifest             = new PackageManifest();
                Manifest.PackageName = tbName.Text;
                Manifest.Author      = tbAuthor.Text;
                Manifest.Version     = tbVersion.Text;
                Manifest.DllPath     = cbbMainDll.SelectedValue.ToString();
                Manifest.Description = tbDescription.Text;

                PackageDefinition definition     = Definitions.Find(def => def.Extension == cbbPackageType.SelectedValue.ToString());
                SaveFileDialog    saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = $"{definition.Name} (*.{definition.Extension})";
                bool?result = saveFileDialog.ShowDialog();
                if (result.HasValue)
                {
                    if (result.Value == true)
                    {
                        if (Packages.Pack(contents.ToList(), saveFileDialog.FileName, Manifest))
                        {
                            DoneAlert.Show($"package created.\nLocation:\n{saveFileDialog.FileName}");
                        }
                    }
                }
            }
        }
        /// <inheritdoc />
        public override void Initialize()
        {
            SaveCommand    = new SaveCommand();
            CancelCommand  = new CancelCommand();
            AddCommand     = new AddCommand();
            RemoveCommand  = new RemoveCommand();
            PackageElement = Repository.GetContextObject().Element;
            UMLNameValue   = PackageElement.Name;
            AliasValue     = PackageElement.Alias;
            TaggedValues   = PackageElement.TaggedValues;

            //Finalize list of stereotype tags to add
            switch (PackageElement.Stereotype)
            {
            case "LogicalModel":
            case "CoreModel":
            case "ApplicationModel":
            case "Vocabulary":
            case "ApplicationProfile":
                _toAddModelMetadataTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "WasDerivedFrom"));
                break;
            }

            //Retrieve all tagged values and store them in a list
            //Tagged values are stored in a list to avoid iterating Collections multiple times, which is very costly
            //In a future iteration of the addin, avoid iterating the collection even once, instead using Repository.SQLQuery to retrieve
            //an XML-formatted list of every Tagged Value where the owner ID is PackageElement.ElementID
            for (short i = 0; i < TaggedValues.Count; i++)
            {
                var tv = TaggedValues.GetAt(i);
                _taggedValuesList.Add(tv);
            }

            // Add tagged values to list of ViewmodelTaggedValues
            DanishViewmodelTaggedValues        = AddTaggedValuesToViewmodelTaggedValues(_toAddDanishTaggedValues, _taggedValuesList);
            EnglishViewmodelTaggedValues       = AddTaggedValuesToViewmodelTaggedValues(_toAddEnglishTaggedValues, _taggedValuesList);
            ModelMetadataViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddModelMetadataTaggedValues, _taggedValuesList);
        }
        /// <inheritdoc />
        public override void Initialize()
        {
            SaveCommand   = new SaveCommand();
            CancelCommand = new CancelCommand();
            AddCommand    = new AddCommand();
            RemoveCommand = new RemoveCommand();

            Element      = Repository.GetContextObject();
            UMLNameValue = Element.Name;
            AliasValue   = Element.Alias;
            TaggedValues = Element.TaggedValues;

            //Finalize list of stereotype tags to add
            switch (Element.Stereotype)
            {
            case "OwlClass":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentClass"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubClassOf"));
                StereotypeString = (string)ResourceDictionary["OwlClassCharacteristics"];
                break;

            case "RdfsClass":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentClass"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubClassOf"));
                StereotypeString = (string)ResourceDictionary["RdfsClassCharacteristics"];
                break;

            case "Individual":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SameAs"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "Type"));
                StereotypeString = (string)ResourceDictionary["IndividualCharacteristics"];
                break;
            }

            //Retrieve all tagged values and store them in a list
            //Tagged values are stored in a list to avoid iterating Collections multiple times, which is very costly
            //In a future iteration of the addin, avoid iterating the collection even once, instead using Repository.SQLQuery to retrieve
            //an XML-formatted list of every Tagged Value where the owner ID is Element.ElementID
            for (short i = 0; i < TaggedValues.Count; i++)
            {
                TaggedValue tv = TaggedValues.GetAt(i);
                _taggedValuesList.Add(tv);
            }

            // Retrieve URI tagged value and save it in URIViewmodelTaggedValue
            var result = RetrieveTaggedValues(_taggedValuesList, "URI");

            URIViewmodelTaggedValue = new ViewModelTaggedValue(result.First())
            {
                ResourceDictionary = ResourceDictionary,
                Key = Definitions.Find(ptv => ptv.Key == "URI").Key
            };
            URIViewmodelTaggedValue.Initialize();
            URIValue = URIViewmodelTaggedValue.Value;

            // Add tagged values to list of ViewmodelTaggedValues
            DanishViewmodelTaggedValues     = AddTaggedValuesToViewmodelTaggedValues(_toAddDanishTaggedValues, _taggedValuesList);
            EnglishViewmodelTaggedValues    = AddTaggedValuesToViewmodelTaggedValues(_toAddEnglishTaggedValues, _taggedValuesList);
            ProvenanceViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddProvenanceTaggedValues, _taggedValuesList);
            StereotypeViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddStereotypeTaggedValues, _taggedValuesList);
        }
Beispiel #4
0
        /// <inheritdoc />
        public override void Initialize()
        {
            ConnectorEndType  = ConnectorEnd.End == "Supplier" ? "Target" : "Source";
            UMLNameValue      = ConnectorEnd.Role;
            AliasValue        = ConnectorEnd.Alias;
            MultiplicityValue = ConnectorEnd.Cardinality;
            TaggedValues      = ConnectorEnd.TaggedValues;

            //Finalize list of stereotype tags to add
            switch (ConnectorEnd.Stereotype)
            {
            case "RdfsProperty":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "RangeConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "DomainConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubPropertyOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentProperty"));
                StereotypeString = (string)ResourceDictionary["RdfsPropertyCharacteristics"];
                break;

            case "ObjectProperty":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "RangeConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "DomainConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubPropertyOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "InverseOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "FunctionalProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "InverseFunctionalProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SymmetricProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "TransitiveProperty"));
                StereotypeString = (string)ResourceDictionary["ObjectPropertyCharacteristics"];
                break;
            }

            //Retrieve all tagged values and store them in a list
            //Tagged values are stored in a list to avoid iterating Collections multiple times, which is very costly
            //In a future iteration of the addin, avoid iterating the collection even once, instead using Repository.SQLQuery to retrieve
            //an XML-formatted list of every Tagged Value where the owner ID is Element.ElementID
            for (short i = 0; i < TaggedValues.Count; i++)
            {
                RoleTag tv = TaggedValues.GetAt(i);
                _taggedValuesList.Add(tv);
            }

            // Retrieve URI tagged value and save it in URIViewmodelTaggedValue
            try
            {
                var result = RetrieveTaggedValues(_taggedValuesList, "URI");
                URIViewmodelTaggedValue = new ViewModelTaggedValue(result.First())
                {
                    ResourceDictionary = ResourceDictionary,
                    Key = Definitions.Find(ptv => ptv.Key == "URI").Key
                };
                URIViewmodelTaggedValue.Initialize();
                URIValue = URIViewmodelTaggedValue.Value;
            }
            catch (ArgumentException)
            {
                //URI does not exist: Do nothing
            }

            // Add tagged values to list of ViewmodelTaggedValues
            DanishViewmodelTaggedValues     = AddTaggedValuesToViewmodelTaggedValues(_toAddDanishTaggedValues, _taggedValuesList);
            EnglishViewmodelTaggedValues    = AddTaggedValuesToViewmodelTaggedValues(_toAddEnglishTaggedValues, _taggedValuesList);
            ProvenanceViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddProvenanceTaggedValues, _taggedValuesList);
            StereotypeViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddStereotypeTaggedValues, _taggedValuesList);
        }