com.teamscale.commons.links.TeamscaleCommitLinkProvider 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.PublicProjectId;
import org.conqat.engine.service.shared.ServiceUtils;
import org.conqat.engine.service.shared.client.ServiceClientUris;
import org.conqat.lib.commons.string.StringUtils;
/**
* Helper class for obtaining links to global and project specific services of
* the current Teamscale instance. If a non-null {@link CommitDescriptor} is
* passed, all project services supporting the
* {@link ServiceClientUris#TIMESTAMP_PARAMETER_NAME} use this commit for
* queries.
*/
public class TeamscaleCommitLinkProvider extends TeamscaleProjectLinkProvider {
private final CommitDescriptor commit;
public TeamscaleCommitLinkProvider(String baseUrl, PublicProjectId projectId, CommitDescriptor commit) {
super(baseUrl, projectId);
this.commit = commit;
}
/** Returns a link to the findings detail view for the given finding. */
public String createFindingsDetailLink(String findingId) {
return baseUrl + "findings.html#details/" + ServiceUtils.encodePathSegment(projectId.toString())
+ createIdOptionString(findingId);
}
/** Returns a link to the activity details view for the current commit. */
public String createCommitDetailsLink() {
return baseUrl + "activity.html#details/" + ServiceUtils.encodePathSegment(projectId.toString())
+ createOptionString();
}
private String createOptionString() {
if (commit == null) {
return StringUtils.EMPTY_STRING;
}
return ServiceClientUris.createOptionString(ServiceClientUris.TIMESTAMP_PARAMETER_NAME,
commit.toServiceCallFormat());
}
private String createIdOptionString(String findingId) {
if (commit == null) {
return ServiceClientUris.createOptionString("id", findingId);
}
return ServiceClientUris.createOptionString("id", findingId, ServiceClientUris.TIMESTAMP_PARAMETER_NAME,
commit.toServiceCallFormat());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy