PropertyEventMethodIndex
WebSquare.ModelUtil - 5.0_4.4547B.20211124.201933

WebSquare.ModelUtil Package

Type

engine

Property Summary

Event Summary

Method Summary

abort( submissionId )
Aborts the currently running submission.
copyChildrenNodes( srcXPath , destXPath , mode )
Copies the child nodes of scrXPath to the child nodes specified by destXPath.
copyNode( srcXPath , destXPath )
Appends the srcXPath node to the child node of the destXPath.
executeParallel( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in parallel without creating a workflow.
executeSerial( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in serial without creating a workflow.
executeSubmission( submissionID , requestData , obj )
Executes the submission of the corresponding submissionID.
executeWhilst( submission , condFn , maxRepeat , processMsg , resolveCallback , rejectCallback , id )
Repeatedly calls a certain submission without creating a workflow.
executeWorkflow( workflowId )
Executes the workflow of the received workflowId or workflowObj.
findInstanceNode( xpath )
Returns the nodes of the specified XPath inside the instance.
findInstanceNodes( xpath )
An array of document elements (or nodes) found by XPath
findSerializedNode( xpath )
WebSquare
getInstanceValue( xpath )
Returns the nodeValue of the instance of the corresponding XPath.
getRefToReqData( submissionObj )
Converts the ref of the submission into string, and returns the converted string.
getRunningWorkflow( workflowID )
Returns the object of the currently running first workflow.
getRunningWorkflowID( )
Returns the ID of the currently running workflow.
getSubmission( id )
Returns the submission of the corresponding ID.
getWorkflow( id )
Gets the workflow object of the corresponding ID.
isRunningWorkflow( workflowID )
Check whether there is a currently running workflow.
rejectWorkflow( reject , workflowID )
Rejects the currently running workflow.
removeChildNodes( xpath )
Removes the child nodes of the XPath.
removeInstanceNode( xpath )
Removes the instance nodes of the XPath.
removeInstanceNodes( xpath )
Removes the instance nodes of the XPath.Removes the instance nodes of the XPath.
setInstanceNode( doc , xpath , modelID , mode )
Sets the document or element in the instance node of the XPath.
setInstanceValue( xpath , value )
Sets the nodeValue in the instance node of the XPath.

Property Detail

Event Detail

Method Detail

abort( submissionId )
Aborts the currently running submission.
Parameter
nametyperequireddescription
submissionIdStringYID of the submission to abort
Sample
WebSquare.ModelUtil.abort( "ID of the submission to abort" );
copyChildrenNodes( srcXPath , destXPath , mode )
Copies the child nodes of scrXPath to the child nodes specified by destXPath in one of the following ways:
replaces all child nodes (replaceAll),
erges the child nodes of srcXPath and destXPath (overwrite),
appends child nodes of srcXPath to destXPath (append),
sets only the child nodes of destXPath (replaceOnly).
Parameter
nametyperequireddescription
srcXPathStringYxPath of the data to copy
destXPathStringYxPath of the destination
modeStringY( "replaceAll", "overwrite", "replaceOnly", "append" )
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> <selectedBook> <title lang="eng">Learning XML2</title> <price>39.952</price> <author>Erik T. Ray</author> </selectedBook> WebSquare.ModelUtil.copyChildrenNodes( "bookstore/book[@idx='2']" , "selectedBook", "replaceAll"); selectedBook node in the model is as shown below. <selectedBook> <title lang="eng">Learning XML</title> <price>39.95</price> </selectedBook> WebSquare.ModelUtil.copyChildrenNodes( "bookstore/book[@idx='2']" , "selectedBook", "overwrite"); <selectedBook> <title lang="eng">Learning XML</title> <price>39.95</price> <author>Erik T. Ray</author> </selectedBook> WebSquare.ModelUtil.copyChildrenNodes( "bookstore/book[@idx='2']" , "selectedBook", "append"); <selectedBook> <title lang="eng">Learning XML2</title> <price>39.952</price> <author>Erik T. Ray</author> <title lang="eng">Learning XML</title> <price>39.95</price> </selectedBook> WebSquare.ModelUtil.copyChildrenNodes( "bookstore/book[@idx='2']" , "selectedBook", "replaceOnly");
copyNode( srcXPath , destXPath )
Appends the srcXPath node to the child node of the destXPath.
The existing nodes under destXPath will be removed.
Parameter
nametyperequireddescription
srcXPathStringYxPath of the data to append
destXPathStringYxPath of the destination
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> WebSquare.ModelUtil.copyNode( "bookstore/book[@idx='2']" , "selectedBook"); selectedBook node in the model is as shown below. <selectedBook> <book idx='2'> <title lang='eng'>Learning XML</title> <price>39.95</price> </book> </selectedBook>
executeParallel( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in parallel without creating a workflow.
submission1 call -> submission2 call -> submission1 callback -> submission2 callback
Parameter
nametyperequireddescription
submissionarrayYid array ex) ["submission1", "submission2", "submission3"]
processMsgStringN
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
WebSquare.ModelUtil.executeParallel( ["submission1", "submission2", "submission3"],processMsg, final_callback, reject_callback, id) ; submission1,submission2, submission3 call -> submission1 callback -> submission2 callback -> submission3 callback -> final_callback or reject_callback
executeSerial( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in serial without creating a workflow.
submission1 call -> submission1 callback -> submission2 call -> submission2 callback
Parameter
nametyperequireddescription
submissionarrayYid array ex) ["submission1", "submission2", "submission3"]
processMsgStringN
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
WebSquare.ModelUtil.executeSerial( ["submission1", "submission2", "submission3"], processMsg,final_callback, reject_callback) ; submission1 call/callback -> submission2 call/callback -> submission3 call/callback -> final_callback or reject_callback
executeSubmission( submissionID , requestData , obj )
Executes the submission of the specified submissionID.
Parameter
nametyperequireddescription
submissionIDStringYID of the submission
requestDataObjectNRequested data
objObjectNComponent to disable during submission
Sample
WebSquare.ModelUtil.executeSubmission ("submission1") ; Execute submission1.
executeWhilst( submission , condFn , maxRepeat , processMsg , resolveCallback , rejectCallback , id )
Repeatedly calls a certain submission without creating a workflow.
Parameter
nametyperequireddescription
submissionStringYID
condFnfunctionYpre function checking the execution status
maxRepeatintYMaximum execution count. Can be used to control infinite loops when the workflow can be identified only by the condition.
processMsgStringN
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
WebSquare.ModelUtil.executeSerial( "submission1", cond_check, 100, processMsg,final_callback, reject_callback, id) ; Repeatedly calls (and calls back) the submission not more than 100 times when cond_check is success. -> final_callback or reject_callback
executeWorkflow( workflowId )
Executes the workflow of the received workflowId or workflowObj.
Parameter
nametyperequireddescription
workflowIdObjectYworkflow ID or workflowObj
Sample
WebSquare.ModelUtil.executeWorkflow ("workflow1") ; workflowCollection/Run the workflow of which ID is workflow1. Or var workflowObj= {"id":"workflow1", "processMsg" : "Running.. ", "step" : [{ "type":"submit", "action" : "submission1"}, { "type":"submit","pre": cond, "action" : "submission2"}, { "type":"submitDone", "action" : "submission1", "post":post}, { "type":"submitDone", "action" : "submission2", "post":post} ], "resolveCallback" : final_callback, "rejectCallback": reject_callback }) ; WebSquare.ModelUtil.executeWorkflow (workflowObj) ; Run the workflow with the workflowObj object.
findInstanceNode( xpath )
Finds the nodeValue of the instance of the corresponding XPath. If multiple nodes exists, returns the first node.
Parameter
nametyperequireddescription
xpathStringYXPath of the instance node to find
Return
typedescription
Xml ElementXML element found by XPath
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> var xmlDoc = WebSquare.ModelUtil.findInstanceNode ("bookstore/book"); The xmlDoc is as shown below. <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book>
findInstanceNodes( xpath )
Finds the nodeValue of the instance of the corresponding XPath as an array.
Parameter
nametyperequireddescription
xpathStringYXPath of the instance node to find
Return
typedescription
ObjectAn array of document elements (or nodes) found by XPath
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> var xmlDoc = WebSquare.ModelUtil.findInstanceNodes( "bookstore/book" ); xmlDoc.length is 2. xmlDoc[0] is as shown below. <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> xmlDoc[1] is as shown below. <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book>
findSerializedNode( xpath )
Serializes the node found by WebSquare.ModelUtil.findInstanceNode, and returns the result.
Parameter
nametyperequireddescription
xpathStringYXPath of the instance node to find
Return
typedescription
StringSerialized document element (node)
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> var xmlStr = WebSquare.ModelUtil.findSerializedNode ("bookstore/book"); xmlStr is as shown below. <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book>
getInstanceValue( xpath )
Returns the nodeValue of the instance of the corresponding XPath.
f the node is an element, child nodes will be searched from the first to the last.
If the node is an attribute, child nodes will not be searched.
Instead, the nodeValue will be immeidately returned.
Parameter
nametyperequireddescription
xpathStringYXPath of the instance node to find
Return
typedescription
StringnodeValue found by XPath
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> var value1 = WebSquare.ModelUtil.getInstanceValue( "bookstore/book/title[@lang='eng']" ); var value2 = WebSquare.ModelUtil.getInstanceValue( "bookstore/book/title" ); var value3 = WebSquare.ModelUtil.getInstanceValue( "bookstore/book/title/@lang" ); value1 and value2 is Harry Potter. value3 is eng.
getRefToReqData( submissionObj )
Converts the ref of the submission into string, and returns the converted string.
Parameter
nametyperequireddescription
submissionObjObjectYsubmission object
getRunningWorkflow( workflowID )
Returns the ID of the currently running first workflow.
Parameter
nametyperequireddescription
workflowIDStringNworkflow ID
Return
typedescription
ObjectCurrently running workflow object
Sample
f the submission has been dynamically created, the objects can be obtained only in the running node (pre, defaultCallback, callback, resolveCallback, rejectCallback, etc.) Use workflowObj.result to get the result of the completed submissions. var workflowObj = WebSquare.ModelUtil.getRunningWorkflow( );
getRunningWorkflowID( )
Returns the ID of the currently running workflow.
Return
typedescription
StringID of the currently running workflow
Sample
Return the currently running workflow ID var runID = WebSquare.ModelUtil.getRunningWorkflowID( );
getSubmission( id )
Submission of the specified ID will be returned.
Parameter
nametyperequireddescription
idStringYID of the submission
Return
typedescription
ObjectSubmission of the specified ID
Sample
The submission is as shown below. <xf:submission id="submission1" ref="request" target="response" action="" method="" mediatype="text/xml" encoding="UTF-8" instance="" replace="instance" errorHandler="" customHandler="" mode="asynchronous" processMsg=""> </xf:submission> var sub = WebSquare.ModelUtil.getSubmission( "submission1" ); sub is a submission object and can be accessed as shown below. sub.action = "/getBookInfo.jsp"; sub.method = "get"; ...
getWorkflow( id )
Gets the workflow object of the corresponding ID.
Parameter
nametyperequireddescription
idStringYworkflow ID
Return
typedescription
ObjectWorkflow of the corresponding ID
Sample
If workflow1 is defined in XML, the workflow object can be obtained even before execution. If the submission has been dynamically created, the objects can be obtained only in the running node (pre, defaultCallback, callback, resolveCallback, rejectCallback, etc.) Use workflowObj.result to get the result of the completed submissions. var workflowObj = WebSquare.ModelUtil.getWorkflow( "workflow1" );
isRunningWorkflow( workflowID )
Check whether there is a currently running workflow.
If the workflow ID is known, the execution status of the workflow will be returned.
Parameter
nametyperequireddescription
workflowIDStringNworkflow ID
Return
typedescription
booleanExecution status
Sample
Check whether there is a currently running workflow. var isRun = WebSquare.ModelUtil.isRunningWorkflow( );
rejectWorkflow( reject , workflowID )
Rejects the currently running workflow. When the workflow ID is given, the workflow will be rejected only when in running.
Parameter
nametyperequireddescription
rejectStringNReason of rejection
workflowIDStringN
Return
typedescription
ObjectRejected workflow Object
Sample
var workflowObj = WebSquare.ModelUtil.rejectWorkflow( );
removeChildNodes( xpath )
Removes the child nodes of the XPath.
Parameter
nametyperequireddescription
xpathStringYXPath of the parent to remove the child nodes
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> WebSquare.ModelUtil.removeChildNodes("bookstore/book"); The bookstore node is as shown below. <bookstore> <book idx="1"/> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore>
removeInstanceNode( xpath )
Removes the child node of the XPath.
Parameter
nametyperequireddescription
xpathStringYXPath of the node to remove
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> WebSquare.ModelUtil.removeInstanceNode("bookstore/book"); The bookstore node is as shown below. <bookstore> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore>
removeInstanceNodes( xpath )
Removes the instance nodes of the XPath.
Parameter
nametyperequireddescription
xpathStringYXPath of the node to remove
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> WebSquare.ModelUtil.removeInstanceNodes("bookstore/book"); The bookstore node is as shown below. <bookstore/>
setInstanceNode( doc , xpath , modelID , mode )
Sets the document or element in the instance node of the XPath.
In the replace mode, the existing nodes will be removed and new nodes will be added.
In append mode, new nodes will be appended to the existing nodes.
If not specified, the replace mode will be used.
Parameter
nametyperequireddescription
docObjectYDocument or Document Element (node)
xpathStringYXPath to set the node
modelIDStringNModel ID of the XPath to set the node (Currently not available.)
modeStringNmode ("replace", "append")
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> <selectedBook> <title lang="eng">Learning XML2</title> <price>39.952</price> <author>Erik T. Ray</author> </selectedBook> var doc = WebSquare.ModelUtil.findInstanceNode( "bookstore/book" ); WebSquare.ModelUtil.setInstanceNode( doc, "selectedBook", null , "replace" ); selectedBook node in the model is as shown below. <selectedBook> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> </selectedBook> var doc = WebSquare.ModelUtil.findInstanceNode( "bookstore/book" ); WebSquare.ModelUtil.setInstanceNode( doc, "selectedBook", null , "append" ); <selectedBook> <title lang="eng">Learning XML2</title> <price>39.952</price> <author>Erik T. Ray</author> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> </selectedBook>
setInstanceValue( xpath , value )
Sets the nodeValue in the instance node of the XPath.
Parameter
nametyperequireddescription
xpathStringYXPath of the instance node
valueStringYText value to set
Return
typedescription
BooleanIf the mode does not exist, false. Otherwise, true.
Sample
Bind the data with the model as shown below. <bookstore> <book idx="1"> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore> var value1 = WebSquare.ModelUtil.setInstanceValue( "bookstore/book/title/@lang" , "kor"); var value2 = WebSquare.ModelUtil.setInstanceValue( "bookstore/book/title" , "Harry Potter"); value1 and value2 are true. The following is the resulting XML document. <bookstore> <book idx="1"> <title lang="kor">Harry Potter</title> <price>29.99</price> </book> <book idx="2"> .. Omitted </book> </bookstore>