All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.teamscale.commons.links.TeamscaleCommitLinkProvider Maven / Gradle / Ivy

There is a newer version: 2025.1.0-rc2
Show newest version
package com.teamscale.commons.links;

import org.conqat.engine.index.shared.CommitDescriptor;
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. 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, String projectAliasOrId, CommitDescriptor commit) {
		super(baseUrl, projectAliasOrId);
		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(projectAliasOrId)
				+ createOptionString(findingId);
	}

	private String createOptionString(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