|
@@ -27,7 +27,7 @@ from django.contrib.contenttypes import generic
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
|
|
from django.core.urlresolvers import reverse
|
|
from django.core.urlresolvers import reverse
|
|
|
-from django.db import models
|
|
|
|
|
|
|
+from django.db import models, transaction
|
|
|
from django.db.models import Q
|
|
from django.db.models import Q
|
|
|
from django.utils.translation import ugettext as _, ugettext_lazy as _t
|
|
from django.utils.translation import ugettext as _, ugettext_lazy as _t
|
|
|
|
|
|
|
@@ -262,63 +262,66 @@ class DocumentManager(models.Manager):
|
|
|
def sync(self):
|
|
def sync(self):
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
- from oozie.models import Workflow, Coordinator, Bundle
|
|
|
|
|
-
|
|
|
|
|
- for job in list(chain(Workflow.objects.all(), Coordinator.objects.all(), Bundle.objects.all())):
|
|
|
|
|
- if job.doc.count() > 1:
|
|
|
|
|
- LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
- job.doc.all().delete()
|
|
|
|
|
-
|
|
|
|
|
- if not job.doc.exists():
|
|
|
|
|
- doc = Document.objects.link(job, owner=job.owner, name=job.name, description=job.description)
|
|
|
|
|
- tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
- doc.tags.add(tag)
|
|
|
|
|
- if job.is_trashed:
|
|
|
|
|
- doc.send_to_trash()
|
|
|
|
|
- if job.is_shared:
|
|
|
|
|
- doc.share_to_default()
|
|
|
|
|
- if hasattr(job, 'managed'):
|
|
|
|
|
- if not job.managed:
|
|
|
|
|
- doc.extra = 'jobsub'
|
|
|
|
|
- doc.save()
|
|
|
|
|
- if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
- job.doc.get().share_to_default()
|
|
|
|
|
|
|
+ with transaction.atomic():
|
|
|
|
|
+ from oozie.models import Workflow, Coordinator, Bundle
|
|
|
|
|
+
|
|
|
|
|
+ for job in list(chain(Workflow.objects.all(), Coordinator.objects.all(), Bundle.objects.all())):
|
|
|
|
|
+ if job.doc.count() > 1:
|
|
|
|
|
+ LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
+ job.doc.all().delete()
|
|
|
|
|
+
|
|
|
|
|
+ if not job.doc.exists():
|
|
|
|
|
+ doc = Document.objects.link(job, owner=job.owner, name=job.name, description=job.description)
|
|
|
|
|
+ tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
+ doc.tags.add(tag)
|
|
|
|
|
+ if job.is_trashed:
|
|
|
|
|
+ doc.send_to_trash()
|
|
|
|
|
+ if job.is_shared:
|
|
|
|
|
+ doc.share_to_default()
|
|
|
|
|
+ if hasattr(job, 'managed'):
|
|
|
|
|
+ if not job.managed:
|
|
|
|
|
+ doc.extra = 'jobsub'
|
|
|
|
|
+ doc.save()
|
|
|
|
|
+ if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
+ job.doc.get().share_to_default()
|
|
|
except Exception, e:
|
|
except Exception, e:
|
|
|
LOG.warn(force_unicode(e))
|
|
LOG.warn(force_unicode(e))
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
- from beeswax.models import SavedQuery
|
|
|
|
|
-
|
|
|
|
|
- for job in SavedQuery.objects.all():
|
|
|
|
|
- if job.doc.count() > 1:
|
|
|
|
|
- LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
- job.doc.all().delete()
|
|
|
|
|
-
|
|
|
|
|
- if not job.doc.exists():
|
|
|
|
|
- doc = Document.objects.link(job, owner=job.owner, name=job.name, description=job.desc, extra=job.type)
|
|
|
|
|
- tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
- doc.tags.add(tag)
|
|
|
|
|
- if job.is_trashed:
|
|
|
|
|
- doc.send_to_trash()
|
|
|
|
|
- if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
- job.doc.get().share_to_default()
|
|
|
|
|
|
|
+ with transaction.atomic():
|
|
|
|
|
+ from beeswax.models import SavedQuery
|
|
|
|
|
+
|
|
|
|
|
+ for job in SavedQuery.objects.all():
|
|
|
|
|
+ if job.doc.count() > 1:
|
|
|
|
|
+ LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
+ job.doc.all().delete()
|
|
|
|
|
+
|
|
|
|
|
+ if not job.doc.exists():
|
|
|
|
|
+ doc = Document.objects.link(job, owner=job.owner, name=job.name, description=job.desc, extra=job.type)
|
|
|
|
|
+ tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
+ doc.tags.add(tag)
|
|
|
|
|
+ if job.is_trashed:
|
|
|
|
|
+ doc.send_to_trash()
|
|
|
|
|
+ if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
+ job.doc.get().share_to_default()
|
|
|
except Exception, e:
|
|
except Exception, e:
|
|
|
LOG.warn(force_unicode(e))
|
|
LOG.warn(force_unicode(e))
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
- from pig.models import PigScript
|
|
|
|
|
-
|
|
|
|
|
- for job in PigScript.objects.all():
|
|
|
|
|
- if job.doc.count() > 1:
|
|
|
|
|
- LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
- job.doc.all().delete()
|
|
|
|
|
-
|
|
|
|
|
- if not job.doc.exists():
|
|
|
|
|
- doc = Document.objects.link(job, owner=job.owner, name=job.dict['name'], description='')
|
|
|
|
|
- tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
- doc.tags.add(tag)
|
|
|
|
|
- if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
- job.doc.get().share_to_default()
|
|
|
|
|
|
|
+ with transaction.atomic():
|
|
|
|
|
+ from pig.models import PigScript
|
|
|
|
|
+
|
|
|
|
|
+ for job in PigScript.objects.all():
|
|
|
|
|
+ if job.doc.count() > 1:
|
|
|
|
|
+ LOG.warn('Deleting duplicate document %s for %s' % (job.doc.all(), job))
|
|
|
|
|
+ job.doc.all().delete()
|
|
|
|
|
+
|
|
|
|
|
+ if not job.doc.exists():
|
|
|
|
|
+ doc = Document.objects.link(job, owner=job.owner, name=job.dict['name'], description='')
|
|
|
|
|
+ tag = DocumentTag.objects.get_example_tag(user=job.owner)
|
|
|
|
|
+ doc.tags.add(tag)
|
|
|
|
|
+ if job.owner.username == SAMPLE_USERNAME:
|
|
|
|
|
+ job.doc.get().share_to_default()
|
|
|
except Exception, e:
|
|
except Exception, e:
|
|
|
LOG.warn(force_unicode(e))
|
|
LOG.warn(force_unicode(e))
|
|
|
|
|
|