Class: UMLDiagram

Defined in: web-src/coffee/model/uml/umldiagram.coffee
Inherits: model.Diagram

Overview

A UML diagram representation.

Instance Method Summary

Constructor Details

# (void) constructor(graph = null)

Parameters:

  • graph ( joint.Graph )

Instance Method Details

# (void) get_factory()

# (void) set_factory(factory)

# (void) get_graph()

# (void) set_graph(graph)

# (void) refresh_URIs_diag()

Refreshing URIs in diagram for namespaces changes.

# (void) _add_events() Bound

Add events to the joint.Graph instance assigned to @graph. This method should consider each link in any association (also remove roles) and any generalization.

# (void) get_clases()

# (void) get_generalizations()

# (void) get_associations()

# (void) get_attributes()

# (void) get_clase(nombre)

# (Class) find_class_by_name(name)

Find Primitive Messages


Parameters:

  • name ( String )

Returns:

  • ( Class ) — The first class founded that have the given name.

# (Class) find_class_by_classid(classid)

Parameters:

  • classid ( String )

Returns:

  • ( Class ) — The class with the provided ClassID

Parameters:

  • linkid ( String )

Returns:

  • ( Link ) — The MyModel's link.

Parameters:

  • linkid ( String )

Returns:

  • ( Link ) — The MyModel's link.

# (Generalization) find_generalization_by_id(generalizationid)

Parameters:

  • generalizationid ( String )

Returns:

# (Association) find_association_by_id(associationid)

Parameters:

  • associationid ( String )

Returns:

  • ( Association ) — The MyModel's Association.

# (void) find_association_by_role(role)

# (Attribute) find_attribute_by_id(attributeid)

Parameters:

  • attributeid ( String )

Returns:

# (void) find_attribute_by_name(name)

# (void) find_attribute_by_source_and_target(name, class_a, type_a)

# (Generalization) find_IsA_with_parent(parentclass)

Find a generalization that contains the given parent

generalization.

Parameters:

  • parentclass ( Class ) A Class instance that is the parent of the

Returns:

  • ( Generalization ) — null if nothing founded, a Generalization instance otherwise.

Find the Link instances with the given name.

Parameters:

  • name ( string )

Returns:

  • Array

# (void) show_class_info(class_id)

# (void) show_gen_info(gen_id)

# (void) show_assoc_info(assoc_id)

# (void) add_generalization(class_parent, class_childs, disjoint = false, covering = false, name = null, position = null, inferred = false)

Add a Generalization link.

If a generalziation already exists for the same parent, just add the class into the same Generalization instance. Constraints are ignored in this case.

This methods try to normalize all parameters and then call add_generalization_objs().

Parameters:

  • class_parent ( string, object ) The parent class/generalizationicon Id string or the class_parent Class/GeneralizationIcon object.
  • class_child_id ( string, array of strings, array of objects, object ) The child class string, an array of class Ids strings, an array of Class objects or the child object.

# (void) add_generalization_objs(class_parent, class_child, disjoint = false, covering = false, name = null, position, inferred = false)

Add a Generalization link.

If a generalziation already exists for the same parent, just add the class into the same Generalizatino instance. Constraints are ignored in this case.

Parameters:

  • class_parent ( Class/GeneralizationIcon instance ) A Class/GeneralizationIcon object.
  • class_child ( Class instance ) A Class object.

# (void) edit_covering(gen_id, covering)

# (void) edit_disjoint(gen_id, disjoint)

# (void) add_association(class_a_id, class_b_id, name = null, mult = null, roles = null, position = null, inferred = false)

TODO: see if roles in n-ary. Currently we support onle one role for each class for the same assoc.

Add a new UML association between two or more classes. It also manage adding classes to assoc and editing roles

to the first relationship while remaining 2..n contain the associated ones to respective target classes.

Parameters:

  • class_a_id ( string ) the ID of the class that started the association.
  • class_b_id ( Array<string> ) the ID of the other classes involved in the association.
  • name ( string ) optional. The name of the association.
  • mult ( array ) optional. An array of strings with the cardinalities. First elements contains the cardinality associated
  • roles ( array ) optional. An array of strings with the roles. Similar to mult.

# (void) add_association_class(class_a_id, class_b_id, name, mult = null, roles = null, position = null)

TODO: see if roles in n-ary. Currently we support onle one role for each class for the same assoc.

Add a new UML association with class between two or more classes. It also manage adding classes to assoc and editing roles

to the first relationship while remaining 2..n contain the associated ones to respective target classes.

Parameters:

  • class_a_id ( string ) the ID of the class that started the association.
  • class_b_id ( Array<string> ) the ID of the other classes involved in the association.
  • name ( string ) optional. The name of the association.
  • mult ( array ) optional. An array of strings with the cardinalities. First elements contains the cardinality associated
  • roles ( array ) optional. An array of strings with the roles. Similar to mult.

# (Class) add_class(hash_data)

Hash Data

  • name (mandatory)
  • attribs (optional)
  • methods (optional)
  • position (optional)
diagram_instance.add_class({name: "class A"})
diagram_instance.add_class({name: "class B", attrs: ["attrib1", "attrib2"], methods: ["method1", "method2"], position: {x: 20, y: 20}})

Parameters:

  • hash_data ( Hash ) data information for creating the new Class instance.

Returns:

  • ( Class ) — The new class

See also:

# (void) agregar_clase(clase)

# (void) add_attribute(class_a_id, name, type)

Class are created in crowd without attributes. This function adds attributes to classes by associating the current class to a attribute name (uri) and its datatype (another uri)

@param

# (void) add_assoc_class(hash_data)

# (void) agregar_assoc_clase(clase)

# (void) delete_class(c)

Parameters:

  • c ( Class instance )

# (Generalization) agregar_generalization(generalization)

Returns:

# (void) delete_generalization(c)

Parameters:

  • c ( Generalization instance )

# (void) delete_association(c)

Delete association removes also internal associated classes (non shown) for n-ary associations without class

Parameters:

  • c ( Association instance )

Search for all links associated to the given class.

Parameters:

  • c ( Class instance ) The class.

Returns:

  • ( ? ) — Array of Links instances.

Remove all links associated to the given class.

Parameters:

  • c ( Class instance ) The class.

# (void) delete_association_by_id(associationid)

# (void) delete_generalization_by_id(generalizationid)

# (Association) agregar_association(association)

Returns:

  • ( Association ) — The new associationIcon

# (void) rename_class(classid, name)

Rename class takes name, prefix and url and validate if both prefix and url are different from null Otherwise, it updates the uri associated to classid class

@param classid. A String with the class id to be renamed @param name. A String with the name for class id

Remove the link by its Joint CellID from the diagram.

Parameters:

  • linkid ( string ) the Joint CellID.

Remove the link by its source and target from the diagram.

@param name,class_a,class_b are strings

Remove the given link from the diagram.

Parameters:

  • link ( Link instance ) The link to remove.

# (void) update_view(class_id, paper)

Update the view associated to the given class's classid if it have already created its joint object. The view to be updated must be of the given paper

# (void) update_gen_view(gen_id, paper)

Update the view associated to the given class's classid if it have already created its joint object. The view to be updated must be of the given paper

# (void) delete_class_by_name(name)

Remove the class from the diagram.

# (void) delete_class_by_classid(classid)

Delete a class selecting by using its Joint Model

Parameters:

  • string. ( classid )

# (void) reset()

Reset the current diagram to start over empty.

Remove all classes and associations.

Limitations

If the link is a generalization it adds as a new generalization, not as part of another one.

For example, if you want to add another child into an already existent generalization, use add_generalization(same_parent, new_child) message.

# (void) set_satisfiable(classes_list)

Show these classes as satisifiable.

Parameters:

  • classes_list ( Array<String> ) a list of classes names.

See also:

# (void) set_class_satisfiable(class_name)

Satisfiability

Satifiability objects managent messages.

Show this class as satisfiable.

Parameters:

  • class_name ( String ) The class name.

# (void) set_unsatisfiable(classes_list)

Show these classes as unsatisifiable.

Parameters:

  • classes_list ( Array<String> ) a list of classes names.

See also:

# (void) set_class_unsatisfiable(class_name)

Show this class as unsatisfiable.

Parameters:

  • class_name ( String ) The class name.

# (void) set_inferredSubs(isubs_list)

Show new inferred subsumptions.

Parameters:

  • isubs_list ( Array<String> ) a list of subsumptions.
  • inferred ( Boolean ) last parameter indicates that this subsumption has been inferred

See also:

# (void) set_inferredSub_elt(isub)

# (void) set_inferredCards(icards_list)

Show new inferred cardinalities.

Parameters:

  • icards_list ( Array<String> ) a list of assoc with new cardinalities.
  • inferred ( Boolean ) last parameter indicates that this cardinality has been inferred

See also:

# (void) set_inferredCards_elt(icard)

# (void) to_json()

JSON Import/Export

Messages for supporting JSON translation.

Return a JSON representing the Diagram.

We want to send only some things not all the JSON the object has. So, we drop some things, like JointJS graph objects.

Use JSON.stringify(json_object) to translate a JSON object to string.

# (void) import_json(json)

TODO: Better programmed it would be if we pass a JSON part to the constructor of each model class. Leaving the responsability of each MyModel class to create itself.

Import all classes and associations from a JSON object.

Make sure to reset() this diagram if you don't want the classes already on this model.

Parameters:

  • json ( JSON object ) a JSON object. Use json = JSON.parse(jsonstr) to retrieve from a string.

# (void) actualizar_graph()

Joint Graph Management


Update a joint.Graph instance with the new cells.

# (boolean) same_elts(diag)

Comparing Diagrams


Two diagram are equivalents if has the same classes and links with the same names and attributes.

Returns:

  • boolean

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: