use of net.nemerosa.ontrack.extension.api.model.EntityInformation 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)));
}
use of net.nemerosa.ontrack.extension.api.model.EntityInformation in project ontrack by nemerosa.
the class BuildSVNInformationExtension method getInformation.
@Override
public Optional<EntityInformation> getInformation(ProjectEntity entity) {
if (entity instanceof Build) {
Build build = (Build) entity;
// Gets the branch SVN information
Property<SVNBranchConfigurationProperty> branchConfigurationProperty = propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class);
Property<SVNProjectConfigurationProperty> projectConfigurationProperty = propertyService.getProperty(build.getBranch().getProject(), SVNProjectConfigurationPropertyType.class);
if (branchConfigurationProperty.isEmpty() || projectConfigurationProperty.isEmpty()) {
return Optional.empty();
} else {
// Loads the repository
SVNRepository repository = svnService.getRepository(projectConfigurationProperty.getValue().getConfiguration().getName());
// Gets the build history
try (Transaction ignored = transactionService.start()) {
return Optional.of(new EntityInformation(this, svnChangeLogService.getBuildSVNHistory(repository, build)));
}
}
} else {
return Optional.empty();
}
}
Aggregations