Package io.inversion.action.db
Class DbGetAction<A extends DbGetAction>
- java.lang.Object
-
- io.inversion.Rule<A>
-
- io.inversion.Action<A>
-
- io.inversion.action.db.DbGetAction<A>
-
- All Implemented Interfaces:
java.lang.Comparable<A>
public class DbGetAction<A extends DbGetAction> extends Action<A>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.inversion.Rule
Rule.RuleMatcher
-
-
Field Summary
Fields Modifier and Type Field Description protected intmaxRows-
Fields inherited from class io.inversion.Rule
ALL_METHODS, configMap, description, excludeMatchers, excludeOn, includeMatchers, includeOn, log, name, order, params
-
-
Constructor Summary
Constructors Constructor Description DbGetAction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigureOp(io.inversion.utils.Task task, Op op)This task has been selected to run as part of the supplied operation, this callback allows actions to perform any custom configuration on the op.protected voidexpand(Request request, Collection collection, java.util.List<io.inversion.json.JSMap> parentObjs, java.util.Set expands, java.lang.String expandsPath, org.apache.commons.collections4.map.MultiKeyMap pkCache)This is more complicated than it seems like it would need to be because it attempts to retrieve all values of a relationship at a time for the whole document.protected static java.lang.StringexpandPath(java.lang.String path, java.lang.Object next)protected java.util.List<Rule.RuleMatcher>getDefaultIncludeMatchers()Designed to allow subclasses to provide a default match behavior of no configuration was provided by the developer.protected static java.lang.StringgetForeignKey(Relationship rel, io.inversion.json.JSMap node)intgetMaxRows()protected java.util.List<io.inversion.utils.KeyValue<java.lang.String,java.lang.String>>getRelatedKeys(Relationship rel, Index idxToMatch, Index idxToRetrieve, java.util.List<java.lang.String> toMatchEks)protected static java.lang.StringgetResourceKey(Collection collection, io.inversion.json.JSMap node)protected java.util.List<io.inversion.json.JSMap>recursiveGet(org.apache.commons.collections4.map.MultiKeyMap pkCache, Collection collection, java.util.Collection resourceKeys, java.lang.String expandsPath)voidrun(Request req, Response res)Override this method with your custom business logic or override one of the http method "doMETHOD" specific handlers.protected Resultsselect(Request req, Collection collection, Api api)protected static booleanshouldExpand(java.util.Set<java.lang.String> expands, java.lang.String path, Relationship rel)static java.lang.StringstripTerms(java.lang.String url, java.lang.String... tokens)DbGetActionwithMaxRows(int maxRows)-
Methods inherited from class io.inversion.Action
doDelete, doGet, doPatch, doPost, doPut, getFullIncludePaths, getIncludePaths, isDecoration, joinPaths, joinPaths0, run0, withDecoration
-
Methods inherited from class io.inversion.Rule
afterWiringComplete, checkLazyConfig, compareTo, doLazyConfig, getAllExcludePaths, getAllIncludeMethods, getAllIncludePaths, getDescription, getExcludeMatchers, getIncludeMatchers, getName, getOrder, getParams, match, match, matches, matches, toString, withDescription, withExcludeOn, withExcludeOn, withIncludeOn, withIncludeOn, withName, withOrder, withParam, withParams
-
-
-
-
Method Detail
-
configureOp
public void configureOp(io.inversion.utils.Task task, Op op)This task has been selected to run as part of the supplied operation, this callback allows actions to perform any custom configuration on the op.- Overrides:
configureOpin classAction<A extends DbGetAction>- Parameters:
task-op-
-
getDefaultIncludeMatchers
protected java.util.List<Rule.RuleMatcher> getDefaultIncludeMatchers()
Description copied from class:RuleDesigned to allow subclasses to provide a default match behavior of no configuration was provided by the developer.- Overrides:
getDefaultIncludeMatchersin classRule<A extends DbGetAction>- Returns:
- the default include match "*","*"
-
getForeignKey
protected static java.lang.String getForeignKey(Relationship rel, io.inversion.json.JSMap node)
-
getResourceKey
protected static java.lang.String getResourceKey(Collection collection, io.inversion.json.JSMap node)
-
stripTerms
public static java.lang.String stripTerms(java.lang.String url, java.lang.String... tokens)
-
expandPath
protected static java.lang.String expandPath(java.lang.String path, java.lang.Object next)
-
shouldExpand
protected static boolean shouldExpand(java.util.Set<java.lang.String> expands, java.lang.String path, Relationship rel)
-
run
public void run(Request req, Response res) throws ApiException
Description copied from class:ActionOverride this method with your custom business logic or override one of the http method "doMETHOD" specific handlers.- Overrides:
runin classAction<A extends DbGetAction>- Parameters:
req- the Request being servicedres- the Reponse being generated- Throws:
ApiException
-
select
protected Results select(Request req, Collection collection, Api api) throws ApiException
- Throws:
ApiException
-
expand
protected void expand(Request request, Collection collection, java.util.List<io.inversion.json.JSMap> parentObjs, java.util.Set expands, java.lang.String expandsPath, org.apache.commons.collections4.map.MultiKeyMap pkCache)
This is more complicated than it seems like it would need to be because it attempts to retrieve all values of a relationship at a time for the whole document. It does not run a recursive query for each resource and each relationship which could mean hundreds and hundreds of queries per document. This should result in number of queries proportional to the number of expands terms that does not increase with the number of results at any level of the expansion.- Parameters:
request- the request being servicedcollection- the collection being queriedparentObjs- the records that were just selectedexpands- the definition of which properties should be expandedexpandsPath- the path we are currently onpkCache- a cache of things already looked up
-
getRelatedKeys
protected java.util.List<io.inversion.utils.KeyValue<java.lang.String,java.lang.String>> getRelatedKeys(Relationship rel, Index idxToMatch, Index idxToRetrieve, java.util.List<java.lang.String> toMatchEks) throws ApiException
- Throws:
ApiException
-
recursiveGet
protected java.util.List<io.inversion.json.JSMap> recursiveGet(org.apache.commons.collections4.map.MultiKeyMap pkCache, Collection collection, java.util.Collection resourceKeys, java.lang.String expandsPath) throws ApiException- Throws:
ApiException
-
getMaxRows
public int getMaxRows()
-
withMaxRows
public DbGetAction withMaxRows(int maxRows)
-
-