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

Who pipeline #9

Merged
merged 4 commits into from
May 29, 2024
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 @@ -51,7 +51,7 @@ public void start(@Nonnull AcceptsOneWidget container) {
generatedAnnotationsSettingsPresenter.start(view.getGeneratedAnnotationsViewContainer());
}

public void setSettings(@Nonnull EntityCrudKitSettings<?> settings) {
public void setSettings(@Nonnull EntityCrudKitSettings settings) {
EntityCrudKitPrefixSettings prefixSettings = settings.getPrefixSettings();
prefixSettingsPresenter.setPrefixSettings(prefixSettings);
EntityCrudKitSuffixSettings suffixSettings = settings.getSuffixSettings();
Expand All @@ -61,7 +61,7 @@ public void setSettings(@Nonnull EntityCrudKitSettings<?> settings) {
}

@Nonnull
public EntityCrudKitSettings<?> getSettings() {
public EntityCrudKitSettings getSettings() {
EntityCrudKitPrefixSettings prefixSettings = prefixSettingsPresenter.getPrefixSettings();
EntityCrudKitSuffixSettings suffixSettings = suffixSettingsPresenter.getSuffixSettings();
GeneratedAnnotationsSettings generatedAnnotationsSettings = generatedAnnotationsSettingsPresenter.getSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +61,8 @@ public class ProjectPresenter implements HasDispose, HasProjectId {

private final LargeNumberOfChangesManager largeNumberOfChangesHandler;

private final LoggedInUserProvider loggedInUserProvider;


@Inject
public ProjectPresenter(ProjectId projectId,
Expand All @@ -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;
Expand All @@ -85,6 +89,7 @@ public ProjectPresenter(ProjectId projectId,
this.eventBus = eventBus;
this.projectTagsStyleManager = projectTagsStyleManager;
this.largeNumberOfChangesHandler = largeNumberOfChangesHandler;
this.loggedInUserProvider = loggedInUserProvider;
}

@Nonnull
Expand All @@ -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(), r.getWebsocketUrl(), this.loggedInUserProvider.getCurrentUserId().getUserName());

});

}

private void handleProjectLoaded(@Nonnull AcceptsOneWidget container, @Nonnull EventBus eventBus, @Nonnull ProjectViewPlace place) {
Expand All @@ -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();
Expand All @@ -146,27 +156,38 @@ public void dispatchEventsFromWebsocket(String data) {
dispatchServiceManager.execute(TranslateEventListAction.create(data), (GetProjectEventsResult result) -> eventPollingManager.dispatchEvents(result.getEvents()));

}
/*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 websocketUrl, String userId)/*-{
try {
var that = this;

var stompClient = new $wnd.StompJs.Client({
brokerURL: 'ws://webprotege-local.edu/wsapps',
brokerURL: websocketUrl,
debug: function(str) {
$wnd.console.log(str);
console.log(str);
},
reconnectDelay: 5000,
reconnectDelay: 30000,
heartbeatIncoming: 4000,
heartbeatOutgoing: 4000,
connectHeaders: {
'token': token,
'userId': userId,
'Authorization' : 'Bearer ' + token,
'login': 'Bearer ' + token
}
});


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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void applySettings() {
eventBus.fireEvent(new ProjectSettingsChangedEvent(projectSettings).asGWTEvent());
settingsPresenter.goToNextPlace();
});
EntityCrudKitSettings<?> settings = entityCrudKitSettingsPresenter.getSettings();
EntityCrudKitSettings settings = entityCrudKitSettingsPresenter.getSettings();
dispatchServiceManager.execute(new SetEntityCrudKitSettingsAction(projectId,
settings, settings,
IRIPrefixUpdateStrategy.LEAVE_INTACT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public <A extends Action<R>, R extends Result> DispatchServiceResultContainer ex
return DispatchServiceResultContainer.create(result);
}
if(action instanceof GetUserInfoAction) {
GetUserInfoResult result = GetUserInfoResult.create(executionContext.getToken());
var websocketUrl = System.getenv("webprotege.websocketUrl");
GetUserInfoResult result = GetUserInfoResult.create(executionContext.getToken(), websocketUrl != null ? websocketUrl : "ws://webprotege-local.edu/wsapps");
return DispatchServiceResultContainer.create(result);
}
var result = sendRequest(action, executionContext);
Expand All @@ -85,7 +86,6 @@ private <A extends Action<R>, R extends Result> R sendRequest(A action,
ExecutionContext executionContext) throws IOException, InterruptedException {
try {
var httpRequest = requestBuilder.getHttpRequestForAction(action, executionContext);

var httpResponse = httpClient.send(httpRequest,
HttpResponse.BodyHandlers.ofString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import edu.stanford.bmir.protege.web.server.form.FormControlValueDeserializer;
import edu.stanford.bmir.protege.web.shared.crud.GetEntityCrudKitsResult;
import edu.stanford.bmir.protege.web.shared.event.*;
import edu.stanford.bmir.protege.web.shared.form.data.PrimitiveFormControlData;
import edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyChangedEvent;
Expand Down Expand Up @@ -113,6 +114,7 @@ public ObjectMapper get() {
WatchAddedEvent.class,
PackagedProjectChangeEvent.class,
ProjectMovedFromTrashEvent.class,
GetEntityCrudKitsResult.class,
WatchRemovedEvent.class);
mapper.registerModule(module);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"realm": "webprotege",
"auth-server-url": "http://webprotege-local.edu/auth/",
"ssl-required": "external",
"auth-server-url": "${env.KEYCLOAK_AUTH_URL:http://webprotege-local.edu/auth/}",
"ssl-required": "none",
"resource": "webprotege",
"public-client": true,
"confidential-port": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@JsonSubTypes.Type(UuidSuffixKit.class),
@JsonSubTypes.Type(SuppliedNameSuffixKit.class)
})
public abstract class EntityCrudKit<S extends EntityCrudKitSuffixSettings> implements HasKitId, HasDisplayName, Serializable, IsSerializable {
public abstract class EntityCrudKit implements HasKitId, HasDisplayName, Serializable, IsSerializable {

private EntityCrudKitId kitId;

Expand Down Expand Up @@ -85,11 +85,11 @@ public String getDisplayName() {

public abstract EntityCrudKitPrefixSettings getDefaultPrefixSettings();

public abstract S getDefaultSuffixSettings();
public abstract EntityCrudKitSuffixSettings getDefaultSuffixSettings();

public abstract Optional<String> getPrefixValidationMessage(String prefix);

public abstract IRI generateExample(EntityCrudKitPrefixSettings prefixSettings, S suffixSettings);
public abstract IRI generateExample(EntityCrudKitPrefixSettings prefixSettings, EntityCrudKitSuffixSettings suffixSettings);


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
@AutoValue
@GwtCompatible(serializable = true)
public abstract class EntityCrudKitSettings<S extends EntityCrudKitSuffixSettings> implements Serializable {
public abstract class EntityCrudKitSettings implements Serializable {

public static final String PREFIX_SETTINGS = "prefixSettings";

Expand All @@ -34,15 +34,15 @@ public abstract class EntityCrudKitSettings<S extends EntityCrudKitSuffixSetting
* @param suffixSettings The {@link EntityCrudKitSuffixSettings}. Not {@code null}.
* @throws NullPointerException if any argument is {@code null}.
*/
public static <S extends EntityCrudKitSuffixSettings> EntityCrudKitSettings<S> get(@JsonProperty(PREFIX_SETTINGS) @Nonnull EntityCrudKitPrefixSettings prefixSettings,
@JsonProperty(SUFFIX_SETTINGS) S suffixSettings,
public static EntityCrudKitSettings get(@JsonProperty(PREFIX_SETTINGS) @Nonnull EntityCrudKitPrefixSettings prefixSettings,
@JsonProperty(SUFFIX_SETTINGS) EntityCrudKitSuffixSettings suffixSettings,
@JsonProperty(GENERATED_ANNOTATIONS_SETTINGS) @Nonnull GeneratedAnnotationsSettings generatedAnnotationsSettings) {
return new AutoValue_EntityCrudKitSettings<S>(prefixSettings, suffixSettings, generatedAnnotationsSettings);
return new AutoValue_EntityCrudKitSettings(prefixSettings, suffixSettings, generatedAnnotationsSettings);
}

@JsonCreator
public static <S extends EntityCrudKitSuffixSettings> EntityCrudKitSettings<S> fromJson(@JsonProperty(PREFIX_SETTINGS) @Nonnull EntityCrudKitPrefixSettings prefixSettings,
@JsonProperty(SUFFIX_SETTINGS) S suffixSettings,
public static EntityCrudKitSettings fromJson(@JsonProperty(PREFIX_SETTINGS) @Nonnull EntityCrudKitPrefixSettings prefixSettings,
@JsonProperty(SUFFIX_SETTINGS) EntityCrudKitSuffixSettings suffixSettings,
@JsonProperty(GENERATED_ANNOTATIONS_SETTINGS) @Nullable GeneratedAnnotationsSettings generatedAnnotationsSettings) {
return get(prefixSettings,
suffixSettings,
Expand All @@ -63,7 +63,7 @@ public static <S extends EntityCrudKitSuffixSettings> EntityCrudKitSettings<S> f
* @return The suffix settings. Not {@code null}.
*/
@JsonProperty(SUFFIX_SETTINGS)
public abstract S getSuffixSettings();
public abstract EntityCrudKitSuffixSettings getSuffixSettings();

@JsonProperty(GENERATED_ANNOTATIONS_SETTINGS)
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.gwt.user.client.rpc.IsSerializable;
import edu.stanford.bmir.protege.web.shared.crud.oboid.OboIdSuffixSettings;
import edu.stanford.bmir.protege.web.shared.crud.supplied.SuppliedNameSuffixSettings;
import edu.stanford.bmir.protege.web.shared.crud.uuid.UuidSuffixSettings;
Expand All @@ -22,22 +23,16 @@
*/
@JsonSubTypes(
{
@JsonSubTypes.Type(value = UuidSuffixSettings.class,
name = "edu.stanford.bmir.protege.web.shared.crud.uuid.UUIDSuffixSettings"),
@JsonSubTypes.Type(value = UuidSuffixSettings.class,
name = UuidSuffixSettings.TYPE_ID),
@JsonSubTypes.Type(value = SuppliedNameSuffixSettings.class,
name = "edu.stanford.bmir.protege.web.shared.crud.supplied.SuppliedNameSuffixSettings"),
@JsonSubTypes.Type(value = SuppliedNameSuffixSettings.class,
name = SuppliedNameSuffixSettings.TYPE_ID),
@JsonSubTypes.Type(value = OboIdSuffixSettings.class,
name = "edu.stanford.bmir.protege.web.shared.crud.oboid.OBOIdSuffixSettings"),
@JsonSubTypes.Type(value = OboIdSuffixSettings.class,
name = OboIdSuffixSettings.TYPE_ID)
@JsonSubTypes.Type(value = UuidSuffixSettings.class,name = "edu.stanford.bmir.protege.web.shared.crud.uuid.UUIDSuffixSettings"),
@JsonSubTypes.Type(value = UuidSuffixSettings.class,name = UuidSuffixSettings.TYPE_ID),
@JsonSubTypes.Type(value = SuppliedNameSuffixSettings.class,name = "edu.stanford.bmir.protege.web.shared.crud.supplied.SuppliedNameSuffixSettings"),
@JsonSubTypes.Type(value = SuppliedNameSuffixSettings.class, name = SuppliedNameSuffixSettings.TYPE_ID),
@JsonSubTypes.Type(value = OboIdSuffixSettings.class,name = "edu.stanford.bmir.protege.web.shared.crud.oboid.OBOIdSuffixSettings"),
@JsonSubTypes.Type(value = OboIdSuffixSettings.class,name = OboIdSuffixSettings.TYPE_ID)
}
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = EntityCrudKitSuffixSettings.TYPE_PROPERTY)
public abstract class EntityCrudKitSuffixSettings implements HasKitId, Serializable {
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
public abstract class EntityCrudKitSuffixSettings implements HasKitId, Serializable, IsSerializable {

/**
* The type property. This is _class for backwards compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public abstract class GetEntityCrudKitsResult implements Result {


@JsonCreator
public static GetEntityCrudKitsResult create(@JsonProperty("kits") List<EntityCrudKit<?>> kits,
@JsonProperty("currentSettings") EntityCrudKitSettings<?> currentSettings) {
public static GetEntityCrudKitsResult create(@JsonProperty("kits") List<EntityCrudKit> kits,
@JsonProperty("currentSettings") EntityCrudKitSettings currentSettings) {
return new AutoValue_GetEntityCrudKitsResult(kits, currentSettings);
}

public abstract List<EntityCrudKit<?>> getKits();
public abstract List<EntityCrudKit> getKits();

public abstract EntityCrudKitSettings<?> getCurrentSettings();
public abstract EntityCrudKitSettings getCurrentSettings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class SetEntityCrudKitSettingsAction implements ProjectAction<SetEntityCr

private ProjectId projectId;

private EntityCrudKitSettings<? extends EntityCrudKitSuffixSettings> fromSettings;
private EntityCrudKitSettings fromSettings;

private EntityCrudKitSettings<? extends EntityCrudKitSuffixSettings> toSettings;
private EntityCrudKitSettings toSettings;

private IRIPrefixUpdateStrategy prefixUpdateStrategy;

Expand All @@ -29,7 +29,7 @@ public class SetEntityCrudKitSettingsAction implements ProjectAction<SetEntityCr
private SetEntityCrudKitSettingsAction() {
}

public SetEntityCrudKitSettingsAction(ProjectId projectId, EntityCrudKitSettings<?> fromSettings, EntityCrudKitSettings<?> toSettings, IRIPrefixUpdateStrategy prefixUpdateStrategy) {
public SetEntityCrudKitSettingsAction(ProjectId projectId, EntityCrudKitSettings fromSettings, EntityCrudKitSettings toSettings, IRIPrefixUpdateStrategy prefixUpdateStrategy) {
this.projectId = projectId;
this.toSettings = toSettings;
this.fromSettings = fromSettings;
Expand All @@ -46,11 +46,11 @@ public IRIPrefixUpdateStrategy getPrefixUpdateStrategy() {
return prefixUpdateStrategy;
}

public EntityCrudKitSettings<? extends EntityCrudKitSuffixSettings> getToSettings() {
public EntityCrudKitSettings getToSettings() {
return toSettings;
}

public EntityCrudKitSettings<? extends EntityCrudKitSuffixSettings> getFromSettings() {
public EntityCrudKitSettings getFromSettings() {
return fromSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableList;
import com.google.gwt.user.client.rpc.IsSerializable;

import javax.annotation.Nonnull;
import java.io.Serializable;

/**
* Matthew Horridge
Expand All @@ -15,10 +17,14 @@
*/
@AutoValue
@GwtCompatible(serializable = true)
public abstract class GeneratedAnnotationsSettings {
public abstract class GeneratedAnnotationsSettings implements Serializable, IsSerializable {

public static final String DESCRIPTORS = "descriptors";

public GeneratedAnnotationsSettings(){

}


@JsonCreator
public static GeneratedAnnotationsSettings get(@JsonProperty(DESCRIPTORS) ImmutableList<GeneratedAnnotationDescriptor> descriptors) {
Expand Down
Loading
Loading