Skip to content

Commit 4bd4619

Browse files
authored
Feature/add group support (#25)
* move JiraProject to common api; add urls to JiraProject * add Group,Project,Status,Version,Confluence attribute support to InsightObjectOperator * convert test to getOrNull * add tests for Status, Project, Version * udpate testresources for Group, Status, Project, Version * fix project attribute URLs * rename remote debugging profiles * add full support for project versions
1 parent f4a792f commit 4bd4619

File tree

24 files changed

+732
-111
lines changed

24 files changed

+732
-111
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2024 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class ConfluencePage(
25+
@field:NotNull val id: Int, // pageId
26+
@field:NotNull val title: String,
27+
@field:NotNull val url: String,
28+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2024 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class JiraGroup(
25+
@field:NotNull val name: String,
26+
@field:NotNull val avatarUrl: String? = null,
27+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2024 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class JiraProject(
25+
@field:NotNull val id: Long,
26+
@field:NotNull val key: String,
27+
@field:NotNull val name: String,
28+
val url: String, // links to self or insight, depending on context
29+
val avatarUrl: String? = null, // default size 48*48
30+
)

kotlin-atlassian-client-core-common/src/main/kotlin/com/linkedplanet/kotlinatlassianclientcore/common/api/JiraUser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* kotlin-atlassian-client-core-common
44
* %%
5-
* Copyright (C) 2022 - 2023 linked-planet GmbH
5+
* Copyright (C) 2022 - 2024 linked-planet GmbH
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2024 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class ProjectVersion(
25+
@field:NotNull val id: Int,
26+
@field:NotNull val name: String,
27+
@field:NotNull val avatarUrl: String,
28+
@field:NotNull val url: String,
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2024 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class StatusAttribute(
25+
@field:NotNull val id: Int,
26+
@field:NotNull val name: String,
27+
@field:NotNull val category: StatusCategory,
28+
@field:NotNull val objectSchemaId: Int,
29+
val description: String?,
30+
)
31+
32+
enum class StatusCategory(val category: Int){
33+
INACTIVE(0),
34+
ACTIVE(1),
35+
PENDING(2);
36+
37+
companion object {
38+
private val map = StatusCategory.values().associateBy { it.category }
39+
infix fun from(value: Int): StatusCategory? = map[value]
40+
}
41+
}

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/InsightObjectExtensions.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121

2222
package com.linkedplanet.kotlininsightclient.api.model
2323

24+
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraGroup
25+
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraProject
2426
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraUser
27+
import com.linkedplanet.kotlinatlassianclientcore.common.api.ProjectVersion
28+
import com.linkedplanet.kotlinatlassianclientcore.common.api.StatusAttribute
2529
import java.time.LocalDate
2630
import java.time.ZonedDateTime
2731

@@ -146,6 +150,25 @@ fun InsightObject.getUserList(id: InsightAttributeId): List<JiraUser> =
146150
getAttributeAs<InsightAttribute.User>(id)?.users ?: emptyList()
147151
// endregion user
148152

153+
//region ObjectAttributeValue.Group
154+
fun InsightObject.getGroupList(id: InsightAttributeId): List<JiraGroup> =
155+
getAttributeAs<InsightAttribute.Group>(id)?.groups ?: emptyList()
156+
// endregion user
157+
158+
//region ObjectAttributeValue.Status
159+
fun InsightObject.getStatus(id: InsightAttributeId): StatusAttribute? =
160+
getAttributeAs<InsightAttribute.Status>(id)?.status
161+
// endregion user
162+
163+
//region ObjectAttributeValue.Project
164+
fun InsightObject.getProjectList(id: InsightAttributeId): List<JiraProject> =
165+
getAttributeAs<InsightAttribute.Project>(id)?.projects ?: emptyList()
166+
// endregion user
167+
168+
//region ObjectAttributeValue.Version
169+
fun InsightObject.getVersionList(id: InsightAttributeId): List<ProjectVersion> =
170+
getAttributeAs<InsightAttribute.Version>(id)?.versions ?: emptyList()
171+
// endregion user
149172

150173
// region ObjectAttributeValue.Reference
151174
fun InsightObject.getSingleReferenceValue(id: InsightAttributeId): InsightReference? =

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
package com.linkedplanet.kotlininsightclient.api.model
2121

22+
import com.linkedplanet.kotlinatlassianclientcore.common.api.StatusAttribute
23+
import com.linkedplanet.kotlinatlassianclientcore.common.api.ProjectVersion
24+
import com.linkedplanet.kotlinatlassianclientcore.common.api.ConfluencePage
25+
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraGroup
26+
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraProject
2227
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraUser
2328
import io.swagger.v3.oas.annotations.media.Schema
2429
import java.time.LocalDate
@@ -258,6 +263,7 @@ sealed class InsightAttribute(
258263
data class Confluence(
259264
@get:JvmName("getAttributeId")
260265
@field:NotNull override val attributeId: InsightAttributeId,
266+
@field:NotNull val pages: List<ConfluencePage>,
261267
override val schema: ObjectTypeSchemaAttribute?
262268
) : InsightAttribute(
263269
attributeId,
@@ -273,8 +279,13 @@ sealed class InsightAttribute(
273279
data class Group(
274280
@get:JvmName("getAttributeId")
275281
@field:NotNull override val attributeId: InsightAttributeId,
276-
override val schema: ObjectTypeSchemaAttribute?) :
277-
InsightAttribute(attributeId, schema, AttributeTypeEnum.Group){
282+
@field:NotNull val groups: List<JiraGroup>,
283+
override val schema: ObjectTypeSchemaAttribute?
284+
) : InsightAttribute(
285+
attributeId,
286+
schema,
287+
AttributeTypeEnum.Group
288+
) {
278289
override fun toString() = "Group attributeId=$attributeId"
279290
}
280291

@@ -284,8 +295,10 @@ sealed class InsightAttribute(
284295
data class Version(
285296
@get:JvmName("getAttributeId")
286297
@field:NotNull override val attributeId: InsightAttributeId,
287-
override val schema: ObjectTypeSchemaAttribute?) :
288-
InsightAttribute(attributeId, schema, AttributeTypeEnum.Version){
298+
@field:NotNull val versions: List<ProjectVersion>,
299+
override val schema: ObjectTypeSchemaAttribute?
300+
) :
301+
InsightAttribute(attributeId, schema, AttributeTypeEnum.Version) {
289302
override fun toString() = "Version attributeId=$attributeId"
290303
}
291304

@@ -295,6 +308,7 @@ sealed class InsightAttribute(
295308
data class Project(
296309
@get:JvmName("getAttributeId")
297310
@field:NotNull override val attributeId: InsightAttributeId,
311+
@field:NotNull val projects: List<JiraProject>,
298312
override val schema: ObjectTypeSchemaAttribute?) :
299313
InsightAttribute(attributeId, schema, AttributeTypeEnum.Project){
300314
override fun toString() = "Project attributeId=$attributeId"
@@ -307,8 +321,13 @@ sealed class InsightAttribute(
307321
data class Status(
308322
@get:JvmName("getAttributeId")
309323
@field:NotNull override val attributeId: InsightAttributeId,
310-
override val schema: ObjectTypeSchemaAttribute?) :
311-
InsightAttribute(attributeId, schema, AttributeTypeEnum.Status){
324+
@field:NotNull val status: StatusAttribute?,
325+
override val schema: ObjectTypeSchemaAttribute?
326+
) : InsightAttribute(
327+
attributeId,
328+
schema,
329+
AttributeTypeEnum.Status
330+
) {
312331
override fun toString() = "Status attributeId=$attributeId"
313332
}
314333

@@ -355,6 +374,27 @@ sealed class InsightAttribute(
355374
infix fun InsightAttributeId.toUsers(users: List<JiraUser>) =
356375
User(this, users, schema = null)
357376

377+
infix fun InsightAttributeId.toGroup(group: JiraGroup?) =
378+
Group(this, listOfNotNull(group), schema = null)
379+
380+
infix fun InsightAttributeId.toGroups(groups: List<JiraGroup>) =
381+
Group(this, groups, schema = null)
382+
383+
infix fun InsightAttributeId.toProject(project: JiraProject?) =
384+
Project(this, listOfNotNull(project), schema = null)
385+
386+
infix fun InsightAttributeId.toProjects(projects: List<JiraProject>) =
387+
Project(this, projects, schema = null)
388+
389+
infix fun InsightAttributeId.toStatus(status: StatusAttribute?) =
390+
Status(this, status, schema = null)
391+
392+
infix fun InsightAttributeId.toVersion(version: ProjectVersion?) =
393+
Version(this, listOfNotNull(version), schema = null)
394+
395+
infix fun InsightAttributeId.toVersions(versions: List<ProjectVersion>) =
396+
Version(this, versions, schema = null)
397+
358398
infix fun InsightAttributeId.toReference(referencedObjectId: InsightObjectId?) =
359399
Reference(
360400
this,

0 commit comments

Comments
 (0)