Skip to content
Snippets Groups Projects
Commit 6db278f3 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

feat(services): add nid and new release fields to projects model

parent c9bdf773
No related branches found
No related tags found
1 merge request!266feat(cache): Add default fetch for loading cache to simplify usage
......@@ -22,112 +22,115 @@ import io.soabase.recordbuilder.core.RecordBuilder;
* Model representing the return data from the projects-api at '/api/projects'
*/
@RecordBuilder
public record Project(String projectId, String shortProjectId, String name, String summary, String url, String websiteUrl, List<WebsiteRepo> websiteRepo,
String logo, List<String> tags, List<Repo> githubRepos, List<Repo> gitlabRepos, GithubProject github, GitlabProject gitlab,
List<Repo> gerritRepos, List<ProjectParticipant> contributors, List<ProjectParticipant> committers,
List<ProjectParticipant> projectLeads, List<Collaboration> industryCollaborations, Object specProjectWorkingGroup,
List<Release> releases, String topLevelProject) {
public Project(String projectId, String shortProjectId, String name, String summary, String url, String websiteUrl, List<WebsiteRepo> websiteRepo,
String logo, List<String> tags, List<Repo> githubRepos, List<Repo> gitlabRepos, GithubProject github, GitlabProject gitlab,
List<Repo> gerritRepos, List<ProjectParticipant> contributors, List<ProjectParticipant> committers,
List<ProjectParticipant> projectLeads, List<Collaboration> industryCollaborations, Object specProjectWorkingGroup,
List<Release> releases, String topLevelProject) {
this.projectId = Objects.requireNonNull(projectId);
this.shortProjectId = Objects.requireNonNull(shortProjectId);
this.name = Objects.requireNonNull(name);
this.summary = Objects.requireNonNull(summary);
this.url = Objects.requireNonNull(url);
this.websiteUrl = Objects.requireNonNull(websiteUrl);
this.websiteRepo = Objects.requireNonNull(websiteRepo);
this.logo = Objects.requireNonNull(logo);
this.tags = Objects.requireNonNull(tags);
this.githubRepos = Objects.requireNonNull(githubRepos);
this.gitlabRepos = Objects.requireNonNull(gitlabRepos);
this.github = Objects.requireNonNull(github);
this.gitlab = Objects.requireNonNull(gitlab);
this.gerritRepos = Objects.requireNonNull(gerritRepos);
this.contributors = Objects.requireNonNull(contributors);
this.committers = Objects.requireNonNull(committers);
this.projectLeads = Objects.requireNonNull(projectLeads);
this.industryCollaborations = Objects.requireNonNull(industryCollaborations);
this.specProjectWorkingGroup = Objects.requireNonNull(specProjectWorkingGroup);
this.releases = Objects.requireNonNull(releases);
this.topLevelProject = Objects.requireNonNull(topLevelProject);
public record Project(int nid, String projectId, String shortProjectId, String name, String summary, String url, String websiteUrl,
List<WebsiteRepo> websiteRepo, String logo, List<String> tags, List<Repo> githubRepos, List<Repo> gitlabRepos, GithubProject github,
GitlabProject gitlab, List<Repo> gerritRepos, List<ProjectParticipant> contributors, List<ProjectParticipant> committers,
List<ProjectParticipant> projectLeads, List<Collaboration> industryCollaborations, Object specProjectWorkingGroup,
List<Release> releases, String topLevelProject) {
public Project(int nid, String projectId, String shortProjectId, String name, String summary, String url, String websiteUrl,
List<WebsiteRepo> websiteRepo, String logo, List<String> tags, List<Repo> githubRepos, List<Repo> gitlabRepos, GithubProject github,
GitlabProject gitlab, List<Repo> gerritRepos, List<ProjectParticipant> contributors, List<ProjectParticipant> committers,
List<ProjectParticipant> projectLeads, List<Collaboration> industryCollaborations, Object specProjectWorkingGroup,
List<Release> releases, String topLevelProject) {
this.nid = nid;
this.projectId = Objects.requireNonNull(projectId);
this.shortProjectId = Objects.requireNonNull(shortProjectId);
this.name = Objects.requireNonNull(name);
this.summary = Objects.requireNonNull(summary);
this.url = Objects.requireNonNull(url);
this.websiteUrl = Objects.requireNonNull(websiteUrl);
this.websiteRepo = Objects.requireNonNull(websiteRepo);
this.logo = Objects.requireNonNull(logo);
this.tags = Objects.requireNonNull(tags);
this.githubRepos = Objects.requireNonNull(githubRepos);
this.gitlabRepos = Objects.requireNonNull(gitlabRepos);
this.github = Objects.requireNonNull(github);
this.gitlab = Objects.requireNonNull(gitlab);
this.gerritRepos = Objects.requireNonNull(gerritRepos);
this.contributors = Objects.requireNonNull(contributors);
this.committers = Objects.requireNonNull(committers);
this.projectLeads = Objects.requireNonNull(projectLeads);
this.industryCollaborations = Objects.requireNonNull(industryCollaborations);
this.specProjectWorkingGroup = Objects.requireNonNull(specProjectWorkingGroup);
this.releases = Objects.requireNonNull(releases);
this.topLevelProject = Objects.requireNonNull(topLevelProject);
}
public Optional<Collaboration> getSpecWorkingGroup() {
// stored as map as empty returns an array instead of a map
Object specProjectWorkingGroup = specProjectWorkingGroup();
if (specProjectWorkingGroup instanceof Map) {
// we checked in line above that the map exists, so we can safely cast it
@SuppressWarnings("unchecked")
Map<Object, Object> map = (Map<Object, Object>) specProjectWorkingGroup;
Object name = map.get("name");
Object id = map.get("id");
if (name instanceof String nameStr && id instanceof String idStr) {
return Optional.of(ProjectCollaborationBuilder.builder().id(idStr).name(nameStr).build());
}
}
public Optional<Collaboration> getSpecWorkingGroup() {
// stored as map as empty returns an array instead of a map
Object specProjectWorkingGroup = specProjectWorkingGroup();
if (specProjectWorkingGroup instanceof Map) {
// we checked in line above that the map exists, so we can safely cast it
@SuppressWarnings("unchecked")
Map<Object, Object> map = (Map<Object, Object>) specProjectWorkingGroup;
return Optional.empty();
}
Object name = map.get("name");
Object id = map.get("id");
@RecordBuilder
public record WebsiteRepo(String checkoutDir, String sourceBranch, String url) {
if (name instanceof String nameStr && id instanceof String idStr) {
return Optional.of(ProjectCollaborationBuilder.builder().id(idStr).name(nameStr).build());
}
}
return Optional.empty();
public WebsiteRepo(String checkoutDir, String sourceBranch, String url) {
this.checkoutDir = Objects.requireNonNull(checkoutDir);
this.sourceBranch = Objects.requireNonNull(sourceBranch);
this.url = Objects.requireNonNull(url);
}
}
@RecordBuilder
public record WebsiteRepo(String checkoutDir, String sourceBranch, String url) {
@RecordBuilder
public record Repo(String url) {
public WebsiteRepo(String checkoutDir, String sourceBranch, String url) {
this.checkoutDir = Objects.requireNonNull(checkoutDir);
this.sourceBranch = Objects.requireNonNull(sourceBranch);
this.url = Objects.requireNonNull(url);
}
public Repo(String url) {
this.url = Objects.requireNonNull(url);
}
}
@RecordBuilder
public record Repo(String url) {
@RecordBuilder
public record GithubProject(String org, List<String> ignoredRepos) {
public Repo(String url) {
this.url = Objects.requireNonNull(url);
}
public GithubProject(String org, List<String> ignoredRepos) {
this.org = Objects.requireNonNull(org);
this.ignoredRepos = Objects.requireNonNull(ignoredRepos);
}
@RecordBuilder
public record GithubProject(String org, List<String> ignoredRepos) {
public GithubProject(String org, List<String> ignoredRepos) {
this.org = Objects.requireNonNull(org);
this.ignoredRepos = Objects.requireNonNull(ignoredRepos);
}
}
}
@RecordBuilder
public record ProjectParticipant(String username, String fullName, String url) {
@RecordBuilder
public record ProjectParticipant(String username, String fullName, String url) {
public ProjectParticipant(String username, String fullName, String url) {
this.username = Objects.requireNonNull(username);
this.fullName = Objects.requireNonNull(fullName);
this.url = Objects.requireNonNull(url);
}
public ProjectParticipant(String username, String fullName, String url) {
this.username = Objects.requireNonNull(username);
this.fullName = Objects.requireNonNull(fullName);
this.url = Objects.requireNonNull(url);
}
}
@RecordBuilder
public record Collaboration(String name, String id) {
@RecordBuilder
public record Collaboration(String name, String id) {
public Collaboration(String name, String id) {
this.name = name;
this.id = Objects.requireNonNull(id);
}
public Collaboration(String name, String id) {
this.name = name;
this.id = Objects.requireNonNull(id);
}
}
@RecordBuilder
public record Release(String name, String url) {
@RecordBuilder
public record Release(String name, String url, boolean tracked, List<String> associatedFiles) {
public Release(String name, String url) {
this.name = Objects.requireNonNull(name);
this.url = Objects.requireNonNull(url);
}
public Release(String name, String url, boolean tracked, List<String> associatedFiles) {
this.name = Objects.requireNonNull(name);
this.url = Objects.requireNonNull(url);
this.associatedFiles = Objects.requireNonNull(associatedFiles);
this.tracked = tracked;
}
}
}
......@@ -46,169 +46,151 @@ import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class MockProjectsAPI implements ProjectsAPI {
private List<Project> projects;
private List<InterestGroup> igs;
private List<Project> projects;
private List<InterestGroup> igs;
public MockProjectsAPI() {
this.projects = new ArrayList<>();
public MockProjectsAPI() {
this.projects = new ArrayList<>();
// sample repos
Repo r1 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/sample").build();
Repo r2 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/test").build();
Repo r3 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/prototype.git").build();
Repo r4 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/tck-proto").build();
Repo r5 = ProjectRepoBuilder.builder().url("/gitroot/sample/gerrit.project.git").build();
Repo r6 = ProjectRepoBuilder.builder().url("/gitroot/sample/gerrit.other-project").build();
// sample repos
Repo r1 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/sample").build();
Repo r2 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/test").build();
Repo r3 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/prototype.git").build();
Repo r4 = ProjectRepoBuilder.builder().url("http://www.github.com/eclipsefdn/tck-proto").build();
Repo r5 = ProjectRepoBuilder.builder().url("/gitroot/sample/gerrit.project.git").build();
Repo r6 = ProjectRepoBuilder.builder().url("/gitroot/sample/gerrit.other-project").build();
// sample users
ProjectParticipant u1 = ProjectProjectParticipantBuilder.builder().url("").username("da_wizz").fullName("da_wizz").build();
ProjectParticipant u2 = ProjectProjectParticipantBuilder.builder().url("").username("grunter").fullName("grunter").build();
// sample users
ProjectParticipant u1 = ProjectProjectParticipantBuilder.builder().url("").username("da_wizz").fullName("da_wizz").build();
ProjectParticipant u2 = ProjectProjectParticipantBuilder.builder().url("").username("grunter").fullName("grunter").build();
this.projects
.add(ProjectBuilder
.builder()
.name("Sample project")
.projectId("sample.proj")
.shortProjectId("sample.proj")
.summary("summary")
.url("project.url.com")
.websiteUrl("someproject.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.githubRepos(Arrays.asList(r1, r2))
.gitlabRepos(Collections.emptyList())
.gitlab(GitlabProjectBuilder.builder().ignoredSubGroups(Collections.emptyList()).projectGroup("").build())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.gerritRepos(Arrays.asList(r5))
.contributors(Collections.emptyList())
.committers(Arrays.asList(u1, u2))
.projectLeads(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.specProjectWorkingGroup(Collections.emptyMap())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
this.projects
.add(ProjectBuilder
.builder()
.nid(1)
.name("Sample project")
.projectId("sample.proj")
.shortProjectId("sample.proj")
.summary("summary")
.url("project.url.com")
.websiteUrl("someproject.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.githubRepos(Arrays.asList(r1, r2))
.gitlabRepos(Collections.emptyList())
.gitlab(GitlabProjectBuilder.builder().ignoredSubGroups(Collections.emptyList()).projectGroup("").build())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.gerritRepos(Arrays.asList(r5))
.contributors(Collections.emptyList())
.committers(Arrays.asList(u1, u2))
.projectLeads(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.specProjectWorkingGroup(Collections.emptyMap())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
this.projects
.add(ProjectBuilder
.builder()
.name("Prototype thing")
.projectId("sample.proto")
.specProjectWorkingGroup(Collections.emptyMap())
.githubRepos(Arrays.asList(r3))
.gitlabRepos(Collections.emptyList())
.gerritRepos(Arrays.asList(r6))
.committers(Arrays.asList(u2))
.projectLeads(Collections.emptyList())
.gitlab(GitlabProjectBuilder
.builder()
.ignoredSubGroups(Collections.emptyList())
.projectGroup("eclipse/dash-second")
.build())
.shortProjectId("sample.proto")
.websiteUrl("someproject.com")
.summary("summary")
.url("project.url.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.contributors(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
this.projects
.add(ProjectBuilder
.builder()
.nid(2)
.name("Prototype thing")
.projectId("sample.proto")
.specProjectWorkingGroup(Collections.emptyMap())
.githubRepos(Arrays.asList(r3))
.gitlabRepos(Collections.emptyList())
.gerritRepos(Arrays.asList(r6))
.committers(Arrays.asList(u2))
.projectLeads(Collections.emptyList())
.gitlab(GitlabProjectBuilder.builder().ignoredSubGroups(Collections.emptyList()).projectGroup("eclipse/dash-second").build())
.shortProjectId("sample.proto")
.websiteUrl("someproject.com")
.summary("summary")
.url("project.url.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.contributors(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
this.projects
.add(ProjectBuilder
.builder()
.name("Spec project")
.projectId("spec.proj")
.specProjectWorkingGroup(Map.of("id", "proj1", "name", "proj1"))
.githubRepos(Arrays.asList(r4))
.gitlabRepos(Collections.emptyList())
.gerritRepos(Collections.emptyList())
.gitlab(GitlabProjectBuilder
.builder()
.ignoredSubGroups(Arrays.asList("eclipse/dash/mirror"))
.projectGroup("eclipse/dash")
.build())
.committers(Arrays.asList(u1, u2))
.projectLeads(Collections.emptyList())
.shortProjectId("spec.proj")
.summary("summary")
.url("project.url.com")
.websiteUrl("someproject.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.contributors(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
this.projects
.add(ProjectBuilder
.builder()
.nid(3)
.name("Spec project")
.projectId("spec.proj")
.specProjectWorkingGroup(Map.of("id", "proj1", "name", "proj1"))
.githubRepos(Arrays.asList(r4))
.gitlabRepos(Collections.emptyList())
.gerritRepos(Collections.emptyList())
.gitlab(
GitlabProjectBuilder.builder().ignoredSubGroups(Arrays.asList("eclipse/dash/mirror")).projectGroup("eclipse/dash").build())
.committers(Arrays.asList(u1, u2))
.projectLeads(Collections.emptyList())
.shortProjectId("spec.proj")
.summary("summary")
.url("project.url.com")
.websiteUrl("someproject.com")
.websiteRepo(Collections.emptyList())
.logo("logoUrl.com")
.tags(Collections.emptyList())
.github(ProjectGithubProjectBuilder.builder().org("org name").ignoredRepos(Collections.emptyList()).build())
.contributors(Collections.emptyList())
.industryCollaborations(Collections.emptyList())
.releases(Collections.emptyList())
.topLevelProject("eclipse")
.build());
igs = Arrays
.asList(InterestGroupBuilder
.builder()
.projectId("foundation-internal.ig.mittens")
.id("1")
.logo("")
.state("active")
.title("Magical IG Tributed To Eclipse News Sources")
.description(InterestGroupDescriptorBuilder.builder().full("Sample").summary("Sample").build())
.scope(InterestGroupDescriptorBuilder.builder().full("Sample").summary("Sample").build())
.gitlab(GitlabProjectBuilder
.builder()
.ignoredSubGroups(Collections.emptyList())
.projectGroup("eclipse-ig/mittens")
.build())
.leads(Arrays
.asList(InterestGroupInterestGroupParticipantBuilder
.builder()
.url("https://api.eclipse.org/account/profile/zacharysabourin")
.username("zacharysabourin")
.fullName("zachary sabourin")
.organization(InterestGroupOrganizationBuilder
.builder()
.documents(Collections.emptyMap())
.id("id")
.name("org")
.build())
.build()))
.participants(Arrays
.asList(InterestGroupInterestGroupParticipantBuilder
.builder()
.url("https://api.eclipse.org/account/profile/skilpatrick")
.username("skilpatrick")
.fullName("Skil Patrick")
.organization(InterestGroupOrganizationBuilder
.builder()
.documents(Collections.emptyMap())
.id("id")
.name("org")
.build())
.build()))
.shortProjectId("mittens")
.resources(InterestGroupResourceBuilder.builder().members("members").website("google.com").build())
.mailingList("mailinglist.com")
.build());
}
@Override
public Uni<RestResponse<List<Project>>> getProjects(BaseAPIParameters params, int isSpecProject) {
List<Project> out = projects;
if (isSpecProject == 1) {
out = out.stream().filter(p -> p.getSpecWorkingGroup().isPresent()).toList();
}
igs = Arrays
.asList(InterestGroupBuilder
.builder()
.projectId("foundation-internal.ig.mittens")
.id("1")
.logo("")
.state("active")
.title("Magical IG Tributed To Eclipse News Sources")
.description(InterestGroupDescriptorBuilder.builder().full("Sample").summary("Sample").build())
.scope(InterestGroupDescriptorBuilder.builder().full("Sample").summary("Sample").build())
.gitlab(GitlabProjectBuilder.builder().ignoredSubGroups(Collections.emptyList()).projectGroup("eclipse-ig/mittens").build())
.leads(Arrays
.asList(InterestGroupInterestGroupParticipantBuilder
.builder()
.url("https://api.eclipse.org/account/profile/zacharysabourin")
.username("zacharysabourin")
.fullName("zachary sabourin")
.organization(InterestGroupOrganizationBuilder.builder().documents(Collections.emptyMap()).id("id").name("org").build())
.build()))
.participants(Arrays
.asList(InterestGroupInterestGroupParticipantBuilder
.builder()
.url("https://api.eclipse.org/account/profile/skilpatrick")
.username("skilpatrick")
.fullName("Skil Patrick")
.organization(InterestGroupOrganizationBuilder.builder().documents(Collections.emptyMap()).id("id").name("org").build())
.build()))
.shortProjectId("mittens")
.resources(InterestGroupResourceBuilder.builder().members("members").website("google.com").build())
.mailingList("mailinglist.com")
.build());
}
return Uni.createFrom().item(MockDataPaginationHandler.paginateData(params, out));
@Override
public Uni<RestResponse<List<Project>>> getProjects(BaseAPIParameters params, int isSpecProject) {
List<Project> out = projects;
if (isSpecProject == 1) {
out = out.stream().filter(p -> p.getSpecWorkingGroup().isPresent()).toList();
}
@Override
public Uni<RestResponse<List<InterestGroup>>> getInterestGroups(BaseAPIParameters params) {
return Uni.createFrom().item(MockDataPaginationHandler.paginateData(params, igs));
}
return Uni.createFrom().item(MockDataPaginationHandler.paginateData(params, out));
}
@Override
public Uni<RestResponse<List<InterestGroup>>> getInterestGroups(BaseAPIParameters params) {
return Uni.createFrom().item(MockDataPaginationHandler.paginateData(params, igs));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment