Skip to content
Open
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 @@ -15,11 +15,63 @@

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

import org.finos.legend.sdlc.domain.model.project.DevelopmentStream;
import org.finos.legend.sdlc.domain.model.project.DevelopmentStreamType;
import org.finos.legend.sdlc.domain.model.project.DevelopmentStreamVisitor;
import org.finos.legend.sdlc.domain.model.version.VersionId;

public interface Patch
import java.util.Objects;

public class Patch extends DevelopmentStream
{
String getProjectId();
private String projectId;
private VersionId patchReleaseVersionId;

public Patch(String projectId, VersionId patchReleaseVersionId)
{
super(DevelopmentStreamType.PATCH.toString());
this.projectId = Objects.requireNonNull(projectId, "projectId may not be null");
this.patchReleaseVersionId = Objects.requireNonNull(patchReleaseVersionId, "patchReleaseVersionId is not null");
}

public Patch()
{
super(DevelopmentStreamType.PATCH.toString());
}

public String getProjectId()
{
return this.projectId;
}

public VersionId getPatchReleaseVersionId()
{
return this.patchReleaseVersionId;
}

@Override
public <T> T visit(DevelopmentStreamVisitor<T> visitor)
{
return visitor.visit(this);
}

@Override
public boolean equals(Object other)
{
return (this == other) ||
((other instanceof Patch) && this.patchReleaseVersionId.equals(((Patch) other).patchReleaseVersionId));
}

@Override
public int hashCode()
{
return this.patchReleaseVersionId.hashCode();
}

@Override
protected StringBuilder appendAdditionalInfo(StringBuilder builder)
{
return this.patchReleaseVersionId.appendVersionIdString(builder.append(" patchVersion="));
}

VersionId getPatchReleaseVersionId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,55 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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

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

import org.finos.legend.sdlc.domain.model.patch.Patch;
import org.finos.legend.sdlc.domain.model.version.VersionId;
import org.finos.legend.sdlc.server.domain.api.project.source.SourceSpecification;

public abstract class WorkspaceSource
import java.util.Objects;

public abstract class DevelopmentStream
{
WorkspaceSource()
private static String type;

public DevelopmentStream(String type)
{
this.type = Objects.requireNonNull(type, "developemnt stream type amy not be null");
}

public abstract SourceSpecification getSourceSpecification();

public abstract <T> T visit(WorkspaceSourceVisitor<T> visitor);
public abstract <T> T visit(DevelopmentStreamVisitor<T> visitor);

@Override
public String toString()
{
return appendString(new StringBuilder()).toString();
}

StringBuilder appendString(StringBuilder builder)
public StringBuilder appendString(StringBuilder builder)
{
return appendAdditionalInfo(builder.append("<").append(getClass().getSimpleName())).append('>');
}

protected abstract StringBuilder appendAdditionalInfo(StringBuilder builder);

public static ProjectWorkspaceSource projectWorkspaceSource()
public String getType()
{
return this.type;
}

public static ProjectDevelopmentStream projectDevelopmentStream()
{
return ProjectWorkspaceSource.INSTANCE;
return ProjectDevelopmentStream.INSTANCE;
}

public static PatchWorkspaceSource patchWorkspaceSource(String patch)
public static Patch patch(String projectId, VersionId patchReleaseVersionId)
{
return patchWorkspaceSource(VersionId.parseVersionId(patch));
return new Patch(projectId, patchReleaseVersionId);
}

public static PatchWorkspaceSource patchWorkspaceSource(VersionId patch)
public static Patch patch(String projectId, String patchReleaseVersionId)
{
return new PatchWorkspaceSource(patch);
return new Patch(projectId, VersionId.parseVersionId(patchReleaseVersionId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,42 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.finos.legend.sdlc.server.domain.api.workspace;
package org.finos.legend.sdlc.domain.model.project;

import org.finos.legend.sdlc.domain.model.patch.Patch;

import java.util.function.Consumer;

public abstract class WorkspaceSourceConsumer implements WorkspaceSourceVisitor<Void>, Consumer<WorkspaceSource>
public abstract class DevelopmentStreamConsumer implements DevelopmentStreamVisitor<Void>, Consumer<DevelopmentStream>
{
@Override
public final Void visit(ProjectWorkspaceSource source)
public final Void visit(ProjectDevelopmentStream source)
{
accept(source);
return null;
}

@Override
public final Void visit(PatchWorkspaceSource source)
public final Void visit(Patch source)
{
accept(source);
return null;
}

@Override
public final void accept(WorkspaceSource source)
public final void accept(DevelopmentStream source)
{
source.visit(this);
}

protected void accept(ProjectWorkspaceSource source)
protected void accept(ProjectDevelopmentStream source)
{
// nothing by default
}

protected void accept(PatchWorkspaceSource source)
protected void accept(Patch source)
{
// nothing by default
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2023 Goldman Sachs
//
// 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 org.finos.legend.sdlc.domain.model.project;

public enum DevelopmentStreamType
{
PROJECT_MAIN, PATCH
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.finos.legend.sdlc.server.domain.api.workspace;
package org.finos.legend.sdlc.domain.model.project;

import org.finos.legend.sdlc.domain.model.patch.Patch;

import java.util.function.Function;

public interface WorkspaceSourceVisitor<T> extends Function<WorkspaceSource, T>
public interface DevelopmentStreamVisitor<T> extends Function<DevelopmentStream, T>
{
default T visit(ProjectWorkspaceSource source)
default T visit(ProjectDevelopmentStream source)
{
throw new UnsupportedOperationException("Unsupported workspace source specification: " + source);
throw new UnsupportedOperationException("Unsupported development stream specification: " + source);
}

default T visit(PatchWorkspaceSource source)
default T visit(Patch source)
{
throw new UnsupportedOperationException("Unsupported workspace source specification: " + source);
throw new UnsupportedOperationException("Unsupported development stream specification: " + source);
}

@Override
default T apply(WorkspaceSource source)
default T apply(DevelopmentStream source)
{
return source.visit(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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

import org.finos.legend.sdlc.server.domain.api.project.source.SourceSpecification;
package org.finos.legend.sdlc.domain.model.project;

public class ProjectWorkspaceSource extends WorkspaceSource
public class ProjectDevelopmentStream extends DevelopmentStream
{
static final ProjectWorkspaceSource INSTANCE = new ProjectWorkspaceSource();
static final ProjectDevelopmentStream INSTANCE = new ProjectDevelopmentStream();

private ProjectWorkspaceSource()
private ProjectDevelopmentStream()
{
super(DevelopmentStreamType.PROJECT_MAIN.toString());
}

@Override
public SourceSpecification getSourceSpecification()
{
return SourceSpecification.projectSourceSpecification();
}

@Override
public <T> T visit(WorkspaceSourceVisitor<T> visitor)
public <T> T visit(DevelopmentStreamVisitor<T> visitor)
{
return visitor.visit(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@

package org.finos.legend.sdlc.domain.model.project.workspace;

import org.finos.legend.sdlc.domain.model.project.DevelopmentStream;

public interface Workspace
{
String getProjectId();

String getUserId();

String getWorkspaceId();

DevelopmentStream getSource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

import org.finos.legend.sdlc.domain.model.project.workspace.Workspace;
import org.finos.legend.sdlc.domain.model.user.User;
import org.finos.legend.sdlc.domain.model.project.workspace.WorkspaceType;

Expand All @@ -26,8 +27,12 @@ public interface Review

String getProjectId();

Workspace getWorkspace();

@Deprecated
String getWorkspaceId();

@Deprecated
WorkspaceType getWorkspaceType();

String getTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Comparison getWorkspaceCreationComparison(String projectId, WorkspaceSpec
}

@Override
public Comparison getWorkspaceSourceComparison(String projectId, WorkspaceSpecification workspaceSpecification)
public Comparison getDevelopmentStreamComparison(String projectId, WorkspaceSpecification workspaceSpecification)
{
throw FSException.unavailableFeature();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

package org.finos.legend.sdlc.server.api.review;

import org.finos.legend.sdlc.domain.model.project.workspace.WorkspaceType;
import org.finos.legend.sdlc.domain.model.project.DevelopmentStream;
import org.finos.legend.sdlc.domain.model.review.Approval;
import org.finos.legend.sdlc.domain.model.review.Review;
import org.finos.legend.sdlc.domain.model.review.ReviewState;
import org.finos.legend.sdlc.server.domain.api.review.ReviewApi;
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.exception.FSException;

Expand All @@ -28,7 +27,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiPredicate;

public class FileSystemReviewApi implements ReviewApi
{
Expand All @@ -44,13 +42,13 @@ public Review getReview(String projectId, String reviewId)
}

@Override
public List<Review> getReviews(String projectId, ReviewState state, Iterable<String> revisionIds, BiPredicate<String, WorkspaceType> workspaceIdAndTypePredicate, Set<WorkspaceSource> sources, Instant since, Instant until, Integer limit)
public List<Review> getReviews(String projectId, Set<DevelopmentStream> workspaceSources, ReviewState state, Iterable<String> revisionIds, Instant since, Instant until, Integer limit)
{
return Collections.emptyList();
}

@Override
public List<Review> getReviews(boolean assignedToMe, boolean authoredByMe, List<String> labels, BiPredicate<String, WorkspaceType> workspaceIdAndTypePredicate, ReviewState state, Instant since, Instant until, Integer limit)
public List<Review> getReviews(boolean assignedToMe, boolean authoredByMe, Set<DevelopmentStream> workspaceSources, List<String> labels, ReviewState state, Instant since, Instant until, Integer limit)
{
return Collections.emptyList();
}
Expand Down
Loading