-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added create new project from project backup
- Loading branch information
Showing
8 changed files
with
243 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...in/java/edu/stanford/protege/webprotege/icd/projects/PrepareBackupFilesForUseRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package edu.stanford.protege.webprotege.icd.projects; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import edu.stanford.protege.webprotege.common.Request; | ||
import edu.stanford.protege.webprotege.csv.DocumentId; | ||
|
||
import static edu.stanford.protege.webprotege.icd.projects.PrepareBackupFilesForUseRequest.CHANNEL; | ||
|
||
@JsonTypeName(CHANNEL) | ||
public record PrepareBackupFilesForUseRequest( | ||
@JsonProperty("fileSubmissionId") DocumentId fileSubmissionId | ||
) implements Request<PrepareBackupFilesForUseResponse> { | ||
|
||
public static final String CHANNEL = "icatx.versioning.PrepareBinaryFileBackupForUse"; | ||
|
||
@Override | ||
public String getChannel() { | ||
return CHANNEL; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...n/java/edu/stanford/protege/webprotege/icd/projects/PrepareBackupFilesForUseResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package edu.stanford.protege.webprotege.icd.projects; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import edu.stanford.protege.webprotege.common.BlobLocation; | ||
import edu.stanford.protege.webprotege.dispatch.Result; | ||
|
||
import static edu.stanford.protege.webprotege.icd.projects.PrepareBackupFilesForUseRequest.CHANNEL; | ||
|
||
@JsonTypeName(CHANNEL) | ||
public record PrepareBackupFilesForUseResponse( | ||
@JsonProperty("binaryFileLocation") BlobLocation binaryFileLocation | ||
) implements Result { | ||
} |
49 changes: 49 additions & 0 deletions
49
...java/edu/stanford/protege/webprotege/project/CreateNewProjectFromProjectBackupAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package edu.stanford.protege.webprotege.project; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.google.common.base.Objects; | ||
import edu.stanford.protege.webprotege.common.ProjectId; | ||
import edu.stanford.protege.webprotege.dispatch.Action; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
|
||
@JsonTypeName(CreateNewProjectFromProjectBackupAction.CHANNEL) | ||
public record CreateNewProjectFromProjectBackupAction( | ||
@JsonProperty("newProjectId") ProjectId newProjectId, | ||
@JsonProperty("newProjectSettings") NewProjectSettings newProjectSettings | ||
) implements Action<CreateNewProjectFromProjectBackupResult> { | ||
|
||
public static final String CHANNEL = "webprotege.projects.CreateNewProjectFromProjectBackup"; | ||
|
||
@Override | ||
public String getChannel() { | ||
return CHANNEL; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(newProjectId, newProjectSettings); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (!(obj instanceof CreateNewProjectFromProjectBackupAction)) { | ||
return false; | ||
} | ||
CreateNewProjectFromProjectBackupAction other = (CreateNewProjectFromProjectBackupAction) obj; | ||
return this.newProjectId.equals(other.newProjectId) && this.newProjectSettings.equals(other.newProjectSettings); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper("CreateNewProjectFromProjectBackupAction") | ||
.addValue(newProjectId) | ||
.addValue(newProjectSettings) | ||
.toString(); | ||
} | ||
|
||
|
||
} |
55 changes: 55 additions & 0 deletions
55
.../stanford/protege/webprotege/project/CreateNewProjectFromProjectBackupCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package edu.stanford.protege.webprotege.project; | ||
|
||
import edu.stanford.protege.webprotege.authorization.*; | ||
import edu.stanford.protege.webprotege.ipc.*; | ||
import reactor.core.publisher.Mono; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.*; | ||
|
||
import static edu.stanford.protege.webprotege.access.BuiltInAction.*; | ||
|
||
|
||
@WebProtegeHandler | ||
public class CreateNewProjectFromProjectBackupCommandHandler implements AuthorizedCommandHandler<CreateNewProjectFromProjectBackupAction, CreateNewProjectFromProjectBackupResult> { | ||
|
||
|
||
private final CreateProjectSagaManager createProjectSagaManager; | ||
|
||
|
||
public CreateNewProjectFromProjectBackupCommandHandler(CreateProjectSagaManager createProjectSagaManager) { | ||
this.createProjectSagaManager = createProjectSagaManager; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getChannelName() { | ||
return CreateNewProjectFromProjectBackupAction.CHANNEL; | ||
} | ||
|
||
@Override | ||
public Class<CreateNewProjectFromProjectBackupAction> getRequestClass() { | ||
return CreateNewProjectFromProjectBackupAction.class; | ||
} | ||
|
||
@Override | ||
public Mono<CreateNewProjectFromProjectBackupResult> handleRequest(CreateNewProjectFromProjectBackupAction request, | ||
ExecutionContext executionContext) { | ||
var result = createProjectSagaManager.executeFromBackup(request.newProjectSettings(), executionContext); | ||
return Mono.fromFuture(result); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Resource getTargetResource(CreateNewProjectFromProjectBackupAction request) { | ||
return ApplicationResource.get(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Collection<ActionId> getRequiredCapabilities() { | ||
return List.of(CREATE_EMPTY_PROJECT.getActionId(), UPLOAD_PROJECT.getActionId()); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...java/edu/stanford/protege/webprotege/project/CreateNewProjectFromProjectBackupResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.stanford.protege.webprotege.project; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.google.common.base.Objects; | ||
import edu.stanford.protege.webprotege.dispatch.Result; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
import static edu.stanford.protege.webprotege.icd.projects.PrepareBackupFilesForUseRequest.CHANNEL; | ||
|
||
@JsonTypeName(CHANNEL) | ||
public record CreateNewProjectFromProjectBackupResult( | ||
@JsonProperty("projectDetails") ProjectDetails projectDetails | ||
) implements Result { | ||
|
||
public static CreateNewProjectFromProjectBackupResult create(ProjectDetails projectDetails) { | ||
return new CreateNewProjectFromProjectBackupResult(projectDetails); | ||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(projectDetails); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (!(obj instanceof CreateNewProjectFromProjectBackupResult)) { | ||
return false; | ||
} | ||
CreateNewProjectFromProjectBackupResult other = (CreateNewProjectFromProjectBackupResult) obj; | ||
return this.projectDetails.equals(other.projectDetails); | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper("CreateNewProjectFromProjectBackupResult") | ||
.addValue(projectDetails) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters