Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Oct 17, 2023
1 parent 0954647 commit 6fa4b27
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
package org.opensearch.sql.datasources.model.transport;

import lombok.Getter;
import java.io.IOException;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.sql.datasource.model.DataSourceMetadata;

import java.io.IOException;
import java.util.Map;

import static org.opensearch.sql.analysis.DataSourceSchemaIdentifierNameResolver.DEFAULT_DATASOURCE_NAME;
import static org.opensearch.sql.datasources.utils.XContentParserUtils.CONNECTOR_FIELD;
import static org.opensearch.sql.datasources.utils.XContentParserUtils.NAME_FIELD;

public class DataSourceActionRequest extends ActionRequest {

public DataSourceActionRequest(StreamInput in) throws IOException {
super(in);
}
public DataSourceActionRequest(StreamInput in) throws IOException {
super(in);
}

Check warning on line 12 in datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java#L11-L12

Added lines #L11 - L12 were not covered by tests

@Override
public ActionRequestValidationException validate() {
return null;
}
@Override
public ActionRequestValidationException validate() {
return null;

Check warning on line 16 in datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java#L16

Added line #L16 was not covered by tests
}

public DataSourceActionRequest() {
}
public DataSourceActionRequest() {}

// public DataSourceMetadata getSourceMetadata() {
// return null;
// }
//
// public Map<String, Object> getDataSourceData() {
// return Map.of();
// }
// public DataSourceMetadata getSourceMetadata() {
// return null;
// }
//
// public Map<String, Object> getDataSourceData() {
// return Map.of();
// }
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package org.opensearch.sql.datasources.model.transport;

import java.io.IOException;
import lombok.Getter;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;

import java.io.IOException;

public class DataSourceActionResponse extends ActionResponse {
@Getter
String result;

public DataSourceActionResponse() {
}
public class DataSourceActionResponse extends ActionResponse {
@Getter String result;

public DataSourceActionResponse(StreamInput in) throws IOException {
super(in);
}
public DataSourceActionResponse() {}

@Override
public void writeTo(StreamOutput streamOutput) throws IOException {
public DataSourceActionResponse(StreamInput in) throws IOException {
super(in);
}

Check warning on line 16 in datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java#L15-L16

Added lines #L15 - L16 were not covered by tests

}
}
@Override
public void writeTo(StreamOutput streamOutput) throws IOException {}

Check warning on line 19 in datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java#L19

Added line #L19 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.io.IOException;
import java.util.Map;
import lombok.Getter;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.io.IOException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.io.IOException;
import lombok.Getter;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.sql.datasource.model.DataSourceMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.io.IOException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ private RestChannelConsumer executeUpdateRequest(RestRequest restRequest, NodeCl
new ActionListener<>() {
@Override
public void onResponse(
DataSourceActionResponse updateDataSourceActionResponse) {
DataSourceActionResponse updateDataSourceActionResponse) {
restChannel.sendResponse(
new BytesRestResponse(
RestStatus.OK,
"application/json; charset=UTF-8",
updateDataSourceActionResponse.getResult()));
}

@Override
@Override
public void onFailure(Exception e) {
handleException(e, restChannel);
}
Expand All @@ -223,27 +223,25 @@ private RestChannelConsumer executePatchRequest(RestRequest restRequest, NodeCli
return restChannel ->
Scheduler.schedule(

Check warning on line 224 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L222-L224

Added lines #L222 - L224 were not covered by tests
nodeClient,
() ->
{
nodeClient.execute(
TransportDataSourceAction.ACTION_TYPE,
new PatchDataSourceActionRequest(dataSourceData),
new ActionListener<>() {
@Override
public void onResponse(
DataSourceActionResponse patchDataSourceActionResponse) {
restChannel.sendResponse(
new BytesRestResponse(
RestStatus.OK,
"application/json; charset=UTF-8",
patchDataSourceActionResponse.getResult()));
}
() -> {
nodeClient.execute(

Check warning on line 227 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L227

Added line #L227 was not covered by tests
TransportDataSourceAction.ACTION_TYPE,
new PatchDataSourceActionRequest(dataSourceData),
new ActionListener<>() {

Check warning on line 230 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L230

Added line #L230 was not covered by tests
@Override
public void onResponse(DataSourceActionResponse patchDataSourceActionResponse) {
restChannel.sendResponse(

Check warning on line 233 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L233

Added line #L233 was not covered by tests
new BytesRestResponse(
RestStatus.OK,
"application/json; charset=UTF-8",
patchDataSourceActionResponse.getResult()));
}

Check warning on line 238 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L237-L238

Added lines #L237 - L238 were not covered by tests

@Override
public void onFailure(Exception e) {
handleException(e, restChannel);
}
});
@Override
public void onFailure(Exception e) {
handleException(e, restChannel);
}

Check warning on line 243 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L242-L243

Added lines #L242 - L243 were not covered by tests
});
});

Check warning on line 245 in datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java#L245

Added line #L245 was not covered by tests
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,29 @@ protected void doExecute(
UpdateDataSourceActionRequest request1 = (UpdateDataSourceActionRequest) request;
dataSourceService.updateDataSource(request1.getDataSourceMetadata());
String responseContent =
new JsonResponseFormatter<String>(PRETTY) {
@Override
protected Object buildJsonObject(String response) {
return response;
}
}.format("Updated DataSource with name " + request1.getDataSourceMetadata().getName());
new JsonResponseFormatter<String>(PRETTY) {
@Override
protected Object buildJsonObject(String response) {
return response;
}
}.format("Updated DataSource with name " + request1.getDataSourceMetadata().getName());
actionListener.onResponse(new UpdateDataSourceActionResponse(responseContent));
} else if (request instanceof PatchDataSourceActionRequest) {
PatchDataSourceActionRequest request2 = (PatchDataSourceActionRequest) request;
dataSourceService.patchDataSource(request2.getDataSourceData());
String responseContent =
new JsonResponseFormatter<String>(PRETTY) {
@Override
protected Object buildJsonObject(String response) {
return response;
}
}.format("Updated DataSource with name " + request2.getDataSourceData().get(NAME_FIELD));
new JsonResponseFormatter<String>(PRETTY) {

Check warning on line 75 in datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java#L72-L75

Added lines #L72 - L75 were not covered by tests
@Override
protected Object buildJsonObject(String response) {
return response;

Check warning on line 78 in datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java#L78

Added line #L78 was not covered by tests
}
}.format(
"Updated DataSource with name " + request2.getDataSourceData().get(NAME_FIELD));
actionListener.onResponse(new PatchDataSourceActionResponse(responseContent));
} else {
throw new IllegalArgumentException("Unexpected request type");

Check warning on line 84 in datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java

View check run for this annotation

Codecov / codecov/patch

datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java#L80-L84

Added lines #L80 - L84 were not covered by tests
}
// actionListener.onResponse(new UpdateDataSourceActionResponse(responseContent));
// actionListener.onResponse(new UpdateDataSourceActionResponse(responseContent));
} catch (Exception e) {
actionListener.onFailure(e);
}
Expand Down
11 changes: 5 additions & 6 deletions plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,12 @@ public List<RestHandler> getRestHandlers(
new ActionType<>(TransportGetDataSourceAction.NAME, GetDataSourceActionResponse::new),
TransportGetDataSourceAction.class),
new ActionHandler<>(
new ActionType<>(
TransportDataSourceAction.NAME, DataSourceActionResponse::new),
new ActionType<>(TransportDataSourceAction.NAME, DataSourceActionResponse::new),
TransportDataSourceAction.class),
// new ActionHandler<>(
// new ActionType<>(
// TransportPatchDataSourceAction.NAME, PatchDataSourceActionResponse::new),
// TransportPatchDataSourceAction.class),
// new ActionHandler<>(
// new ActionType<>(
// TransportPatchDataSourceAction.NAME, PatchDataSourceActionResponse::new),
// TransportPatchDataSourceAction.class),
new ActionHandler<>(
new ActionType<>(
TransportDeleteDataSourceAction.NAME, DeleteDataSourceActionResponse::new),
Expand Down

0 comments on commit 6fa4b27

Please sign in to comment.