Class: ORMDiagram

Defined in: web-src/coffee/model/orm/ormdiagram.coffee
Inherits: model.Diagram

Overview

An ER 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) get_clases()

# (void) get_clase(nombre)

# (void) find_class_by_name(name)

# (void) find_class_by_classid(classid)

# (?) 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:

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

# (void) add_generalization(class_parent, class_childs, disjoint = false, covering = 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.

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

Parameters:

  • class_parent ( string, object ) The parent class Id string or the class_parent Class 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)

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 instance ) A Class object.
  • class_child ( Class instance ) A Class object.

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

Parameters:

  • class_a_id ( string ) the ID of the first class.
  • class_b_id ( string ) the ID of the second class.
  • name ( string ) optional. The name of the association.
  • mult ( array ) optional. An array of two strings with the cardinality from class a and to class b.
  • roles ( array ) optional. An array of two strings with the from and to roles.

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

# (?) add_class(hash_data)

Hash Data

  • name (mandatory)
  • attribs (optional)
  • methods (optional)

Examples:

Adding a class

diagram_instance.add_class({name: "class A"})
diagram_instance.add_class({name: "class B", ["attrib1", "attrib2"], ["method1", "method2"]})

Parameters:

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

Returns:

  • ( ? ) — The new class

See also:

# (void) agregar_clase(clase)

# (void) delete_class(c)

Parameters:

  • c ( Class 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) rename_class(classid, name)

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) 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)

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) actualizar_graph()

Update a joint.Graph instance with the new cells.

# (void) to_json()

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.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: