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

import net.nemerosa.ontrack.model.structure.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Gives access to the structure. See {@link net.nemerosa.ontrack.model.structure.ProjectEntityType} for
 * the list of entities that are mapped.
 */
@RestController
@RequestMapping("/structure")
public class StructureController extends AbstractProjectEntityController {

    @Autowired
    public StructureController(StructureService structureService) {
        super(structureService);
    }

    /**
     * Project access
     */
    @RequestMapping(value = "entity/project/{project}", method = RequestMethod.GET)
    public Project project(@PathVariable String project) {
        return structureService.findProjectByName(project);
    }

    /**
     * Branch access
     */
    @RequestMapping(value = "entity/branch/{project}/{branch}", method = RequestMethod.GET)
    public Branch branch(@PathVariable String project, @PathVariable String branch) {
        return structureService.findBranchByName(project, branch);
    }

    /**
     * Promotion level access
     */
    @RequestMapping(value = "entity/promotionLevel/{project}/{branch}/{promotionLevel}", method = RequestMethod.GET)
    public PromotionLevel promotionLevel(@PathVariable String project, @PathVariable String branch, @PathVariable String promotionLevel) {
        return structureService.findPromotionLevelByName(project, branch, promotionLevel);
    }

    /**
     * Validation stamp access
     */
    @RequestMapping(value = "entity/validationStamp/{project}/{branch}/{validationStamp}", method = RequestMethod.GET)
    public ValidationStamp validationStamp(@PathVariable String project, @PathVariable String branch, @PathVariable String validationStamp) {
        return structureService.findValidationStampByName(project, branch, validationStamp);
    }

    @RequestMapping(value = "entity/build/{project}/{branch}/{build:.*}", method = RequestMethod.GET)
    public Build build(@PathVariable String project, @PathVariable String branch, @PathVariable String build) {
        return structureService.findBuildByName(project, branch, build);
    }

    // FIXME PROMOTION_RUN<commit_msg>#1 Be lenient for the final name in the URL<commit_after>package net.nemerosa.ontrack.boot.ui;

import net.nemerosa.ontrack.model.structure.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Gives access to the structure. See {@link net.nemerosa.ontrack.model.structure.ProjectEntityType} for
 * the list of entities that are mapped.
 */
@RestController
@RequestMapping("/structure")
public class StructureController extends AbstractProjectEntityController {

    @Autowired
    public StructureController(StructureService structureService) {
        super(structureService);
    }

    /**
     * Project access
     */
    @RequestMapping(value = "entity/project/{project:.*}", method = RequestMethod.GET)
    public Project project(@PathVariable String project) {
        return structureService.findProjectByName(project);
    }

    /**
     * Branch access
     */
    @RequestMapping(value = "entity/branch/{project}/{branch:.*}", method = RequestMethod.GET)
    public Branch branch(@PathVariable String project, @PathVariable String branch) {
        return structureService.findBranchByName(project, branch);
    }

    /**
     * Promotion level access
     */
    @RequestMapping(value = "entity/promotionLevel/{project}/{branch}/{promotionLevel:.*}", method = RequestMethod.GET)
    public PromotionLevel promotionLevel(@PathVariable String project, @PathVariable String branch, @PathVariable String promotionLevel) {
        return structureService.findPromotionLevelByName(project, branch, promotionLevel);
    }

    /**
     * Validation stamp access
     */
    @RequestMapping(value = "entity/validationStamp/{project}/{branch}/{validationStamp:.*}", method = RequestMethod.GET)
    public ValidationStamp validationStamp(@PathVariable String project, @PathVariable String branch, @PathVariable String validationStamp) {
        return structureService.findValidationStampByName(project, branch, validationStamp);
    }

    @RequestMapping(value = "entity/build/{project}/{branch}/{build:.*}", method = RequestMethod.GET)
    public Build build(@PathVariable String project, @PathVariable String branch, @PathVariable String build) {
        return structureService.findBuildByName(project, branch, build);
    }

    // FIXME PROMOTION_RUN
{'fraction_non_alphanumeric': 0.1057347670250896, 'fraction_numerical': 0.00019912385503783353, 'mean_word_length': 4.49562363238512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6442955', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1263, 'n_words': 282}