Skip to content

Commit

Permalink
Merge pull request #5164 from jay-hodgson/SWC-6537
Browse files Browse the repository at this point in the history
SWC-6537: remove reference to /table/sql/transform service call
  • Loading branch information
jay-hodgson committed Aug 25, 2023
2 parents f21282c + 3affba5 commit 98af37b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ Entity updateFileEntity(
void deleteAccessApprovals(String accessRequirement, String accessorId)
throws RestServiceException;

String generateSqlWithFacets(
String basicSql,
List<org.sagebionetworks.repo.model.table.FacetColumnRequest> selectedFacets,
List<ColumnModel> schema
) throws RestServiceException;

Boolean isUserAllowedToRenderHTML(String userId) throws RestServiceException;

long getTeamMemberCount(String teamId) throws RestServiceException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,6 @@ void deleteAccessApprovals(
AsyncCallback<Void> asyncCallback
);

void generateSqlWithFacets(
String basicSql,
List<FacetColumnRequest> selectedFacets,
List<ColumnModel> schema,
AsyncCallback<String> callback
);

void isUserAllowedToRenderHTML(
String userId,
AsyncCallback<Boolean> callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,27 +420,29 @@ private void setQuery(Query query, boolean isFromResults) {
ginInjector.getSynapseJSNIUtils().consoleError(e);
}
};
OnQueryResultBundleCallback onQueryResultBundleChange = newQueryResultBundleJson -> {
try {
JSONObjectAdapter adapter = ginInjector
.getJSONObjectAdapter()
.createNew(newQueryResultBundleJson);
this.currentQueryResultBundle = new QueryResultBundle(adapter);
this.queryExecutionFinished(
true,
QueryResultEditorWidget.isQueryResultEditable(
this.currentQueryResultBundle,
tableType
)
);
} catch (JSONObjectAdapterException e) {
ginInjector.getSynapseJSNIUtils().consoleError(e);
}
};
OnQueryResultBundleCallback onQueryResultBundleChange =
newQueryResultBundleJson -> {
try {
JSONObjectAdapter adapter = ginInjector
.getJSONObjectAdapter()
.createNew(newQueryResultBundleJson);
this.currentQueryResultBundle = new QueryResultBundle(adapter);
this.queryExecutionFinished(
true,
QueryResultEditorWidget.isQueryResultEditable(
this.currentQueryResultBundle,
tableType
)
);
} catch (JSONObjectAdapterException e) {
ginInjector.getSynapseJSNIUtils().consoleError(e);
}
};

OnViewSharingSettingsHandler onViewSharingSettingsHandler = entityId -> {
onViewSharingSettingsClicked(entityId);
};
OnViewSharingSettingsHandler onViewSharingSettingsHandler =
entityId -> {
onViewSharingSettingsClicked(entityId);
};
JSONObjectAdapter adapter = ginInjector
.getJSONObjectAdapter()
.createNew();
Expand All @@ -462,22 +464,6 @@ private void setQuery(Query query, boolean isFromResults) {
}
}

private void generateSqlWithFacets(AsyncCallback<String> callback) {
if (
currentQuery.getSelectedFacets() == null ||
currentQuery.getSelectedFacets().isEmpty()
) {
callback.onSuccess(currentQuery.getSql());
} else {
synapseClient.generateSqlWithFacets(
currentQuery.getSql(),
currentQuery.getSelectedFacets(),
tableBundle.getColumnModels(),
callback
);
}
}

/**
* Set the view to show no columns message.
*/
Expand Down Expand Up @@ -664,27 +650,10 @@ public void onStartingNewQuery(Query newQuery) {
setQuery(newQuery, true);
}

@Override
public void onShowDownloadFilesProgrammatically() {
AsyncCallback<String> callback = new AsyncCallback<String>() {
@Override
public void onSuccess(String sql) {
String escapedSql = sql.replace("\"", "\\\"");
fileViewClientsHelp.setQuery(escapedSql);
fileViewClientsHelp.show();
}

@Override
public void onFailure(Throwable caught) {
view.showErrorMessage(caught.getMessage());
}
};
generateSqlWithFacets(callback);
}

@Override
public void onAddToDownloadList() {
AddToDownloadListV2 newAddToDownloadList = ginInjector.getAddToDownloadListV2();
AddToDownloadListV2 newAddToDownloadList =
ginInjector.getAddToDownloadListV2();
view.setAddToDownloadList(newAddToDownloadList);
newAddToDownloadList.configure(
entityBundle.getEntity().getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,5 @@ public interface QueryInputListener {
*/
public void onEditResults();

/**
* user clicked download files (from view) button.
*/
public void onShowDownloadFilesProgrammatically();

void onAddToDownloadList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@
import org.sagebionetworks.repo.model.search.query.SearchQuery;
import org.sagebionetworks.repo.model.table.ColumnChange;
import org.sagebionetworks.repo.model.table.ColumnModel;
import org.sagebionetworks.repo.model.table.Dataset;
import org.sagebionetworks.repo.model.table.FacetColumnRequest;
import org.sagebionetworks.repo.model.table.TableSchemaChangeRequest;
import org.sagebionetworks.repo.model.table.TableUpdateRequest;
import org.sagebionetworks.repo.model.table.TableUpdateTransactionRequest;
import org.sagebionetworks.repo.model.table.TransformSqlWithFacetsRequest;
import org.sagebionetworks.repo.model.v2.wiki.V2WikiHistorySnapshot;
import org.sagebionetworks.repo.model.v2.wiki.V2WikiPage;
import org.sagebionetworks.repo.model.wiki.WikiPage;
Expand All @@ -103,7 +100,6 @@
import org.sagebionetworks.schema.adapter.org.json.AdapterFactoryImpl;
import org.sagebionetworks.util.SerializationUtils;
import org.sagebionetworks.web.client.SynapseClient;
import org.sagebionetworks.web.server.servlet.filter.CrawlFilter;
import org.sagebionetworks.web.shared.MembershipRequestBundle;
import org.sagebionetworks.web.shared.OpenTeamInvitationBundle;
import org.sagebionetworks.web.shared.OpenUserInvitationBundle;
Expand Down Expand Up @@ -2089,26 +2085,6 @@ public Entity updateFileEntity(
}
}

@Override
public String generateSqlWithFacets(
String basicSql,
List<FacetColumnRequest> selectedFacets,
List<ColumnModel> schema
) throws RestServiceException {
try {
org.sagebionetworks.client.SynapseClient synapseClient =
createSynapseClient();
TransformSqlWithFacetsRequest request =
new TransformSqlWithFacetsRequest();
request.setSqlToTransform(basicSql);
request.setSelectedFacets(selectedFacets);
request.setSchema(schema);
return synapseClient.transformSqlRequest(request);
} catch (SynapseException e) {
throw ExceptionUtil.convertSynapseException(e);
}
}

@Override
public Boolean isUserAllowedToRenderHTML(String userId)
throws RestServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -141,8 +140,6 @@ public class TableEntityWidgetV2Test {
@Captor
ArgumentCaptor<Query> queryCaptor;

public static final String FACET_SQL =
"select * from syn123 where \"x\" = 'a'";
public static final String EXPECTED_SQL_FOR_CLIENT =
"select * from syn123 where \\\"x\\\" = 'a'";

Expand Down Expand Up @@ -231,15 +228,6 @@ public void before() {
mockEventBus
);

AsyncMockStubber
.callSuccessWith(FACET_SQL)
.when(mockSynapseClient)
.generateSqlWithFacets(
anyString(),
anyList(),
anyList(),
any(AsyncCallback.class)
);
// The test bundle
entityBundle = new EntityBundle();
entityBundle.setEntity(tableEntity);
Expand Down Expand Up @@ -574,7 +562,8 @@ public void testOnExecuteQuery() throws JSONObjectAdapterException {
newBundle.setQueryCount(expectedQueryCount);
newBundle.writeToJSONObject(adapter);

OnQueryResultBundleCallback queryResultCallback = onQueryResultBundleCallbackCaptor.getValue();
OnQueryResultBundleCallback queryResultCallback =
onQueryResultBundleCallbackCaptor.getValue();
queryResultCallback.run(adapter.toJSONString());

assertEquals(
Expand All @@ -583,7 +572,8 @@ public void testOnExecuteQuery() throws JSONObjectAdapterException {
);

// test OnViewSharingSettingsHandler
OnViewSharingSettingsHandler onViewSharingSettingsHandler = onViewSharingSettingsHandlerCaptor.getValue();
OnViewSharingSettingsHandler onViewSharingSettingsHandler =
onViewSharingSettingsHandlerCaptor.getValue();
String testEntityId = "syn0000001";
onViewSharingSettingsHandler.onViewSharingSettingsClicked(testEntityId);

Expand Down Expand Up @@ -731,26 +721,6 @@ public void testEditTablePreflightPassed() {
.showEditor(any(QueryResultBundle.class), any(TableType.class));
}

@Test
public void testOnShowDownloadFiles() {
Query startQuery = new Query();
startQuery.setSql(FACET_SQL);
when(mockQueryChangeHandler.getQueryString()).thenReturn(startQuery);
widget.configure(
entityBundle,
versionNumber,
true,
false,
mockQueryChangeHandler,
mockActionMenu
);

widget.onShowDownloadFilesProgrammatically();

verify(mockFileViewClientsHelp).setQuery(EXPECTED_SQL_FOR_CLIENT);
verify(mockFileViewClientsHelp).show();
}

@Test
public void testAutoAddToDownloadListV2() throws JSONObjectAdapterException {
when(
Expand Down
Loading

0 comments on commit 98af37b

Please sign in to comment.