Search in sources :

Example 6 with ID

use of net.nemerosa.ontrack.model.structure.ID in project ontrack by nemerosa.

the class ProjectEntityExtensionController method getInformation.

/**
 * Gets the list of information extensions for an entity
 */
@RequestMapping(value = "information/{entityType}/{id}", method = RequestMethod.GET)
public Resources<EntityInformation> getInformation(@PathVariable ProjectEntityType entityType, @PathVariable ID id) {
    // Gets the entity
    ProjectEntity entity = getEntity(entityType, id);
    // List of informations to return
    List<EntityInformation> informations = extensionManager.getExtensions(EntityInformationExtension.class).stream().map(x -> x.getInformation(entity)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    // OK
    return Resources.of(informations, uri(MvcUriComponentsBuilder.on(getClass()).getInformation(entityType, id)));
}
Also used : EntityInformationExtension(net.nemerosa.ontrack.extension.api.EntityInformationExtension) PathVariable(org.springframework.web.bind.annotation.PathVariable) EntityInformation(net.nemerosa.ontrack.extension.api.model.EntityInformation) StructureService(net.nemerosa.ontrack.model.structure.StructureService) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Action(net.nemerosa.ontrack.model.support.Action) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) ProjectEntityType(net.nemerosa.ontrack.model.structure.ProjectEntityType) ProjectEntityActionExtension(net.nemerosa.ontrack.extension.api.ProjectEntityActionExtension) List(java.util.List) Resources(net.nemerosa.ontrack.ui.resource.Resources) MvcUriComponentsBuilder(org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder) EntityInformationExtension(net.nemerosa.ontrack.extension.api.EntityInformationExtension) ProjectEntity(net.nemerosa.ontrack.model.structure.ProjectEntity) Optional(java.util.Optional) ExtensionManager(net.nemerosa.ontrack.extension.api.ExtensionManager) ID(net.nemerosa.ontrack.model.structure.ID) Optional(java.util.Optional) ProjectEntity(net.nemerosa.ontrack.model.structure.ProjectEntity) EntityInformation(net.nemerosa.ontrack.extension.api.model.EntityInformation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ID

use of net.nemerosa.ontrack.model.structure.ID in project ontrack by nemerosa.

the class AccountServiceIT method admin_can_delete_promotion_run.

/**
 * Regression test for #427
 */
@Test
public void admin_can_delete_promotion_run() throws Exception {
    // Creates an account
    ID id = account().getId();
    // Assigns the Administrator role to this account
    asUser().with(AccountManagement.class).call(() -> accountService.saveGlobalPermission(PermissionTargetType.ACCOUNT, id.get(), new PermissionInput("ADMINISTRATOR")));
    // Gets the ACL of the account
    Account account = asUser().with(AccountManagement.class).call(() -> accountService.withACL(AuthenticatedAccount.of(accountService.getAccount(id))));
    // Creates any project
    Project project = doCreateProject();
    // Checks the account can delete a promotion run
    assertTrue("An administrator must be granted the promotion run deletion", account.isGranted(project.id(), PromotionRunDelete.class));
}
Also used : Project(net.nemerosa.ontrack.model.structure.Project) ID(net.nemerosa.ontrack.model.structure.ID) Test(org.junit.Test)

Aggregations

ID (net.nemerosa.ontrack.model.structure.ID)7 Collectors (java.util.stream.Collectors)3 StructureService (net.nemerosa.ontrack.model.structure.StructureService)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Optional (java.util.Optional)2 Branch (net.nemerosa.ontrack.model.structure.Branch)2 Project (net.nemerosa.ontrack.model.structure.Project)2 ProjectEntityType (net.nemerosa.ontrack.model.structure.ProjectEntityType)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GraphQLInt (graphql.Scalars.GraphQLInt)1 GraphQLString (graphql.Scalars.GraphQLString)1 DataFetcher (graphql.schema.DataFetcher)1 GraphQLArgument.newArgument (graphql.schema.GraphQLArgument.newArgument)1 GraphQLFieldDefinition (graphql.schema.GraphQLFieldDefinition)1 GraphQLFieldDefinition.newFieldDefinition (graphql.schema.GraphQLFieldDefinition.newFieldDefinition)1 LocalDate (java.time.LocalDate)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1