简体   繁体   中英

How many types of bundle in guidewire policy centre

Explain bundle types like current bundle new bundle. When we will use & how it will act on my transaction. Explain with example please.

Caution: Don't run below Gosu Script in Production

A "current" bundle is a bundle that contains objects available to the current code context. This includes, but is not limited to, the user interface and plugins. These bundles are created automatically by the Guidewire application to create, modify, or edit data. Integration developers can reference entities in the current bundle. They can also commit current bundles, though in some situations this is not advisable.

var bundleVar = gw.transaction.Transaction.getCurrent()
bundle.Commit()

A read-only bundle is a bundle that contains entities retrieved from the database. This includes both entities returned as the result of a query, and entities referenced by the foreign key of a related entity when the related entity is in a read-only bundle. The entities in a read-only bundle cannot be modified. However, you can copy entities from a read-only bundle into a writeable bundle.

Example: Querying

在此处输入图像描述

A new bundle is a bundle created explicitly by integration code. Unlike a read-only bundle, you can modify and commit data in a new bundle. Unlike a current bundle, you can commit a new bundle without having to worry about later interaction occurring in the bundle.

•Creating a new bundle (no user specified):

gw.transaction.Transaction.runWithNewBundle(\ newBundle -> {
  CodeBlock } )

Example: Updatoing the Vin Number

//Getting the peopicy period by Job number
var period=Job.finder.findJobByJobNumber("12345").LatestPeriod
gw.transaction.Transaction.runWithNewBundle(\ newBundle -> {
  //Adding present object to the bundle
  
  newBundle.add(period)
  period.PersonalAutoLine.Vehicles.each(\ veh -> {
       print("before script ="+veh.Vin)
       veh.Vin="12345678"
       print("After script ="+veh.Vin)
  }
  } )

• •Creating a new bundle (as specified user):

gw.transaction.Transaction.runWithNewBundle(\ newBundle -> {
  CodeBlock } , user )

Example: Updating the Vin Number by User- Super User

gw.transaction.Transaction.runWithNewBundle(\ newBundle -> {
  //Adding present object to the bundle
  period.PersonalAutoLine.Vehicles.each(\ veh -> {
       veh.Vin="12345678"
  }
  } , "su")

•The runWithNewBundle() method inherently commits the bundle at the end of the method

There are mainly 3 types of Bundles.

  1. Current Bundle (Example: If a transaction is initiated in Guidewire UI, then automatically Current Bundle will be created by Guidewire itself)

  2. Read Only Bundle (Example: If you select any results from Database, then the results fetched using the Gosu Query will be available in Read Only Bundle. To make it writeable bundle then add the results to New Bundle)

  3. New Bundle (Example: This bundle is used for committing data or Entities, when you work with Batch Process, Webservice the Guidewire will not create any bundle, where in the developer has to create a new Bundle (run with new bundle) to commit the data to DB)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM