<commit_before>package net.nemerosa.ontrack.boot.ui

import net.nemerosa.ontrack.model.labels.Label
import net.nemerosa.ontrack.model.labels.ProjectLabelForm
import net.nemerosa.ontrack.model.labels.ProjectLabelManagementService
import net.nemerosa.ontrack.model.structure.ID
import net.nemerosa.ontrack.model.structure.StructureService
import net.nemerosa.ontrack.ui.controller.AbstractResourceController
import net.nemerosa.ontrack.ui.resource.Resources
import org.springframework.web.bind.annotation.*
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on

@RestController
@RequestMapping("/rest/labels/projects/{projectId")
class ProjectLabelController(
        private val structureService: StructureService,
        private val projectLabelManagementService: ProjectLabelManagementService
) : AbstractResourceController() {

    @GetMapping("")
    fun getLabelsForProject(@PathVariable projectId: Int): Resources<Label> {
        return Resources.of(
                projectLabelManagementService.getLabelsForProject(
                        structureService.getProject(ID.of(projectId))
                ),
                uri(on(this::class.java).getLabelsForProject(projectId))
        )
    }

    @PutMapping("")
    fun setLabelsForProject(@PathVariable projectId: Int, @RequestBody form: ProjectLabelForm): Resources<Label> {
        projectLabelManagementService.associateProjectToLabels(
                structureService.getProject(ID.of(projectId)),
                form
        )
        return getLabelsForProject(projectId)
    }<commit_msg>#615 Correction of URL for the project label controller<commit_after>package net.nemerosa.ontrack.boot.ui

import net.nemerosa.ontrack.model.labels.Label
import net.nemerosa.ontrack.model.labels.ProjectLabelForm
import net.nemerosa.ontrack.model.labels.ProjectLabelManagementService
import net.nemerosa.ontrack.model.structure.ID
import net.nemerosa.ontrack.model.structure.StructureService
import net.nemerosa.ontrack.ui.controller.AbstractResourceController
import net.nemerosa.ontrack.ui.resource.Resources
import org.springframework.web.bind.annotation.*
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on

@RestController
@RequestMapping("/rest/labels/projects")
class ProjectLabelController(
        private val structureService: StructureService,
        private val projectLabelManagementService: ProjectLabelManagementService
) : AbstractResourceController() {

    @GetMapping("{projectId}")
    fun getLabelsForProject(@PathVariable projectId: Int): Resources<Label> {
        return Resources.of(
                projectLabelManagementService.getLabelsForProject(
                        structureService.getProject(ID.of(projectId))
                ),
                uri(on(this::class.java).getLabelsForProject(projectId))
        )
    }

    @PutMapping("{projectId}")
    fun setLabelsForProject(@PathVariable projectId: Int, @RequestBody form: ProjectLabelForm): Resources<Label> {
        projectLabelManagementService.associateProjectToLabels(
                structureService.getProject(ID.of(projectId)),
                form
        )
        return getLabelsForProject(projectId)
    }
{'fraction_non_alphanumeric': 0.08855291576673865, 'fraction_numerical': 0.0009256402344955261, 'mean_word_length': 4.003086419753086, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3526291', 'n_tokens_mistral': 848, 'n_tokens_neox': 829, 'n_words': 124}