-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from camunda-community-hub/285-import-decisions
feat: Add GraphQL API for decisions and DRGs
- Loading branch information
Showing
22 changed files
with
1,229 additions
and
392 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
data/src/main/kotlin/io/zeebe/zeeqs/data/entity/Decision.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.zeebe.zeeqs.data.entity | ||
|
||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.Id | ||
|
||
@Entity | ||
data class Decision( | ||
@Id @Column(name = "key_") val key: Long, | ||
val decisionId: String, | ||
val decisionName: String, | ||
val version: Int, | ||
val decisionRequirementsKey: Long, | ||
val decisionRequirementsId: String | ||
) |
19 changes: 19 additions & 0 deletions
19
data/src/main/kotlin/io/zeebe/zeeqs/data/entity/DecisionRequirements.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.zeebe.zeeqs.data.entity | ||
|
||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.Id | ||
import javax.persistence.Lob | ||
|
||
@Entity | ||
data class DecisionRequirements( | ||
@Id @Column(name = "key_") val key: Long, | ||
val decisionRequirementsId: String, | ||
val decisionRequirementsName: String, | ||
val version: Int, | ||
val namespace: String, | ||
@Lob val dmnXML: String, | ||
val deployTime: Long, | ||
val resourceName: String, | ||
@Lob val checksum: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
data/src/main/kotlin/io/zeebe/zeeqs/data/repository/DecisionRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.zeebe.zeeqs.data.repository | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import org.springframework.data.repository.PagingAndSortingRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
interface DecisionRepository : PagingAndSortingRepository<Decision, Long> { | ||
|
||
fun findAllByDecisionRequirementsKey(decisionRequirementsKey: Long): List<Decision> | ||
} |
8 changes: 8 additions & 0 deletions
8
data/src/main/kotlin/io/zeebe/zeeqs/data/repository/DecisionRequirementsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.zeebe.zeeqs.data.repository | ||
|
||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
import org.springframework.data.repository.PagingAndSortingRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
interface DecisionRequirementsRepository : PagingAndSortingRepository<DecisionRequirements, Long> |
8 changes: 8 additions & 0 deletions
8
...hql-api/src/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/connection/DecisionConnection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.connection | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
|
||
class DecisionConnection( | ||
val getItems: () -> List<Decision>, | ||
val getCount: () -> Long | ||
) |
19 changes: 19 additions & 0 deletions
19
...src/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/connection/DecisionConnectionResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.connection | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionConnectionResolver { | ||
|
||
@SchemaMapping(typeName = "DecisionConnection", field = "nodes") | ||
fun nodes(connection: DecisionConnection): List<Decision> { | ||
return connection.getItems() | ||
} | ||
|
||
@SchemaMapping(typeName = "DecisionConnection", field = "totalCount") | ||
fun totalCount(connection: DecisionConnection): Long { | ||
return connection.getCount() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...main/kotlin/io/zeebe/zeeqs/graphql/resolvers/connection/DecisionRequirementsConnection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.connection | ||
|
||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
|
||
class DecisionRequirementsConnection( | ||
val getItems: () -> List<DecisionRequirements>, | ||
val getCount: () -> Long | ||
) |
19 changes: 19 additions & 0 deletions
19
...lin/io/zeebe/zeeqs/graphql/resolvers/connection/DecisionRequirementsConnectionResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.connection | ||
|
||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionRequirementsConnectionResolver { | ||
|
||
@SchemaMapping(typeName = "DecisionRequirementsConnection", field = "nodes") | ||
fun nodes(connection: DecisionRequirementsConnection): List<DecisionRequirements> { | ||
return connection.getItems() | ||
} | ||
|
||
@SchemaMapping(typeName = "DecisionRequirementsConnection", field = "totalCount") | ||
fun totalCount(connection: DecisionRequirementsConnection): Long { | ||
return connection.getCount() | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
graphql-api/src/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/query/DecisionQueryResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.query | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import io.zeebe.zeeqs.data.repository.DecisionRepository | ||
import io.zeebe.zeeqs.graphql.resolvers.connection.DecisionConnection | ||
import org.springframework.data.domain.PageRequest | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.graphql.data.method.annotation.Argument | ||
import org.springframework.graphql.data.method.annotation.QueryMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionQueryResolver( | ||
private val decisionRepository: DecisionRepository | ||
) { | ||
|
||
@QueryMapping | ||
fun decisions( | ||
@Argument perPage: Int, | ||
@Argument page: Int | ||
): DecisionConnection { | ||
return DecisionConnection( | ||
getItems = { decisionRepository.findAll(PageRequest.of(page, perPage)).toList() }, | ||
getCount = { decisionRepository.count() } | ||
) | ||
} | ||
|
||
@QueryMapping | ||
fun decision(@Argument key: Long): Decision? { | ||
return decisionRepository.findByIdOrNull(key) | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...c/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/query/DecisionRequirementsQueryResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.query | ||
|
||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
import io.zeebe.zeeqs.data.repository.DecisionRequirementsRepository | ||
import io.zeebe.zeeqs.graphql.resolvers.connection.DecisionRequirementsConnection | ||
import org.springframework.data.domain.PageRequest | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.graphql.data.method.annotation.Argument | ||
import org.springframework.graphql.data.method.annotation.QueryMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionRequirementsQueryResolver( | ||
private val decisionRequirementsRepository: DecisionRequirementsRepository | ||
) { | ||
|
||
@QueryMapping | ||
fun decisionRequirements( | ||
@Argument perPage: Int, | ||
@Argument page: Int | ||
): DecisionRequirementsConnection { | ||
return DecisionRequirementsConnection( | ||
getItems = { | ||
decisionRequirementsRepository.findAll(PageRequest.of(page, perPage)).toList() | ||
}, | ||
getCount = { decisionRequirementsRepository.count() } | ||
) | ||
} | ||
|
||
@QueryMapping | ||
fun decisionRequirement(@Argument key: Long): DecisionRequirements? { | ||
return decisionRequirementsRepository.findByIdOrNull(key) | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
.../main/kotlin/io/zeebe/zeeqs/graphql/resolvers/subscription/DecisionSubscriptionMapping.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.subscription | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import io.zeebe.zeeqs.data.reactive.DataUpdatesSubscription | ||
import org.springframework.graphql.data.method.annotation.SubscriptionMapping | ||
import org.springframework.stereotype.Controller | ||
import reactor.core.publisher.Flux | ||
|
||
@Controller | ||
class DecisionSubscriptionMapping( | ||
private val subscription: DataUpdatesSubscription | ||
) { | ||
|
||
@SubscriptionMapping | ||
fun decisionUpdates(): Flux<Decision> { | ||
return subscription.decisionSubscription() | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...api/src/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/type/DecisionRequirementsResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.type | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
import io.zeebe.zeeqs.data.repository.DecisionRepository | ||
import org.springframework.graphql.data.method.annotation.Argument | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionRequirementsResolver( | ||
private val decisionRepository: DecisionRepository | ||
) { | ||
|
||
@SchemaMapping(typeName = "DecisionRequirements", field = "deployTime") | ||
fun deployTime( | ||
decisionRequirements: DecisionRequirements, | ||
@Argument zoneId: String | ||
): String? { | ||
return decisionRequirements.deployTime.let { | ||
ResolverExtension.timestampToString( | ||
it, | ||
zoneId | ||
) | ||
} | ||
} | ||
|
||
@SchemaMapping(typeName = "DecisionRequirements", field = "decisions") | ||
fun decisions(decisionRequirements: DecisionRequirements): List<Decision> { | ||
return decisionRepository.findAllByDecisionRequirementsKey( | ||
decisionRequirementsKey = decisionRequirements.key | ||
) | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
graphql-api/src/main/kotlin/io/zeebe/zeeqs/graphql/resolvers/type/DecisionResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.zeebe.zeeqs.graphql.resolvers.type | ||
|
||
import io.zeebe.zeeqs.data.entity.Decision | ||
import io.zeebe.zeeqs.data.entity.DecisionRequirements | ||
import io.zeebe.zeeqs.data.repository.DecisionRequirementsRepository | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class DecisionResolver( | ||
private val decisionRequirementsRepository: DecisionRequirementsRepository | ||
) { | ||
|
||
@SchemaMapping(typeName = "Decision", field = "decisionRequirements") | ||
fun decisionRequirements(decision: Decision): DecisionRequirements? { | ||
return decisionRequirementsRepository.findByIdOrNull(decision.decisionRequirementsKey) | ||
} | ||
|
||
} |
Oops, something went wrong.