示例#1
0
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")
示例#2
0
文件: api.py 项目: jiesicheng/hue
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")
示例#3
0
文件: api.py 项目: jiesicheng/hue
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)
示例#4
0
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)
示例#5
0
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")
示例#6
0
文件: api.py 项目: FashtimeDotCom/hue
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)
示例#7
0
文件: api.py 项目: FashtimeDotCom/hue
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)
示例#8
0
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);
示例#9
0
文件: views.py 项目: jackerxff/hue
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)
示例#10
0
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)
示例#11
0
文件: views.py 项目: dizhu/hue
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);
示例#12
0
文件: views.py 项目: joey/hue
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)
示例#13
0
文件: api.py 项目: Web5design/hue
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")
示例#14
0
文件: api.py 项目: sandredd/hue-1
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)
示例#15
0
文件: api.py 项目: bugcy013/hue
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")
示例#16
0
文件: api.py 项目: FashtimeDotCom/hue
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)
示例#17
0
文件: api.py 项目: ymc/hue
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")
示例#18
0
文件: api.py 项目: Web5design/hue
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")
示例#19
0
文件: api.py 项目: zwqjsj0404/hue
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,
                )
示例#20
0
文件: api.py 项目: zwqjsj0404/hue
                    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")
示例#21
0
                    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")
示例#22
0
文件: api.py 项目: jiesicheng/hue
        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")