com.teamscale.commons.links.TeamscaleProjectLinkProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
The newest version!
/*
* Copyright (c) CQSE GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.teamscale.commons.links;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.conqat.engine.index.shared.CommitDescriptor;
import org.conqat.engine.index.shared.MergeRequestIdentifier;
import org.conqat.engine.index.shared.PublicProjectId;
import org.conqat.lib.commons.net.UrlUtils;
import com.teamscale.commons.service.client.ServiceClientUris;
/**
* Helper class for obtaining links to global and project specific services of the current Teamscale
* instance.
*/
public class TeamscaleProjectLinkProvider extends TeamscaleLinkProvider {
/** The primary project ID. May be null. */
protected final PublicProjectId projectId;
public TeamscaleProjectLinkProvider(String baseUrl, PublicProjectId projectId) {
super(baseUrl);
this.projectId = projectId;
}
/** Returns a link to the delta perspective for the given commit. */
public String createDeltaPerspectiveLink(CommitDescriptor firstCommit, CommitDescriptor lastCommit,
boolean mergeRequestMode) {
String result = baseUrl + "delta/findings/" + UrlUtils.encodePathSegment(projectId.toString())
+ ServiceClientUris.createOptionString("from", firstCommit.toServiceCallFormat(), "to",
lastCommit.toServiceCallFormat());
if (mergeRequestMode) {
result += "&showMergeFindings=true";
}
return result;
}
/** Returns a link to the merge request details view. */
public String createMergeRequestDetailsLink(MergeRequestIdentifier mergeRequestId) {
return baseUrl + "activity/merge-requests/" + UrlUtils.encodePathSegment(projectId.toString()) + "/"
+ UrlUtils.encodePathSegment(mergeRequestId.toString());
}
/** Returns a link to the task details view. */
public String createTaskDetailLink(int taskId) {
return baseUrl + "qualitycontrol/tasks/" + UrlUtils.encodePathSegment(projectId.toString()) + "/?id=" + taskId;
}
/**
* Returns a link to the issue perspective for the given issue.
*
* @param issueId
* The Teamscale internal id of the issue (see
* {@code TeamscaleIssue.TeamscaleIssueId#getInternalId()})
* @param branch
* The branch to obtain TGA info from. Can be {@code null} if the branch should be
* auto-selected.
*/
public String createIssuePerspectiveLink(String issueId, @Nullable String branch,
boolean hideResolvedFindingsInLink) {
String link = baseUrl + "activity/issues/" + UrlUtils.encodePathSegment(projectId.toString())
+ "/?action=view&id=" + UrlUtils.encodeQueryParameter(issueId);
if (hideResolvedFindingsInLink) {
link += "&hideResolvedFindings=true";
}
if (branch != null) {
link += "&issueBranch=" + UrlUtils.encodeQueryParameter(branch);
}
return link;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy