def _workflow(request, workflow): response = {'status': -1, 'data': 'None'} workflow_dict = model_to_dict(workflow) node_list = [node.get_full_node() for node in workflow.node_list] nodes = [model_to_dict(node) for node in node_list] for index in range(0, len(node_list)): nodes[index]['child_links'] = [model_to_dict(link) for link in node_list[index].get_all_children_links()] workflow_dict['nodes'] = nodes response['status'] = 0 response['data'] = workflow_dict return HttpResponse(json.dumps(response), mimetype="application/json")
def workflow_jobsub_actions(request, workflow): if request.method not in ['GET', 'POST']: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET or POST request.'), error_code=405) available_actions = OozieDesign.objects.all() if request.method == 'POST': form = ImportJobsubDesignForm(data=request.POST, choices=[(action.id, action.name) for action in available_actions]) if form.is_valid(): try: design = OozieDesign.objects.get(id=form.cleaned_data['jobsub_id']) action = convert_jobsub_design(design) action.workflow = workflow response = { 'status': 0, 'data': { 'node': model_to_dict(action) } } response['data']['node']['child_links'] = [] return HttpResponse(json.dumps(response), mimetype="application/json") except OozieDesign.DoesNotExist, e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Job Designer design does not exist.'), data={'exception': str(e)}, error_code=400) except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Could not convert Job Designer design.'), data={'exception': str(e)}, error_code=400) except Exception, e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'exception': str(e)}, error_code=400)
def workflows(request): if request.method not in ['GET']: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) if request.GET.get('managed', 'false').lower() == 'false': extra = 'jobsub' else: extra = '' workflow_docs = Document.objects.get_docs(request.user, Workflow, extra=extra) response = { 'status': 0, 'data': { 'workflows': [ model_to_dict(workflow.content_object) for workflow in workflow_docs ] } } return HttpResponse(json.dumps(response), mimetype="application/json")
def workflow_actions(request, workflow): if request.method != "GET": raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_("Must be GET request."), error_code=405) action_list = [action.get_full_node() for action in workflow.actions] response = {"status": 0, "data": {"actions": [model_to_dict(action) for action in action_list]}} return JsonResponse(response)
def _workflow(request, workflow): response = {"status": -1, "data": "None"} workflow_dict = model_to_dict(workflow) node_list = [node.get_full_node() for node in workflow.node_list] nodes = [model_to_dict(node) for node in node_list] for index in range(0, len(node_list)): nodes[index]["child_links"] = [model_to_dict(link) for link in node_list[index].get_all_children_links()] workflow_dict["nodes"] = nodes response["status"] = 0 response["data"] = workflow_dict return JsonResponse(response)
def get_design(request, design_id): workflow = _get_design(design_id) node = workflow.start.get_child('to') node_dict = model_to_dict(node) node_dict['id'] = design_id node_dict['is_shared'] = workflow.is_shared node_dict['editable'] = workflow.owner.id == request.user.id node_dict['parameters'] = workflow.parameters return render_json(node_dict, js_safe=True);
def get_design(request, design_id): workflow = _get_design(design_id) node = workflow.start.get_child("to") node_dict = model_to_dict(node) node_dict["id"] = design_id node_dict["is_shared"] = workflow.is_shared node_dict["editable"] = workflow.owner.id == request.user.id node_dict["parameters"] = workflow.parameters return render_json(node_dict, js_safe=True)
def get_design(request, design_id): workflow = _get_design(design_id) node = workflow.start.get_child('to') node_dict = model_to_dict(node) node_dict['id'] = design_id node_dict['is_shared'] = workflow.is_shared node_dict['editable'] = workflow.owner.id == request.user.id node_dict['parameters'] = workflow.parameters return render_json(node_dict, js_safe=True)
def get_design(request, design_id): workflow = _get_design(design_id) node = workflow.start.get_child('to') node_dict = model_to_dict(node) node_dict['id'] = design_id for key in node_dict: if key not in JSON_FIELDS: if key not in SKIP_ESCAPE: node_dict[key] = escapejs(node_dict[key]) node_dict['editable'] = workflow.owner.id == request.user.id return render_json(node_dict);
def get_design(request, design_id): workflow = _get_design(design_id) _check_permission(request, workflow.owner.username, _("Access denied: edit design %(id)s.") % {"id": design_id}) node = workflow.start.get_child("to") node_dict = model_to_dict(node) node_dict["id"] = design_id for key in node_dict: if key not in JSON_FIELDS: node_dict[key] = escapejs(node_dict[key]) node_dict["editable"] = True return render_json(node_dict)
def workflow_actions(request, workflow): if request.method != 'GET': raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) action_list = [action.get_full_node() for action in workflow.actions] response = { 'status': 0, 'data': { 'actions': [model_to_dict(action) for action in action_list] } } return HttpResponse(json.dumps(response), mimetype="application/json")
def workflow_actions(request, workflow): if request.method != 'GET': raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) action_list = [action.get_full_node() for action in workflow.actions] response = { 'status': 0, 'data': { 'actions': [model_to_dict(action) for action in action_list] } } return JsonResponse(response)
def workflows(request): if request.method not in ['GET']: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) workflows = request.GET.get('managed', 'false').lower() == 'true' and Workflow.objects.managed() or Workflow.objects.unmanaged() workflows_accessible = filter(lambda x: Job.objects.can_read(request.user, x.id), workflows) response = { 'status': 0, 'data': { 'workflows': [model_to_dict(workflow) for workflow in workflows_accessible] } } return HttpResponse(json.dumps(response), mimetype="application/json")
def workflows(request): if request.method not in ["GET"]: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_("Must be GET request."), error_code=405) if request.GET.get("managed", "false").lower() == "false": extra = "jobsub" else: extra = "" workflow_docs = Document.objects.get_docs(request.user, Workflow, extra=extra) response = { "status": 0, "data": {"workflows": [model_to_dict(workflow.content_object) for workflow in workflow_docs]}, } return JsonResponse(response)
def workflows(request): if request.method not in ['GET']: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) workflows = request.GET.get('managed', 'false').lower( ) == 'true' and Workflow.objects.managed() or Workflow.objects.unmanaged() workflows_accessible = filter( lambda x: Job.objects.can_read(request.user, x.id), workflows) response = { 'status': 0, 'data': { 'workflows': [model_to_dict(workflow) for workflow in workflows_accessible] } } return HttpResponse(json.dumps(response), mimetype="application/json")
def workflows(request): if request.method not in ['GET']: raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET request.'), error_code=405) if request.GET.get('managed', 'false').lower() == 'false': extra='jobsub' else: extra='' workflow_docs = Document.objects.get_docs(request.user, Workflow, extra=extra) response = { 'status': 0, 'data': { 'workflows': [model_to_dict(workflow.content_object) for workflow in workflow_docs] } } return HttpResponse(json.dumps(response), mimetype="application/json")
def workflow_jobsub_actions(request, workflow): if request.method not in ["GET", "POST"]: raise StructuredException( code="METHOD_NOT_ALLOWED_ERROR", message=_("Must be GET or POST request."), error_code=405 ) available_actions = OozieDesign.objects.all() if request.method == "POST": form = ImportJobsubDesignForm( data=request.POST, choices=[(action.id, action.name) for action in available_actions] ) if form.is_valid(): try: design = OozieDesign.objects.get(id=form.cleaned_data["jobsub_id"]) action = convert_jobsub_design(design) action.workflow = workflow response = {"status": 0, "data": {"node": model_to_dict(action)}} response["data"]["node"]["child_links"] = [] return HttpResponse(json.dumps(response), mimetype="application/json") except OozieDesign.DoesNotExist, e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Job Designer design does not exist."), data={"exception": str(e)}, error_code=400, ) except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Could not convert Job Designer design."), data={"exception": str(e)}, error_code=400, ) except Exception, e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Error importing node from Job Designer"), data={"exception": str(e)}, error_code=400, )
message=_("Job Designer design does not exist."), data={"exception": str(e)}, error_code=400, ) except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Could not convert Job Designer design."), data={"exception": str(e)}, error_code=400, ) except Exception, e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Error importing node from Job Designer"), data={"exception": str(e)}, error_code=400, ) else: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_("Error importing node from Job Designer"), data={"errors": form.errors}, error_code=400, ) else: available_actions = OozieDesign.objects.all() response = {"status": 0, "data": {"nodes": [model_to_dict(action) for action in available_actions]}} return HttpResponse(json.dumps(response), mimetype="application/json")
message=_('Could not convert Job Designer design.'), data={'exception': str(e)}, error_code=400) except Exception, e: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'exception': str(e)}, error_code=400) else: raise StructuredException( code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'errors': form.errors}, error_code=400) else: available_actions = OozieDesign.objects.all() response = { 'status': 0, 'data': { 'nodes': [model_to_dict(action) for action in available_actions] } } return HttpResponse(json.dumps(response), mimetype="application/json") def autocomplete_properties(request): return HttpResponse(_STD_PROPERTIES_JSON, mimetype="application/json")
action = convert_jobsub_design(design) action.workflow = workflow response = { 'status': 0, 'data': { 'node': model_to_dict(action) } } response['data']['node']['child_links'] = [] return HttpResponse(json.dumps(response), mimetype="application/json") except OozieDesign.DoesNotExist, e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Job Designer design does not exist.'), data={'exception': str(e)}, error_code=400) except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Could not convert Job Designer design.'), data={'exception': str(e)}, error_code=400) except Exception, e: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'exception': str(e)}, error_code=400) else: raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'errors': form.errors}, error_code=400) else: available_actions = OozieDesign.objects.all() response = { 'status': 0, 'data': { 'nodes': [model_to_dict(action) for action in available_actions] } } return HttpResponse(json.dumps(response), mimetype="application/json")