def _resolve_and_save_trigger(self, entity_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id): actual_id, unsaved_id = self._resolve(EntityType.trigger, entity_id, entity_map, actual_entities_by_unsaved_id) if actual_id: return actual_id node_id = self._node_id(EntityType.trigger, unsaved_id) trigger = Trigger.from_dict(entity_map['unsaved_entities'][node_id]) assert isinstance(trigger, Trigger) if trigger.data.args and trigger.data.args.get('completed_workflow_id'): trigger.data.args['completed_workflow_id'] = self._resolve_and_save_workflow(trigger.data.args['completed_workflow_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.args and trigger.data.args.get('event_id'): trigger.data.args['event_id'] = self._resolve_and_save_event(trigger.data.args['event_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.args and trigger.data.args.get('subscription_id'): trigger.data.args['subscription_id'] = self._resolve_and_save_subscription(trigger.data.args['subscription_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.workflow_ids: wf_ids = set() for wf_id in trigger.data.workflow_ids: wf_ids.add(self._resolve_and_save_workflow(wf_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id)) trigger.data.workflow_ids = list(wf_ids) if trigger.data.args.get('completed_trigger_ids'): t_ids = set() for t_id in trigger.data.args['completed_trigger_ids']: t_ids.add(self._resolve_and_save_trigger(t_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id)) trigger.data.args['completed_trigger_ids'] = list(t_ids) trigger = self._trigger_service.save_trigger(trigger, commit_and_initialize=False, flush=True) actual_entities_by_node_id[node_id] = trigger actual_entities_by_unsaved_id[unsaved_id] = trigger return trigger.id
def post_trigger(): trigger = Trigger.from_dict(request.get_json()) return { 'results': trigger_service().save_trigger(trigger=trigger, user_id=current_user.email).to_dict() }
def _resolve_and_save_trigger(self, entity_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id): actual_id, unsaved_id = self._resolve(EntityType.trigger, entity_id, entity_map, actual_entities_by_unsaved_id) if actual_id: return actual_id node_id = self._node_id(EntityType.trigger, unsaved_id) trigger = Trigger.from_dict(entity_map['unsaved_entities'][node_id]) assert isinstance(trigger, Trigger) if trigger.data.args and trigger.data.args.get('completed_workflow_id'): trigger.data.args['completed_workflow_id'] = self._resolve_and_save_workflow(trigger.data.args['completed_workflow_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.args and trigger.data.args.get('event_id'): trigger.data.args['event_id'] = self._resolve_and_save_event(trigger.data.args['event_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.args and trigger.data.args.get('subscription_id'): trigger.data.args['subscription_id'] = self._resolve_and_save_subscription(trigger.data.args['subscription_id'], entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) if trigger.data.workflow_ids: wf_ids = set() for wf_id in trigger.data.workflow_ids: wf_ids.add(self._resolve_and_save_workflow(wf_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id)) trigger.data.workflow_ids = list(wf_ids) if trigger.data.args.get('completed_trigger_ids'): t_ids = set() for t_id in trigger.data.args['completed_trigger_ids']: t_ids.add(self._resolve_and_save_trigger(t_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id)) trigger.data.args['completed_trigger_ids'] = list(t_ids) trigger = self._trigger_service.save_trigger(trigger, commit_and_initialize=False, flush=True) actual_entities_by_node_id[node_id] = trigger actual_entities_by_unsaved_id[unsaved_id] = trigger return trigger.id
def patch_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ p = JsonPatch(request.get_json()) return update_trigger(trigger, Trigger.from_dict(p.apply(trigger.to_dict())))
def put_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ return update_trigger(trigger, Trigger.from_dict(request.get_json()))
def post_trigger(): trigger = Trigger.from_dict(request.get_json()) return {'results': trigger_service().save_trigger(trigger).to_dict()}
def patch_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ p = JsonPatch(request.get_json()) return update_trigger(trigger, Trigger.from_dict(p.apply(trigger.to_dict())))
def put_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ return update_trigger(trigger, Trigger.from_dict(request.get_json()))
def post_trigger(): trigger = Trigger.from_dict(request.get_json()) return {'results': trigger_service().save_trigger(trigger=trigger, user_id=current_user.email).to_dict()}
def put_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ updated_trigger = Trigger.from_dict(request.get_json()) trigger = trigger_service().update_trigger_state( trigger, updated_trigger.data.state) return {'results': trigger.to_dict()}
def put_trigger(trigger): """ :type trigger: dart.model.trigger.Trigger """ updated_trigger = Trigger.from_dict(request.get_json()) trigger = trigger_service().update_trigger_state(trigger, updated_trigger.data.state) return {'results': trigger.to_dict()}
def post_trigger(): trigger = Trigger.from_dict(request.get_json()) return {'results': trigger_service().save_trigger(trigger).to_dict()}