In EMF, a user can draw UML diagram and that UML model can be transformed into Java code. As far as I know EMF has its own internal data structure to capture the UML model user draws. And what I want to do is to make UML model by coding, not by drawing, i.e., by using EMF's internal data structure representing UML metamodel(Class, Package, Attribute, etc). Like,
UmlClass myClass = new UmlClass();
UmlAttribute myAttr = new UmlAttribute();
myClass.addAttribute(myAttr);
Is this possible(not even by EMF)? Anyway, I want to use a robust data structure that exactly reflects OMG's standard UML specification.
Thanks in advance.
EMF is a modelling framework designed to support modelling in general, not just UML.
If it is UML in particular you're after, there is indeed such an implementation built on top of EMF. Check out UML2.
There are no classes exactly reflecting the OMG specification, but EMF ECore is a meta model for models. Therefore you can do what you want using EMF ECore. There is lots of doc at http://www.eclipse.org/modeling/emf/docs/#overviews and an excellent book. The link has a picture and link to the book.
An example:
EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
EClass myClass = ecoreFactory.createEClass();
myClass.setName("MyClass");
EAttribute myAttr = ECoreFactory.createEAttribute();
myAttr.setName("myAttr");
myAttr.setEType(EcorePackage.Literals.ESTRING);
myClass.getEStructuralFeatures().add(myAttr);
Related
Are Entity Relationship Diagrams(ERD's) considered a type of UML diagram or are they a separate thing?
I have another idea. I think we should look in-depth.
When we are talking about ERD (Entity Relationship Diagram), we are talking about Entity Relationship Modeling.
It is firstly introduced by Peter Chen (1976). He has two famous articles on Entity Relationship Modeling (see first and second articles)
He talked about Entity-Relationship Modeling (not Entity-Relationship Diagram). It is ER Model.
There is another paper in 1975 about Modeling the Real World System.
ER Modeling is (see reference, the second paragraph):
In software engineering an ER model is commonly formed to represent
things that a business needs to remember in order to perform business
processes. Consequently, the ER model becomes an abstract data model
that defines a data or information structure that can be implemented
in a database, typically a relational database.
Diagramming Convention Techniques
When we are talking about ER Modeling, there many diagramming convention techniques.
Chen Notation (some links need translation)
IDEF1X Notation
Bechman Notation
Martin notation
(min, max)-notation of Jean-Raymond Abrial in 1974
UML class diagrams
And other notations (see reference)
All of above notations are using for ER Modeling or Data Modeling.
There is no earth-shattering difference between UML notation and other ER notations. They all model the most important elements of data models.
Finally: UML is a set of standard graphical tools to model the whole or parts of a project. We can use UML (Class Diagram) for ER Modeling and name them our ER Models or ERDs. So we can say: this is my ERD in UML Notation.
ERD is it's own thing. It's not in UML specification. You can download specification PDF from the link.
UML is a common notation/language for object oriented modeling and it includes a multitude of diagram types. ERD is a diagram for data modeling (attributes and relationships). Some structural UML diagrams are fairly similar in what you can model, but the concept is different.
Types of UML diagrams:
This was the first search on Google:
Key Difference: UML stands for Unified Modeling Language. ERD stands for Entity Relationship Diagram. UML is a popular and standardized modeling language that is primarily used for object oriented softwares. Entity-Relationship diagrams are used in structured analysis and conceptual modeling
UML, as an object oriented notation, have nothing to data modeling. Lots times I read about attributes as data columns. It is not true. We can put to an attribute simple data or any complicated other object.
For data modeling (database, relational database) we use ERD diagram, for storing data in object systems we can use ORM (object relational model), it is mixed UML/Data model, if we use pattern like a active table or active record.
I have a different opinion to Jarek. There is nothing stopping you modelling data using UML. Remember that UML is not new at its foundations, It represents the evolution of a number of types of diagrams which had already existed (ERDs included), and an attempt to standardise these notations to create a consistent language for the communication of system design.
ERDs are used to model (largely) a static model of a system. They show (unsurprisingly) the relevant entities in a system and articulate the manner in which they are related.
In UML Class Diagrams were born from ER diagrams to represent the relationship between classes. If you consider that (in its simplest form) a class is the combination of data and methods, by ignoring methods you are left with a data model (albeit with a syntax which varies from traditional ERDs).
So ERDs correlate to Class Diagrams in UML if you choose to exclude methods and those aspects of the model designed to indicate data protection.
However UML itself serves a broader purpose, as a family of modelling tools that collectively can be used to model both the static and dynamic nature of a system.
It includes diagrams that facilitate for a more complete model of a system than you can get through describing its entities (or data):
Class Diagrams for static object relationship modelling,
Object Diagrams for dynamic mnodelling of object/instance relationships
State Machine/Diagrams for modelling how a system transitions through states
Sequence and Collaboaration diagrams to demonstrate how components of a system will work together
Activity Diagrams (replacing flow charts) to demonstrate/document imperative flow
and a few others I'll leave you to investigate (check out http://www.agilemodeling.com/essays/umlDiagrams.htm for an overview)
I have a different opinion to Andy. In UML Class Diagrams you describe relationship between two classes. With ERD you can talk about relationships between more than two entities.
This is the reason why the cardinality in Chen-Diagrams are on opposite site compared to UML Class Diagrams. You have to think about number of relations for every single entity.
Let's take a look at one simple example:
In this little example every supplier must be in relationship with at least one delivery. But there can be items not being delivered and projects without any deliveries.
I am looking for an UML modeling tool (e.g. uml designer, papyrus, modelio or such) with a support for collaboration diagrams (as described here : http://www.uml-diagrams.org/collaboration-diagrams/collaboration.html and here http://www.uml-diagrams.org/collaboration-diagrams/collaboration-use.html)
I am especially interested by the ability to draw this kind of schema:
I would also appreciate it if somebody could link me to a good tutorial about this.
PS : To give some context, I am mostly interested in collaboration diagrams in order to describe which part of a class diagram are taking part in a given design pattern (from example which classes of a class diagram are the observer/subject of an observer pattern).
To create a composite structure diagram under Modelio, you have to:
Create a project.
Select UML root project under the model explorer.
Create a Class.
Select the created Class and create a Composite Structure diagram.
The following screenshot show the required steps.
I'm currently working on a project for my university and one teacher told me I was wrong to think that there could be classes in a UML class diagram (thinking of it as a design diagram) to which there would be no equivalent in a data model. He then pressured me to provide a counter-example to prove my point but I just couldn't think of one.
I checked a few books I had about UML like "Learning UML 2.0," "Applying UML and Patterns" and UML 2 for dummies, but I couldn't find any information regarding which classes appear on a class diagram. I asked him about implementation classes but he told me that they shouldn't be included in a class diagram. So I'm at a loss here.
I also checked this questions before posting:
Differences between a conceptual UML class diagram and an ERD?
Generate UML from a conceptual data model
how to relate data with function in uml class diagram
But they don't really solve the question I have.
Thanks for any insight you might have.
Both your teacher and you are unnecessarily distracted by the differences between UML and conceptual data modeling (which I take to be tantamount to ER modeling). The real issue you and your teacher are discussing is the difference between analysis and design, regardless of the model used.
A UML model can be created that diagrams the problem as stated or that diagrams the solution as designed. In the first case, implementation classes should be omitted, because they do not pertain to the problem domain. In the second case, they should be included. The first case is analysis. The second case is design.
The same ambiguity exists with regard to ER diagrams. Some people, including myself, use ER models and ER diagrams only to represent the data requirements inherent in the problem itself. This is what is most often meant by "conceptual data modeling". In this framework, the only entities that should appear are entities that have a perceived reality in the subject matter itself, and are not merely constructs inside the database or the application(s). This is analysis.
But there are plenty of other people, perhaps a majority, who use ER diagrams to pictorialize the design of a schema of tables. In this framework, foreign keys are included, and junction tables are elevated to the status of entities, even though they are not subject matter entities. There's nothing inherently wrong in this, so long as the distiction between analysis and design is kept clear.
Unfortunately, the distinction between analysis and design is very often obscured beyond recognition. There are dozens of instances of this right here in SO.
So, if a confusion between analysis and design is allowed to creep into the discussion between you and your teacher, the discussion could end up going in almost any direction.
"one teacher told me I was wrong to think that there could be classes in a UML class diagram (thinking of it as a design diagram) to which there would be no equivalent in a data model. He then pressured me to provide a counter-example to prove my point but I just couldn't think of one."
He is right. In the stage of conceptual analysis/conceptual design, those rectangular boxes in a UML class diagram depict "concepts". And whatever the "concept" happens to be, you can always also draw an E/R diagram around it to illustrate (the nature of) that concept, other concepts that relate to it, and what the nature of those relationships is.
From my understanding of UML, it does NOT define what should be in a diagram. I found this example in the IBM site: (image did'nt lode, so here is the link: http://www.ibm.com/developerworks/webservices/library/ws-RESTservices/)
Surely, a servlet is not part of a domain model.
A UML class diagram us used to model classes, which are entities that have attributes and methods. IMHO, it doesn't matter if they are part of the domain model or are functional classes that support the application. If you need to show them to the customer, they must be there.
I have an conceptual data model (Relational model) created using powerAMC for my database but i wanted to generate DAO from it using acceleo and for that i need it in UML , is there a way to generate UML from a conceptual data model model ?
Acceleo can generate code from any models defined with any EMF based metamodel. The UML project of the Eclipse Foundation defines an UML metamodel based on EMF so that users can create UML models based on EMF and Acceleo can thus generate code from those models.
If you want to use another metamodel, you can do it, so if you want to create a metamodel that matches more closely your data structure, feel free to do so. As an example, you can see here a metamodel that I have created of the Scala language and my generator uses models defined from this metamodel to generate the code. You can find an example of a generator using this metamodel here. You can see in this example that the Acceleo generator is defined on my scala metamodel "http://github.com/sbegaudeau/acceleo/scalametamodel/2011/01" (contrary to an Acceleo generator that would be defined on UML that would be using the standard UML metamodel "http://www.eclipse.org/uml2/3.0.0/UML") and I can manipulate in Acceleo some concepts from this metamodel directly like traits (if you are familiar with Scala).
So you can:
create a metamodel that matches your concepts
create a small converter in java to create an EMF model (instance of your metamodel defining the concepts of your database) and then transform the data in your database to an EMF model that you just have to save.
use Acceleo with your models :)
Regards,
Stephane Begaudeau
Disclaimer: I am the leader of Acceleo.
PowerAMC has a data model which is not object like UML. It is therefore impossible to transform it to UML.
If you have directly the generated database then you can create the UML model from the code but not from database modeler.
We have an application that generates a XSD file that represents database tables.
I now need to convert the XSD in to a UML model. This will allow clients to change the model using a modelling tool (such as Magicdraw, RSA, Eclipse, ct) and then run another of our tools to generate other artifacts.
How can I convert from XSD to UML ?
We own MagicDraw so I was looking in to the Transformations functionality that should do this for me but for some reason I can't import the XSD, although it is valid.
I'm also confused when it talks about XML Schemas and XMI format. How do these differ from my XSD file?
Thanks.
Sarah
The best tool that I have found for this purpose is the XML modelling tool. Its been a while since it was updated, but it works. I blogged about it at Modelling wsdl as uml
There are some tools able to transform XML schemas into UML diagrams (see a list here, read the comments in the post) but the XML/XMI import of MagicDraw (and in general of any other UML tool) will not work in your schema since they expect a specific type of XML file (XMI format) which is the standard used to provide a XML-based definition of a UML model.
That is, XMI files are used to store UML models in XML and they follow a predefined XSD. In theory UML tools should be able to exchange UML models stored in XMI but unfortunately, this "model once open anywhere" is not true (but this is another story)
You can try to use the Eclipse Dali plugin which would generate a java code directly from your database. Once you get the code you can reverse into UML.
From UML to database you could try to add java persistence annotations in your code coming from your UML class diagram. When you have the annotated code then try hibernate to create your database.
This would do the job but having multiple layers means that you loose tracability between your original data model and UML and back. This is called the pojo cycle.