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
/*
* 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.conqat.engine.index.shared.CommitDescriptor;
import org.conqat.engine.index.shared.MergeRequestIdentifier;
import org.conqat.engine.index.shared.PublicProjectId;
import org.conqat.engine.service.shared.ServiceUtils;
import org.conqat.engine.service.shared.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.html#findings/" + ServiceUtils.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.html#merge-requests/" + ServiceUtils.encodePathSegment(projectId.toString()) + "/"
+ ServiceUtils.encodePathSegment(mergeRequestId.toString());
}
/** Returns a link to the issue perspective for the given issue. */
public String createIssuePerspectiveLink(String issueId, boolean hideResolvedFindingsInLink) {
String link = baseUrl + "activity.html#issues/" + ServiceUtils.encodePathSegment(projectId.toString())
+ "/?action=view&id=" + ServiceUtils.encodeQueryParameter(issueId);
if (hideResolvedFindingsInLink) {
link += "&hideResolvedFindings=true";
}
return link;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy