Skip to content

Commit

Permalink
Fixed rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Klish committed Sep 22, 2020
1 parent c3ac3da commit 04c432e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 163 deletions.
96 changes: 0 additions & 96 deletions elide-core/src/main/java/com/yahoo/elide/Elide.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,6 @@ protected Set<Class<?>> registerCustomSerdeScan() {
return ClassScanner.getAnnotatedClasses(ElideTypeConverter.class);
}

/**
* Handle GET.
*
* @param path the path
* @param queryParams the query params
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse get(String path, MultivaluedMap<String, String> queryParams, Object opaqueUser) {
return get(null, path, queryParams, opaqueUser);
}

/**
* Handle GET.
*
Expand Down Expand Up @@ -197,32 +185,6 @@ public ElideResponse get(String baseUrlEndPoint, String path, MultivaluedMap<Str
});
}

/**
* Handle POST.
*
* @param path the path
* @param jsonApiDocument the json api document
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse post(String path, String jsonApiDocument, Object opaqueUser) {
return post(null, path, jsonApiDocument, null, opaqueUser);
}

/**
* Handle POST.
*
* @param path the path
* @param jsonApiDocument the json api document
* @param queryParams the query params
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse post(String path, String jsonApiDocument,
MultivaluedMap<String, String> queryParams, Object opaqueUser) {
return post(null, path, jsonApiDocument, queryParams, opaqueUser);
}

/**
* Handle POST.
*
Expand Down Expand Up @@ -264,21 +226,6 @@ public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDoc
});
}

/**
* Handle PATCH.
*
* @param contentType the content type
* @param accept the accept
* @param path the path
* @param jsonApiDocument the json api document
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse patch(String contentType, String accept,
String path, String jsonApiDocument, Object opaqueUser) {
return patch(null, contentType, accept, path, jsonApiDocument, null, opaqueUser);
}

/**
* Handle PATCH.
*
Expand All @@ -298,23 +245,6 @@ public ElideResponse patch(String baseUrlEndPoint, String contentType, String ac
null, opaqueUser, apiVersion, UUID.randomUUID());
}

/**
* Handle PATCH.
*
* @param contentType the content type
* @param accept the accept
* @param path the path
* @param jsonApiDocument the json api document
* @param queryParams the query params
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse patch(String contentType, String accept,
String path, String jsonApiDocument,
MultivaluedMap<String, String> queryParams, Object opaqueUser) {
return patch(null, contentType, accept, path, jsonApiDocument, queryParams, opaqueUser);
}

/**
* Handle PATCH.
*
Expand Down Expand Up @@ -362,18 +292,6 @@ public ElideResponse patch(String baseUrlEndPoint, String contentType, String ac
return handleRequest(false, opaqueUser, dataStore::beginTransaction, requestId, handler);
}

/**
* Handle DELETE.
*
* @param path the path
* @param jsonApiDocument the json api document
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse delete(String path, String jsonApiDocument, Object opaqueUser) {
return delete(null, path, jsonApiDocument, null, opaqueUser);
}

/**
* Handle DELETE.
*
Expand All @@ -389,20 +307,6 @@ public ElideResponse delete(String baseUrlEndPoint, String path, String jsonApiD
return delete(baseUrlEndPoint, path, jsonApiDocument, null, opaqueUser, apiVersion, UUID.randomUUID());
}

/**
* Handle DELETE.
*
* @param path the path
* @param jsonApiDocument the json api document
* @param queryParams the query params
* @param opaqueUser the opaque user
* @return Elide response object
*/
public ElideResponse delete(String path, String jsonApiDocument,
MultivaluedMap<String, String> queryParams, Object opaqueUser) {
return delete(null, path, jsonApiDocument, queryParams, opaqueUser);
}

/**
* Handle DELETE.
*
Expand Down
18 changes: 0 additions & 18 deletions elide-core/src/main/java/com/yahoo/elide/core/RequestScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,6 @@ public class RequestScope implements com.yahoo.elide.security.RequestScope {
/* Used to filter across heterogeneous types during the first load */
private FilterExpression globalFilterExpression;

/**
* Create a new RequestScope with specified update status code.
*
* @param path the URL path
* @param jsonApiDocument the document for this request
* @param transaction the transaction for this request
* @param user the user making this request
* @param queryParams the query parameters
* @param elideSettings Elide settings object
*/
public RequestScope(String path,
JsonApiDocument jsonApiDocument,
DataStoreTransaction transaction,
User user,
MultivaluedMap<String, String> queryParams,
ElideSettings elideSettings) {
this(null, path, jsonApiDocument, transaction, user, queryParams, elideSettings);
}
/**
* Create a new RequestScope with specified update status code.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,5 @@ public void testInMemoryDataStore() {
assertTrue(tos.contains("Table class example.StringId contents"));
assertTrue(tos.contains("Table class example.UpdateAndCreate contents"));
assertTrue(tos.contains("Table class example.User contents"));
assertTrue(tos.contains("Table class example.packageshareable.ContainerWithPackageShare contents"));
assertTrue(tos.contains("Table class example.packageshareable.ShareableWithPackageShare contents"));
assertTrue(tos.contains("Table class example.packageshareable.UnshareableWithEntityUnshare contents"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class AbstractHQLQueryBuilder {
protected static final String FROM = " FROM ";
protected static final String JOIN = " JOIN ";
protected static final String LEFT = " LEFT";
protected static final String FETCH = "FETCH ";
protected static final String FETCH = " FETCH ";
protected static final String SELECT = "SELECT ";
protected static final String AS = " AS ";
protected static final String DISTINCT = "DISTINCT ";
Expand All @@ -53,7 +53,6 @@ public abstract class AbstractHQLQueryBuilder {
protected static final boolean USE_ALIAS = true;
protected static final boolean NO_ALIAS = false;
protected Set<String> alreadyJoined = new HashSet<>();
protected Set<String> alreadyJoinedAliases = new HashSet<>();

/**
* Represents a relationship between two entities.
Expand Down Expand Up @@ -170,8 +169,9 @@ protected void addPaginationToQuery(Query query) {
* @param skipFetches Don't fetch join
* @return A HQL string representing the join
*/
private String joinClauseFromPath(Path path, boolean skipFetches) {
private String extractJoinClause(Path path, boolean skipFetches) {
StringBuilder joinClause = new StringBuilder();

String previousAlias = null;

for (Path.PathElement pathElement : path.getPathElements()) {
Expand Down Expand Up @@ -203,14 +203,14 @@ private String joinClauseFromPath(Path path, boolean skipFetches) {
//This is a to-One relationship belonging to the collection being retrieved.
if (!skipFetches && entityProjection.getIncludedRelationsName().contains(fieldName) && type.isToOne()
&& !type.isComputed() && previousAlias == null) {
fetch = FETCH;
fetch = "FETCH ";

}
String joinFragment = LEFT + JOIN + fetch + joinKey + SPACE + alias + SPACE;

if (!alreadyJoined.contains(joinKey)) {
joinClause.append(joinFragment);
alreadyJoined.add(joinKey);
alreadyJoinedAliases.add(alias);
}

previousAlias = alias;
Expand Down Expand Up @@ -243,17 +243,12 @@ protected String extractToOneMergeJoins(Class<?> entityClass, String alias,
continue;
}
String joinKey = alias + PERIOD + relationshipName;
String relationshipAlias = alias + UNDERSCORE + relationshipName;

if (alreadyJoined.contains(joinKey)) {
continue;
}

alreadyJoined.add(joinKey);
alreadyJoinedAliases.add(relationshipAlias);
joinString.append(LEFT);
joinString.append(JOIN);
joinString.append(FETCH);
joinString.append(" LEFT JOIN FETCH ");
joinString.append(joinKey);
joinString.append(SPACE);
alreadyJoined.add(joinKey);
Expand All @@ -262,26 +257,6 @@ protected String extractToOneMergeJoins(Class<?> entityClass, String alias,
return joinString.toString();
}

/**
* Builds a explicit LEFT JOIN clauses instead of implicit sorting joins.
* @param sorting The sorting object passed from the client
* @param sortClass The class to sort.
* @return The JOIN clause that can be added to the FROM clause.
*/
protected String explicitSortJoins(final Optional<Sorting> sorting, Class<?> sortClass) {
StringBuilder joinClause = new StringBuilder();
if (sorting.isPresent() && !sorting.get().isDefaultInstance()) {
final Map<Path, Sorting.SortOrder> validSortingRules = sorting.get().getValidSortingRules(
sortClass, dictionary
);
for (Map.Entry<Path, Sorting.SortOrder> entry : validSortingRules.entrySet()) {
Path path = entry.getKey();
joinClause.append(joinClauseFromPath(path, true));
}
}
return joinClause.toString();
}

/**
* Returns a sorting object into a HQL ORDER BY string.
* @param sorting The sorting object passed from the client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,26 @@ public Query build() {

Boolean sortOverRelationship = entityProjection.getSorting() != null
&& entityProjection.getSorting().getSortingPaths().keySet()
.stream().anyMatch(path -> path.getPathElements().size() > 1);
.stream().anyMatch(path -> path.getPathElements().size() > 1);
if (requiresDistinct && sortOverRelationship) {
//SQL does not support distinct and order by on columns which are not selected
throw new InvalidValueException("Combination of pagination, sorting over relationship and"
+ " filtering over toMany relationships unsupported");
+ " filtering over toMany relationships unsupported");
}
query = session.createQuery(
SELECT
+ (requiresDistinct ? DISTINCT : "")
+ entityAlias
+ FROM
+ entityName
+ AS
+ entityAlias
+ SPACE
+ joinClause
+ SPACE
+ filterClause
+ SPACE
+ getSortClause(entityProjection.getSorting())
+ (requiresDistinct ? DISTINCT : "")
+ entityAlias
+ FROM
+ entityName
+ AS
+ entityAlias
+ SPACE
+ joinClause
+ SPACE
+ filterClause
+ SPACE
+ getSortClause(entityProjection.getSorting())
);

//Fill in the query parameters
Expand All @@ -94,7 +94,6 @@ public Query build() {
+ SPACE
+ getJoinClauseFromSort(entityProjection.getSorting())
+ extractToOneMergeJoins(entityClass, entityAlias)
+ explicitSortJoins(sorting, entityClass)
+ SPACE
+ getSortClause(entityProjection.getSorting()));
}
Expand Down

0 comments on commit 04c432e

Please sign in to comment.