Example #1
0
 public void addClasses(Class element)
 {
     if (element != null)
     {
         classes.Add(element.name, element);
         element.Package = this;
     }
 }
 public InstanceSpecification(string name, Class classe)
     : base(name)
 {
     //Debug.Log("InstanceSpecification::instanciate : " + name + " : " + classe.getFullName());
     this.classifier = classe;
     if (this.classifier != null)
     {
         if (this.classifier.Instances.ContainsKey(this.name)) this.classifier.Instances.Remove(this.name);
         this.classifier.Instances.Add(this.name, this);
         slots = new Dictionary<string, Slot>();
         smBehaviorExecution = new List<StateMachineBehaviorExecution>();
         createInstanceFromClass();
     }
 }
Example #3
0
        public Class _lookForOperation(Class cl)
        {
            MascaretApplication.Instance.VRComponentFactory.Log("----- Trying to create opaque behavior : " + cl.name + " : " + body + " : " + cl.Parents.Count);
            if (cl.Operations.ContainsKey(body))
            {
                return cl;
            }
            else if (cl.Parents.Count != 0)
            {

                return _lookForOperation((Class)(cl.Parents[0]));
            }
            else
            {
                System.Console.WriteLine("Ca va planter.....");
                return null;
            }
        }
Example #4
0
        //Default Parameters opposite = null ,ValueSpecification def= ,null,DomainSpecification domain=null
        public Property(string name, Class cl, Classifier type, Property opposite, ValueSpecification def, DomainSpecification domain)
            : base(name)
        {
            this.type = type;
            this.classifier = cl;
            this.opposite = opposite;
            this.defaultValue = null;
            this.domain = domain;
            this.isComposite = false;
            this.isNavigable = false;
            this.isReadOnly = false;
            this.isDerived = false;
            this.isUnique = false;
            this.isOrdered = false;
            this.minimumNumber = 0;
            this.maximumNumber = 1;

            if (def != null)
                this.defaultValue = def;
            else
            {
                string typeName = type.name;
                if (typeName == "real")
                {
                    this.defaultValue = new LiteralReal();
                }
                else if (typeName == "integer")
                {
                    this.defaultValue = new LiteralInteger();
                }
                else if (typeName == "string")
                {
                    this.defaultValue = new LiteralString();
                }
                else if (typeName == "boolean")
                {
                    this.defaultValue = new LiteralBoolean();
                }
                else if (typeName == "bool")
                {
                    this.defaultValue = new LiteralBoolean();
                }
            }
        }
Example #5
0
 public SoundProperty(string name, Class classe)
     : base(name, classe, MascaretApplication.Instance.Model.getBasicType("sound"), null, null, null)
 {
 }
Example #6
0
 public Unit(string name, Class classe)
     : base(name, classe)
 {
 }
Example #7
0
        public void addAttribute(XElement attrNode, Class cl)
        {
            // Bouml preserved body begin 0001FB67
            //Debug.Log(" -------- Add Attribute ");
            XElement typeNode = null;

            foreach (XElement child in attrNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("type") == 0)
                {
                    typeNode = child;
                    break;
                }
            }
            if (isStereotypedBuiltIn(attrNode))
            {//TODO Pour le moment on ignore les propri�t�s builtIn
                return;
            }

            string assoId = "";

            XAttribute attr = (XAttribute)attrNode.Attribute("association");
            if (attr != null)
            {
                assoId = attr.Value;
            }
            else
            {
                attr = (XAttribute)attrNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id");
                if (attr == null) attr = (XAttribute)attrNode.Attribute("{http://www.omg.org/spec/XMI/20131001}id");

                if (attr != null) assoId = attr.Value;
            }

            //add at end of package
            //Debug.Log ("ASSO : " + assoId);

            if (!_idAsso.ContainsKey(assoId))
            {
                List<KeyValuePair<Class, XElement>> liste = new List<KeyValuePair<Class, XElement>>();
                liste.Add(new KeyValuePair<Class, XElement>(cl, attrNode));
                _idAsso.Add(assoId, liste);
            }
            else
            {
                _idAsso[assoId].Add(new KeyValuePair<Class, XElement>(cl, attrNode));
            }

            // Bouml preserved body end 0001FB67
        }
Example #8
0
        public void addActivityToClass(XElement activityNode, Class cl)
        {
            string name = activityNode.Attribute("name").Value;

            //Debug.Log(" ###### Adding Activity to class : " + cl.getFullName() + " : " + name);

            bool hasSpecification = false;
            string idoperation = "";
            if (activityNode.Attribute("specification") != null)
            {
                idoperation = activityNode.Attribute("specification").Value;
                hasSpecification = true;
            }

            Activity activity = new Activity(name);

            foreach (XElement child in activityNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("group") == 0)
                    addActivityGroup(child, activity);
            }
            foreach (XElement child in activityNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("node") == 0)
                    addActivityNode(child, activity);
                else if (child.Name.LocalName.CompareTo("ownedParameter") == 0)
                    addActivityParameter(child, activity);
            }
            foreach (XElement child in activityNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("edge") == 0)
                    addActivityEdge(child, activity);
            }

            if (hasSpecification)
            {
                if (_idOperations.ContainsKey(idoperation))
                    _idOperations[idoperation].Method = activity;
                //else
                //Debug.Log("[ModelLoader2 Warning] Operation : " + idoperation
                //+ " not found for activity " + name );
            }
            else
            {
                if (cl.hasOperation(name))
                {
                    Operation op = cl.Operations[name];
                    op.Method = activity;
                }
            }
            //	pkg->addActivity(activity);
            activity.Description = getComment(activityNode);
            activity.Summary = getSummary(activityNode);
            activity.Tags = getTags(activityNode);
        }
Example #9
0
        public Property _addAttribute(XElement attrNode, Class cl)
        {
            //  StreamWriter file = new StreamWriter("attribute.txt");

            string type = "", attrName = "", strVal = "", typeNodeType = "";
            string id = "";
            bool derived = false;
            Classifier attributeType = null;
            XElement typeNode = null, defaultNode = null;

            XAttribute attrid = (XAttribute)attrNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id");
            if (attrid != null) id = attrid.Value;

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

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

            attr = (XAttribute)attrNode.Attribute("name");
            if (attr != null) attrName = attr.Value;

            attr = (XAttribute)attrNode.Attribute("isDerived");
            if (attr != null && attr.Value.CompareTo("true") == 0)
            {
                derived = true;
            }
            else if (attr != null && attr.Value.CompareTo("true") != 0)
            {
                derived = false;
            }

            foreach (XElement child in attrNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("type") == 0)
                    typeNode = child;
                if (child.Name.LocalName.CompareTo("defaultValue") == 0)
                    defaultNode = child;
            }

            if (defaultNode != null)
            {
                attr = (XAttribute)defaultNode.Attribute("value");
                if (attr != null)
                {
                    strVal = attr.Value;
                }
            }
            //  file.WriteLine("Attribut : " + attrName);
            //  file.Flush();

            if (typeNode != null)
            {

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

                if (attr != null) typeNodeType = attr.Value;
                else
                {
                    //  file.WriteLine("Pas d'attribut type"); file.Flush();
                    typeNodeType = ((XAttribute)typeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}idref")).Value;
                    if (typeNodeType == null) attr = (XAttribute)typeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}idref");

                    attributeType = model.getBasicType(typeNodeType.ToLower());
                    //  file.WriteLine(attributeType.name); file.Flush();
                }

                if (typeNodeType.CompareTo("uml:Class") == 0)
                {
                    attr = (XAttribute)typeNode.Attribute("idref");

                    if (attr != null && _classifiers.ContainsKey(attr.Value))
                        attributeType = _classifiers[attr.Value];
                    else if (attr != null)
                    {
                        attributeType = model.getBasicType(attr.Value.ToLower());
                    }

                }
                else if (typeNodeType.CompareTo("uml:PrimitiveType") == 0)
                {
                    string strType = "";

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

                    attributeType = model.getBasicType(strType.ToLower());

                }
            }
            else
            {

                typeNode = attrNode;

                attr = (XAttribute)typeNode.Attribute("type");
                if (attr != null) typeNodeType = attr.Value;

                if (_classifiers.ContainsKey(typeNodeType))
                {
                    attributeType = _classifiers[typeNodeType];
                }
                else
                    attributeType = model.getBasicType(typeNodeType.ToLower());
            }

            ValueSpecification valueSpec = null;

            if (derived)
            {

                Expression curExpression = new Expression(strVal, attributeType);

                valueSpec = (ValueSpecification)curExpression;
            }
            else if (strVal.CompareTo("") == 0)
            {
                //value = attributeType.createValueFromString(strVal);
            }

            if (strVal != "")
            {
                MascaretApplication.Instance.VRComponentFactory.Log("HAS A DEFAULT VALUE : " + strVal);
                valueSpec = attributeType.createValueFromString(strVal);
            }

            Property attrProp = new Property(attrName, cl, attributeType, null, valueSpec, null);
            if (hasStereotype(id))
            {
                attrProp.Stereotype = getStereotype(id);
                MascaretApplication.Instance.VRComponentFactory.Log("DEBUG /// STEREOTYPE : " + attrName + " : " + attrProp.Stereotype);
            }

            string mulStr = "1";

            foreach (XElement child in attrNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("upperValue") == 0)
                {
                    attr = (XAttribute)child.Attribute("value");
                    if (attr != null && attr.Value.CompareTo("*") == 0)
                        mulStr = "-1";
                    if (attr != null && attr.Value.CompareTo("") == 0)
                        mulStr = "1";

                    break;
                }

            }

            //  file.Close();

            attrProp.MaximumNumber = int.Parse(mulStr);
            mulStr = "1";

            foreach (XElement child in attrNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("lowerValue") == 0)
                {
                    attr = (XAttribute)child.Attribute("value");
                    if (attr != null && attr.Value.CompareTo("*") == 0)
                        mulStr = "-1";
                    if (attr != null && attr.Value.CompareTo("") == 0)
                        mulStr = "0";

                    break;
                }

            }

            attrProp.MinimumNumber = int.Parse(mulStr);

            //derived
            attrProp.IsDerived = derived;

            cl.addAttribute(attrProp);
            attrProp.Description = getComment(attrNode);
            attrProp.Summary = getSummary(attrNode);
            attrProp.Tags = getTags(attrNode);

            return attrProp;

            // Bouml preserved body end 0001FBE7
        }
Example #10
0
        public void addStateMachineToClass(XElement smNode, Class classe)
        {
            //StreamWriter file = MascaretApplication.Instance.logfile;

            //Debug.Log ("********* [ModelLoader2 Info] addStateMachineToClass (SM: ");

            string name = smNode.Attribute("name").Value;

            //Debug.Log("RQ : " + name + " Class: " + classe.getFullName());
            // file.WriteLine("StateMachine : " + name); file.Flush();
            StateMachine machine = new StateMachine(name);

            machine.Description = getComment(smNode);
            machine.Summary = getSummary(smNode);
            machine.Tags = getTags(smNode);

            // SubMachine ?
            //if (smNode->hasProperty("submachineState")) {
            //	string subMachineRef = smNode->getProperty("id");
            //	_subStateMachines[subMachineRef] = machine;
            //cerr << "SUB STATE MACHINE" << endl;
            //} else {
            classe.addOwnedBehavior(machine);
            machine.Owner = classe;
            //}

            Dictionary<string, Vertex> vertices = new Dictionary<string, Vertex>();

            foreach (XElement child in smNode.Elements())
            {
                if (child.Name.LocalName.CompareTo("packagedElement") == 0 || child.Name.LocalName.CompareTo("ownedMember") == 0)
                {
                    string childType = "";
                    //  file.WriteLine("Child : " + child.Name.LocalName);
                    //  file.Flush();

                    XAttribute attr = (XAttribute)child.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) childType = attr.Value;

                    if (childType == "uml:Trigger")
                    {
                        string id = "";
                        //   file.WriteLine("Trigger");
                        XAttribute attr3 = (XAttribute)child.Attribute("{http://schema.omg.org/spec/XMI/2.1}id");
                        if (attr3 == null) attr3 = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}id");

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

                        foreach (XElement child2 in child.Elements())
                        {
                            if (child2.Name.LocalName.CompareTo("event") == 0)
                            {
                                XAttribute attr2 = (XAttribute)child2.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) childType = attr2.Value;
                                if (childType.CompareTo("uml:SignalEvent") == 0)
                                {
                                    XElement cSignal = child2.Element("signal");
                                    XAttribute idSignal = (XAttribute)cSignal.Attribute("{http://schema.omg.org/spec/XMI/2.1}idref");
                                    if (idSignal == null) idSignal = (XAttribute)cSignal.Attribute("{http://www.omg.org/spec/XMI/20131001}idref");

                                    string idref = idSignal.Value;
                                    Signal signal = _signals[idref];
                                    //   file.WriteLine("Signal name : " + signal.name); file.Flush();
                                    SignalEvent signalEvent = new SignalEvent(signal.name);
                                    signalEvent.SignalClass = signal;

                                    _events.Add(id, signalEvent);
                                }
                            }
                        }
                    }
                }
            }

            foreach (XElement child in smNode.Elements())
            {
                if (child.Name.LocalName == "region")
                {
                    //Debug.Log(" ####### add region .....");
                    Region region = new Region();
                    machine.Region.Add(region);
                    addMachineRegion(child, machine, region, vertices);
                }
                else if (child.Name.LocalName == "transition")
                {
                    //Debug.Log(" ####### add transition.....");
                    addMachineTransition(child, machine, vertices);
                }

            }
            //    file.Close();
        }
Example #11
0
 public GeometryProperty(string name, Class classe, Classifier type)
     : base(name, classe, type)
 {
 }
Example #12
0
    public void addConnector(XElement attrNode, Class cl)
    {
        Connector connector = new Connector();
        cl.addConnector(connector);

        foreach (XElement child in attrNode.Elements())
        {
            if (child.Name.LocalName.CompareTo("end") == 0)
            {
                string partWithPort = "";
                string role = "";

                

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

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


                if (partWithPort != "")
                {
                    ConnectorEnd ce = new ConnectorEnd();
                    connector.addEnd(ce);
                    ConnectorEndT cet;
                    cet.ce = ce;
                    cet.partWithPort = partWithPort;
                    cet.role = role;
                    _connectors.Add(cet);
                }

            }
        }

    }
Example #13
0
 public Port(string name, Class cl, Classifier type, Property opposite, ValueSpecification def, DomainSpecification domain)
     : base(name, cl, type, opposite, def, domain)
 {
 }
Example #14
0
 public Operation(string name, Class owner, Behavior behavior)
     : base(name, behavior)
 {
     this.classifier = owner;
     this.type = null;
 }
Example #15
0
        //TODO: choper contenu de data (tag? description?)
        public void addOperation(XElement opNode, Class cl)
        {
            // Bouml preserved body begin 0001FAE7

            string opName = "";

            XAttribute attr = (XAttribute)opNode.Attribute("name");
            if (attr != null) opName = attr.Value;

            // Pour l'instant que Opaque Behavior (C++ / Python)
            OpaqueBehavior b = null;
            string datas = "";
            //default C++
            string opClassName = cl.name + "_" + opName;
            //        xmiOperation.getTaggedValue("C++",data);
            //TODO choper contenu data
            if (datas.CompareTo(String.Empty) != 0)
            {
                if (datas.Contains("{PYTHON}"))
                {
                    string python = "{PYTHON}";
                    datas = datas.Substring(python.Length);
                }
                else if (datas.Contains("{OCL}"))
                {
                    string ocl = "{OCL}";
                    datas = datas.Substring(ocl.Length);

                    //b = new OclQuery(opClassName);
                    //b.Body=datas;

                }
                else
                {
                    _opaqueBehaviorsCode.Add(new KeyValuePair<string, string>(opClassName, datas));
                    //b=new OpaqueBehavior(opClassName); b.Body=opClassName;
                    b = new OpaqueBehavior(opName);
                    b.Body = opName;
                }
            }
            else
            {
                b = new OpaqueBehavior(opName);
                b.Body = opName;
            }

            Operation operation = new Operation(opName, cl, b);
            _addParameters(operation, opNode);

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

            if (attr != null)
            {
                //Debug.Log(" Blurp : " + attr.Value);
                _idOperations.Add(attr.Value, operation);
            }

            //Debug.Log opNode.getProperty("id") );
            //TODO : normalement a devrait etre fait par le new Operation
            cl.addOperation(operation);
            operation.Description = getComment(opNode);
            operation.Summary = getSummary(opNode);
            operation.Tags = getTags(opNode);
            // Bouml preserved body end 0001FAE7
        }
Example #16
0
 public PathProperty(string name, Class classe)
     : base(name, classe, MascaretApplication.Instance.Model.getBasicType("path"))
 {
 }
Example #17
0
 public TopologicalProperty(string name, Class classe, Classifier type)
     : base(name, classe, type, null, null, null)
 {
 }