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
package com.teamscale.commons.links;
import org.conqat.engine.index.shared.CommitDescriptor;
import org.conqat.engine.index.shared.MergeRequestIdentifier;
import org.conqat.engine.service.shared.ServiceUtils;
import org.conqat.engine.service.shared.client.ServiceClientUris;
import com.google.common.base.Preconditions;
/**
* Helper class for obtaining links to global and project specific services of
* the current Teamscale instance.
*/
public class TeamscaleProjectLinkProvider extends TeamscaleLinkProvider {
/** The project alias or id if no alias is set. */
protected final String projectAliasOrId;
public TeamscaleProjectLinkProvider(String baseUrl, String projectAliasOrId) {
super(baseUrl);
Preconditions.checkNotNull(projectAliasOrId, "Project alias or id can't be null.");
this.projectAliasOrId = projectAliasOrId;
}
/** Returns a link to the delta perspective for the given commit. */
public String createDeltaPerspectiveLink(CommitDescriptor firstCommit, CommitDescriptor lastCommit,
boolean mergeRequestMode) {
String result = baseUrl + "delta.html#findings/" + ServiceUtils.encodePathSegment(projectAliasOrId)
+ 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.html#merge-requests/" + ServiceUtils.encodePathSegment(projectAliasOrId) + "/"
+ ServiceUtils.encodePathSegment(mergeRequestId.toString());
}
/** Returns a link to the issue perspective for the given issue. */
public String createIssuePerspectiveLink(String issueId) {
return baseUrl + "issues.html#/" + ServiceUtils.encodePathSegment(projectAliasOrId) + "/"
+ ServiceUtils.encodePathSegment(issueId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy