-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added public endpoint for fetching subset of projects info
- Loading branch information
1 parent
01e5f89
commit 8b05aeb
Showing
5 changed files
with
114 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
src/main/java/org/radarbase/management/service/dto/ProjectLiteDTO.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,55 @@ | ||
package org.radarbase.management.service.dto | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import org.radarbase.management.domain.enumeration.ProjectStatus | ||
import reactor.util.annotation.NonNull | ||
import java.io.Serializable | ||
import javax.validation.constraints.NotNull | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
class ProjectLiteDTO : Serializable { | ||
@NonNull | ||
var projectName: String? = null | ||
|
||
@NonNull | ||
var description: String? = null | ||
|
||
@NotNull | ||
var location: String? = null | ||
var projectStatus: ProjectStatus? = null | ||
|
||
|
||
override fun toString() = "PublicProjectDTO(" + | ||
"projectName=$projectName, " + | ||
"description=$description, " + | ||
"location=$location, " + | ||
"projectStatus=$projectStatus" + | ||
")" | ||
|
||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as ProjectLiteDTO | ||
|
||
if (projectName != other.projectName) return false | ||
if (description != other.description) return false | ||
if (location != other.location) return false | ||
if (projectStatus != other.projectStatus) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = projectName?.hashCode() ?: 0 | ||
result = 31 * result + (description?.hashCode() ?: 0) | ||
result = 31 * result + (location?.hashCode() ?: 0) | ||
result = 31 * result + (projectStatus?.hashCode() ?: 0) | ||
return result | ||
} | ||
|
||
companion object { | ||
private const val serialVersionUID = 1L | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/radarbase/management/web/rest/ProjectLiteResource.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,43 @@ | ||
package org.radarbase.management.web.rest | ||
|
||
import io.micrometer.core.annotation.Timed | ||
import org.radarbase.management.service.ProjectService | ||
import org.radarbase.management.web.rest.util.PaginationUtil | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.data.domain.Pageable | ||
import org.springframework.data.web.PageableDefault | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
/** | ||
* GET /lite-projects : get all the projects. | ||
* | ||
* @return the ResponseEntity with status 200 (OK) and the list of ProjectLiteDTO | ||
*/ | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
class ProjectLiteResource( | ||
@Autowired private val projectService: ProjectService | ||
) { | ||
|
||
@GetMapping("lite-projects") | ||
@Timed | ||
fun getProjectsInfo( | ||
@PageableDefault(size = Int.MAX_VALUE) pageable: Pageable, | ||
): ResponseEntity<*> { | ||
log.debug("REST request to get Projects for public endpoint") | ||
val page = projectService.findProjectsForPublicEndpoint(pageable) | ||
val headers = PaginationUtil | ||
.generatePaginationHttpHeaders(page, "/api/lite-projects") | ||
return ResponseEntity(page.content, headers, HttpStatus.OK) | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(ProjectLiteResource::class.java) | ||
} | ||
} |