Example #1
0
 public ModelGenerationForm(EA.Repository repository, EA.Package navigationPackage, EA.Package interactionPackage,
     List<EA.Element> useCases)
 {
     InitializeComponent();
     this.repository = repository;
     this.navigationPackage = navigationPackage;
     this.interactionPackage = interactionPackage;
     this.useCases = useCases;
 }
        // constructor
        public Svn(EA.Repository rep, EA.Package pkg)  {
            _pkg = pkg;
            _rep = rep;
            _vcPath = "";
            if (pkg.IsControlled)
            {

                _vcPath = Util.GetVccFilePath(rep, pkg);
            }

            
        }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     _pkg = rep.GetPackageByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { _pkg.Notes = _Description; }
     if ((fieldType & (FindAndReplaceItem.FieldType.Name | FindAndReplaceItem.FieldType.Stereotype) ) > 0)
     {
         // model don't have an element
         if (_pkg.ParentID != 0)
         {
             EA.Element el = rep.GetElementByGuid(GUID);
             el.StereotypeEx = _Stereotype;
             el.Name = _Name;
             el.Update();
         }
         _pkg.Name = _Name;
     }
     _isUpdated = true;
     _pkg.Update();
 }
        public FindAndReplace(EA.Repository rep, EA.Package pkg, string findString, 
            string replaceString,
            bool isCaseSensitive, bool isRegularExpression, bool isIgnoreWhiteSpace,
            bool isNameSearch, bool isDescriptionSearch, bool isStereotypeSearch, bool isTagSearch,
            string taggedValueNames, 
            bool isPackageSearch, bool isElementSearch, bool isDiagramSearch,
            bool isAttributeSearch, bool isOperationSearch
            ) {
            _rep = rep;
            _pkg = pkg;
            _findString = findString;
            _replaceString = replaceString;
            _isRegularExpression = isRegularExpression;
            _isCaseSensitive = isCaseSensitive;
            _isIgnoreWhiteSpace = isIgnoreWhiteSpace;
            if (isNameSearch) _searchFieldTypes = FindAndReplaceItem.FieldType.Name;
            if (isDescriptionSearch) _searchFieldTypes = _searchFieldTypes | FindAndReplaceItem.FieldType.Description;
            if (isTagSearch) _searchFieldTypes = _searchFieldTypes | FindAndReplaceItem.FieldType.Tag;

            if (isStereotypeSearch) _searchFieldTypes = _searchFieldTypes | FindAndReplaceItem.FieldType.Stereotype;
            
            // tagged value names
            string s = taggedValueNames.Replace(' ',','); // remove blanks
            _taggedValueNames = s.Split(new Char[] { ',', ';',':',' ' }, System.StringSplitOptions.RemoveEmptyEntries);


            _isPackageSearch = isPackageSearch;
            _isElementSearch = isElementSearch;
            _isDiagramSearch = isDiagramSearch;
            _isAttributeSearch = isAttributeSearch;
            _isOperationSearch = isOperationSearch;
            _isTagSearch = isTagSearch;

            _regExPattern = PrepareRegexp();
            _index = -1;

        }
Example #5
0
 public static EA.Package getAssociatedOutputProfile(EA.Repository Repository, EA.Package ProfileDefinitionPackage)
 {
     EA.Connector con = ProfileDefinitionPackage.Connectors.Cast <EA.Connector>().SingleOrDefault(t => R2Const.ST_TARGETPROFILE.Equals(t.Stereotype));
     if (con != null)
     {
         EA.Element packageElement = Repository.GetElementByID(con.SupplierID);
         if (R2Const.ST_FM_PROFILE.Equals(packageElement.Stereotype))
         {
             // con.SupplierID is the ElementID of the PackageElement
             // Find the Package with the PackageElement by selecting the child Package in the parent Package where
             // the ElementID is con.SupplierID
             return(Repository.GetPackageByID(packageElement.PackageID).Packages.Cast <EA.Package>().Single(p => p.Element.ElementID == con.SupplierID));
         }
     }
     EAHelper.LogMessage("Expected <create> relationship to a <HL7-FM-Profile> Package == Compiled Profile Model");
     return(null);
 }
        static public Hashtable sampleToJObject(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramElements)
        {
            Hashtable result = new Hashtable();

            //logger.log("sampleToObject");

            //IList<EA.Element> clazzes = MetaDataManager.diagramClasses(Repository, diagramElements.elementsList);
            //logger.log("GetClazzes" + clazzes.Count);

            //IList<EA.Element> components = MetaDataManager.diagramComponents(Repository, diagramElements.elementsList);
            //logger.log("GetComponents" + components.Count);


            //IList<EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagramElements.elementsList);
            //logger.log("GetSamples" + samples.Count);

            //samples = samples.Concat(clazzes).ToList();
            //samples = samples.Concat(components).ToList();
            IList <EA.Element> samples = diagramElements.elementsList;

            logger.log("All" + samples.Count);

            EA.Element root = MetaDataManager.findContainer(Repository, diagram, diagramElements, RoundTripAddInClass.EA_STEREOTYPE_POPULATION);

            MetaDataManager.extractDiagramMetaData(result, root);

            logger.log("Classifier ID:" + root.ClassifierID);

            Dictionary <int, JObject> instances = new Dictionary <int, JObject>();
            JArray container           = new JArray();
            string containerName       = root.Name;
            string containerClassifier = "Classes";

            if (root.ClassifierID != 0)
            {
                EA.Element rootClassifier = Repository.GetElementByID(root.ClassifierID);
                containerName       = root.Name;
                containerClassifier = rootClassifier.Name;
            }

            foreach (EA.Element sample in samples)
            {
                //logger.log("Sample Name:" + sample.Name);

                if (sample.Stereotype == RoundTripAddInClass.EA_STEREOTYPE_POPULATION)
                {
                    continue;
                }

                if (root.ClassifierID != 0 && sample.ClassfierID != root.ClassfierID)
                {
                    //skip root elements that are the population elements.
                    continue;
                }

                //logger.log("Sample Name2:" + sample.Name);

                String     type  = "";
                EA.Element clazz = null;
                if (sample.ClassifierID != 0)
                {
                    clazz = diagramElements.elementIDHash[sample.ClassifierID];
                    type  = clazz.Name;
                }
                else
                {
                    logger.log("Classifier is null");
                }

                EA.Package package = diagramElements.packageIDHash[sample.PackageID];

                JObject jsonClass = null;

                {
                    jsonClass = new JObject();
                    jsonClass.Add(new JProperty(RoundTripAddInClass.POPULATION_PROPERTY_GUID, sample.ElementGUID));
                    jsonClass.Add(new JProperty(RoundTripAddInClass.POPULATION_PROPERTY_NAME, sample.Name));
                    jsonClass.Add(new JProperty(RoundTripAddInClass.POPULATION_PROPERTY_NOTES, sample.Notes));
                    jsonClass.Add(new JProperty(RoundTripAddInClass.POPULATION_PROPERTY_PACKAGE, package.Name));
                    if (clazz != null)
                    {
                        jsonClass.Add(new JProperty(RoundTripAddInClass.POPULATION_PROPERTY_TYPE, clazz.Name));
                    }

                    container.Add(jsonClass);
                }

                string rs = sample.RunState;

                ObjectManager.addRunStateToJson(rs, jsonClass);
                ObjectManager.addTagsToJson(sample, jsonClass);
            }

            logger.log("Export container:" + containerName);

            foreach (EA.Element clazz in samples)
            {
                JObject jsonClass = null;
                if (!instances.TryGetValue(clazz.ElementID, out jsonClass))
                {
                    continue;
                }
                if (jsonClass != null)
                {
                    logger.log("Found jsonClass:" + clazz.Name);
                    foreach (EA.Connector con in clazz.Connectors)
                    {
                        //logger.log("Found connector:");
                        EA.Element related = null;
                        if (clazz.ElementID == con.ClientID)
                        {
                            related = Repository.GetElementByID(con.SupplierID);

                            try
                            {
                                object o = instances[related.ElementID];
                            }
                            catch (KeyNotFoundException)
                            {
                                //Object is in package but not on the diagram
                                continue;
                            }

                            if (related != null && instances[related.ElementID] != null)
                            {
                                if (con.SupplierEnd.Cardinality.Equals(RoundTripAddInClass.CARDINALITY_0_TO_MANY) ||
                                    con.SupplierEnd.Cardinality.Equals(RoundTripAddInClass.CARDINALITY_1_TO_MANY)
                                    )
                                {
                                    //logger.log("Found array");

                                    string propertyName = related.Name;
                                    //Override with the connection supplier end
                                    try {
                                        if (con.SupplierEnd.Role.Length > 0)
                                        {
                                            propertyName = con.SupplierEnd.Role;
                                        }
                                    } catch (Exception) { }

                                    JProperty p = jsonClass.Property(propertyName);
                                    if (p == null)
                                    {
                                        JArray ja = new JArray();
                                        ja.Add(instances[related.ElementID]);
                                        //logger.log("Adding array property:"+ related.Name);
                                        jsonClass.Add(new JProperty(propertyName, ja));
                                    }
                                    else
                                    {
                                        JArray ja = (JArray)p.Value;
                                        //logger.log("Adding to array property");
                                        ja.Add(instances[related.ElementID]);
                                    }
                                }
                                else
                                {
                                    string propertyName = related.Name;
                                    //Override with the connection supplier end
                                    try {
                                        if (con.SupplierEnd.Role.Length > 0)
                                        {
                                            propertyName = con.SupplierEnd.Role;
                                        }
                                    } catch (Exception) { }
                                    //logger.log("Adding property:" + related.Name);
                                    jsonClass.Add(new JProperty(propertyName, instances[related.ElementID]));
                                }
                            }
                        }
                    }
                }
            }

            //KeyValuePair<string,JObject> kv = new KeyValuePair<string,JObject>(containerName,container);
            //return kv;

            //logger.log("REturning result");
            result.Add("sample", containerName);
            result.Add("class", containerClassifier);
            result.Add("json", container);
            return(result);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="bdts"></param>
 private void checkC564oo(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
 {
 }
        /// <summary>
        /// Validate the given bLibrary
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        internal override void validate(IValidationContext context, string scope)
        {
            EA.Package package = context.Repository.GetPackageByID(Int32.Parse(scope));
            //Get all BDTs from the given package
            Dictionary <Int32, EA.Element> bdts = new Dictionary <int, EA.Element>();

            Utility.getAllElements(package, bdts, UPCC.BDT.ToString());

            checkC514b(context, package);

            checkC514i(context, package);

            checkC564a(context, package, bdts);

            checkC564b(context, package, bdts);

            checkC564c(context, package, bdts);

            checkC564d(context, package, bdts);

            checkC564e(context, package, bdts);

            checkC564f(context, package, bdts);

            checkC564g(context, package, bdts);

            checkC564h(context, package, bdts);

            checkC564i(context, package, bdts);

            checkC564j(context, package, bdts);

            checkC564k(context, package, bdts);

            checkC564l(context, package, bdts);

            checkC564m(context, package, bdts);

            checkC564n(context, package, bdts);

            checkC564o(context, package, bdts);

            checkC564p(context, package, bdts);

            checkC564q(context, package, bdts);

            checkC564r(context, package, bdts);

            checkC564s(context, package, bdts);

            checkC564t(context, package, bdts);

            checkC564u(context, package, bdts);

            checkC564v(context, package, bdts);

            checkC564w(context, package, bdts);

            checkC564x(context, package, bdts);

            checkC564y(context, package, bdts);

            checkC564z(context, package, bdts);

            checkC564aa(context, package, bdts);

            checkC564bb(context, package, bdts);

            checkC564cc(context, package, bdts);

            checkC564dd(context, package, bdts);

            checkC564ee(context, package, bdts);

            checkC564ff(context, package, bdts);

            checkC564gg(context, package, bdts);

            checkC564hh(context, package, bdts);

            checkC564ii(context, package, bdts);

            checkC564jj(context, package, bdts);

            checkC564kk(context, package, bdts);

            checkC564ll(context, package, bdts);

            checkC564mm(context, package, bdts);

            checkC564nn(context, package, bdts);

            checkC564oo(context, package, bdts);
        }
Example #9
0
        public void validate(EA.Repository repository, EA.Package rootPackage)
        {
            string sch_filepath = null;

            switch (rootPackage.StereotypeEx)
            {
            case R2Const.ST_FM:
                sch_filepath = Main.getAppDataFullPath(@"Schematron\EHRS_FM_R2-validation.sch");
                break;

            case R2Const.ST_FM_PROFILEDEFINITION:
                sch_filepath = Main.getAppDataFullPath(@"Schematron\EHRS_FM_R2_FPDEF-validation.sch");
                break;

            case R2Const.ST_FM_PROFILE:
                sch_filepath = Main.getAppDataFullPath(@"Schematron\EHRS_FM_R2_FP-validation.sch");
                break;

            default:
                MessageBox.Show(string.Format("Validation not available for {0}.\nChoose ", rootPackage.Name), "Choose other package", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            repository.CreateOutputTab(Properties.Resources.OUTPUT_TAB_HL7_FM);
            repository.ClearOutput(Properties.Resources.OUTPUT_TAB_HL7_FM);
            repository.EnsureOutputVisible(Properties.Resources.OUTPUT_TAB_HL7_FM);

            // TODO: Change to memorybased!!
            // TODO: Transform once to XSL, only if the xsl is older or not existing

            // Create and load the transform with script execution enabled.
            XslCompiledTransform transform = new XslCompiledTransform();
            XsltSettings         settings  = new XsltSettings {
                EnableScript = true
            };
            XmlUrlResolver resolver = new XmlUrlResolver();

            // transform the Schematron to a XSL
            string iso_sch_xsl_filepath = Main.getAppDataFullPath(@"Schematron\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl");

            transform.Load(iso_sch_xsl_filepath, settings, resolver);
            string sch_xsl_filepath = Main.getAppDataFullPath(@"Schematron\EHRS_FM_R2-validation.sch.xsl");

            transform.Transform(sch_filepath, sch_xsl_filepath);

            // export to temp MAX file
            string temp_max_file = Main.getAppDataFullPath(@"Schematron\__temp__.max");

            new MAX_EA.MAXExporter3().exportPackage(repository, rootPackage, temp_max_file);

            // now execute the Schematron XSL
            transform.Load(sch_xsl_filepath, settings, resolver);
            string svrl_filepath = Main.getAppDataFullPath(@"Schematron\svrl_output.xml");

            transform.Transform(temp_max_file, svrl_filepath);

            // build element dictionary
            Dictionary <string, EA.Element> eaElementDict = new Dictionary <string, EA.Element>();

            recurseEaPackage(rootPackage, eaElementDict);

            XmlReader xReader = XmlReader.Create(svrl_filepath);

            // make sure file gets closed
            using (xReader)
            {
                XElement            svrl  = XElement.Load(xReader);
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(xReader.NameTable);
                nsmgr.AddNamespace("svrl", "http://purl.oclc.org/dsdl/svrl");

                appendSvrlMessagesToOutputTab(repository, svrl.XPathSelectElements("//svrl:successful-report", nsmgr), eaElementDict, nsmgr);
                appendSvrlMessagesToOutputTab(repository, svrl.XPathSelectElements("//svrl:failed-assert", nsmgr), eaElementDict, nsmgr);
            }
            MessageBox.Show("Validation done.\nCheck output tab for message and issues.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            repository.EnsureOutputVisible(Properties.Resources.OUTPUT_TAB_HL7_FM);
        }
Example #10
0
 /// <summary>
 /// Return the error message for a connector
 /// </summary>
 /// <param name="taggedValue"></param>
 /// <param name="con"></param>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="package"></param>
 /// <returns></returns>
 private String getConnectorError(String taggedValue, EA.Connector con, EA.Element source, EA.Element target, EA.Package package)
 {
     return("Tagged value " + taggedValue + " of connector with stereotype " + con.Stereotype + " between " + source.Name + " and " + target.Name + " in package " + package.Name + " <<" + package.Element.Stereotype + ">> is missing.");
 }
Example #11
0
 /// <summary>
 /// Returns the package error
 /// </summary>
 /// <param name="taggedValue"></param>
 /// <param name="package"></param>
 /// <returns></returns>
 private String getPackageError(String taggedValue, EA.Package package)
 {
     return("Tagged value " + taggedValue + " of package " + package.Name + " <<" + package.Element.Stereotype + ">> is missing.");
 }
Example #12
0
        /// <summary>
        /// Validate tagged values of an element
        /// </summary>
        /// <param name="context"></param>
        /// <param name="element"></param>
        /// <param name="package"></param>
        private void validateBPUC_BTUC_BCUC_TaggedValues(IValidationContext context, EA.Element element, EA.Package package)
        {
            bool foundDefinition    = false;
            bool foundBeginsWhen    = false;
            bool foundPreCondition  = false;
            bool foundEndsWhen      = false;
            bool foundPostCondition = false;
            bool foundExceptions    = false;
            bool foundAction        = false;


            foreach (EA.TaggedValue tv in element.TaggedValues)
            {
                String n = tv.Name;

                if (n == UMMTaggedValues.definition.ToString())
                {
                    foundDefinition = true;
                }
                if (n == UMMTaggedValues.beginsWhen.ToString())
                {
                    foundBeginsWhen = true;
                }
                if (n == UMMTaggedValues.preCondition.ToString())
                {
                    foundPreCondition = true;
                }
                if (n == UMMTaggedValues.endsWhen.ToString())
                {
                    foundEndsWhen = true;
                }
                if (n == UMMTaggedValues.postCondition.ToString())
                {
                    foundPostCondition = true;
                }
                if (n == UMMTaggedValues.exceptions.ToString())
                {
                    foundExceptions = true;
                }
                if (n == UMMTaggedValues.actions.ToString())
                {
                    foundAction = true;
                }
            }

            if (!foundDefinition)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("definition", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundBeginsWhen)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("beginsWhen", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundPreCondition)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("precondition", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundEndsWhen)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("endsWhen", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundPostCondition)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("postCondition", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundExceptions)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("exceptions", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }

            if (!foundAction)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("actions", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }
        }
Example #13
0
 public static EA.Package getAssociatedProfileDefinition(EA.Repository repository, EA.Package selectedSectionPackage)
 {
     EA.Package   baseModel = repository.GetPackageByID(selectedSectionPackage.ParentID);
     EA.Connector con       = baseModel.Connectors.Cast <EA.Connector>().SingleOrDefault(t => R2Const.ST_BASEMODEL.Equals(t.Stereotype) || "Usage".Equals(t.Type));
     if (con != null)
     {
         EA.Element packageElement = repository.GetElementByID(con.ClientID);
         if (R2Const.ST_FM_PROFILEDEFINITION.Equals(packageElement.Stereotype))
         {
             // con.ClientID is the ElementID of the PackageElement
             // Find the Package with the PackageElement by selecting the child Package in the parent Package where
             // the ElementID is con.ClientID
             return(repository.GetPackageByID(packageElement.PackageID).Packages.Cast <EA.Package>().Single(p => p.Element.ElementID == con.ClientID));
         }
     }
     EAHelper.LogMessage("Expected <use> relationship to a <HL7-FM> Package == Base Model");
     return(null);
 }
Example #14
0
 public virtual ModelEntity.Package Wrap(EA.Package p)
 {
     return(new ModelEntity.Package(p, this));
 }
Example #15
0
        public EA.Package Add(string parentPackageName, string strNewPackageName, string strNotes = "", XElement CurrXEl = null)
        {
            string strLogInfo = "Package: " + strNewPackageName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (parentPackageName == "")
            {
                string strErrInfo = "Parent package name is empty.";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            if (strNewPackageName == "")
            {
                string strErrInfo = "Package name is empty.";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            EA.Package oNewPackage = (EA.Package)m_Packages[parentPackageName + "/" + strNewPackageName];

            if (oNewPackage != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(oNewPackage);
            }

            if ((EA.Package)m_Packages[parentPackageName] == null)
            {
                string strErrInfo = "Add Failed- parent package does not exist";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            try
            {
                oNewPackage = ((EA.Package)m_Packages[parentPackageName]).Packages.GetByName(strNewPackageName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if (oNewPackage == null)
            {
                oNewPackage       = ((EA.Package)m_Packages[parentPackageName]).Packages.AddNew(strNewPackageName, "Nothing");
                oNewPackage.Notes = strNotes;
                oNewPackage.Update();

                m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage;

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage;
                return(oNewPackage);
            }

            return(oNewPackage);
        }
        /// <summary>
        /// Called when user makes a selection in the menu.
        /// This is your main exit point to the rest of your Add-in
        /// </summary>
        /// <param name="repository">the repository</param>
        /// <param name="location">the location of the menu</param>
        /// <param name="MenuName">the name of the menu</param>
        /// <param name="itemName">the name of the selected menu item</param>
        public override void EA_MenuClick(EA.Repository repository, string location, string MenuName, string itemName)
        {
            EA.Package    pkg        = null;
            EA.ObjectType oType      = repository.GetContextItemType();
            EA.Diagram    diaCurrent = repository.GetCurrentDiagram();
            EA.Connector  conCurrent = null;
            EA.Element    el         = null;


            if (diaCurrent != null)
            {
                conCurrent = diaCurrent.SelectedConnector;
            }
            switch (itemName)
            {
            case MenuAbout:
                About fAbout = new About();
                fAbout.setVersion(Release);     // set release / version
                fAbout.ShowDialog();

                break;


            case MenuMksGetNewest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    mks.GetNewest();
                }

                break;

            case MenuMksGetHistory:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    MessageBox.Show(mks.ViewHistory(), "mks");
                }
                break;


            case MenuMksUndoCheckOut:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks    mks = new Mks(repository, pkg);
                    string msg = mks.UndoCheckout();
                    if (msg != "")
                    {
                        MessageBox.Show(mks.UndoCheckout(), "mks");
                    }
                }
                break;

            // Change name to synomym
            // - Package, recursive
            // - Class
            case MenuChangeClassNameToSynonym:
                // Class recursive
                if (oType.Equals(EA.ObjectType.otElement))
                {
                    el = (EA.Element)repository.GetContextObject();
                    Util.ChangeClassNameToSynonyms(repository, el);
                }
                // Package recursiv
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ChangePackageClassNameToSynonyms(repository, pkg);
                }

                break;



            //

            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVc(repository, pkg);
                }
                break;

            //   For all nested packages:
            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcModeRecursive:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVcRecursive(repository, pkg);
                }
                break;



            case MenuGetVcLatest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatest", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, false, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;
                    repository.WriteOutput("Debug", "End GetLatest " + span.Minutes + " minutes. " + s, 0);
                }

                break;

            case MenuGetVcLatestRecursive:
                if (oType.Equals(EA.ObjectType.otPackage) || oType.Equals(EA.ObjectType.otNone))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatestRecursive", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, true, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;

                    repository.WriteOutput("Debug", "End GetLatestRecursive in " + span.Hours + ":" + span.Minutes + " hh:mm. " + s, 0);
                }

                break;

            case MenuGetVcModeAll:
                //Repository.VersionControlResynchPkgStatuses(false);
                // over all packages
                foreach (EA.Package pkg1 in repository.Models)
                {
                    Util.UpdateVc(repository, pkg1);
                }

                break;

            case MenuGetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    // Get the revision
                    Regex  pattern  = new Regex(@"Revision:[^\$]+");
                    Match  regMatch = pattern.Match(pkg.Notes);
                    string revision = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        revision = regMatch.Value;
                        // add new string
                    }
                    // Get date
                    pattern  = new Regex(@"Date:[^\$]+");
                    regMatch = pattern.Match(pkg.Notes);
                    string date = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        date = regMatch.Value;
                        // add new string
                    }
                    string msg = revision + "  " +
                                 date + "\r\n" +
                                 "Path: " + Util.GetFilePath(repository, pkg) +
                                 "\r\n\r\n" + pkg.Flags + "\r\n" +
                                 Util.GetVCstate(pkg, true);

                    MessageBox.Show(msg, "State");
                }
                break;



            case MenuCopyGuidToClipboard:
                string str  = "";
                string str1 = "";
                string str2 = "";

                if (conCurrent != null)
                {    // Connector
                    EA.Connector con = conCurrent;
                    str = con.ConnectorGUID + " " + con.Name + ' ' + con.Type + "\r\n" +

                          "\r\n Connector: Select ea_guid As CLASSGUID, connector_type As CLASSTYPE,* from t_connector con where ea_guid = '" + con.ConnectorGUID + "'" +

                          "\r\n\r\nSelect o.ea_guid As CLASSGUID, o.object_type As CLASSTYPE,o.name As Name, o.object_type AS ObjectType, o.PDATA1, o.Stereotype, " +
                          "\r\n                       con.Name, con.connector_type, con.Stereotype, con.ea_guid As ConnectorGUID, dia.Name As DiagrammName, dia.ea_GUID As DiagramGUID," +
                          "\r\n                       o.ea_guid, o.Classifier_GUID,o.Classifier " +
                          "\r\nfrom (((t_connector con INNER JOIN t_object o              on con.start_object_id   = o.object_id) " +
                          "\r\nINNER JOIN t_diagramlinks diaLink  on con.connector_id      = diaLink.connectorid ) " +
                          "\r\nINNER JOIN t_diagram dia           on diaLink.DiagramId     = dia.Diagram_ID) " +
                          "\r\nINNER JOIN t_diagramobjects diaObj on diaObj.diagram_ID     = dia.Diagram_ID and o.object_id = diaObj.object_id " +
                          "\r\nwhere         con.ea_guid = '" + con.ConnectorGUID + "' " +
                          "\r\nAND dialink.Hidden  = 0 ";
                    Clipboard.SetText(str);
                    break;
                }
                if (oType.Equals(EA.ObjectType.otElement))
                {    // Element
                    el = (EA.Element)repository.GetContextObject();
                    string pdata1       = el.get_MiscData(0);
                    string pdata1String = "";
                    if (pdata1.EndsWith("}"))
                    {
                        pdata1String = "/" + pdata1;
                    }
                    else
                    {
                        pdata1       = "";
                        pdata1String = "";
                    }
                    string classifier = Util.GetClassifierGuid(repository, el.ElementGUID);
                    str = el.ElementGUID + ":" + classifier + pdata1String + " " + el.Name + ' ' + el.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + el.ElementGUID + "'";
                    if (classifier != "")
                    {
                        if (el.Type.Equals("ActionPin"))
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, 'Parameter' As CLASSTYPE,* from t_operationparams op where ea_guid = '" + classifier + "'";
                        }
                        else
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + classifier + "'";
                        }
                    }
                    if (pdata1 != "")
                    {
                        str = str + "\r\n PDATA1:  Select ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + pdata1 + "'";
                    }

                    // Look for diagram object
                    EA.Diagram curDia = repository.GetCurrentDiagram();
                    if (curDia != null)
                    {
                        foreach (EA.DiagramObject diaObj in curDia.DiagramObjects)
                        {
                            if (diaObj.ElementID == el.ElementID)
                            {
                                str = str + "\r\n\r\n" +
                                      "select * from t_diagramobjects where object_id = " + diaObj.ElementID.ToString();
                                break;
                            }
                        }
                    }
                }

                if (oType.Equals(EA.ObjectType.otDiagram))
                {    // Element
                    EA.Diagram dia = (EA.Diagram)repository.GetContextObject();
                    str = dia.DiagramGUID + " " + dia.Name + ' ' + dia.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, diagram_type As CLASSTYPE,* from t_diagram dia where ea_guid = '" + dia.DiagramGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otPackage))
                {    // Element
                    pkg = (EA.Package)repository.GetContextObject();
                    str = pkg.PackageGUID + " " + pkg.Name + ' ' + " Package " + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, 'Package' As CLASSTYPE,* from t_package pkg where ea_guid = '" + pkg.PackageGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otAttribute))
                {    // Element
                    str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = typAttr.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = Format(typAttr.object_id))";
                    }
                    EA.Attribute attr = (EA.Attribute)repository.GetContextObject();
                    str = attr.AttributeID + " " + attr.Name + ' ' + " Attribute " + "\r\n" +
                          "\r\n " +
                          "\r\nSelect ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE,* from t_attribute attr where ea_guid = '" + attr.AttributeGUID + "'" +
                          "\r\n Class has Attributes:" +
                          "\r\nSelect attr.ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE, " +
                          "\r\n       o.Name As Class, o.object_type, " +
                          "\r\n       attr.Name As AttrName, attr.Type As Type, " +
                          "\r\n       typAttr.Name " +
                          "\r\n   from (t_object o INNER JOIN t_attribute attr on (o.object_id = attr.object_id)) " +
                          "\r\n                   " + str1 +
                          "\r\n   where attr.ea_guid = '" + attr.AttributeGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otMethod))
                {    // Element
                    str1 = "LEFT JOIN t_object parTyp on (par.classifier = parTyp.object_id))";
                    str2 = "LEFT JOIN t_object opTyp on (op.classifier = opTyp.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = " LEFT JOIN t_object parTyp on (par.classifier = Format(parTyp.object_id))) ";
                        str2 = " LEFT JOIN t_object opTyp  on (op.classifier  = Format(opTyp.object_id))";
                    }

                    EA.Method op = (EA.Method)repository.GetContextObject();
                    str = op.MethodGUID + " " + op.Name + ' ' + " Operation " +
                          "\r\nOperation may have type " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,opTyp As OperationType, op.Name As OperationName, typ.Name As TypName,*" +
                          "\r\n   from t_operation op LEFT JOIN t_object typ on (op.classifier = typ.object_id)" +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,* " +
                          "\r\n    from t_operation op INNER JOIN t_object o on (o.object_id = op.object_id)" +
                          "\r\n    where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation has Parameters/Typ and may have operationtype" +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,op.Name As ClassName, op.Name As OperationName, opTyp.Name As OperationTyp, par.Name As ParName,parTyp.name As ParTypeName " +
                          "\r\n   from ((t_operation op INNER JOIN t_operationparams par on (op.OperationID = par.OperationID) )" +
                          "\r\n                        " + str1 +
                          "\r\n                        " + str2 +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "' " +
                          "\r\n  Order by par.Pos ";
                }
                Clipboard.SetText(str);
                break;

            // delete undefined referencee
            case MenuDeleteExternalReference:
                if (diaCurrent != null)
                {
                    foreach (EA.DiagramObject diaObj in diaCurrent.SelectedObjects)
                    {
                        EA.Element el1 = repository.GetElementByID(diaObj.ElementID);
                        string     s   = String.Format("External Reference of diagram '{0}', name:'{1}' ID={2} GUID='{3}' deleted", diaCurrent.Name, el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                else
                {
                    foreach (EA.Element el1 in repository.GetTreeSelectedElements())
                    {
                        string s = String.Format("External Reference of tree, name:'{0}' ID={1} GUID='{2}' deleted", el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                break;

            // Recursive delete undefined referencee
            case MenuDeleteExternalReferenceRecursive:
                pkg = null;
                if (oType.Equals(EA.ObjectType.otNone))
                {
                    oType = repository.GetTreeSelectedItemType();
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetTreeSelectedObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetTreeSelectedObject();
                    }
                }
                else
                {
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetContextObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetContextObject();
                    }
                }
                if (pkg != null)
                {
                    RecursivePackages.doRecursivePkg(repository,
                                                     pkg,
                                                     null,                        // Packages
                                                     SetDeleteUndefinedReference, // Elements
                                                     null,                        // Diagrams
                                                     null);
                }
                if (el != null)
                {
                    RecursivePackages.doRecursiveEl(repository,
                                                    el,
                                                    SetDeleteUndefinedReference, // Elements
                                                    null,                        // Diagrams
                                                    null);
                }

                break;
            }
        }
Example #17
0
            /**
             * Factory method to create correct model class based on the EA.Element
             */
            public static R2ModelElement Create(EA.Repository repository, EA.Element element)
            {
                R2ModelElement modelElement = null;

                switch (element.Stereotype)
                {
                case R2Const.ST_FM_PROFILEDEFINITION:
                    modelElement = new R2ProfileDefinition(element);
                    break;

                case R2Const.ST_SECTION:
                    modelElement = new R2Section(element);
                    break;

                case R2Const.ST_HEADER:
                case R2Const.ST_FUNCTION:
                    modelElement = new R2Function(element);
                    break;

                case R2Const.ST_CRITERION:
                    modelElement = new R2Criterion(element);
                    break;

                case R2Const.ST_COMPILERINSTRUCTION:
                    int genCount = element.Connectors.Cast <EA.Connector>().Count(c => "Generalization".Equals(c.Type));
                    if (genCount == 0)
                    {
                        // Try Dependency/Generalization in case this is a Section Compiler instruction
                        genCount = element.Connectors.Cast <EA.Connector>().Count(c => "Dependency".Equals(c.Type) && "Generalization".Equals(c.Stereotype));
                        if (genCount == 0)
                        {
                            MessageBox.Show(string.Format("{0} is a Compiler Instruction.\nExpected one(1) Generalization to a Base Element.\nFix this manually.", element.Name), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(null);
                        }
                    }
                    else if (genCount > 1)
                    {
                        MessageBox.Show(string.Format("{0} is a Compiler Instruction.\nExpected one(1) Generalization, but got {1}.\nFix this manually.", element.Name, genCount), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(null);
                    }
                    EA.Connector generalization = element.Connectors.Cast <EA.Connector>().SingleOrDefault(c => "Generalization".Equals(c.Type));
                    // Try Dependency/Generalization in case this is a Section Compiler instruction
                    if (generalization == null)
                    {
                        generalization = element.Connectors.Cast <EA.Connector>().SingleOrDefault(c => "Dependency".Equals(c.Type) && "Generalization".Equals(c.Stereotype));
                    }
                    EA.Element baseElement = repository.GetElementByID(generalization.SupplierID);
                    switch (baseElement.Stereotype)
                    {
                    case R2Const.ST_SECTION:
                        modelElement             = new R2Section(element);
                        modelElement.BaseElement = new R2Section(baseElement);
                        break;

                    case R2Const.ST_HEADER:
                    case R2Const.ST_FUNCTION:
                        modelElement             = new R2Function(element);
                        modelElement.BaseElement = new R2Function(baseElement);
                        break;

                    case R2Const.ST_CRITERION:
                        modelElement             = new R2Criterion(element);
                        modelElement.BaseElement = new R2Criterion(baseElement);
                        break;
                    }
                    modelElement.IsCompilerInstruction = true;
                    if (repository != null)
                    {
                        modelElement.BaseElement.Path = GetModelElementPath(repository, baseElement);
                    }
                    break;
                }
                if (modelElement != null && repository != null)
                {
                    modelElement.Path = GetModelElementPath(repository, element);

                    // is element is in profile definition package this is a compiler instruction
                    EA.Package ProfileDefinitionPackage = repository.GetPackageByID(((EA.Element)modelElement.SourceObject).PackageID);
                    if (R2Const.ST_FM_PROFILEDEFINITION.Equals(ProfileDefinitionPackage.StereotypeEx))
                    {
                        modelElement.IsCompilerInstruction = true;

                        // The ProfileType is needed for R2FunctionCI's in the FunctionForm
                        if (modelElement is R2Function)
                        {
                            R2Function function = (R2Function)modelElement;
                            function.ProfileDefinition = (R2ProfileDefinition)Create(EAHelper.repository, ProfileDefinitionPackage.Element);
                        }
                        else if (modelElement is R2Criterion)
                        {
                            R2Criterion criterion = (R2Criterion)modelElement;
                            criterion.ProfileDefinition = (R2ProfileDefinition)Create(EAHelper.repository, ProfileDefinitionPackage.Element);
                        }
                    }
                }
                return(modelElement);
            }
Example #18
0
        /// <summary>
        /// Validate the Stakeholder
        /// </summary>
        /// <param name="context"></param>
        /// <param name="element"></param>
        /// <param name="package"></param>
        private void validateBusinessPartnerAndStakeholder(IValidationContext context, EA.Element element, EA.Package package)
        {
            bool foundInterest = false;

            foreach (EA.TaggedValue tv in element.TaggedValues)
            {
                if (tv.Name == UMMTaggedValues.interest.ToString())
                {
                    foundInterest = true;
                }
            }

            if (!foundInterest)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("interest", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }
        }
        /// <summary>
        /// Check constraint C99
        ///
        /// The number of AuthorizedRoles participating in a BusinessCollaborationUseCase
        /// MUST match the number of AuthorizedRoles participating in the BusinessRealization
        /// realizing this BusinessCollaborationUseCase
        /// </summary>
        /// <param name="context"></param>
        /// <param name="brv"></param>
        /// <returns></returns>
        private void checkC99(IValidationContext context, EA.Package brv)
        {
            //Get the Authorized Roles
            IList <EA.Element> aroles = Utility.getAllElements(brv, new List <EA.Element>(), UMM.AuthorizedRole.ToString());

            int countBR = 0;
            int countBC = 0;

            //Count the AR of the BusinessRealization
            foreach (EA.Element ar in aroles)
            {
                if (doesParticipateInBR(context, ar))
                {
                    countBR++;
                }
            }

            //Count the AR of the BCUC
            //Get the BusinessRealization first
            EA.Element bcuc = null;
            EA.Element br   = Utility.getElementFromPackage(brv, UMM.bRealization.ToString());
            if (br != null)
            {
                foreach (EA.Connector con in br.Connectors)
                {
                    if (con.Type == "Realisation" && con.Stereotype == "realizes")
                    {
                        if (con.ClientID == br.ElementID)
                        {
                            EA.Element supplier = context.Repository.GetElementByID(con.SupplierID);
                            if (supplier.Stereotype == UMM.bCollaborationUC.ToString())
                            {
                                bcuc = supplier;
                                break;
                            }
                        }
                    }
                }

                if (bcuc != null)
                {
                    foreach (EA.Connector con in bcuc.Connectors)
                    {
                        if (con.SupplierID == bcuc.ElementID && con.Stereotype == UMM.participates.ToString())
                        {
                            EA.Element client = context.Repository.GetElementByID(con.ClientID);
                            if (client.Stereotype == UMM.AuthorizedRole.ToString())
                            {
                                countBC++;
                            }
                        }
                    }
                }
            }


            if (countBC != countBR)
            {
                context.AddValidationMessage(new ValidationMessage("Violation of constraint C99.", "The number of AuthorizedRoles participating in a BusinessCollaborationUseCase MUST match the number of AuthorizedRoles participating in the BusinessRealization realizing this BusinessCollaborationUseCase. \n\n" + countBR + " AuthorizedRoles participate in the BusinessRealization and " + countBC + " AuthorizedRoles participate in the BusinessCollaborationUseCase.", "BRV", ValidationMessage.errorLevelTypes.ERROR, brv.PackageID));
            }
        }
Example #20
0
        /// <summary>
        /// Validate the tagged values of a package
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        internal void validatePackageTaggedValues(IValidationContext context, EA.Package p)
        {
            bool foundJustification = false;
            bool foundBusinessTerm  = false;
            bool foundCopyright     = false;
            bool foundOwner         = false;
            bool foundReference     = false;
            bool foundStatus        = false;
            bool foundURI           = false;
            bool foundVersion       = false;

            bool foundObjective           = false;
            bool foundScope               = false;
            bool foundBusinessOpportunity = false;


            foreach (EA.TaggedValue t in p.Element.TaggedValues)
            {
                String n = t.Name;

                if (n == UMMTaggedValues.justification.ToString())
                {
                    foundJustification = true;
                }
                else if (n == UMMTaggedValues.businessTerm.ToString())
                {
                    foundBusinessTerm = true;
                }
                else if (n == UMMTaggedValues.copyright.ToString())
                {
                    foundCopyright = true;
                }
                else if (n == UMMTaggedValues.owner.ToString())
                {
                    foundOwner = true;
                }
                else if (n == UMMTaggedValues.reference.ToString())
                {
                    foundReference = true;
                }
                else if (n == UMMTaggedValues.status.ToString())
                {
                    foundStatus = true;
                }
                else if (n == UMMTaggedValues.URI.ToString())
                {
                    foundURI = true;
                }
                else if (n == UMMTaggedValues.version.ToString())
                {
                    foundVersion = true;
                }
                else if (n == UMMTaggedValues.objective.ToString())
                {
                    foundObjective = true;
                }
                else if (n == UMMTaggedValues.scope.ToString())
                {
                    foundScope = true;
                }
                else if (n == UMMTaggedValues.businessOpportunity.ToString())
                {
                    foundBusinessOpportunity = true;
                }
            }

            //Raise an error if a taggedvalue is missing

            //Justification is a tagged value only occurring in  the bCollModel
            if (p.Element.Stereotype == UMM.bCollModel.ToString() && !foundJustification)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("justification", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            //Objective is a tagged value only occurring in a BusinessArea or ProcessArea
            if ((p.Element.Stereotype == UMM.bArea.ToString() || p.Element.Stereotype == UMM.ProcessArea.ToString()) && !foundObjective)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("objective", p), "BRV", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            //Scope is a tagged value only occurring in a BusinessArea or ProcessArea
            if ((p.Element.Stereotype == UMM.bArea.ToString() || p.Element.Stereotype == UMM.ProcessArea.ToString()) && !foundScope)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("scope", p), "BRV", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            //businessOpportunity is a tagged value only occurring in a BusinessArea or ProcessArea
            if ((p.Element.Stereotype == UMM.bArea.ToString() || p.Element.Stereotype == UMM.ProcessArea.ToString()) && !foundBusinessOpportunity)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("businessOpportunity", p), "BRV", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundBusinessTerm)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("businessTerm", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundCopyright)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("copyright", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundOwner)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("owner", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundReference)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("reference", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundStatus)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("status", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundURI)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("URI", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }

            if (!foundVersion)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getPackageError("version", p), "BCM", ValidationMessage.errorLevelTypes.WARN, p.PackageID));
            }
        }
 /// <summary>
 /// Check the tagged values of the BusinessRealizationView
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 private void checkTV_BusinessRealizationView(IValidationContext context, EA.Package p)
 {
     //Check the TaggedValues of the BusinessRealizationView package
     new TaggedValueValidator().validatePackage(context, p);
 }
Example #22
0
 /// <summary>
 /// Returns the package error
 /// </summary>
 /// <param name="taggedValue"></param>
 /// <param name="package"></param>
 /// <param name="element"></param>
 /// <returns></returns>
 private String getElementError(String taggedValue, EA.Package package, EA.Element element)
 {
     return("Tagged value " + taggedValue + " of element " + element.Name + " in package " + package.Name + " <<" + package.Element.Stereotype + ">> is missing.");
 }
 /// <summary>
 /// Create a package element. Be aware that a package element also contains an element to support
 /// element specific things like tagged values.
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="GUID"></param>
 public FindAndReplaceItemPackage(EA.Repository rep, string GUID)  : base(rep, GUID)
 {
     this._el  = rep.GetElementByGuid(GUID);
     this._pkg = rep.GetPackageByGuid(GUID);
     this.load(rep);
 }
 /// <summary>
 /// Import of ReqIF DOORS Requirements
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="pkg"></param>
 /// <param name="importFile"></param>
 /// <param name="settings"></param>
 /// <param name="reqIfLog"></param>
 public DoorsReqIf(EA.Repository rep, EA.Package pkg, string importFile, FileImportSettingsItem settings, List <ReqIfLog> reqIfLog) : base(rep, pkg, importFile, settings, reqIfLog)
 {
 }
Example #25
0
 /// <summary>
 /// A CDT shall be one of the approved CDTs published in the UN/CEFACT Data Type Catalogue.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="d"></param>
 /// <param name="cdts"></param>
 private void checkC534b(IValidationContext context, EA.Package d, Dictionary <Int32, EA.Element> cdts)
 {
     //Not implemented yet since the UN/CEFACt Data Type Catalogue has not been released yet.
 }
        /// <summary>
        /// Check constraint C8
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pa"></param>
        private void checkC8(IValidationContext context, EA.Package pa)
        {
            EA.Collection packages = pa.Packages;

            if (packages != null)
            {
                //Iterate over the packages under the business requirements view
                foreach (EA.Package p in packages)
                {
                    //No BusinessDomain View must be located underneath any of the first level packages underneath the business requirements view
                    IList <EA.Package> bdvs = Utility.getAllSubPackagesWithGivenStereotypeRecursively(p,
                                                                                                      new List
                                                                                                      <EA.Package>(),
                                                                                                      UMM.bDomainV.
                                                                                                      ToString());
                    if (bdvs != null && bdvs.Count != 0)
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C8.",
                                                                           "A BusinessDomainView, a BusinessPartnerView, and a BusinessEntityView MUST be located directly under a BusinessRequirementsView.. \n\nPackage " +
                                                                           p.Name + " contains an invalid BusinessDomainView.", "BRV",
                                                                           ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }

                    //No BusinessPartnerView must be located underneath any of the first level packages underneath the business requirements view
                    IList <EA.Package> bpvs = Utility.getAllSubPackagesWithGivenStereotypeRecursively(p,
                                                                                                      new List
                                                                                                      <EA.Package>(),
                                                                                                      UMM.bPartnerV.
                                                                                                      ToString());
                    if (bpvs != null && bpvs.Count != 0)
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C8.",
                                                                           "A BusinessDomainView, a BusinessPartnerView, and a BusinessEntityView MUST be located directly under a BusinessRequirementsView.. \n\nPackage " +
                                                                           p.Name + " contains an invalid BusinessPartnerView.",
                                                                           "BRV", ValidationMessage.errorLevelTypes.ERROR,
                                                                           p.PackageID));
                    }

                    //No BusinessEntityView must be located underneath any of the first level packages underneath the business requirements view
                    IList <EA.Package> bevs = Utility.getAllSubPackagesWithGivenStereotypeRecursively(p,
                                                                                                      new List
                                                                                                      <EA.Package>(),
                                                                                                      UMM.bEntityV.
                                                                                                      ToString());
                    if (bevs != null && bevs.Count != 0)
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C8.",
                                                                           "A BusinessDomainView, a BusinessPartnerView, and a BusinessEntityView MUST be located directly under a BusinessRequirementsView.. \n\nPackage " +
                                                                           p.Name + " contains an invalid BusinessEntityView.", "BRV",
                                                                           ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }
                }

                //Make sure there are'nt any other packages in underneath the BRV
                foreach (EA.Package p in packages)
                {
                    String stereotype = Utility.getStereoTypeFromPackage(p);
                    if (
                        !(stereotype == UMM.bDomainV.ToString() || stereotype == UMM.bPartnerV.ToString() ||
                          stereotype == UMM.bEntityV.ToString()))
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C8.",
                                                                           "A BusinessDomainView, a BusinessPartnerView, and a BusinessEntityView MUST be located directly under a BusinessRequirementsView.. \n\nPackage " +
                                                                           p.Name + " has an invalid stereotype.", "BRV",
                                                                           ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }
                }
            }
        }
Example #27
0
 /// <summary>
 /// A CDT supplementary component shall be one of the specified CDT supplementary components as defined in the UN/CEFACT Data Type Catalogue.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="cdts"></param>
 private void checkC534j(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> cdts)
 {
     //Not implemented yet since we do not have a valid UN/CEFACT Data Type Catalogue yet
 }
 /// <summary>
 /// A BDT supplementary component’s cardinality shall be a restriction of the cardinality of the underlying CDT or less qualified BDT but never an extension thereof.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="bdts"></param>
 private void checkC564q(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
 {
     //Not a crucial constraint - will be implemented at a later stage
 }
Example #29
0
        /// <summary>
        /// Validate BusinessTransactionAction
        /// </summary>
        /// <param name="context"></param>
        /// <param name="e"></param>
        /// <param name="package"></param>
        private void validateBusinessTransactionAction(IValidationContext context, EA.Element e, EA.Package package)
        {
            bool foundTimeToPerform = false;
            bool foundIsConcurrent  = false;

            String valueTimeToPerform = "";
            String valueIsConcurrent  = "";


            foreach (EA.TaggedValue tv in e.TaggedValues)
            {
                String n = tv.Name;
                String v = tv.Value;

                if (n == UMMTaggedValues.timeToPerform.ToString())
                {
                    foundTimeToPerform = true;
                    valueTimeToPerform = v;
                }
                else if (n == UMMTaggedValues.isConcurrent.ToString())
                {
                    foundIsConcurrent = true;
                    valueIsConcurrent = v;
                }
            }


            if (!foundTimeToPerform)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("timeToPerform", package, e), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isDuration(valueTimeToPerform))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value timeToPerform of element " + e.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are xsd:duration or null. E.g P5Y2M10DT15H4M3S represents 5 years, 2 months, 10 days, 15 hours, 4 mintues and 3 seconds.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }


            if (!foundIsConcurrent)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isConcurrent", package, e), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsConcurrent))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isConcurrent of element " + e.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }
        }
        private static void sync_population_runstate(EA.Repository Repository, EA.Element sample, EA.Element classifier, JObject jo, EA.Package pkg, DiagramCache diagramCache)
        {
            logger.log("Syncing JObject:" + sample.Name);
            Dictionary <string, RunState> rs  = ObjectManager.parseRunState(sample.RunState);
            Dictionary <string, RunState> nrs = new Dictionary <string, RunState>();

            sample.ClassifierID = classifier.ElementID;

            foreach (JProperty p in jo.Properties())
            {
                if (p.Name == RoundTripAddInClass.POPULATION_PROPERTY_GUID)
                {
                    continue;
                }
                if (p.Name == RoundTripAddInClass.POPULATION_PROPERTY_NAME)
                {
                    sample.Name = p.Value.ToString();
                    continue;
                }
                if (p.Name == RoundTripAddInClass.POPULATION_PROPERTY_NOTES)
                {
                    sample.Notes = p.Value.ToString();
                    continue;
                }

                if (p.Name == RoundTripAddInClass.POPULATION_PROPERTY_TYPE)
                {
                    string     classifierName = p.Value.ToString();
                    EA.Element clazz          = RepositoryHelper.queryClassifier(Repository, classifierName);
                    if (clazz != null)
                    {
                        sample.ClassifierID = clazz.ElementID;
                        continue;
                    }
                }
                //string rsv=null;
                if (p.Value.Type != JTokenType.Object && p.Value.Type != JTokenType.Array)
                {
                    //logger.log("Adding Property:" + sample.Name);
                    RunState r;
                    if (rs.ContainsKey(p.Name))
                    {
                        r = rs[p.Name];
                    }
                    else
                    {
                        r     = new RunState();
                        r.key = p.Name;
                    }
                    r.value = p.Value.ToString();

                    nrs.Add(r.key, r);
                }
            }

            sample.RunState = ObjectManager.renderRunState(nrs);
            //logger.log(sample.RunState);
            sample.Update();
        }
Example #31
0
        /// <summary>
        /// Validate BusinessActions
        /// </summary>
        /// <param name="context"></param>
        /// <param name="e"></param>
        /// <param name="package"></param>
        private void validateInformationPins(IValidationContext context, EA.Element e, EA.Package package)
        {
            bool foundIsConfidential  = false;
            bool foundIsTamperProof   = false;
            bool foundIsAuthenticated = false;

            String valueIsConfidential  = "";
            String valueIsTamperProof   = "";
            String valueIsAuthenticated = "";

            EA.Element element = context.Repository.GetElementByID(e.ParentID);


            foreach (EA.TaggedValue tv in e.TaggedValues)
            {
                String n = tv.Name;
                String v = tv.Value;

                if (n == UMMTaggedValues.isConfidential.ToString())
                {
                    foundIsConfidential = true;
                    valueIsConfidential = v;
                }
                else if (n == UMMTaggedValues.isTamperProof.ToString())
                {
                    foundIsTamperProof = true;
                    valueIsTamperProof = v;
                }
                else if (n == UMMTaggedValues.isAuthenticated.ToString())
                {
                    foundIsAuthenticated = true;
                    valueIsAuthenticated = v;
                }
            }

            if (!foundIsConfidential)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isConfidential", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsConfidential))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isConfidential of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }


            if (!foundIsTamperProof)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isTamperProof", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsTamperProof))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isTamperProof of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundIsAuthenticated)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isAuthenticated", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsAuthenticated))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isAuthenticated of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }
        }
        private static void sync_population(EA.Repository Repository, EA.Element sample, EA.Element classifier, JArray ja, EA.Package pkg, DiagramCache diagramCache)
        {
            logger.log("Syncing JArray:" + sample.Name);
            Dictionary <string, RunState> rs  = ObjectManager.parseRunState(sample.RunState);
            Dictionary <string, RunState> nrs = new Dictionary <string, RunState>();

            foreach (JObject jo in ja.Children <JObject>())
            {
                logger.log("Syncing Child:");
                JToken guidToken = null;
                if (jo.TryGetValue(RoundTripAddInClass.POPULATION_PROPERTY_GUID, out guidToken))
                {
                    String     guid = guidToken.ToString();
                    EA.Element el   = diagramCache.elementGuidHash[guid];
                    if (el == null)
                    {
                        el = Repository.GetElementByGuid(guid);
                    }
                    if (el != null)
                    {
                        //logger.log("Found element for guid" + guid);
                        ObjectManager.sync_element_taggedvalue(Repository, el, classifier, jo, pkg, diagramCache);
                    }
                    else
                    {
                        logger.log("No element for guid" + guid);
                    }
                }
                else
                {
                    logger.log("No guid, adding element" + jo.ToString());
                    EA.Element el = pkg.Elements.AddNew("", "Object");
                    logger.log("No guid, adding element" + jo.ToString());
                    ObjectManager.sync_element_taggedvalue(Repository, el, classifier, jo, pkg, diagramCache);
                }
            }
        }
Example #33
0
        /// <summary>
        /// Validate BusinessActions
        /// </summary>
        /// <param name="context"></param>
        /// <param name="element"></param>
        /// <param name="package"></param>
        private void validateBusinessActions(IValidationContext context, EA.Element element, EA.Package package)
        {
            bool foundIsAuthorizationRequired        = false;
            bool foundIsNonRepudationRequired        = false;
            bool foundIsNonRepudationReceiptRequired = false;
            bool foundTimeToAcknowledgeReceipt       = false;
            bool foundTimeToAcknowledgeProcessing    = false;
            bool foundIsIntelligibleCheckRequired    = false;

            bool foundTimeToRespond = false;
            bool foundRetryCount    = false;


            String valueIsAuthorizationRequired        = "";
            String valueIsNonRepudationRequired        = "";
            String valueIsNonRepudationReceiptRequired = "";
            String valueTimeToAcknowledgeReceipt       = "";
            String valueTimeToAcknowledgeProcessing    = "";
            String valueIsIntelligibleCheckRequired    = "";
            String valueTimeToRespond = "";
            String valueRetrycount    = "";


            foreach (EA.TaggedValue tv in element.TaggedValues)
            {
                String n = tv.Name;
                String v = tv.Value;

                if (n == UMMTaggedValues.isAuthorizationRequired.ToString())
                {
                    foundIsAuthorizationRequired = true;
                    valueIsAuthorizationRequired = v;
                }
                else if (n == UMMTaggedValues.isNonRepudiationRequired.ToString())
                {
                    foundIsNonRepudationRequired = true;
                    valueIsNonRepudationRequired = v;
                }
                else if (n == UMMTaggedValues.isNonRepudiationReceiptRequired.ToString())
                {
                    foundIsNonRepudationReceiptRequired = true;
                    valueIsNonRepudationReceiptRequired = v;
                }
                else if (n == UMMTaggedValues.timeToAcknowledgeReceipt.ToString())
                {
                    foundTimeToAcknowledgeReceipt = true;
                    valueTimeToAcknowledgeReceipt = v;
                }
                else if (n == UMMTaggedValues.timeToAcknowledgeProcessing.ToString())
                {
                    foundTimeToAcknowledgeProcessing = true;
                    valueTimeToAcknowledgeProcessing = v;
                }
                else if (n == UMMTaggedValues.isIntelligibleCheckRequired.ToString())
                {
                    foundIsIntelligibleCheckRequired = true;
                    valueIsIntelligibleCheckRequired = v;
                }
                else if (n == UMMTaggedValues.timeToRespond.ToString())
                {
                    foundTimeToRespond = true;
                    valueTimeToRespond = v;
                }
                else if (n == UMMTaggedValues.retryCount.ToString())
                {
                    foundRetryCount = true;
                    valueRetrycount = v;
                }
            }


            if (!foundIsAuthorizationRequired)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isAuthorizationRequired", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsAuthorizationRequired))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isAuthorizationRequired of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }


            if (!foundIsNonRepudationRequired)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isNonRepudiationRequired", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsNonRepudationRequired))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isNonRepudiationRequired of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundIsNonRepudationReceiptRequired)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isNonRepudiationReceiptRequired", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsNonRepudationReceiptRequired))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isNonRepudiationReceiptRequired of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundTimeToAcknowledgeReceipt)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("timeToAcknowledgeReceipt", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isDuration(valueTimeToAcknowledgeReceipt))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value timeToAcknowledgeReceipt of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are xsd:duration or null. E.g P5Y2M10DT15H4M3S represents 5 years, 2 months, 10 days, 15 hours, 4 mintues and 3 seconds.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundTimeToAcknowledgeProcessing)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("timeToAcknowledgeProcessing", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isDuration(valueTimeToAcknowledgeProcessing))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value timeToAcknowledgeProcessing of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are xsd:duration or null. E.g P5Y2M10DT15H4M3S represents 5 years, 2 months, 10 days, 15 hours, 4 mintues and 3 seconds.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundIsIntelligibleCheckRequired)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isIntelligibleCheckRequired", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsIntelligibleCheckRequired))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isIntelligibleCheckRequired of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            //A RequestingAction has two additional taggedvalues in comparison to a RespondingAction
            if (element.Stereotype == UMM.ReqAction.ToString())
            {
                if (!foundTimeToRespond)
                {
                    context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("timeToRespond", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
                else
                {
                    if (!isDuration(valueTimeToRespond))
                    {
                        context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value timeToRespond of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are xsd:duration or null. E.g P5Y2M10DT15H4M3S represents 5 years, 2 months, 10 days, 15 hours, 4 mintues and 3 seconds.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                    }
                }

                if (!foundRetryCount)
                {
                    context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("retryCount", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
                else
                {
                    if (!isPositiveInteger(valueRetrycount))
                    {
                        context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value retryCount of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nRetryCount must be a figure greater or equal zero.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                    }
                }
            }
        }
Example #34
0
        /// <summary>
        /// Validate a abusiness transaction
        /// </summary>
        /// <param name="context"></param>
        /// <param name="element"></param>
        /// <param name="package"></param>
        private void validateBusinessTransaction(IValidationContext context, EA.Element element, EA.Package package)
        {
            bool   foundBusinessTransactionType   = false;
            bool   foundIsSecureTransportRequired = false;
            String valueBusinessTransactionType   = "";
            String valueIsSecureTransportRequired = "";

            foreach (EA.TaggedValue tv in element.TaggedValues)
            {
                if (tv.Name == UMMTaggedValues.businessTransactionType.ToString())
                {
                    foundBusinessTransactionType = true;
                    valueBusinessTransactionType = tv.Value;
                }
                else if (tv.Name == UMMTaggedValues.isSecureTransportRequired.ToString())
                {
                    foundIsSecureTransportRequired = true;
                    valueIsSecureTransportRequired = tv.Value;
                }
            }

            if (!foundBusinessTransactionType)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("businessTransactionType", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                //Found the tagged value - check if the values are ok
                if (!(valueBusinessTransactionType == "CommercialTransaction" ||
                      valueBusinessTransactionType == "Request/Confirm" || valueBusinessTransactionType == "Query/Response" ||
                      valueBusinessTransactionType == "Request/Response" ||
                      valueBusinessTransactionType == "Notification" ||
                      valueBusinessTransactionType == "InformationDistribution"))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value businessTransactionType of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are: Commercial Transaction, Request/Confirm, Query/Response, Request/Response, Notification, Information Distribution.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }

            if (!foundIsSecureTransportRequired)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("isSecureTransportRequired", package, element), "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
            }
            else
            {
                if (!isBoolean(valueIsSecureTransportRequired))
                {
                    context.AddValidationMessage(new ValidationMessage("Wrong tagged value.", "Tagged value isSecureTransportRequired of element " + element.Name + " in package " + package.Name + " has an invalid value. \n\nAllowed values are true and false.", "BCV", ValidationMessage.errorLevelTypes.ERROR, package.PackageID));
                }
            }
        }
 /// <summary>
 /// Create a package element. Be aware that a package element also contains an element to support
 /// element specific things like tagged values.
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="GUID"></param>
 public  FindAndReplaceItemPackage(EA.Repository rep, string GUID)  :base( rep, GUID)
 {
     this._el = rep.GetElementByGuid(GUID);
     this._pkg = rep.GetPackageByGuid(GUID);
     this.load(rep);
 }