예제 #1
0
        public void _addParameters(Operation op, XElement opNode)
        {
            // Bouml preserved body begin 0001FCE7
            foreach (XElement child in opNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("ownedParameter") == 0)
                {
                    string paramName = "", paramKind = "", id = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) paramName = attr.Value;

                    attr = (XAttribute)child.Attribute("direction");
                    if (attr != null) paramKind = attr.Value;

                    attr = (XAttribute)child.Attribute("{http://schema.omg.org/spec/XMI/2.1}id");
                    if (attr == null) attr = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}id");

                    if (attr != null) id = attr.Value;

                    Parameter parameter = new Parameter(paramName, paramKind, null);

                    attr = (XAttribute)child.Attribute("type");
                    if (attr != null)
                    {
                        _parameters.Add(id, parameter);
                        _paramToType.Add(id, attr.Value); //set type after
                        op.addParameter(parameter);
                    }
                    else
                    {
                        foreach (XElement gChild in child.Elements())
                        {

                            if (gChild.Name.LocalName.CompareTo("type") == 0)
                            {

                                attr = (XAttribute)gChild.Attribute("{http://schema.omg.org/spec/XMI/2.1}type");
                                if (attr == null) attr = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}type");

                                if (attr != null && attr.Value.CompareTo("uml:Class") == 0)
                                {
                                    _parameters.Add(id, parameter);
                                    XAttribute attr2 = (XAttribute)gChild.Attribute("idref");
                                    if (attr2 != null) _paramToType.Add(id, attr2.Value); //set type after
                                }
                                else if (attr != null && attr.Value.CompareTo("uml:PrimitiveType") == 0)
                                {
                                    Classifier type = null;
                                    string strType = "";

                                    XAttribute attr2 = (XAttribute)gChild.Attribute("href");
                                    if (attr2 != null) strType = attr2.Value.Substring(attr2.Value.IndexOf("#") + 1);

                                    type = model.getBasicType(strType.ToLower());
                                    parameter.Type = type;

                                }
                                else if (attr == null)
                                {
                                    _parameters.Add(id, parameter);

                                    XAttribute attr2 = (XAttribute)gChild.Attribute("{http://schema.omg.org/spec/XMI/2.1}type");
                                    if (attr2 == null) attr2 = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}type");

                                    if (attr2 != null) _paramToType.Add(id, attr2.Value);
                                }

                                op.addParameter(parameter);

                                break;
                            }
                        }
                    }

                }

            }
            // Bouml preserved body end 0001FCE7
        }
예제 #2
0
        //TODO
        public void addActivityParameter(XElement paramNode, Activity activity)
        {
            string attrName;
            attrName = paramNode.Attribute("name").Value;

            XElement typeNode = paramNode.Element("type");

            Classifier attributeType = null;
            if (typeNode != null && typeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type").Value == "uml:Class")
            {
                string typeId = typeNode.Attribute("idref").Value;
                if (_classifiers.ContainsKey(typeId))
                {
                    attributeType = _classifiers[typeId];
                }
                else
                    attributeType = model.getBasicType(typeId);
            }
            else if (typeNode != null && typeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type").Value == "uml:PrimitiveType")
            {
                string href = typeNode.Attribute("href").Value;
                string strType = href.Substring(href.LastIndexOf('#') + 1);
                attributeType = model.getBasicType(strType);
            }
            else if (typeNode == null)
            {
                typeNode = paramNode;
                string typeId = typeNode.Attribute("type").Value;
                if (_classifiers.ContainsKey(typeId))
                {
                    attributeType = _classifiers[typeId];
                }
                else
                {
                    if (typeId != "")
                    {
                        attributeType = model.getBasicType(typeId);
                    }
                }
            }

            //cerr << " Adding Parameter : " << attrName << " : " << attributeType->getName() << " dans " << activity->getName() << endl;
            ActivityParameterNode parameterNode = new ActivityParameterNode(attrName);
            Parameter parameter = new Parameter(attrName, "read", attributeType);
            parameterNode.Parameter = parameter;
            activity.addNode(parameterNode);
        }
예제 #3
0
 public void addParameter(Parameter param)
 {
     parameters.Add(param);
 }