diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..f023adc4d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,17 @@ +name: Java CI + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Maven + run: mvn --batch-mode --update-snapshots package \ No newline at end of file diff --git a/.github/workflows/pub-docker-hub.yaml b/.github/workflows/pub-docker-hub.yaml new file mode 100644 index 000000000..ce6e49fca --- /dev/null +++ b/.github/workflows/pub-docker-hub.yaml @@ -0,0 +1,29 @@ +name: Publish Docker image to Docker Hub +on: + release: + types: + - published + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKER_USERNAME}} + password: ${{secrets.DOCKER_PASSWORD}} + - uses: actions/checkout@v3 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + server-id: docker.io + server-username: DOCKER_USERNAME + server-password: DOCKER_PASSWORD + - name: Publish package + run: mvn --batch-mode clean deploy +env: + DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} + DOCKER_TOKEN: ${{secrets.DOCKER_PASSWORD}} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9db0ffa7b..868a3597b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ edu.stanford.protege webprotege-gwt-ui - 5.0.5-WHO + 5.0.6-WHO pom diff --git a/readme.md b/readme.md index efa09a1e1..ef53615f7 100644 --- a/readme.md +++ b/readme.md @@ -1,56 +1,3 @@ -WebProtégé -========== +# webprotege-gwt-ui -What is WebProtégé? -------------------- - -WebProtégé is a free, open source collaborative ontology development environment. - -It provides the following features: -- Support for editing OWL 2 ontologies -- A default simple editing interface, which provides access to commonly used OWL constructs -- Full change tracking and revision history -- Collaboration tools such as, sharing and permissions, threaded notes and discussions, watches and email notifications -- Customizable user interface -- Support for editing OBO ontologies -- Multiple file formats for upload and download of ontologies (supported formats: RDF/XML, Turtle, OWL/XML, OBO, and others) - -WebProtégé runs as a Web application. End users access it through their Web browsers. -They do not need to download or install any software. We encourage end-users to use - -https://webprotege.stanford.edu - -This repository houses the code for the WebProtege GWT User Interface. - -Building --------- - -To build WebProtégé from source - -1) Clone the github repository - ``` - git clone https://github.com/protegeproject/webprotege-gwt-ui.git - ``` -2) Open a terminal in the directory where you clone the repository to -3) Use maven to package WebProtégé - ``` - mvn clean package - ``` -5) The WebProtege .war file will be built into the webprotege-server directory - -Running from Maven ------------------- - -To run WebProtégé in SuperDev Mode using maven - -1) Start the GWT code server in one terminal window - ``` - mvn gwt:codeserver - ``` -2) In a different terminal window start the tomcat server - ``` - mvn -Denv=dev tomcat7:run - ``` -3) Start the WebProtégé Backend - -4) Browse to WebProtégé in a Web browser by navigating to [http://localhost:8080](http://localhost:8080) \ No newline at end of file +This is the UI server for WebProtégé. diff --git a/webprotege-gwt-ui-client/pom.xml b/webprotege-gwt-ui-client/pom.xml index 97c0e2125..9aab39bdd 100644 --- a/webprotege-gwt-ui-client/pom.xml +++ b/webprotege-gwt-ui-client/pom.xml @@ -6,7 +6,7 @@ edu.stanford.protege webprotege-gwt-ui - 5.0.5-WHO + 5.0.6-WHO webprotege-gwt-ui-client diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/ProjectPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/ProjectPresenter.java index 6df9ff45b..f0ed431b3 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/ProjectPresenter.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/ProjectPresenter.java @@ -11,7 +11,9 @@ import edu.stanford.bmir.protege.web.client.progress.BusyView; import edu.stanford.bmir.protege.web.client.tag.ProjectTagsStyleManager; import edu.stanford.bmir.protege.web.client.topbar.TopBarPresenter; +import edu.stanford.bmir.protege.web.client.user.LoggedInUserProvider; import edu.stanford.bmir.protege.web.shared.HasDispose; +import edu.stanford.bmir.protege.web.shared.dispatch.actions.GetUserInfoAction; import edu.stanford.bmir.protege.web.shared.dispatch.actions.TranslateEventListAction; import edu.stanford.bmir.protege.web.shared.event.*; import edu.stanford.bmir.protege.web.shared.inject.ProjectSingleton; @@ -59,6 +61,8 @@ public class ProjectPresenter implements HasDispose, HasProjectId { private final LargeNumberOfChangesManager largeNumberOfChangesHandler; + private final LoggedInUserProvider loggedInUserProvider; + @Inject public ProjectPresenter(ProjectId projectId, @@ -72,7 +76,7 @@ public ProjectPresenter(ProjectId projectId, PermissionScreener permissionScreener, WebProtegeEventBus eventBus, ProjectTagsStyleManager projectTagsStyleManager, - LargeNumberOfChangesManager largeNumberOfChangesHandler) { + LargeNumberOfChangesManager largeNumberOfChangesHandler, LoggedInUserProvider loggedInUserProvider) { this.projectId = projectId; this.view = view; this.busyView = busyView; @@ -85,6 +89,7 @@ public ProjectPresenter(ProjectId projectId, this.eventBus = eventBus; this.projectTagsStyleManager = projectTagsStyleManager; this.largeNumberOfChangesHandler = largeNumberOfChangesHandler; + this.loggedInUserProvider = loggedInUserProvider; } @Nonnull @@ -109,7 +114,11 @@ private void displayProject(@Nonnull AcceptsOneWidget container, @Nonnull ProjectViewPlace place) { dispatchServiceManager.execute(new LoadProjectAction(projectId), result -> handleProjectLoaded(container, eventBus, place)); - subscribeToWebsocket(projectId.getId()); + dispatchServiceManager.execute(new GetUserInfoAction(), r -> { + subscribeToWebsocket(projectId.getId(), r.getToken(), this.loggedInUserProvider.getCurrentUserId().getUserName()); + + }); + } private void handleProjectLoaded(@Nonnull AcceptsOneWidget container, @Nonnull EventBus eventBus, @Nonnull ProjectViewPlace place) { @@ -122,6 +131,7 @@ private void handleProjectLoaded(@Nonnull AcceptsOneWidget container, @Nonnull E projectId, largeNumberOfChangesHandler); container.setWidget(view); + dispatchServiceManager.execute(GetProjectTagsAction.create(projectId), r -> projectTagsStyleManager.setProjectTags(r.getTags(), view)); dispatchServiceManager.executeCurrentBatch(); @@ -147,7 +157,7 @@ public void dispatchEventsFromWebsocket(String data) { } /*TODO change the hardcoded broker URL and get it from a config class */ - public native void subscribeToWebsocket(String projectId)/*-{ + public native void subscribeToWebsocket(String projectId, String token, String userId)/*-{ try { var that = this; @@ -156,17 +166,22 @@ public native void subscribeToWebsocket(String projectId)/*-{ debug: function(str) { console.log(str); }, - reconnectDelay: 5000, + reconnectDelay: 30000, heartbeatIncoming: 4000, heartbeatOutgoing: 4000, }); stompClient.onConnect = function(frame) { + var headers = { + 'token': token, + 'userId': userId, + 'Authorization' : 'Bearer ' + token + }; stompClient.subscribe('/topic/project-events/' + projectId, function(message) { that.@edu.stanford.bmir.protege.web.client.project.ProjectPresenter::dispatchEventsFromWebsocket(Ljava/lang/String;)(message.body); - }); + }, headers); }; stompClient.onWebSocketError = function(error) { console.error('Error with websocket', error); diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/sharing/SharingSettingsPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/sharing/SharingSettingsPresenter.java index 7bd0e385a..106fc8d36 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/sharing/SharingSettingsPresenter.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/sharing/SharingSettingsPresenter.java @@ -13,6 +13,8 @@ import edu.stanford.bmir.protege.web.client.permissions.PermissionManager; import edu.stanford.bmir.protege.web.client.progress.BusyView; import edu.stanford.bmir.protege.web.client.settings.SettingsPresenter; +import edu.stanford.bmir.protege.web.client.uuid.UuidV4Provider; +import edu.stanford.bmir.protege.web.shared.perspective.ChangeRequestId; import edu.stanford.bmir.protege.web.shared.project.ProjectId; import edu.stanford.bmir.protege.web.shared.sharing.GetProjectSharingSettingsAction; import edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings; @@ -63,6 +65,9 @@ public class SharingSettingsPresenter implements Presenter { @Nonnull private final ProgressDisplay progressDisplay; + @Nonnull + private UuidV4Provider uuidV4Provider; + @Inject public SharingSettingsPresenter(@Nonnull ProjectId projectId, @Nonnull SharingSettingsView view, @@ -70,6 +75,7 @@ public SharingSettingsPresenter(@Nonnull ProjectId projectId, @Nonnull DispatchServiceManager dispatchServiceManager, @Nonnull PermissionManager permissionManager, @Nonnull PermissionScreener permissionScreener, + @Nonnull UuidV4Provider uuidV4Provider, @Nonnull SettingsPresenter settingsPresenter, @Nonnull Messages messages, @Nonnull DispatchErrorMessageDisplay errorDisplay, @Nonnull ProgressDisplay progressDisplay) { this.projectId = checkNotNull(projectId); @@ -81,6 +87,7 @@ public SharingSettingsPresenter(@Nonnull ProjectId projectId, this.settingsPresenter = checkNotNull(settingsPresenter); this.messages = checkNotNull(messages); this.errorDisplay = checkNotNull(errorDisplay); + this.uuidV4Provider = uuidV4Provider; this.progressDisplay = checkNotNull(progressDisplay); } @@ -113,7 +120,7 @@ private void displaySharingSettings(AcceptsOneWidget container) { private void applyChangesAndGoToNextPlace() { settingsPresenter.goToNextPlace(); ProjectSharingSettings settings = new ProjectSharingSettings(projectId, view.getLinkSharingPermission(), view.getSharingSettings()); - dispatchServiceManager.execute(SetProjectSharingSettingsAction.create(settings), new DispatchServiceCallbackWithProgressDisplay(errorDisplay, progressDisplay) { + dispatchServiceManager.execute(SetProjectSharingSettingsAction.create(settings, ChangeRequestId.get(uuidV4Provider.get()), this.projectId), new DispatchServiceCallbackWithProgressDisplay(errorDisplay, progressDisplay) { @Override public void handleSuccess(SetProjectSharingSettingsResult result) { permissionManager.firePermissionsChanged(); diff --git a/webprotege-gwt-ui-client/src/main/module-dev.gwt.xml b/webprotege-gwt-ui-client/src/main/module-dev.gwt.xml index 1a36537a3..9920a1fc4 100644 --- a/webprotege-gwt-ui-client/src/main/module-dev.gwt.xml +++ b/webprotege-gwt-ui-client/src/main/module-dev.gwt.xml @@ -45,6 +45,11 @@ + + diff --git a/webprotege-gwt-ui-client/src/main/module.gwt.xml b/webprotege-gwt-ui-client/src/main/module.gwt.xml index c480fb76c..ec20cac7b 100644 --- a/webprotege-gwt-ui-client/src/main/module.gwt.xml +++ b/webprotege-gwt-ui-client/src/main/module.gwt.xml @@ -49,6 +49,11 @@ + + diff --git a/webprotege-gwt-ui-server-core/pom.xml b/webprotege-gwt-ui-server-core/pom.xml index 76a658811..61fe910bb 100644 --- a/webprotege-gwt-ui-server-core/pom.xml +++ b/webprotege-gwt-ui-server-core/pom.xml @@ -5,7 +5,7 @@ webprotege-gwt-ui edu.stanford.protege - 5.0.5-WHO + 5.0.6-WHO 4.0.0 diff --git a/webprotege-gwt-ui-server-core/src/main/java/edu/stanford/bmir/protege/web/server/dispatch/impl/DispatchServiceExecutorImpl.java b/webprotege-gwt-ui-server-core/src/main/java/edu/stanford/bmir/protege/web/server/dispatch/impl/DispatchServiceExecutorImpl.java index ed351fd1c..b629d26a8 100644 --- a/webprotege-gwt-ui-server-core/src/main/java/edu/stanford/bmir/protege/web/server/dispatch/impl/DispatchServiceExecutorImpl.java +++ b/webprotege-gwt-ui-server-core/src/main/java/edu/stanford/bmir/protege/web/server/dispatch/impl/DispatchServiceExecutorImpl.java @@ -7,6 +7,8 @@ import edu.stanford.bmir.protege.web.server.rpc.JsonRpcHttpRequestBuilder; import edu.stanford.bmir.protege.web.server.rpc.JsonRpcHttpResponseHandler; import edu.stanford.bmir.protege.web.shared.dispatch.*; +import edu.stanford.bmir.protege.web.shared.dispatch.actions.GetUserInfoAction; +import edu.stanford.bmir.protege.web.shared.dispatch.actions.GetUserInfoResult; import edu.stanford.bmir.protege.web.shared.dispatch.actions.TranslateEventListAction; import edu.stanford.bmir.protege.web.shared.event.GetProjectEventsResult; import edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException; @@ -59,6 +61,10 @@ public , R extends Result> DispatchServiceResultContainer ex GetProjectEventsResult result = objectMapper.readValue(translateEventsAction.getEventList(), GetProjectEventsResult.class); return DispatchServiceResultContainer.create(result); } + if(action instanceof GetUserInfoAction) { + GetUserInfoResult result = GetUserInfoResult.create(executionContext.getToken()); + return DispatchServiceResultContainer.create(result); + } var result = sendRequest(action, executionContext); return DispatchServiceResultContainer.create(result); } diff --git a/webprotege-gwt-ui-server-core/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettings_Serialization_TestCase.java b/webprotege-gwt-ui-server-core/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettings_Serialization_TestCase.java index e4e6e1a8c..bd8fc2cf5 100644 --- a/webprotege-gwt-ui-server-core/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettings_Serialization_TestCase.java +++ b/webprotege-gwt-ui-server-core/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettings_Serialization_TestCase.java @@ -26,7 +26,7 @@ public void shouldSerializeAction() throws IOException { Optional.of(SharingPermission.EDIT), ImmutableList.of( new SharingSetting(PersonId.get("User"), SharingPermission.EDIT) ) - )); + ), null, null); JsonSerializationTestUtil.testSerialization(action, Action.class); } diff --git a/webprotege-gwt-ui-server/pom.xml b/webprotege-gwt-ui-server/pom.xml index cbb185870..4a23c1321 100644 --- a/webprotege-gwt-ui-server/pom.xml +++ b/webprotege-gwt-ui-server/pom.xml @@ -6,7 +6,7 @@ edu.stanford.protege webprotege-gwt-ui - 5.0.5-WHO + 5.0.6-WHO webprotege-gwt-ui-server diff --git a/webprotege-gwt-ui-shared-core/pom.xml b/webprotege-gwt-ui-shared-core/pom.xml index 46fd23b48..460d3ee2c 100644 --- a/webprotege-gwt-ui-shared-core/pom.xml +++ b/webprotege-gwt-ui-shared-core/pom.xml @@ -5,7 +5,7 @@ webprotege-gwt-ui edu.stanford.protege - 5.0.5-WHO + 5.0.6-WHO 4.0.0 diff --git a/webprotege-gwt-ui-shared/pom.xml b/webprotege-gwt-ui-shared/pom.xml index 6fab03695..88507f569 100644 --- a/webprotege-gwt-ui-shared/pom.xml +++ b/webprotege-gwt-ui-shared/pom.xml @@ -6,7 +6,7 @@ edu.stanford.protege webprotege-gwt-ui - 5.0.5-WHO + 5.0.6-WHO webprotege-gwt-ui-shared diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java index 41abb44ba..dcca4cf35 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java @@ -205,7 +205,8 @@ @JsonSubTypes.Type(UpdateObjectPropertyFrameResult.class), @JsonSubTypes.Type(UpdateDataPropertyFrameResult.class), @JsonSubTypes.Type(UpdateAnnotationPropertyFrameResult.class), - @JsonSubTypes.Type(UpdateNamedIndividualFrameResult.class) + @JsonSubTypes.Type(UpdateNamedIndividualFrameResult.class), + @JsonSubTypes.Type(GetUserInfoResult.class) }) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public interface Result extends IsSerializable { diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java index 0a7372de6..cf3906ae4 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java @@ -978,6 +978,8 @@ public class RpcWhiteList implements IsSerializable, Action, Result { DropType _DropType; + GetUserInfoResult _GetUserInfoResult; + public RpcWhiteList() { } } diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoAction.java new file mode 100644 index 000000000..1d70845ea --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoAction.java @@ -0,0 +1,11 @@ +package edu.stanford.bmir.protege.web.shared.dispatch.actions; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.dispatch.Action; +import java.io.Serializable; + +@JsonTypeName("webprotege.users.GetUserInfo") +public class GetUserInfoAction implements Action, Serializable, IsSerializable { + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoResult.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoResult.java new file mode 100644 index 000000000..813f69566 --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/actions/GetUserInfoResult.java @@ -0,0 +1,42 @@ +package edu.stanford.bmir.protege.web.shared.dispatch.actions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; + +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor; +import edu.stanford.bmir.protege.web.shared.dispatch.Result; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + + +@JsonTypeName("webprotege.users.GetUserInfo") +public class GetUserInfoResult implements Result, Serializable, IsSerializable { + + + private String token; + @GwtSerializationConstructor + public GetUserInfoResult(){ + + } + + + @JsonCreator + @NotNull + public static GetUserInfoResult create(@JsonProperty("token") String token) { + GetUserInfoResult response = new GetUserInfoResult(); + response.token = token; + return response; + } + + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsAction.java index 89620fe05..9039fefc4 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsAction.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsAction.java @@ -11,7 +11,7 @@ * Stanford Center for Biomedical Informatics Research * 12/05/15 */ -@JsonTypeName("webprotege.users.GetUserIdCompletions") +@JsonTypeName("webprotege.usersquery.QueryUsers") public class GetUserIdCompletionsAction extends GetPossibleItemCompletionsAction { /** diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsResult.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsResult.java index 2daee743d..b4186ef5c 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsResult.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/itemlist/GetUserIdCompletionsResult.java @@ -15,7 +15,7 @@ * Stanford Center for Biomedical Informatics Research * 12/05/15 */ -@JsonTypeName("webprotege.users.GetUserIdCompletions") +@JsonTypeName("webprotege.usersquery.QueryUsers") public class GetUserIdCompletionsResult extends GetPossibleItemCompletionsResult { /** diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction.java index bda17fcc3..f0222a768 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Objects; import edu.stanford.bmir.protege.web.shared.dispatch.ProjectAction; +import edu.stanford.bmir.protege.web.shared.perspective.ChangeRequestId; import edu.stanford.bmir.protege.web.shared.project.ProjectId; import javax.annotation.Nonnull; @@ -18,32 +19,42 @@ @JsonTypeName("webprotege.sharing.SetProjectSharingSettings") public class SetProjectSharingSettingsAction implements ProjectAction { - private ProjectSharingSettings projectSharingSettings; + private ProjectSharingSettings settings; + + private ChangeRequestId changeRequestId; + + private ProjectId projectId; private SetProjectSharingSettingsAction() { } - private SetProjectSharingSettingsAction(ProjectSharingSettings projectSharingSettings) { - this.projectSharingSettings = checkNotNull(projectSharingSettings); + private SetProjectSharingSettingsAction(ProjectSharingSettings projectSharingSettings, ChangeRequestId changeRequestId, ProjectId projectId) { + this.settings = checkNotNull(projectSharingSettings); + this.projectId = projectId; + this.changeRequestId = changeRequestId; } - public static SetProjectSharingSettingsAction create(ProjectSharingSettings projectSharingSettings) { - return new SetProjectSharingSettingsAction(projectSharingSettings); + public static SetProjectSharingSettingsAction create(ProjectSharingSettings projectSharingSettings, ChangeRequestId changeRequestId, ProjectId projectId) { + return new SetProjectSharingSettingsAction(projectSharingSettings, changeRequestId, projectId); } @Nonnull @Override public ProjectId getProjectId() { - return projectSharingSettings.getProjectId(); + return settings.getProjectId(); + } + + public ProjectSharingSettings getSettings() { + return settings; } - public ProjectSharingSettings getProjectSharingSettings() { - return projectSharingSettings; + public ChangeRequestId getChangeRequestId() { + return changeRequestId; } @Override public int hashCode() { - return Objects.hashCode(projectSharingSettings); + return Objects.hashCode(settings); } @Override @@ -55,14 +66,14 @@ public boolean equals(Object obj) { return false; } SetProjectSharingSettingsAction other = (SetProjectSharingSettingsAction) obj; - return this.projectSharingSettings.equals(other.projectSharingSettings); + return this.settings.equals(other.settings); } @Override public String toString() { return toStringHelper("SetProjectSharingSettingsAction") - .addValue(projectSharingSettings) + .addValue(settings) .toString(); } } diff --git a/webprotege-gwt-ui-shared/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction_TestCase.java b/webprotege-gwt-ui-shared/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction_TestCase.java index 944441a68..9646820ad 100644 --- a/webprotege-gwt-ui-shared/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction_TestCase.java +++ b/webprotege-gwt-ui-shared/src/test/java/edu/stanford/bmir/protege/web/shared/sharing/SetProjectSharingSettingsAction_TestCase.java @@ -1,5 +1,6 @@ package edu.stanford.bmir.protege.web.shared.sharing; +import edu.stanford.bmir.protege.web.shared.perspective.ChangeRequestId; import edu.stanford.bmir.protege.web.shared.project.ProjectId; import org.junit.Before; import org.junit.Test; @@ -33,16 +34,20 @@ public class SetProjectSharingSettingsAction_TestCase { @Mock private ProjectId projectId; + @Mock + private ChangeRequestId changeRequestId; + + @Before public void setUp() throws Exception { - action = SetProjectSharingSettingsAction.create(projectSharingSettings); - otherAction = SetProjectSharingSettingsAction.create(projectSharingSettings); + action = SetProjectSharingSettingsAction.create(projectSharingSettings, changeRequestId, projectId); + otherAction = SetProjectSharingSettingsAction.create(projectSharingSettings, changeRequestId, projectId); when(projectSharingSettings.getProjectId()).thenReturn(projectId); } @Test(expected = NullPointerException.class) public void shouldThrowNullPointerException() { - SetProjectSharingSettingsAction.create(null); + SetProjectSharingSettingsAction.create(null, changeRequestId, projectId); } @Test @@ -72,7 +77,7 @@ public void shouldGenerateToString() { @Test public void shouldReturnSuppliedSharingSettings() { - assertThat(action.getProjectSharingSettings(), is(projectSharingSettings)); + assertThat(action.getSettings(), is(projectSharingSettings)); } @Test