コード例 #1
0
 public frmPhysicalDrawBoard(MetaData md)
 {
     InitializeComponent();
     generate = new GeneratePhysicalModel(md);
     generate.Process();
     pnlPhysical.drawMetaDataPhysical(generate.mdp);
 }
コード例 #2
0
ファイル: JSerializer.cs プロジェクト: rsuneja/erdesigner
 public void saveConceptualToXML(String fpath, MetaData obj)
 {
     serializer = new XmlSerializer(typeof(MetaData));
     FileStream fs = new FileStream(fpath, FileMode.Create);
     serializer.Serialize(fs, obj);
     fs.Close();
 }
コード例 #3
0
 public GeneratePhysicalModel(string url)
 {
     erd = js.loadFromXML(url);
 }
コード例 #4
0
 //Constructors
 public GeneratePhysicalModel(MetaData md)
 {
     erd = md;
 }
コード例 #5
0
        //Get, Load Metadata
        public MetaData getMetaData()
        {
            MetaData ERD = new MetaData();
            foreach (Control c in this.Controls)
            {
                if (c is EntityShape || c is RelationshipShape || c is SubTypeConnector)
                {
                    ShapeBase s = (ShapeBase)c;
                    if (s is EntityShape)
                    {
                        EntityShape en = (EntityShape)s;
                        EntityData entity = (EntityData)en.getMetaData();

                        foreach (AttributeShape att in en.attributes)
                        {
                            AttributeData attribute = (AttributeData)att.getMetaData();
                            if (att.isComposite)
                            {
                                attribute.isComposite = true;
                                foreach (AttributeShape attchild in att.attributeChilds)
                                {
                                    AttributeData attributechild = (AttributeData)attchild.getMetaData();

                                    attribute.AttributeChilds.Add(attributechild);
                                }
                            }
                            entity.Attributes.Add(attribute);
                        }

                        ERD.Entities.Add(entity);
                    }
                    if (s is RelationshipShape)
                    {
                        RelationshipShape rel = (RelationshipShape)s;
                        RelationshipData relationship = (RelationshipData)rel.getMetaData();

                        foreach (AttributeShape att in rel.attributes)
                        {
                            AttributeData attribute = (AttributeData)att.getMetaData();
                            if (att.isComposite)
                            {
                                attribute.isComposite = true;
                                foreach (AttributeShape attchild in att.attributeChilds)
                                {
                                    AttributeData attributechild = (AttributeData)attchild.getMetaData();

                                    attribute.AttributeChilds.Add(attributechild);
                                }
                            }
                            relationship.Attributes.Add(attribute);
                        }

                        foreach (CardinalityShape cardi in rel.cardinalities)
                        {
                            CardinalityData cardinality = new CardinalityData(cardi.Entity.sName, cardi.MinCardinality, cardi.MaxCardinality);

                            relationship.Cardinalities.Add(cardinality);
                        }
                        ERD.Relationships.Add(relationship);
                    }
                    if (s is SubTypeConnector)
                    {
                        SubTypeConnectorData subtypeconnectordata = (SubTypeConnectorData)((SubTypeConnector)s).getMetaData();
                        ERD.SubTypeConnectors.Add(subtypeconnectordata);
                    }
                }
            }
            return ERD;
        }
コード例 #6
0
        public void drawMetaData(MetaData ERD)
        {
            this.Controls.Clear(); //Xóa hết, vẽ lại

            // Vẽ entity và Attribute của nó
            foreach (EntityData en in ERD.Entities)
            {
                EntityShape entity = (EntityShape)en.createNotation();
                this.Controls.Add(entity);

                foreach (AttributeData att in en.Attributes)
                {
                    AttributeShape attribute = (AttributeShape)att.createNotation();

                    if (att.isComposite)
                    {
                        foreach (AttributeData attChild in att.AttributeChilds)
                        {
                            AttributeShape attributeChild = (AttributeShape)attChild.createNotation();
                            attribute.addAttribute(attributeChild);
                            this.Controls.Add(attributeChild);
                        }
                    }
                    entity.addAttribute(attribute);
                    this.Controls.Add(attribute);
                }
            }

            //Phù, mệt wá, ráng thôi, Vẽ tiếp relationship, attribute và cardinality của nó
            //Xài interface, hết mệt
            foreach (RelationshipData rel in ERD.Relationships)
            {
                RelationshipShape relationship = (RelationshipShape)rel.createNotation();
                this.Controls.Add(relationship);

                foreach (AttributeData att in rel.Attributes)
                {
                    AttributeShape attribute = (AttributeShape)att.createNotation();

                    if (att.isComposite)
                    {
                        foreach (AttributeData attChild in att.AttributeChilds)
                        {
                            AttributeShape attributeChild = (AttributeShape)attChild.createNotation();
                            attribute.addAttribute(attributeChild);
                            this.Controls.Add(attributeChild);
                        }
                    }
                    relationship.addAttribute(attribute);
                    this.Controls.Add(attribute);

                }
                foreach (CardinalityData cardi in rel.Cardinalities)
                {
                    //Tìm Entity để add vào Cardinality
                    foreach (ShapeBase s in this.Controls)
                    {
                        if (s.GetType().Name == "EntityShape" && s.sName == cardi.Entity)
                        {
                            relationship.CreateCardinality((EntityShape)s, cardi.MinCardinality, cardi.MaxCardinality);
                            break;
                        }
                    }
                }
            }
            foreach (SubTypeConnectorData subtypeconnectordata in ERD.SubTypeConnectors)
            {
                SubTypeConnector subtypeconnector = (SubTypeConnector)subtypeconnectordata.createNotation();
                foreach (ShapeBase s in this.Controls)
                {
                    if (s is EntityShape && s.sName == subtypeconnectordata.SuperType)
                    {
                        subtypeconnector.supertype = (EntityShape)s;
                        ((EntityShape)s).SubtypeConnector = subtypeconnector;
                    }
                }
                foreach (string subtypename in subtypeconnectordata.SubTypes)
                {
                    foreach (ShapeBase s in this.Controls)
                    {
                        if (s is EntityShape && s.sName == subtypename)
                        {
                            subtypeconnector.addSubType((EntityShape)s);
                        }
                    }
                }
                foreach (ShapeBase s in this.Controls)
                {
                    if (s is AttributeShape && s.sName == subtypeconnectordata.AttributeDiscriminator)
                    {
                        subtypeconnector.AttributeDiscriminator = (AttributeShape)s;
                    }
                }
                this.Controls.Add(subtypeconnector);

            }
            this.Refresh();
        }