def add_transitions_from_selected_state_to_parent():
    """ Generates the default success transition of a state to its parent success port

    :return:
    """
    task_string = "create transition"
    sub_task_string = "to parent state"

    selected_state_m, msg = get_selected_single_state_model_and_check_for_its_parent()
    if selected_state_m is None:
        logger.warning("Can not {0} {1}: {2}".format(task_string, sub_task_string, msg))
        return
    logger.debug("Check to {0} {1} ...".format(task_string, sub_task_string))
    state = selected_state_m.state
    parent_state = state.parent

    # find all possible from outcomes
    from_outcomes = get_all_outcomes_except_of_abort_and_preempt(state)

    # find lowest valid outcome id
    possible_oc_ids = [oc_id for oc_id in state.parent.outcomes.keys() if oc_id >= 0]
    possible_oc_ids.sort()
    to_outcome = state.parent.outcomes[possible_oc_ids[0]]

    oc_connected_to_parent = [oc for oc in from_outcomes if is_outcome_connect_to_state(oc, parent_state.state_id)]
    oc_not_connected = [oc for oc in from_outcomes if not state.parent.get_transition_for_outcome(state, oc)]
    if all(oc in oc_connected_to_parent for oc in from_outcomes):
        logger.info("Remove transition {0} because all outcomes are connected to it.".format(sub_task_string))
        for from_outcome in oc_connected_to_parent:
            transition = parent_state.get_transition_for_outcome(state, from_outcome)
            parent_state.remove(transition)
    elif oc_not_connected:
        logger.debug("Create transition {0} ... ".format(sub_task_string))
        for from_outcome in from_outcomes:
            parent_state.add_transition(state.state_id, from_outcome.outcome_id,
                                        parent_state.state_id, to_outcome.outcome_id)
    else:
        if remove_transitions_if_target_is_the_same(from_outcomes):
            logger.info("Removed transitions origin from outcomes of selected state {0}"
                        "because all point to the same target.".format(sub_task_string))
            return add_transitions_from_selected_state_to_parent()
        logger.info("Will not create transition {0}: Not clear situation of connected transitions."
                    "There will be no transitions to other states be touched.".format(sub_task_string))

    return True
def add_transitions_from_selected_state_to_parent ( ) : task_string = "create transition" sub_task_string = "to parent state" selected_state_m , msg = get_selected_single_state_model_and_check_for_its_parent ( ) if selected_state_m is None : logger . warning ( "Can not {0} {1}: {2}" . format ( task_string , sub_task_string , msg ) ) return logger . debug ( "Check to {0} {1} ..." . format ( task_string , sub_task_string ) ) state = selected_state_m . state parent_state = state . parent from_outcomes = get_all_outcomes_except_of_abort_and_preempt ( state ) possible_oc_ids = [ oc_id for oc_id in state . parent . outcomes . keys ( ) if oc_id >= 0 ] possible_oc_ids . sort ( ) to_outcome = state . parent . outcomes [ possible_oc_ids [ 0 ] ] oc_connected_to_parent = [ oc for oc in from_outcomes if is_outcome_connect_to_state ( oc , parent_state . state_id ) ] oc_not_connected = [ oc for oc in from_outcomes if not state . parent . get_transition_for_outcome ( state , oc ) ] if all ( oc in oc_connected_to_parent for oc in from_outcomes ) : logger . info ( "Remove transition {0} because all outcomes are connected to it." . format ( sub_task_string ) ) for from_outcome in oc_connected_to_parent : transition = parent_state . get_transition_for_outcome ( state , from_outcome ) parent_state . remove ( transition ) elif oc_not_connected : logger . debug ( "Create transition {0} ... " . format ( sub_task_string ) ) for from_outcome in from_outcomes : parent_state . add_transition ( state . state_id , from_outcome . outcome_id , parent_state . state_id , to_outcome . outcome_id ) else : if remove_transitions_if_target_is_the_same ( from_outcomes ) : logger . info ( "Removed transitions origin from outcomes of selected state {0}" "because all point to the same target." . format ( sub_task_string ) ) return add_transitions_from_selected_state_to_parent ( ) logger . info ( "Will not create transition {0}: Not clear situation of connected transitions." "There will be no transitions to other states be touched." . format ( sub_task_string ) ) return True
Generates the default success transition of a state to its parent success port

    :return: