Skip to content

Commit

Permalink
Merge pull request #27 from sanctuuary/dev
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
KoenHav authored Jul 28, 2021
2 parents dfd8aff + 4d1828e commit ec87159
Show file tree
Hide file tree
Showing 27 changed files with 788 additions and 587 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.0] - 2021-07-28

### Added

- Column to public domains list which shows the owner of the domain.
- Official domains are shown with an "official" topic.

### Changed

- Update APE dependency to 1.1.8.
- Rewrote workflow visualization code to fix overlapping nodes.

### Fixed

- Filtering domains based on their topics.
- Less console errors when a domain has no use case.

## [1.2.0] - 2021-07-06

### Added
Expand Down Expand Up @@ -82,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Approve user accounts.

[Unreleased]: https://github.com/sanctuuary/APE-Web/compare/master...dev
[1.3.0]: https://github.com/sanctuuary/APE-Web/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/sanctuuary/APE-Web/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/sanctuuary/APE-Web/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/sanctuuary/APE-Web/releases/tag/v1.0.0
2 changes: 1 addition & 1 deletion back-end/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY pom.xml /app
RUN mvn compile
COPY . /app
RUN mvn package -DskipTests=true -P docker
ENTRYPOINT ["java", "-jar", "target/backend-1.2.0.jar"]
ENTRYPOINT ["java", "-jar", "target/backend-1.3.0.jar"]
4 changes: 2 additions & 2 deletions back-end/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.apexdevs</groupId>
<artifactId>backend</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<name>backend</name>
<description>APE Web back-end</description>

Expand Down Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>io.github.sanctuuary</groupId>
<artifactId>APE</artifactId>
<version>1.1.7</version>
<version>1.1.8</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import com.apexdevs.backend.persistence.exception.RunParametersExceedLimitsExcep
import com.apexdevs.backend.persistence.exception.SynthesisFlagException
import guru.nidi.graphviz.attribute.Rank
import nl.uu.cs.ape.sat.APE
import nl.uu.cs.ape.sat.core.implSAT.SATsolutionsList
import nl.uu.cs.ape.sat.core.solutionStructure.CWLCreator
import nl.uu.cs.ape.sat.core.solutionStructure.ModuleNode
import nl.uu.cs.ape.sat.core.solutionStructure.SolutionsList
import nl.uu.cs.ape.sat.core.solutionStructure.TypeNode
import nl.uu.cs.ape.sat.models.enums.SynthesisFlag
import nl.uu.cs.ape.sat.models.logic.constructs.TaxonomyPredicate
Expand All @@ -34,7 +34,7 @@ import javax.imageio.ImageIO
* @param ape APE instantiated with the correct CoreConfig
*/
class ApeRequest(val domain: Domain, private val rootLocation: Path, val ape: APE, val runParametersOperation: RunParametersOperation) {
private lateinit var solutions: SATsolutionsList
private lateinit var solutions: SolutionsList
/**
* Takes a RunConfig object and adds two local paths and converts it to a JSON object to run the synthesis
* @param runConfig The config provided that is used by APE to run it's synthesis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.apexdevs.backend.web.controller.entity.domain.DomainDetails
import com.apexdevs.backend.web.controller.entity.domain.DomainUploadRequest
import org.bson.types.ObjectId
import org.springframework.stereotype.Component
import java.util.logging.Logger

/**
* Performs domain operations on the database
Expand Down Expand Up @@ -260,4 +261,26 @@ class DomainOperation(val domainRepository: DomainRepository, val userRepository
}
return usersByDomainAndAccess.toList()
}

/**
* Gets the owner of a domain.
* @param domainId The id of the domain to get the owner of.
* @throws UserNotFoundException When the owner user could not be found (if this happens there something seriously wrong, as each domain should have exactly one owner)
*/
@Throws(UserNotFoundException::class)
fun getOwner(domainId: ObjectId): User {
// Get all owners
val owners = userDomainAccessRepository.findAllByDomainIdAndAccess(domainId, DomainAccess.Owner)
val owner = owners[0] // There is only one owner per domain, so get the first and only owner
val user = userRepository.findById(owner.userId)
if (user.isEmpty) {
log.severe("Failed to find owner of domain with ID: $domainId!")
throw UserNotFoundException(this, "Failed to find the owner of the domain")
}
return user.get()
}

companion object {
val log: Logger = Logger.getLogger("DomainOperation_Logger")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@ package com.apexdevs.backend.web.controller.entity.domain
* @param title name of the domain
* @param topics list of the topics the domain belongs to
* @param description the description of the domain
* @param official whether the domain is an official domain
* @param ownerName the display name of the owner of the domain
*/
data class DomainRequest(val id: String, val title: String, val topics: List<String>, val description: String)
data class DomainRequest(
val id: String,
val title: String,
val topics: List<String>,
val description: String,
val official: Boolean,
val ownerName: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import java.util.logging.Logger
class DomainController(val storageService: StorageService, val domainOperation: DomainOperation, val userOperation: UserOperation, val domainCollection: DomainCollection, val topicOperation: TopicOperation) {
/**
* Returns all public domains
* @param user optional user credentials
* @return list of all public domains
*/
@ResponseStatus(HttpStatus.OK)
Expand All @@ -60,7 +59,17 @@ class DomainController(val storageService: StorageService, val domainOperation:
// get all topics of domain and convert it all to a type safe to send
val topicStrings: MutableList<String> = mutableListOf()
domainOperation.getTopics(domain).map { topic: Topic -> topicStrings.add(topic.name) }
safeDomains.add(DomainRequest(domain.id.toHexString(), domain.name, topicStrings, domain.description))
val owner = domainOperation.getOwner(domain.id)
val isAdmin = userOperation.userIsAdmin(owner.email)
safeDomains.add(
DomainRequest(
domain.id.toHexString(),
domain.name, topicStrings,
domain.description,
isAdmin,
owner.displayName
)
)
}

return safeDomains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import io.mockk.mockk
import nl.uu.cs.ape.sat.APE
import nl.uu.cs.ape.sat.constraints.ConstraintTemplate
import nl.uu.cs.ape.sat.constraints.ConstraintTemplateParameter
import nl.uu.cs.ape.sat.core.implSAT.SATsolutionsList
import nl.uu.cs.ape.sat.core.solutionStructure.ModuleNode
import nl.uu.cs.ape.sat.core.solutionStructure.SolutionWorkflow
import nl.uu.cs.ape.sat.core.solutionStructure.SolutionsList
import nl.uu.cs.ape.sat.core.solutionStructure.TypeNode
import nl.uu.cs.ape.sat.models.AllModules
import nl.uu.cs.ape.sat.models.AllTypes
Expand Down Expand Up @@ -59,7 +59,7 @@ internal class ApeRequestTest {

@Test
fun getWorkflows() {
val mockSolutionList = mockk<SATsolutionsList>()
val mockSolutionList = mockk<SolutionsList>()
val mockSolutionWorkflow = mockk<SolutionWorkflow>()
val mockTypeNode = mockk<TypeNode>()
val mockModuleNode = mockk<ModuleNode>()
Expand Down Expand Up @@ -98,7 +98,7 @@ internal class ApeRequestTest {

@Test
fun `error when solutions not found`() {
val mockSolutionList = mockk<SATsolutionsList>()
val mockSolutionList = mockk<SolutionsList>()
val mockSolutionWorkflow = mockk<SolutionWorkflow>()
val mockConfig = mockk<RunConfig>()
val mockJSON = mockk<JSONObject>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal class DomainRequestTest {

private val test = "Test"
private val topicList = listOf(test)
private val domainRequest = DomainRequest(ObjectId.get().toHexString(), test, topicList, test)
private val ownerName = "TestUser"
private val domainRequest = DomainRequest(ObjectId.get().toHexString(), test, topicList, test, false, ownerName)

@Test
fun getTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.ninjasquad.springmockk.MockkBean
import io.mockk.every
import io.mockk.mockk
import org.bson.types.ObjectId
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -226,14 +225,42 @@ class DomainControllerMVCTest(@Autowired val context: WebApplicationContext) {
}
}

@Disabled
@Test
fun `Public domains are retrieved correctly`() {
val domain = Domain(t, t, t, DomainVisibility.Public, t, t, listOf(t), true)
val domainRequest = DomainRequest(domain.id.toHexString(), t, listOf(t), t)
val user = User("[email protected]", "test", "TestUser", UserStatus.Approved)

every { domain.id.toHexString() } returns "testId"

val domainRequest = DomainRequest(domain.id.toHexString(), t, listOf(t), t, false, user.displayName)

every { domainCollection.getPublicDomains() } returns listOf(domain)
every { domainOperation.getTopics(any()) } returns listOf(Topic(t))
every { domainOperation.getOwner(domain.id) } returns user
every { userOperation.userIsAdmin(user.email) } returns false

val expected = ow.writeValueAsString(listOf(domainRequest))
mockMvc.get("/domain/") {
contentType = MediaType.APPLICATION_JSON
}.andExpect {
status { isOk }
content { json(expected) }
}
}

@Test
fun `Public domains are flagged as official correctly`() {
val domain = Domain(t, t, t, DomainVisibility.Public, t, t, listOf(t), true)
val user = User("[email protected]", "test", "TestUser", UserStatus.Approved)

every { domain.id.toHexString() } returns "testId"

val domainRequest = DomainRequest(domain.id.toHexString(), t, listOf(t), t, true, user.displayName)

every { domainCollection.getPublicDomains() } returns listOf(domain)
every { domainOperation.getTopics(any()) } returns listOf(Topic(t))
every { domainOperation.getOwner(domain.id) } returns user
every { userOperation.userIsAdmin(user.email) } returns true

val expected = ow.writeValueAsString(listOf(domainRequest))
mockMvc.get("/domain/") {
Expand Down
2 changes: 1 addition & 1 deletion front-end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front-end/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "front-end",
"version": "1.2.0",
"version": "1.3.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Loading

0 comments on commit ec87159

Please sign in to comment.