Skip to content

Commit

Permalink
Clean up SourceSpecification
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-m-knight-gs committed Jul 27, 2023
1 parent eba38a5 commit bdd92ef
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,134 +18,122 @@
import org.finos.legend.sdlc.domain.model.project.workspace.WorkspaceType;
import org.finos.legend.sdlc.domain.model.version.VersionId;
import org.finos.legend.sdlc.server.domain.api.project.source.SourceSpecification;
import org.finos.legend.sdlc.server.domain.api.project.source.WorkspaceSourceSpecification;
import org.finos.legend.sdlc.server.domain.api.workspace.ProjectWorkspaceSource;
import org.finos.legend.sdlc.server.domain.api.workspace.WorkspaceSource;
import org.finos.legend.sdlc.server.domain.api.workspace.WorkspaceSpecification;
import org.finos.legend.sdlc.server.project.ProjectFileAccessProvider;

public interface ComparisonApi
{
/**
* Get the comparison between user workspace HEAD and BASE
* <p>
* Given a user workspace, returns the comparison from the creation of the workspace
* to the current revision of the workspace
* Get the comparison between workspace HEAD (current revision) and workspace BASE (creation revision).
*
* @param projectId project id
* @param workspaceId workspace id
* @return comparison between user workspace HEAD and BASE
* @param projectId project id
* @param workspaceSpecification workspace specification
* @return comparison between workspace HEAD and BASE
*/
default Comparison getUserWorkspaceCreationComparison(String projectId, String workspaceId)
{
return this.getWorkspaceCreationComparison(projectId, workspaceId, WorkspaceType.USER);
}
Comparison getWorkspaceCreationComparison(String projectId, WorkspaceSpecification workspaceSpecification);

/**
* Get the comparison between group workspace HEAD and BASE
* <p>
* Given a group workspace, returns the comparison from the creation of the workspace
* to the current revision of the workspace
* Get the comparison between the HEAD (current revision) of a workspace and its source.
*
* @param projectId project id
* @param workspaceId workspace id
* @return comparison between group workspace HEAD and BASE
* @param projectId project id
* @param workspaceSpecification workspace specification
* @return comparison between user workspace HEAD and workspace source HEAD
*/
Comparison getWorkspaceSourceComparison(String projectId, WorkspaceSpecification workspaceSpecification);

/**
* Get the comparison for a given review between the HEAD (current revision) of its source (workspace) and target.
* This is equivalent to calling {@link #getWorkspaceSourceComparison} for the source workspace of the review.
*
* @param projectId project id
* @param reviewId review id
* @return comparison between review source HEAD and target HEAD
*/
Comparison getReviewComparison(String projectId, String reviewId);

/**
* Get the comparison for a given review between the HEAD (current revision) and BASE (creation revision) of its
* source workspace. This is equivalent to calling {@link #getWorkspaceCreationComparison} for the source workspace
* of the reivew.
*
* @param projectId project id
* @param reviewId review id
* @return comparison between review workspace HEAD and BASE
*/
Comparison getReviewWorkspaceCreationComparison(String projectId, String reviewId);


// Deprecated APIs

@Deprecated
default Comparison getUserWorkspaceCreationComparison(String projectId, String workspaceId)
{
return getWorkspaceCreationComparison(projectId, workspaceId, WorkspaceType.USER);
}

@Deprecated
default Comparison getGroupWorkspaceCreationComparison(String projectId, String workspaceId)
{
return this.getWorkspaceCreationComparison(projectId, workspaceId, WorkspaceType.GROUP);
}

/**
* Get the comparison between workspace HEAD and workspace BASE
* <p>
* Given a workspace, returns the comparison from the creation of the workspace
* to the current revision of the workspace
*
* @param projectId project id
* @param sourceSpecification source specification
* @return comparison between workspace HEAD and BASE
*/
Comparison getWorkspaceCreationComparison(String projectId, SourceSpecification sourceSpecification);
@Deprecated
default Comparison getWorkspaceCreationComparison(String projectId, SourceSpecification sourceSpecification)
{
if (!(sourceSpecification instanceof WorkspaceSourceSpecification))
{
throw new IllegalArgumentException("Not a workspace source specification: " + sourceSpecification);
}
return getWorkspaceCreationComparison(projectId, ((WorkspaceSourceSpecification) sourceSpecification).getWorkspaceSpecification());
}

@Deprecated
default Comparison getWorkspaceCreationComparison(String projectId, String workspaceId, WorkspaceType workspaceType)
{
return this.getWorkspaceCreationComparison(projectId, SourceSpecification.newSourceSpecification(workspaceId, workspaceType));
return getWorkspaceCreationComparison(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, workspaceType));
}

/**
* Get the comparison between user workspace HEAD and project HEAD
* <p>
* Given a user workspace, returns the comparison from the current revision of the
* project to the current revision of the workspace
*
* @param projectId project id
* @param workspaceId workspace id
* @return comparison between user workspace HEAD and project HEAD
*/
@Deprecated
default Comparison getUserWorkspaceProjectComparison(String projectId, String workspaceId)
{
return this.getWorkspaceProjectComparison(projectId, workspaceId, WorkspaceType.USER);
}

/**
* Get the comparison between group workspace HEAD and project HEAD
* <p>
* Given a group workspace, returns the comparison from the current revision of the
* project to the current revision of the workspace
*
* @param projectId project id
* @param workspaceId workspace id
* @return comparison between group workspace HEAD and project HEAD
*/
@Deprecated
default Comparison getGroupWorkspaceProjectComparison(String projectId, String workspaceId)
{
return this.getWorkspaceProjectComparison(projectId, workspaceId, WorkspaceType.GROUP);
}

/**
* Get the comparison between workspace HEAD and project HEAD
* <p>
* Given a workspace, returns the comparison from the current revision of the
* project to the current revision of the workspace
*
* @param projectId project id
* @param sourceSpecification source specification
* @return comparison between workspace HEAD and project HEAD
*/
Comparison getWorkspaceProjectComparison(String projectId, SourceSpecification sourceSpecification);
@Deprecated
default Comparison getWorkspaceProjectComparison(String projectId, SourceSpecification sourceSpecification)
{
if (!(sourceSpecification instanceof WorkspaceSourceSpecification) || !(((WorkspaceSourceSpecification) sourceSpecification).getWorkspaceSpecification().getSource() instanceof ProjectWorkspaceSource))
{
throw new IllegalArgumentException("Not a project workspace source specification: " + sourceSpecification);
}
return getWorkspaceSourceComparison(projectId, ((WorkspaceSourceSpecification) sourceSpecification).getWorkspaceSpecification());
}

@Deprecated
default Comparison getWorkspaceProjectComparison(String projectId, String workspaceId, WorkspaceType workspaceType)
{
return this.getWorkspaceProjectComparison(projectId, SourceSpecification.newSourceSpecification(workspaceId, workspaceType));
return getWorkspaceSourceComparison(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, workspaceType, ProjectFileAccessProvider.WorkspaceAccessType.WORKSPACE, WorkspaceSource.projectWorkspaceSource()));
}

/**
* Get the comparison for a given review (between review workspace HEAD and project HEAD)
* <p>
* Given a review, returns the comparison for that review
* Uses the diff ref (start and end revision id for review) to get revisions ids for comparison
*
* @param projectId project id
* @param patchReleaseVersionId patch release version
* @param reviewId review id
* @return comparison between review workspace HEAD and project HEAD
*/
Comparison getReviewComparison(String projectId, VersionId patchReleaseVersionId, String reviewId);

default Comparison getReviewComparison(String projectId, String reviewId)
@Deprecated
default Comparison getReviewComparison(String projectId, VersionId patchReleaseVersionId, String reviewId)
{
return this.getReviewComparison(projectId, null, reviewId);
return getReviewComparison(projectId, reviewId);
}

/**
* Get the comparison for a given review (between review workspace HEAD and workspace BASE)
*
* @param projectId project id
* @param patchReleaseVersionId patch release version
* @param reviewId review id
* @return comparison between review workspace HEAD and BASE
*/
Comparison getReviewWorkspaceCreationComparison(String projectId, VersionId patchReleaseVersionId, String reviewId);

default Comparison getReviewWorkspaceCreationComparison(String projectId, String reviewId)
@Deprecated
default Comparison getReviewWorkspaceCreationComparison(String projectId, VersionId patchReleaseVersionId, String reviewId)
{
return this.getReviewWorkspaceCreationComparison(projectId, null, reviewId);
return getReviewWorkspaceCreationComparison(projectId, reviewId);
}
}

Loading

0 comments on commit bdd92ef

Please sign in to comment.