Class ModelWriteRequest<M extends Model>
java.lang.Object
com.onenetwork.platform.data.model.ModelWriteRequest<M>
public class ModelWriteRequest<M extends Model>
extends java.lang.Object
Detailed request for writing Models, which includes parameters for changing natural keys,
returning processed records, etc.
-
Constructor Summary
Constructors Constructor Description ModelWriteRequest(ModelList<M> modelList)
Constructs the write request. -
Method Summary
Modifier and Type Method Description java.lang.Integer
getChunkSize()
{@see #setChunkSize(Integer)}ModelList<M>
getModelList()
Returns the ModelList to be writtenboolean
isChangeNaturalKeys()
Returns whether to attempt to change the natural keys of the model.boolean
isLookupModelLinkNaturalKeys()
In general, when writing models, one can provide either Surrogate Ids or Natural Keys on model link fields.boolean
isReturnProcessedRecords()
Returns whether the write operation should return all processed records instead of the default of errors only.boolean
isRollbackAllOnError()
Returns whether to rollback the entire transaction if any model fails to write.boolean
isSuppressAudit()
By default, Platform will write Audit records if Audit is enabled for the model.void
setChangeNaturalKeys(boolean changeNaturalKeys)
Sets whether to attempt to change the natural keys of the model.void
setChunkSize(java.lang.Integer chunkSize)
When Models are written, Platform separates the list of models into chunks of 50 (or whatever value is specified as "ChunkSize" in InstanceConfig.xml).void
setLookupModelLinkNaturalKeys(boolean lookupModelLinkNaturalKeys)
void
setModelList(ModelList<M> modelList)
void
setReturnProcessedRecords(boolean returnProcessedRecords)
Returns whether the write operation should return all processed records instead of the default of errors only.void
setRollbackAllOnError(boolean rollbackAllOnError)
Sets whether to rollback the entire transaction if any model fails to write.void
setSuppressAudit(boolean suppressAudit)
-
Constructor Details
-
ModelWriteRequest
Constructs the write request.- Parameters:
modelList
- ModelList containing the models to write
-
-
Method Details
-
getModelList
Returns the ModelList to be written -
setModelList
- Parameters:
modelList
- ModelList to be written
-
isChangeNaturalKeys
public boolean isChangeNaturalKeys()Returns whether to attempt to change the natural keys of the model. In order for this to function, you must have prepopulated the surrogate ids on the models being written. By default, natural keys are not changed in the write operation. -
setChangeNaturalKeys
public void setChangeNaturalKeys(boolean changeNaturalKeys)Sets whether to attempt to change the natural keys of the model. In order for this to function, you must have prepopulated the surrogate ids on the models being written. This will overwrite the AllowChange property set on this field in the action. By default, natural keys are not changed in the write operation.- Parameters:
changeNaturalKeys
- whether to change natural keys
-
isReturnProcessedRecords
public boolean isReturnProcessedRecords()Returns whether the write operation should return all processed records instead of the default of errors only. -
setReturnProcessedRecords
public void setReturnProcessedRecords(boolean returnProcessedRecords)Returns whether the write operation should return all processed records instead of the default of errors only.- Parameters:
returnProcessedRecords
- whether to return all processed records instead of the default of errors only.
-
isRollbackAllOnError
public boolean isRollbackAllOnError()Returns whether to rollback the entire transaction if any model fails to write. By default, the Model write operation supports partial success ... if some Models fail to write, those Model will be returned with an Error. However the remaining Models will process successfully. This flag can be set to true to fail all Model writes if even one fails. -
setRollbackAllOnError
public void setRollbackAllOnError(boolean rollbackAllOnError)Sets whether to rollback the entire transaction if any model fails to write. By default, the Model write operation supports partial success ... if some Models fail to write, those Model will be returned with an Error. However the remaining Models will process successfully. This flag can be set to true to fail all Model writes if even one fails.- Parameters:
rollbackAllOnError
- whether to rollback the entire transaction if any model fails to write.
-
isLookupModelLinkNaturalKeys
public boolean isLookupModelLinkNaturalKeys()In general, when writing models, one can provide either Surrogate Ids or Natural Keys on model link fields. Either will be processed properly when persisting the model. However, some workflows may become confused if one or the other is missing. When this boolean is set to true, natural keys for all model link fields will be looked up and populated on the models before calling the workflow, making it where the workflows can consistently use natural keys throughout without worrying about what the client provided.- Returns:
- whether to lookup model link NKs
-
setLookupModelLinkNaturalKeys
public void setLookupModelLinkNaturalKeys(boolean lookupModelLinkNaturalKeys)- Parameters:
lookupModelLinkNaturalKeys
- whether to lookup NKs for model links- See Also:
isLookupModelLinkNaturalKeys()
-
isSuppressAudit
public boolean isSuppressAudit()By default, Platform will write Audit records if Audit is enabled for the model. You can set the SuppressAudit flag to true to bypass this, even when Audit is enabled for the model.- Returns:
- whether to suppress Audit
-
setSuppressAudit
public void setSuppressAudit(boolean suppressAudit)- Parameters:
suppressAudit
- whether to suppress Audit- See Also:
isSuppressAudit()
-
getChunkSize
public java.lang.Integer getChunkSize(){@see #setChunkSize(Integer)}- Returns:
- custom chunk size
-
setChunkSize
public void setChunkSize(java.lang.Integer chunkSize)When Models are written, Platform separates the list of models into chunks of 50 (or whatever value is specified as "ChunkSize" in InstanceConfig.xml). Thus if someone tries to write 60 Shipments, it will be processed in the workflow engine as a chunk of 50 followed by a chunk of 10. There may be cases where you need to control this size. For example, if you are executing a "Consolidate" action, your workflow may need access to all 60 at once in order to consolidate the Shipments properly. In this case, you can set your custom chunk size here. You can set this value to null to force the system to use the default InstanceConfig-driven setting.- Parameters:
chunkSize
- custom chunkSize to set
-