-
Notifications
You must be signed in to change notification settings - Fork 1
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 #65 from ccims/feature/project_graph
Feature/project graph
- Loading branch information
Showing
64 changed files
with
2,139 additions
and
248 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
api-common/src/main/kotlin/gropius/graphql/filter/AffectedByIssueRelatedToFilterEntry.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,38 @@ | ||
package gropius.graphql.filter | ||
|
||
import gropius.model.user.permission.TrackablePermission | ||
import io.github.graphglue.authorization.Permission | ||
import io.github.graphglue.connection.filter.model.FilterEntry | ||
import org.neo4j.cypherdsl.core.Condition | ||
import org.neo4j.cypherdsl.core.Conditions | ||
import org.neo4j.cypherdsl.core.Cypher | ||
import org.neo4j.cypherdsl.core.Node | ||
|
||
/** | ||
* Parsed filter entry of a [AffectedByIssueRelatedToFilterEntryDefinition] | ||
* | ||
* @param trackableId the id of the Trackable to which the entity must be related to | ||
* @param permission the node permission to check | ||
* @param relatedToFilterEntryDefinition [AffectedByIssueRelatedToFilterEntryDefinition] used to create this entry | ||
*/ | ||
class AffectedByIssueRelatedToFilterEntry( | ||
val trackableId: String, | ||
private val relatedToFilterEntryDefinition: AffectedByIssueRelatedToFilterEntryDefinition, | ||
private val permission: Permission? | ||
|
||
) : FilterEntry(relatedToFilterEntryDefinition) { | ||
|
||
override fun generateCondition(node: Node): Condition { | ||
val relatedNode = Cypher.anyNode(node.requiredSymbolicName.value + "_") | ||
val relationship = node.relationshipTo(relatedNode).min(0) | ||
.withProperties(mapOf(TrackablePermission.RELATED_ISSUE_AFFECTED_ENTITY to Cypher.literalTrue())) | ||
val authCondition = if (permission != null) { | ||
relatedToFilterEntryDefinition.generateAuthorizationCondition(permission).generateCondition(relatedNode) | ||
} else { | ||
Conditions.noCondition() | ||
} | ||
val idCondition = relatedNode.property("id").isEqualTo(Cypher.anonParameter(trackableId)) | ||
return Cypher.match(relationship).where(idCondition.and(authCondition)).asCondition() | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...n/src/main/kotlin/gropius/graphql/filter/AffectedByIssueRelatedToFilterEntryDefinition.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,47 @@ | ||
package gropius.graphql.filter | ||
|
||
import graphql.Scalars | ||
import graphql.schema.GraphQLInputType | ||
import gropius.model.architecture.Trackable | ||
import io.github.graphglue.authorization.Permission | ||
import io.github.graphglue.connection.filter.definition.FilterEntryDefinition | ||
import io.github.graphglue.connection.filter.definition.SubFilterGenerator | ||
import io.github.graphglue.connection.filter.definition.generateFilterDefinition | ||
import io.github.graphglue.connection.filter.model.FilterEntry | ||
import io.github.graphglue.data.execution.CypherConditionGenerator | ||
import io.github.graphglue.definition.NodeDefinitionCollection | ||
import io.github.graphglue.util.CacheMap | ||
|
||
/** | ||
* Filter definition entry for affected by issue related to a Trackable. | ||
* Takes the id of the Trackable to which the entities must be related. | ||
* | ||
* @param nodeDefinitionCollection the [NodeDefinitionCollection] to use for authorization | ||
*/ | ||
class AffectedByIssueRelatedToFilterEntryDefinition( | ||
private val nodeDefinitionCollection: NodeDefinitionCollection, | ||
) : FilterEntryDefinition("relatedTo", "Filters for AffectedByIssues which are related to a Trackable") { | ||
|
||
/** | ||
* Provides a condition generator used to filter for Trackables which the Permissions allows to access | ||
* | ||
* @param permission the current read permission, used to only consider nodes in filters which match the permission | ||
* @return the generated condition generator | ||
*/ | ||
fun generateAuthorizationCondition(permission: Permission): CypherConditionGenerator { | ||
return nodeDefinitionCollection.generateAuthorizationCondition( | ||
nodeDefinitionCollection.getNodeDefinition<Trackable>(), | ||
permission | ||
) | ||
} | ||
|
||
override fun parseEntry(value: Any?, permission: Permission?): FilterEntry { | ||
return AffectedByIssueRelatedToFilterEntry( | ||
value!! as String, | ||
this, | ||
permission | ||
) | ||
} | ||
|
||
override fun toGraphQLType(inputTypeCache: CacheMap<String, GraphQLInputType>): GraphQLInputType = Scalars.GraphQLID | ||
} |
38 changes: 38 additions & 0 deletions
38
api-common/src/main/kotlin/gropius/graphql/filter/PartOfProjectFilterEntry.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,38 @@ | ||
package gropius.graphql.filter | ||
|
||
import gropius.model.user.permission.ProjectPermission | ||
import io.github.graphglue.authorization.Permission | ||
import io.github.graphglue.connection.filter.model.FilterEntry | ||
import org.neo4j.cypherdsl.core.Condition | ||
import org.neo4j.cypherdsl.core.Conditions | ||
import org.neo4j.cypherdsl.core.Cypher | ||
import org.neo4j.cypherdsl.core.Node | ||
|
||
/** | ||
* Parsed filter entry of a [AffectedByIssueRelatedToFilterEntryDefinition] | ||
* | ||
* @param projectId the id of the Project to which the entity must be related to | ||
* @param permission the node permission to check | ||
* @param partOfProjectFilterEntryDefinition [PartOfProjectFilterEntryDefinition] used to create this entry | ||
*/ | ||
class PartOfProjectFilterEntry( | ||
val projectId: String, | ||
private val partOfProjectFilterEntryDefinition: PartOfProjectFilterEntryDefinition, | ||
private val permission: Permission? | ||
|
||
) : FilterEntry(partOfProjectFilterEntryDefinition) { | ||
|
||
override fun generateCondition(node: Node): Condition { | ||
val relatedNode = Cypher.anyNode(node.requiredSymbolicName.value + "_") | ||
val relationship = node.relationshipTo(relatedNode).min(0) | ||
.withProperties(mapOf(ProjectPermission.PART_OF_PROJECT to Cypher.literalTrue())) | ||
val authCondition = if (permission != null) { | ||
partOfProjectFilterEntryDefinition.generateAuthorizationCondition(permission).generateCondition(relatedNode) | ||
} else { | ||
Conditions.noCondition() | ||
} | ||
val idCondition = relatedNode.property("id").isEqualTo(Cypher.anonParameter(projectId)) | ||
return Cypher.match(relationship).where(idCondition.and(authCondition)).asCondition() | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
api-common/src/main/kotlin/gropius/graphql/filter/PartOfProjectFilterEntryDefinition.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,45 @@ | ||
package gropius.graphql.filter | ||
|
||
import graphql.Scalars | ||
import graphql.schema.GraphQLInputType | ||
import gropius.model.architecture.Project | ||
import io.github.graphglue.authorization.Permission | ||
import io.github.graphglue.connection.filter.definition.FilterEntryDefinition | ||
import io.github.graphglue.connection.filter.model.FilterEntry | ||
import io.github.graphglue.data.execution.CypherConditionGenerator | ||
import io.github.graphglue.definition.NodeDefinitionCollection | ||
import io.github.graphglue.util.CacheMap | ||
|
||
/** | ||
* Filter definition entry for RelationPartners which are part of a Project. | ||
* Takes the id of the Project of which the RelationPartners must be part of the graph. | ||
* | ||
* @param nodeDefinitionCollection the [NodeDefinitionCollection] to use for authorization | ||
*/ | ||
class PartOfProjectFilterEntryDefinition( | ||
private val nodeDefinitionCollection: NodeDefinitionCollection, | ||
) : FilterEntryDefinition("partOfProject", "Filters for RelationPartners which are part of a Project's component graph") { | ||
|
||
/** | ||
* Provides a condition generator used to filter for Projects which the Permissions allows to access | ||
* | ||
* @param permission the current read permission, used to only consider nodes in filters which match the permission | ||
* @return the generated condition generator | ||
*/ | ||
fun generateAuthorizationCondition(permission: Permission): CypherConditionGenerator { | ||
return nodeDefinitionCollection.generateAuthorizationCondition( | ||
nodeDefinitionCollection.getNodeDefinition<Project>(), | ||
permission | ||
) | ||
} | ||
|
||
override fun parseEntry(value: Any?, permission: Permission?): FilterEntry { | ||
return PartOfProjectFilterEntry( | ||
value!! as String, | ||
this, | ||
permission | ||
) | ||
} | ||
|
||
override fun toGraphQLType(inputTypeCache: CacheMap<String, GraphQLInputType>): GraphQLInputType = Scalars.GraphQLID | ||
} |
16 changes: 16 additions & 0 deletions
16
api-public/src/main/kotlin/gropius/dto/payload/AddComponentVersionToProjectPayload.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,16 @@ | ||
package gropius.dto.payload | ||
|
||
import com.expediagroup.graphql.generator.annotations.GraphQLDescription | ||
import gropius.model.architecture.ComponentVersion | ||
import gropius.model.architecture.Project | ||
|
||
/** | ||
* Payload type for the addComponentVersionToProject mutation | ||
*/ | ||
@GraphQLDescription("Payload type for the addComponentVersionToProject mutation") | ||
class AddComponentVersionToProjectPayload( | ||
@GraphQLDescription("The updated project") | ||
val project: Project, | ||
@GraphQLDescription("The added component version") | ||
val componentVersion: ComponentVersion | ||
) |
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
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
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
Oops, something went wrong.