Class DbPostAction
- All Implemented Interfaces:
Comparable<DbPostAction>
- Direct Known Subclasses:
DbPatchAction,DbPutAction
-
Nested Class Summary
Nested classes/interfaces inherited from class io.inversion.Rule
Rule.RuleMatcher -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanWhen true, forces PUTs to have an resourceKey in the URLFields inherited from class io.inversion.Rule
configMap, configStr, excludeMatchers, excludeOn, includeMatchers, includeOn, log, name, order -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbooleanbooleanbooleanstatic StringvoidUnlike upsert for POST/PUT, this method is specifically NOT recursive for patching nested documents.voidOverride this method with your custom business logic or override one of the http method "doMETHOD" specific handlers.upsert(Request req, Collection collection, JSArray nodes) README README README READMEvoidwithCollapseAll(boolean collapseAll) withGetResponse(boolean expandResponse) withStrictRest(boolean strictRest) Methods inherited from class io.inversion.Rule
checkLazyConfig, compareTo, doLazyConfig, getAllExcludePaths, getAllIncludePaths, getConfig, getConfig, getConfigKeys, getDefaultIncludeMatch, getExcludeMatchers, getIncludeMatchers, getName, getOrder, match, matches, matches, toString, withConfig, withExcludeOn, withExcludeOn, withExcludeOn, withIncludeOn, withIncludeOn, withIncludeOn, withName, withOrder
-
Field Details
-
collapseAll
protected boolean collapseAll -
strictRest
protected boolean strictRestWhen true, forces PUTs to have an resourceKey in the URL -
getResponse
protected boolean getResponse
-
-
Constructor Details
-
DbPostAction
public DbPostAction()
-
-
Method Details
-
nextPath
-
run
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<DbPostAction>- Parameters:
req- the Request being servicedres- the Reponse being generated- Throws:
ApiException
-
patch
Unlike upsert for POST/PUT, this method is specifically NOT recursive for patching nested documents. It will only patch the parent collection/table.TODO: add support for JSON Patch format...maybe
- Parameters:
req- the request to runres- the response to populate- Throws:
ApiException
-
upsert
- Throws:
ApiException
-
upsert
README README README READMEAlgorithm:
Step 1: Upsert all
nodesin this generation...meaning not recursively including key values for all many-to-one foreign keys but excluding all one-to-many and many-to-many key changes...non many-to-one relationships involve modifying other tables that have foreign keys back to this collection's table, not the direct modification of the single table underlying this collection.Step 2: For each relationship POST back through the "front door". This is the primary recursion that enables nested documents to submitted all at once by client. Putting this step first ensure that all new objects are POSTed, with their newly created hrefs placed back in the JSON prior to any PUTs that depend on relationship keys to exist.
Step 3: PKs generated for child documents which are actually relationship parents, are set as foreign keys back on the parent json (which is actually the one-to-many child)
Step 4: Find the key values for all new/kept one-to-many and many-to-many relationships
Step 5.1 Upsert all of those new/kept relationships and create the RQL queries needed find all relationships NOT in the upserts.
Step 5.2 Null out all now invalid many-to-one foreign keys back and delete all now invalid many-to-many relationships rows.
- Parameters:
req- the request being servicedcollection- the collection be modifiednodes- the records to update- Returns:
- the entity keys of all upserted records
-
isCollapseAll
public boolean isCollapseAll() -
withCollapseAll
-
isStrictRest
public boolean isStrictRest() -
withStrictRest
-
isGetResponse
public boolean isGetResponse() -
withGetResponse
-
collapse
-