Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up SourceSpecification, part 1 #685

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.finos.legend.sdlc.domain.model.revision;

import org.finos.legend.sdlc.domain.model.patch.Patch;
import org.finos.legend.sdlc.domain.model.project.workspace.Workspace;
import org.finos.legend.sdlc.domain.model.version.Version;

Expand All @@ -28,4 +29,6 @@ public interface RevisionStatus
List<Workspace> getWorkspaces();

List<Version> getVersions();

List<Patch> getPatches();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,54 @@

package org.finos.legend.sdlc.server.domain.api.backup;

import org.finos.legend.sdlc.server.domain.api.project.SourceSpecification;
import org.finos.legend.sdlc.domain.model.project.workspace.WorkspaceType;
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.WorkspaceSpecification;

public interface BackupApi
{
/**
* Discard the backup workspace
*
* @param projectId project id
* @param workspaceSpecification workspace specification
*/
void discardBackupWorkspace(String projectId, WorkspaceSpecification workspaceSpecification);

/**
* Recover the backup workspace
*
* @param projectId project id
* @param workspaceSpecification workspace specification
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
*/
void recoverBackupWorkspace(String projectId, WorkspaceSpecification workspaceSpecification, boolean forceRecovery);

// Deprecated APIs

/**
* Discard the backup user workspace
*
* @param projectId project id
* @param workspaceId id of backup workspace
* @param projectId project id
* @param workspaceId id of backup workspace
*/
@Deprecated
default void discardBackupUserWorkspace(String projectId, String workspaceId)
{
this.discardBackupWorkspace(projectId, SourceSpecification.newUserWorkspaceSourceSpecification(workspaceId));
discardBackupWorkspace(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, WorkspaceType.USER));
}

/**
* Discard the backup group workspace
*
* @param projectId project id
* @param workspaceId id of backup workspace
* @param projectId project id
* @param workspaceId id of backup workspace
*/
@Deprecated
default void discardBackupGroupWorkspace(String projectId, String workspaceId)
{
this.discardBackupWorkspace(projectId, SourceSpecification.newGroupWorkspaceSourceSpecification(workspaceId));
discardBackupWorkspace(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, WorkspaceType.GROUP));
}

/**
Expand All @@ -46,38 +70,56 @@ default void discardBackupGroupWorkspace(String projectId, String workspaceId)
* @param projectId project id
* @param sourceSpecification source specification
*/
void discardBackupWorkspace(String projectId, SourceSpecification sourceSpecification);
@Deprecated
default void discardBackupWorkspace(String projectId, SourceSpecification sourceSpecification)
{
if (!(sourceSpecification instanceof WorkspaceSourceSpecification))
{
throw new IllegalArgumentException("Not a workspace source specification: " + sourceSpecification);
}
discardBackupWorkspace(projectId, ((WorkspaceSourceSpecification) sourceSpecification).getWorkspaceSpecification());
}

/**
* Recover the backup user workspace
*
* @param projectId project id
* @param workspaceId workspace id
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
* @param projectId project id
* @param workspaceId workspace id
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
*/
@Deprecated
default void recoverBackupUserWorkspace(String projectId, String workspaceId, boolean forceRecovery)
{
this.recoverBackupWorkspace(projectId, SourceSpecification.newUserWorkspaceSourceSpecification(workspaceId), forceRecovery);
recoverBackupWorkspace(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, WorkspaceType.USER), forceRecovery);
}

/**
* Recover the backup group workspace
*
* @param projectId project id
* @param workspaceId workspace id
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
* @param projectId project id
* @param workspaceId workspace id
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
*/
@Deprecated
default void recoverBackupGroupWorkspace(String projectId, String workspaceId, boolean forceRecovery)
{
this.recoverBackupWorkspace(projectId, SourceSpecification.newGroupWorkspaceSourceSpecification(workspaceId), forceRecovery);
recoverBackupWorkspace(projectId, WorkspaceSpecification.newWorkspaceSpecification(workspaceId, WorkspaceType.GROUP), forceRecovery);
}

/**
* Recover the backup workspace
*
* @param projectId project id
* @param projectId project id
* @param sourceSpecification source specification
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
* @param forceRecovery flag indicating that if the workspace and its backup both exist, we will override the workspace by its backup
*/
void recoverBackupWorkspace(String projectId, SourceSpecification sourceSpecification, boolean forceRecovery);
@Deprecated
default void recoverBackupWorkspace(String projectId, SourceSpecification sourceSpecification, boolean forceRecovery)
{
if (!(sourceSpecification instanceof WorkspaceSourceSpecification))
{
throw new IllegalArgumentException("Not a workspace source specification: " + sourceSpecification);
}
recoverBackupWorkspace(projectId, ((WorkspaceSourceSpecification) sourceSpecification).getWorkspaceSpecification(), forceRecovery);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,135 +17,122 @@
import org.finos.legend.sdlc.domain.model.comparison.Comparison;
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.SourceSpecification;
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.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))
{
throw new IllegalArgumentException("Not a 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
Loading