def add_dimension(dimension,**kwargs):
    """
        Add the dimension defined into the object "dimension" to the DB
        If dimension["project_id"] is None it means that the dimension is global, otherwise is property of a project
        If the dimension exists emits an exception
    """
    if numpy.isscalar(dimension):
        # If it is a scalar, converts to an Object
        dimension = {'name': dimension}

    new_dimension = Dimension()
    new_dimension.name = dimension["name"]

    if "description" in dimension and dimension["description"] is not None:
        new_dimension.description = dimension["description"]
    if "project_id" in dimension and dimension["project_id"] is not None:
        new_dimension.project_id = dimension["project_id"]

    # Save on DB
    db.DBSession.add(new_dimension)
    db.DBSession.flush()

    # Load all the record
    db_dimension = db.DBSession.query(Dimension).filter(Dimension.id==new_dimension.id).one()

    return JSONObject(db_dimension)