Try storing serialized search object

Does not seem to be the best solution (https://stackoverflow.com/questions/17662236/java-write-object-to-mysql-each-field-or-serialized-byte-array)  and does not entirely work, but saving it for posterity because there are some interesting changes here
This commit is contained in:
NMerz
2020-11-14 11:40:42 -05:00
parent 2d3e985ded
commit 8653b9a035
10 changed files with 243 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
import com.amazonaws.services.lambda.AWSLambdaClientBuilder;
import com.amazonaws.services.lambda.model.InvokeRequest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -18,13 +21,22 @@ public class ItemSearcher implements CallHandler {
}
@Override
public Object conductAction(Map<String, Object> body, HashMap<String, String> queryParams, String s) throws SQLException {
public Object conductAction(Map<String, Object> body, HashMap<String, String> queryParams, String cognitoID) throws SQLException {
PreparedStatement getItemMatches = connection.prepareStatement(GET_ITEM_MATCHES);
getItemMatches.setString(1, "%" + queryParams.get("id") + "%");
System.out.println(getItemMatches);
ResultSet searchResults = getItemMatches.executeQuery();
ItemSearch searchResultsObject = new ItemSearch(searchResults);
System.out.println(searchResultsObject);
InvokeRequest invokeRequest = new InvokeRequest();
invokeRequest.setFunctionName("SearchHistoryUpdate");
invokeRequest.setPayload("{" +
" \"newSearch\": \"" + queryParams.get("id") + "\"," +
" \"cognitoID\": \""+ cognitoID + "\"" +
"}");
invokeRequest.setInvocationType("Event");
System.out.println(invokeRequest);
AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
return searchResultsObject;
}
}