Skip to content

Commit

Permalink
work on issueType to have only one
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Jul 25, 2024
1 parent c065ea4 commit b6d6d64
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ JPMetamodelGenerator >> defineRelations [
super defineRelations.
(issue property: #components) -* (component property: #issue).
(issue property: #worklogs) -* (worklog property: #issue).
(issue property: #type) - (issueType property: #issue)
(issue property: #type) *- (issueType property: #issues)
]
18 changes: 9 additions & 9 deletions src/JiraPharoAPI-Model/JPIssue.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| Relation | Origin | Opposite | Type | Comment |
|---|
| `components` | `JPIssue` | `issue` | `JPComponent` | |
| `type` | `JPIssue` | `issue` | `JPIssueType` | |
| `type` | `JPIssue` | `issues` | `JPIssueType` | |
| `worklogs` | `JPIssue` | `issue` | `JPWorklog` | |
Expand All @@ -28,16 +28,16 @@ Class {
#name : #JPIssue,
#superclass : #JPEntity,
#instVars : [
'#components => FMMany type: #JPComponent opposite: #issue',
'#created => FMProperty',
'#description => FMProperty',
'#summary => FMProperty',
'#key => FMProperty',
'#id => FMProperty',
'#created => FMProperty',
'#timespent => FMProperty',
'#key => FMProperty',
'#labels => FMProperty',
'#components => FMMany type: #JPComponent opposite: #issue',
'#worklogs => FMMany type: #JPWorklog opposite: #issue',
'#type => FMOne type: #JPIssueType opposite: #issue'
'#summary => FMProperty',
'#timespent => FMProperty',
'#type => FMOne type: #JPIssueType opposite: #issues',
'#worklogs => FMMany type: #JPWorklog opposite: #issue'
],
#category : #'JiraPharoAPI-Model-Entities'
}
Expand Down Expand Up @@ -179,7 +179,7 @@ JPIssue >> timespent: anObject [

{ #category : #accessing }
JPIssue >> type [
"Relation named: #type type: #JPIssueType opposite: #issue"
"Relation named: #type type: #JPIssueType opposite: #issues"

<generated>
^ type
Expand Down
26 changes: 16 additions & 10 deletions src/JiraPharoAPI-Model/JPIssueType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `issue` | `JPIssueType` | `type` | `JPIssue` | |
| `issues` | `JPIssueType` | `type` | `JPIssue` | |
## Properties
Expand All @@ -25,13 +25,13 @@ Class {
#name : #JPIssueType,
#superclass : #JPEntity,
#instVars : [
'#id => FMProperty',
'#avatarId => FMProperty',
'#description => FMProperty',
'#iconUrl => FMProperty',
'#id => FMProperty',
'#issues => FMMany type: #JPIssue opposite: #type',
'#name => FMProperty',
'#subtask => FMProperty',
'#avatarId => FMProperty',
'#issue => FMOne type: #JPIssue opposite: #type'
'#subtask => FMProperty'
],
#category : #'JiraPharoAPI-Model-Entities'
}
Expand All @@ -52,6 +52,12 @@ JPIssueType >> = aJPIssueType [
^ aJPIssueType id = self id
]

{ #category : #adding }
JPIssueType >> addIssue: anObject [
<generated>
^ self issues add: anObject
]

{ #category : #accessing }
JPIssueType >> avatarId [

Expand Down Expand Up @@ -116,19 +122,19 @@ JPIssueType >> id: anObject [
]

{ #category : #accessing }
JPIssueType >> issue [
"Relation named: #issue type: #JPIssue opposite: #type"
JPIssueType >> issues [
"Relation named: #issues type: #JPIssue opposite: #type"

<generated>
<derived>
^ issue
^ issues
]

{ #category : #accessing }
JPIssueType >> issue: anObject [
JPIssueType >> issues: anObject [

<generated>
issue := anObject
issues value: anObject
]

{ #category : #accessing }
Expand Down
9 changes: 7 additions & 2 deletions src/JiraPharoAPI-Tests/JiraPharoImporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ JiraPharoImporterTest >> testLoadIssues [
{ #category : #tests }
JiraPharoImporterTest >> testLoadIssuesWithSameType [

| issueA issueB issueTypeA issueTypeB |
| issueA issueB issueTypeA issueTypeB selectedIssueBySet |
issueTypeA := JPIssueType new
id: 125;
name: 'sub-task';
Expand All @@ -53,7 +53,12 @@ JiraPharoImporterTest >> testLoadIssuesWithSameType [
jpImporter loadIssues: {
issueA.
issueB }.
self assert: model size equals: 3
self assert: model size equals: 3.
"This is necessary because we do not know excalty the type that will be selected since they are the same"
selectedIssueBySet := issueA type.
self assert: issueA type identicalTo: selectedIssueBySet.
self assert: issueB type identicalTo: selectedIssueBySet.
self assert: selectedIssueBySet issues size equals: 2
]

{ #category : #tests }
Expand Down
16 changes: 12 additions & 4 deletions src/JiraPharoAPI/JiraPharoImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ JiraPharoImporter >> importAllIssuesOf: aUsername [
{ #category : #'api - import' }
JiraPharoImporter >> loadIssues: issues [

| issuesToLoad |
| issuesToLoad issueTypeToLoad |
issuesToLoad := issues reject: [ :issueProposedForImmport |
(self model allWithType: JPIssue) anySatisfy: [
:issue | issue id = issueProposedForImmport id ] ].
self model addAll: issuesToLoad.
self model addAll:
issuesToLoad iterator | [ :issue | issue type ] collectIt
| [ :issueType | issueType isNil ] rejectIt > Set
issueTypeToLoad := issuesToLoad iterator
| [ :issue | issue type ] collectIt
| [ :issueType | issueType isNil ] rejectIt
|
[ :issueType | self model includes: issueType ]
rejectIt > Set.
issuesToLoad do: [ :issue |
issueTypeToLoad
detect: [ :ty | ty = issue type ]
ifOne: [ :ty | issue type: ty ] ].
self model addAll: issueTypeToLoad
]

{ #category : #accessing }
Expand Down

0 comments on commit b6d6d64

Please sign in to comment.