浏览代码

[doc2] Import Job Designs as linked doc2

Jenny Kim 9 年之前
父节点
当前提交
7e47c50
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 10 0
      desktop/core/src/desktop/api2.py
  2. 2 0
      desktop/core/src/desktop/models.py

+ 10 - 0
desktop/core/src/desktop/api2.py

@@ -452,6 +452,7 @@ def _convert_documents(user):
   Given a user, converts any existing Document objects to Document2 objects
   """
   from beeswax.models import HQL, IMPALA, RDBMS
+  from oozie.models import Workflow
   from pig.models import PigScript
 
   # If user does not have a home directory, we need to create one and import any orphan documents to it
@@ -492,6 +493,15 @@ def _convert_documents(user):
       doc2 = create_doc2(doc, name=data['name'], doctype=data['type'], description=data['description'], data=notebook.get_json())
       imported_docs.append(doc2)
 
+  # Convert Workflow documents
+  docs = get_unconverted_docs(Workflow)
+  for doc in docs:
+    if doc.content_object:
+      data = doc.content_object.data_dict
+      data.update({'content_type': doc.content_type.model, 'object_id': doc.object_id})
+      doc2 = create_doc2(doc, name=doc.name, doctype='link-workflow', description=doc.description, data=json.dumps(data))
+      imported_docs.append(doc2)
+
   # Convert PigScript documents
   docs = get_unconverted_docs(PigScript)
   for doc in docs:

+ 2 - 0
desktop/core/src/desktop/models.py

@@ -977,6 +977,8 @@ class Document2(models.Model):
       return reverse('search:index') + '?collection=' + str(self.id)
     elif self.type == 'link-pigscript':
       return reverse('pig:index') + '#edit/%s' % self.data_dict.get('object_id', '')
+    elif self.type == 'link-workflow':
+      return '/jobsub/#edit-design/%s' % self.data_dict.get('object_id', '')
     else:
       return reverse('oozie:edit_workflow') + '?workflow=' + str(self.id)