def make_story(self, key, data=None, links=True): return Story(self.server.issue(key, expand='changelog')) if not links: return story transaction.begin() for link in data['fields']['issuelinks']: if link.has_key('outwardIssue'): type = link['type']['name'] key = link['outwardIssue']['key'] if not type in story['links']['out'].keys(): story['links']['out'][type] = Folder() story['links']['out'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s else: if not key in story['links']['out'][type].keys(): s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s elif link.has_key('inwardIssue'): type = link['type']['name'] key = link['inwardIssue']['key'] if not type in story['links']['in'].keys(): story['links']['in'][type] = Folder() story['links']['in'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s else: if not key in story['links']['in'][type].keys(): s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s transaction.commit() return story
def __init__(self): super(Links, self).__init__() self['out'] = Folder() self['in'] = Folder() self['out'].key = 'out' self['in'].key = 'in'
def pull_issues(self, boards, links, time_range, all_issues, add_only, issue_types): import pdb; pdb.set_trace() store = self.cache.data['issues'] if all_issues: issues = self.server.search_issues('', maxResults=0) print 'Refreshing all issues...' elif time_range: issues = self.server.search_issues('updated > "%s"' % time_range , maxResults=0) print 'Pulled stories from %s previous' % time_range count = len(issues) print 'Importing', len(issues), 'stories...' for issue in issues: if store.has_key(issue.key): if add_only: continue print count, 'Updating:', issue.key transaction.begin() story = store[issue.key] story.initialize(self.server.issue( issue.key, expand='changelog')) transaction.commit() else: print count, 'Adding: ', issue.key story = Story(self.server.issue(issue.key, expand='changelog')) transaction.begin() store[story.key] = story transaction.commit() docid = self.cache.document_map.add( ['jira', 'issues', story.key]) transaction.begin() self.cache.catalog.index_doc(docid, story) transaction.commit() count = count - 1 for link in issue.fields.issuelinks: transaction.begin() if hasattr(link, 'outwardIssue') and link.outwardIssue: type = link.type.name key = link.outwardIssue.key if not type in story['links']['out'].keys(): story['links']['out'][type] = Folder() story['links']['out'][type].key = type transaction.commit() if self.cache.data['issues'].has_key(key): s = self.cache.data['issues'][key] else: transaction.begin() s = Story(self.server.issue(key,expand='changelog')) self.cache.data['issues'][key] = s transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', 'issues', key]) self.cache.catalog.index_doc(docid, s) transaction.commit() if not s: continue story['links']['out'][type][key] = s else: if not key in story['links']['out'][type].keys(): if self.cache.data['issues'].has_key(key): s = self.cache.data['issues'][key] else: transaction.begin() s = Story(self.server.issue(key,expand='changelog')) self.cache.data['issues'][key] = s transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', 'issues', key]) self.cache.catalog.index_doc(docid, s) transaction.commit() if not s: continue story['links']['out'][type][key] = s elif hasattr(link, 'inwardIssue') and link.inwardIssue: type = link.type.name key = link.inwardIssue.key if not type in story['links']['in'].keys(): story['links']['in'][type] = Folder() story['links']['in'][type].key = type transaction.commit() if self.cache.data['issues'].has_key(key): s = self.cache.data['issues'][key] else: transaction.begin() s = Story(self.server.issue(key,expand='changelog')) self.cache.data['issues'][key] = s transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', 'issues', key]) self.cache.catalog.index_doc(docid, s) transaction.commit() if not s: continue story['links']['in'][type][key] = s else: if not key in story['links']['in'][type].keys(): if self.cache.data['issues'].has_key(key): s = self.cache.data['issues'][key] else: transaction.begin() s = Story(self.server.issue(key,expand='changelog')) self.cache.data['issues'][key] = s transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', 'issues', key]) self.cache.catalog.index_doc(docid, s) transaction.commit() if not s: continue story['links']['in'][type][key] = s transaction.commit()
def make_story(self, key, data, links=True): if not data['fields']['fixVersions']: return None transaction.begin() story = Story(key) story.id = int(data['id']) story.history = History(data['changelog']) story.url = data['self'] story.title = data['fields']['summary'] story.fix_versions = PersistentList() for version in data['fields']['fixVersions']: story.fix_versions.append(version['name']) story.fix_version = data['fields']['fixVersions'] story.created = datetime.datetime.fromtimestamp(time.mktime( time.strptime(data['fields']['created'][:23], '%Y-%m-%dT%H:%M:%S.%f'))) story.type = data['fields']['issuetype']['id'] story.assignee = data['fields']['assignee'] story.developer = data['fields']['customfield_13435'] story.rank = data['fields']['customfield_12242'] if 'customfield_10722' in data['fields'] and data['fields'][ 'customfield_10722']: story.root_cause = data['fields']['customfield_10722'][ 'value'].strip() else: story.root_cause = '' if 'customfield_13330' in data['fields'] and data['fields'][ 'customfield_13330']: story.root_cause_details = data['fields']['customfield_13330'] else: story.root_cause_details = '' story.scrum_team = None if data['fields'].has_key('customfield_11261'): if data['fields']['customfield_11261']: story.scrum_team = data['fields']['customfield_11261'][ 'value'].strip() else: story.scrum_team = None story.points = None if data['fields'].has_key('customfield_10792'): story.points = data['fields']['customfield_10792'] if story.points: story.points = int(story.points) story.status = int(data['fields']['status']['id']) story.project = data['fields']['project']['key'] if not story.project in self.cache.data: self.cache.data[story.project] = Project(story.project, data['fields']['project']['name']) project = self.cache.data[story.project] for version in story.fix_versions: if version in project.keys(): if not project[version].has_key(story.key): project[version][story.key] = story else: release = Release() release.version = version release[story.key] = story project[version] = release transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', story.project, story.fix_versions[0], story.key]) self.cache.catalog.index_doc(docid, story) transaction.commit() if not links: return story transaction.begin() for link in data['fields']['issuelinks']: if link.has_key('outwardIssue'): type = link['type']['name'] key = link['outwardIssue']['key'] if not type in story['links']['out'].keys(): story['links']['out'][type] = Folder() story['links']['out'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s else: if not key in story['links']['out'][type].keys(): s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s elif link.has_key('inwardIssue'): type = link['type']['name'] key = link['inwardIssue']['key'] if not type in story['links']['in'].keys(): story['links']['in'][type] = Folder() story['links']['in'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s else: if not key in story['links']['in'][type].keys(): s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s transaction.commit() return story