Add nullable attribute to a class in enterprise architect - uml

I am using enterprise architect for UML. I need to generate code from the model.
I need have a nullable double attribute in a class.
I am able to add a double attribute but don't know how to make it nullable.
Do anyone have any idea how to add a nullable attribute.

There is a small problems with your question, let me first answer the part about the EA, and get to it later.
In UML you denote nullable type as
+attributeName : TypeName [0..1]
+fromUser : User [0..1]
in EA this is done in the Multiplicity section Select the class->Hit F9->Select the attribute->Click detail
Lower bound and Upper bound are the fields you are looking for, if each are 1 this attribute has a single value [1] usually not depicted in the diagram
[0..1] can have a value of null.
[*] can have any amount of values.
[1..*] collection that contains at least one value
[n..m] collection that contains between n and m values. n and m are replaced by concrete numbers
in many languages double is a primitive/value type you can not make it null. If you need to, you have to use Double. Note the first letter is capital.

Related

UML Notation for depicting relationship

Can someone please explain to me what do the highlighted elements mean in a snapshot of a UML class diagram shown below:
The plus symbol
The text inside the curly braces
The image above has been taken from the UML specifications at http://www.omg.org/spec/UML/
on further reading I found
The curly braces are called "adornments", which in this case have been placed on relationship. In this case they have been used to place constraints on the elements that are part of the relationship.
Still no clue about the + symbol.
Adornments are everything added to the connectors, namely text labels. The curly brackets are constraints. These can be either plain text or OCL. The subsets is a keyword within UML. P. 17 of the UML spec says
Association Ends: each specified by its name, type, and multiplicity, any additional properties such as {union}, and a link to its opposite end. If the association end subsets or redefines others, this is shown in the additional properties as {subsets } or {redefines }, where is a link to the applicable end. This is followed by a textual description of the purpose and meaning of the association end. If an association end is derived, the name will be preceded by a forward slash. If the association end is a composition, this is indicated by a small black diamond adjacent to the name of the end.
The plus says the attribute (which the role name ownedTemplateSignature is) has public visibility. P. 60 of the specs:
public
A Named Element with public visibility is visible to all elements that can access the contents of the Namespace that owns it.
private
A NamedElement with private visibility is only visible inside the Namespace that owns it.
protected
A NamedElement with protected visibility is visible to Elements that have a generalization relationship to the Namespace that owns it.
package
A NamedElement with package visibility is visible to all Elements within the nearest enclosing Package (given that other owning Elements have proper visibility). Outside the nearest enclosing Package, a NamedElement marked as having package visibility is not visible. Only NamedElements that are not owned by Packages can be marked as having package visibility.
And on p. 111:
<visibility> is the visibility of the Property. (See VisibilityKind - sub clause 7.4.)
<visibility> ::= ‘+’ | ‘-‘ | ‘#’ | ‘~’
(in the order of the list above, e.g. '+' is public)
And to extend as suggested by #granier, the little dot (which had been introduced with 2.1.1) at the end of the associations has this meaning: (p. 200)
Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which for brevity we will term a dot. The dot is to be drawn integral to the graphic path of the line, at the point where it meets the Classifier, inserted between the end of the line and the side of the node representing the Classifier. The diameter of the dot shall not exceed half the height of the aggregation diamond, and shall be larger than the width of the line. This avoids visual confusion with the filled diamond notation while ensuring that it can be distinguished from the line. The dot shows that the model includes a Property of the type represented by the Classifier touched by the dot. This Property is owned by the Classifier at the other end. In such a case it is normal to suppress the Property from the attributes compartment of the owning Classifier.
Actually the whole page is talking about ownership and navigability. But basically the dot means that the class at the opposite end owns the relation which means it can navigate towards the dotted class. Dots at either side mean that both classes know of each other.

Drop down menu for String values in Hybris Management Console

I have a requirement to display a drop down menu for a String type in Hybris Management Console, restricting the value to some specific values.
As suggested in several forums, I tried to create this entry as an enumeration type but characters like '-' are to be allowed in the enumeration values, as this column receives some specific values which comprise of '-'.
How do I solve this issue?
The people advising you probably didn't understand your requirements. As such, an enumeration type is clearly not appropriate in this case. Consider the alternatives. Is there a Map Type available? What other type might allow you to achieve your goal?
Actually, you could use the hybris Enumeration. In hybris Enum Types have a code and a name. The code is the unique representation for this enum and cannot contain a "-". The name however is a localized representation of that value and can include every character your database is able to store. Have a look here:
https://help.hybris.com/6.5.0/hcd/8c895989866910148d6a802f06651702.html
Additionally, hybris enables you to dynamically create new enumeration values, which is kind of nice.

Define the multiplicity of an association by an attribute

In the example I made every object of the type "Folder" have an array of type "File" with the name "content" a size of "n" as a private attribute (just saying my understanding of it to make sure that I am not already wrong there). That's how I see it in most examples but I never understand what "n" now is. Is it another attribute of the "Folder" object or is it something that we specify in another part of an UML diagram or something else completely?
What I am trying to achieve is that every object of the type "Folder" has an additional attribute that specifies the size of the "content" array.
Of course, you can not only write 0..*, but use any concrete number, too. If that number has some external definition, you can use there n, as you have it.
The external definition means "not defined by class diagram elements, except notes". Everything that you need to be said on a class diagram page, but can't because of the UML limitations, should be put in a note.
So, n can be defined in appropriate note on the page or in some different document or both.
As #Kilian had mentioned, in the case of some more complicated dependencies of such variables you can use constraints. This way seems to me the most powerful.
But if n has no objective definition or dependency, but is a simple variable that can have any meaning, then it will be correct to use a rule, such as 0..*, or 1..*, or maybe 3..5, according to the reality you are working with.

OWL: only one property among many properties exists

I want to express the xs:choice element from XSD in OWL:
XML Schema choice element allows only one of the elements contained in the declaration to be present within the containing element.
I think maybe I should first define a property group in OWL, and then specify only one of the properties in the group is allowed exists. Any help?
I think maybe I should first define a property group in OWL, and then
specify only one of the properties in the group is allowed exists. Any
help?
There's no notion of "property group" in OWL, but you could get a similar effect using subproperties and disjoint properties. For instance, you could have a property hierarchy like this:
hasVehicleChoice
hasCar
hasTruck
Then, you can declare that hasCar and hasTruck are disjoint. That means that a individual can't have the same value for both properties. That means that you can't say:
x hasCar vechicle72
x hasTruck vechicle72
That's not enough to say that they can't have different values though. You could still have
x hasCar vechicle72
x hasTruck vechicle75
To avoid that, you could make hasVehicleChoice be a functional property (meaning each individual has 0 or 1 values for it, but no more), or use a subclass axiom with a restriction, like
Person subClassOf (hasVehicleChoice exactly 1)
Then, each person would have exactly one vehicle choice, and since hasCar and hasTruck are disjoint, the person can't have both.
All that said, this isn't a common pattern in OWL ontologies, and there's not a particularly convenient way of encoding it. If you don't need it all that often, you might be better off just using the subclass axioms and property restrictions directly. E.g.,
Person subClassOf ((hasCar exactly 1) and (hasTruck exactly 0)) or ((hasCar exactly 0) and (hasTruck exactly 1))

How to specifiy enumeration literal as default value in UML Attribute?

I currently doing some model transformations using EMF-UML-Implementation.
In my model transformation I create an uml class with some attributes. The attributes are type of enumerations I also created.
Some of the attribute should get a default value. The default value should be enumeration literals.
The question now is, how do I get the enumeration literals to the defaultValue-property of the Property.
I already have found that I have to use ValueSpecification. But the UML superstructure says not much about that (page 139 f.). Which properties do I have to use for setting the defaultValue to enumeration literals?
I think the main problem I have is, that the use of ValueSpecification is unclear to me. Currently I only use default to set the default values, which is type of String.
The defaultValue-property takes a ValueSpecification argument. So in your case, you need an InstanceValue for this purpose (which derives from ValueSpecification). The InstanceValue itself has an instance-property, which takes an InstanceSpecification as argument. As EnumerationLiteral derives from InstanceSpecification, you can now simply assign one of your EnumerationLiterals to it.

Resources