Example: Creating assignable entities
Creating an assignable extension entity type
To create an assignable extension entity, perform the following steps:
- Step 1: Create extension entity type UserAssignableEntity_Ext
- Step 2: Create assignment class NewAssignableMethodsImpl
- Step 3: Test assignment of your extension entity instance
Step 1: Create extension entity type UserAssignableEntity_Ext
The first step in creating an assignable entity type is to create the entity or extend the entity if it already exists.
About this task
The assignable entity type implements the following:
CCAssignabledelegate classCCAssignableMethodsinterface
The entity type must link to a Gosu class that defines the necessary assignment methods and properties. The
following procedure creates a new extension entity that implements NewAssignableMethodsImpl, a
delegate class.
Procedure
-
Create the new extension entity file.
- In Studio, navigate to .
- Right-click Entity and select .
-
Provide the required information for the new entity definition.
-
Enter the name of the extension entity in the text field.
To follow the rest of this procedure, use the name UserAssignableEntity_Ext.
- In Entity Type, select entity.
-
In Desc, type:
Assignable extension entity, for testing
- In Type, select retireable.
- Select the check boxes Extendable and Final.
- Click OK.
-
Enter the name of the extension entity in the text field.
-
In the entity editor, add the following items to UserAssignableEntity_Ext.
Element type Attribute Value fulldescription Simple entity that you can assign. This entity does not have a foreign key. implementsEntity name CCAssignable implementsInterface iface gw.api.assignment.CCAssignableMethods impl gw.assignment.NewAssignableMethodsImpl column name InstanceUpdateTime type datetime nullok true column name VarcharColumn type varchar nullok true columnparam name size value 60 typekey name Country typelist Country nullok true typekey name PhoneType typelist PhoneType nullok true index name internal1 indexcol name VarcharColumn keyposition 1
Results
Notice the following:
- Entity
UserAssignableEntity_Extimplements theCCAssignabledelegate. - Entity
UserAssignableEntity_Extuses class NewAssignableMethodsImpl, which implements theCCAssignableMethodsinterface, to define the necessary assignment methods and properties.
What to do next
See also
- For information on how to extend the data model, see Modifying the base data model.
- For information on the data model in general, see The PolicyCenter data model.
Step 2: Create assignment class NewAssignableMethodsImpl
Any new assignable entity must implement the CCAssignableMethods interface.
Before you begin
About this task
The following procedure defines a delegate class that provides an implementation of the methods in the
CCAssignableMethods interface. In the example, the
NewAssignableMethodsImpl class extends the abstract superclass
CCAssignableMethodsBaseImpl. The CCAssignableMethodsBaseImpl abstract
superclass provides standard implementations of some of the functionality for which the
CCAssignableMethods interface provides method signatures.
Procedure
-
Create a new class file in the package gw.assignment and name it
NewAssignableMethodsImpl.
- In Studio, navigate to .
- Right-click assignment and select .
-
Enter the name of the class in the text box.
For this example, enter the following class name.
NewAssignableMethodsImpl -
Click OK.
Studio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
-
Have your class do one of the following.
- Implement the interface
gw.api.assignment.CCAssignableMethods. - Extend the abstract superclass gw.api.assignment.CCAssignableMethodsBaseImpl.
Which of these options you implement depends on your business needs. In either case, you must provide method bodies for all unimplemented methods. To determine what methods you need to implement, you need merely to have your class implement the interface or extend the abstract superclass.
In this example, you extend the abstract superclass. Make the class declaration look like the following line.class NewAssignableMethodsImpl extends CCAssignableMethodsBaseImpl {The editor shows an error at CCAssignableMethodsBaseImpl.
- Implement the interface
- Press Alt-Enter and click Import class.
-
Press Alt-Enter and click Implement methods. Then, click
OK.
Studio provides skeleton method overrides for all the abstract methods in the gw.api.assignment.CCAssignableMethodsBaseImpl class. In later steps, you also override other methods that the abstract class implements.
-
Add a constructor to the class by entering the following code before the first overridden method.
construct(testEntity : UserAssignableEntity_Ext) { super(testEntity) } -
Add the following methods that override methods in CCAssignableMethodsBaseImpl.
override property get Owner() : UserAssignableEntity_Ext { return super.Owner as UserAssignableEntity_Ext } override function shouldCascadeAssignment(parent : Assignable, defaultOwnerUserId : Key, defaultGroupId : Key) : boolean { return false } - To resolve the error indication, press Alt-Enter and click Import class. Import the class gw.pl.persistence.core.Key.
Results
package gw.assignment
uses gw.api.assignment.CCAssignableMethods
uses gw.api.assignment.CCAssignableMethodsBaseImpl
uses gw.entity.ILinkPropertyInfo
uses gw.pl.persistence.core.Key
class NewAssignableMethodsImpl extends CCAssignableMethodsBaseImpl {
construct(testEntity : UserAssignableEntity_Ext) {
super(testEntity)
}
override property get AssignmentReviewActivitySubject() : String {
return null
}
override property get AssignmentReviewActivityLinkProperty() : ILinkPropertyInfo {
return null
}
override property get OwningClaim() : Claim {
return null
}
override function pushAssignmentPopup(list : List<CCAssignableMethods>) {
}
override property get ChildrenForCascadeAssignment() : List<CCAssignableMethods> {
return null
}
override property get Owner() : UserAssignableEntity_Ext {
return super.Owner as UserAssignableEntity_Ext
}
override function shouldCascadeAssignment(parent : Assignable, defaultOwnerUserId : Key,
defaultGroupId : Key) : boolean {
return false
}
}What to do next
Step 3: Test assignment of your extension entity instance
Before you begin
About this task
Procedure
- Stop the server, if it is running.
- Start the server from within Studio.
- Correct any problems that occur and repeat the previous steps until the server starts without errors.
-
If you have not already done so, load the demonstration data into the database.
The next step requires this data.
- Click to open the Studio Gosu Scratchpad.
-
Enter the following code in the Gosu Scratchpad tab.
uses gw.api.database.Query uses gw.api.database.Relop uses gw.transaction.Transaction var _users = Query.make(User).join(User#Credential).compare(Credential#UserName, Equals, "aapplegate") var _usr = _users.select().AtMostOneRow var _group = _usr.GroupUsers[0].Group Transaction.runWithNewBundle(\bundle -> { var newExtEntity = new UserAssignableEntity_Ext() }, "su") -
Click Run.
Output similar to the following lines appears in the Console tab.
true The assign method succeeded. Thus, it returns true. Andy Applegate The user that is assigned the newExtEntity (UserAssignableEntity_Ext) object. Auto1 - TeamA The group that is assigned the newExtEntity (UserAssignableEntity_Ext) object.
Making your extension entity eligible for round-robin assignment
To assign an entity instance through round-robin assignment, you invoke the assignUserByRoundRobin method on the entity. To implement round-robin assignment on the assignable entity, you need to add extra tracking properties for the round-robin state to the following entities:
DynamicAssignmentStateGroupAssignmentStateGroupUserAssignmentState
To do so, you add these properties as an extension to a base configuration entity. If the base entity does not exist, you create an extension entity with the necessary properties.
Finally, you must create a new Gosu class that extends (subclasses) the AssignmentType class. You add methods to this subclass to instruct the round-robin infrastructure how to find the newly added properties.
The following procedures assume the existence of an assignable entity type named UserAssignableEntity_Ext. The steps in Creating an assignable extension entity type describe how to create this entity.
This example includes the following steps:
- Step 1: Extend the AssignmentState entity types
- Step 2: Subclass class AssignmentType
- Step 3: Create class UserAssignableEntityExtEnhancement
- Step 4: Test round-robin assignment
Step 1: Extend the AssignmentState entity types
You extend AssignmentState entity types to add fields on the object that ClaimCenter uses to track information for the round robin state.
Before you begin
About this task
The first step in creating an entity type that you can use with round-robin assignment is to extend the following base configuration entity types:
DynamicAssignmentStateGroupAssignmentStateGroupUserAssignmentState
Procedure
-
In Guidewire Studio, open
DynamicAssignmentState.etx for editing or create a new entity extension.
-
Press Ctrl-N and start entering the entity type name.
Studio displays a number of matches because files with the name DynamicAssignmentState already exist.
- If DynamicAssignmentState.etx appears in the list, double-click that file.
- If DynamicAssignmentState.etx is not in the list, create a new extension by navigating to . Right-click Entity and select . Enter DynamicAssignmentState and click OK.
-
Press Ctrl-N and start entering the entity type name.
-
In the entity editor, add the following items to the DynamicAssignmentState
extension.
Element type Attribute Value foreignkey name LastTEAEUser fkentity User nullok true columnName LastTEAEUserId foreignkey name LastTEAEGrp fkentity Group nullok true columnName LastTEAEGrpId foreignkey name LastTCAUser fkentity User nullok true columnName LastTCAUserId foreignkey name LastTCAGrp fkentity Group nullok true columnName LastTCAGrpId - Add fields to the file GroupAssignmentState.etx. If this file does not exist, you need to create it. Follow the instructions in Step 1 to search for GroupAssignmentState.etx.
-
In the entity editor, add the following items to the GroupAssignmentState
extension.
Element type Attribute Value foreignkey name LastTEAEUser fkentity User nullok true columnName LastTEAEUserId foreignkey name LastTEAEGrp fkentity Group nullok true columnName LastTEAEGrpId foreignkey name LastTCAUser fkentity User nullok true columnName LastTCAUserId foreignkey name LastTCAGrp fkentity Group nullok true columnName LastTCAGrpId column name TEAELoad type integer nullok true column name TCALoad type integer nullok true - Add fields to the file GroupUserAssignmentState.etx. If this file does not exist, you need to create it. Follow the instructions in Step 1 to search for GroupUserAssignmentState.etx.
-
In the entity editor, add the following items to the GroupUserAssignmentState
extension.
Element type Attribute Value column name TEAELoad type integer nullok true column name TCALoad type integer nullok true
What to do next
Step 2: Subclass class AssignmentType
The AssignmentType class contains getter and setter methods that inform the round-robin mechanism of the location of fields in the AssignmentState entity types.
Before you begin
About this task
Procedure
-
Create a new class file in the package gw.assignment and name it
UserAssignableEntityExtAssignmentType.
- In Studio, navigate to .
- Right-click assignment and select .
-
Enter the name of the class in the text box.
For this example, enter the following class name.
UserAssignableEntityExtAssignmentTypeStudio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
-
Enter the following code in your class file.
package gw.assignment uses gw.api.assignment.AssignmentType uses gw.entity.IEntityType uses gw.pl.persistence.core.Key class UserAssignableEntityExtAssignmentType extends AssignmentType { construct() {} override function getLastAssignedUser(groupState : GroupAssignmentState) : Key { return groupState.LastTEAEUser.ID } override function getLastAssignedUser(dynamicState : DynamicAssignmentState) : Key { return dynamicState.LastTEAEUser.ID } override function setLastAssignedUser(groupState : GroupAssignmentState, user : Key) { groupState.LastTEAEUser = groupState.Bundle.loadBean(user) as User } override function setLastAssignedUser(dynamicState : DynamicAssignmentState, user : Key) { dynamicState.LastTEAEUser = dynamicState.Bundle.loadBean(user) as User } override function getUserLoad(groupUserState : GroupUserAssignmentState) : int { return groupUserState.TEAELoad } override function setUserLoad(groupUserState : GroupUserAssignmentState, load : int) { groupUserState.TEAELoad = load } override function getLastAssignedGroup(groupState : GroupAssignmentState) : Key { return groupState.LastTEAEGrp.ID } override function getLastAssignedGroup(dynamicState : DynamicAssignmentState) : Key { return dynamicState.LastTEAEGrp.ID } override function setLastAssignedGroup(groupState : GroupAssignmentState, group : Key) { groupState.LastTEAEGrp = groupState.Bundle.loadBean(group) as Group } override function setLastAssignedGroup(dynamicState : DynamicAssignmentState, group : Key) { dynamicState.LastTEAEGrp = dynamicState.Bundle.loadBean(group) as Group } override function getGroupLoad(groupState : GroupAssignmentState) : int { return groupState.TEAELoad } override function setGroupLoad(groupState : GroupAssignmentState, load : int) { groupState.TEAELoad = load } protected override property get AssignableClass() : IEntityType { return UserAssignableEntity_Ext } }Studio indicates that the code is invalid in the get AssignableClass method definition because you have not yet created the necessary UserAssignableEntity_Ext Gosu enhancement. You create this entity enhancement in the next step.
What to do next
Step 3: Create class UserAssignableEntityExtEnhancement
You create an enhancement to the UserAssignableEntity_Ext entity type for use in creating instances of that type.
Before you begin
Procedure
-
Create a new enhancement file and name it
UserAssignableEntityExtEnhancement.
- In Studio, navigate to .
- Right-click assignment and select .
-
Enter the UserAssignableEntity_Ext in the Enhanced type
text box.
The text that you enter filters the available entity types. If multiple selections are shown, ensure that you select UserAssignableEntity_Ext. This entity type is the one that you need to enhance.
-
Enter the name of the class in the Type to enhance text box.
For this example, enter the following class name.
UserAssignableEntityExtEnhancementStudio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
- Click OK.
-
Enter the following code in the enhancement file.
package gw.assignment uses gw.api.assignment.AssignmentType enhancement UserAssignableEntityExtEnhancement : UserAssignableEntity_Ext { static property get ASSIGNMENT_TYPE() : AssignmentType { return new UserAssignableEntityExtAssignmentType() } }
What to do next
Step 4: Test round-robin assignment
After you create an assignable entity type that is suitable for use with round-robin assignment, you must test your work to verify that you have performed the previous steps correctly.
Before you begin
About this task
Procedure
- Stop the server, if it is running.
- Start the server from within Studio.
- Correct any problems that occur and repeat the previous steps until the server starts without errors.
-
If you have not already done so, load the demonstration data into the database.
The next step requires this data.
- Click to open the Studio Gosu Scratchpad.
-
Enter the following code in the Gosu Scratchpad tab.
uses gw.api.database.Query uses gw.api.database.Relop uses gw.transaction.Transaction var _users = Query.make(User).join(User#Credential).compare(Credential#UserName, Equals, "aapplegate") var _usr = _users.select().AtMostOneRow var _group = _usr.GroupUsers[0].Group Transaction.runWithNewBundle(\bundle -> { for (i in 1..3) { print("Pass " + i + ":") var newExtEntity = new UserAssignableEntity_Ext() // Assign the entity to the specified user and group print(newExtEntity.assign(_group, _usr) + "\t\t\tThe assign method succeeded. Thus, it returns true.") print(newExtEntity.AssignedUser + "\tThe user that is assigned the newExtEntity (UserAssignableEntity_Ext) object.") print(newExtEntity.AssignedGroup + "\tThe group that is assigned the newExtEntity (UserAssignableEntity_Ext) object.") var assignedToUser = newExtEntity.assignUserByRoundRobin(false, _group) print("\t" + assignedToUser + "\t\t\tThe assignUserByRoundRobin method succeeded. Thus, it returns true.") print("\t" + newExtEntity.AssignedUser + "\tThe assignUserByRoundRobin method assigns the object to the next person in the group.") } }, "su") -
Click Run.
Output similar to the following lines appears in the Console tab.
Pass 1: true The assign method succeeded. Thus, it returns true. Andy Applegate The user that is assigned the newExtEntity (UserAssignableEntity_Ext) object. Auto1 - TeamA The group that is assigned the newExtEntity (UserAssignableEntity_Ext) object. true The assignUserByRoundRobin method succeeded. Thus, it returns true. Andy Applegate The assignUserByRoundRobin method assigns the object to the next person in the group. Pass 2: true The assign method succeeded. Thus, it returns true. Andy Applegate The user that is assigned the newExtEntity (UserAssignableEntity_Ext) object. Auto1 - TeamA The group that is assigned the newExtEntity (UserAssignableEntity_Ext) object. true The assignUserByRoundRobin method succeeded. Thus, it returns true. Sue Smith The assignUserByRoundRobin method assigns the object to the next person in the group. Pass 3: true The assign method succeeded. Thus, it returns true. Andy Applegate The user that is assigned the newExtEntity (UserAssignableEntity_Ext) object. Auto1 - TeamA The group that is assigned the newExtEntity (UserAssignableEntity_Ext) object. true The assignUserByRoundRobin method succeeded. Thus, it returns true. Betty Baker The assignUserByRoundRobin method assigns the object to the next person in the group.
Creating an assignable extension entity type that uses foreign keys
To create an assignable extension entity type with foreign key links to Claim
and Activity, perform the following steps:
- Step 1: Create extension entity type TestClaimAssignable_Ext
- Step 2: Add foreign keys to assignable entity types
- Step 3: Create new assignment type for extension entity type TestClaimAssignable_Ext
- Step 4: Create enhancement class TestClaimAssignableExtEnhancement
- Step 5: Create delegate class TestClaimAssignableMethodsImpl
- Step 6: Add the necessary permission for the extension entity type
- Step 7: Test assignment of the assignable entity type
Step 1: Create extension entity type TestClaimAssignable_Ext
Before you begin
About this task
The first step is to create the assignable entity type. As with any assignable entity type, it must implement the following:
CCAssignabledelegate classCCAssignableMethodsinterface
Procedure
-
Create the new extension entity type.
- In Studio, navigate to .
- Right-click Entity and select .
-
Provide the required information for the new entity type definition.
-
Enter the name of the extension entity type in the text field.
To follow the rest of this procedure, use the name TestClaimAssignable_Ext.
- In Entity Type, select entity.
-
In Desc, type:
CCAssignable extension entity, which has a foreign key back to Claim, used for testing
- In Type, select retireable.
- Select the check boxes Extendable and Final.
- Click OK.
-
Enter the name of the extension entity type in the text field.
-
In the entity editor, add the following items to TestClaimAssignable_Ext.
Element type Attribute Value exportable true fulldescription Simple test assignable with a foreign key back to Claim. This foreign key, together with the CCAssignableMethods delegate in TestClaimAssignableMethodsImpl, allows this entity type to participate in manual assignment, assignment to claim owner and cascading. An instance of this type also creates history events as it is assigned. implementsEntity name Extractable implementsEntity name CCAssignable implementsInterface iface gw.api.assignment.CCAssignableMethods impl gw.assignment.TestClaimAssignableMethodsImpl foreignkey name Claim fkentity Claim nullok false columnName ClaimID desc The Claim for this test assignable exportable false
Results
Notice the following:
- Entity TestClaimAssignable_Ext implements the CCAssignable delegate.
- Entity TestClaimAssignable_Ext uses class TestClaimAssignableMethodsImpl, which implements the CCAssignableMethods interface, to define the necessary assignment methods and properties.
- Entity TestClaimAssignable_Ext has a foreign key back to Claim.
What to do next
Step 2: Add foreign keys to assignable entity types
To link your assignable entity type to a base configuration assignable entity type, you need a foreign key from that base configuration entity type to your assignable entity type.
Before you begin
Procedure
-
In Guidewire Studio, open Claim.etx for editing or
create a new entity extension.
-
Press Ctrl-N and start entering the entity type name.
Studio displays a number of matches because files with the name Claim already exist.
- Find Claim.etx in the list and double-click that file.
-
Press Ctrl-N and start entering the entity type name.
-
In the entity editor, add the following items to the Claim extension.
Element type Attribute Value array name TestClaimAssignables arrayentity TestClaimAssignable_Ext desc Test assignables for this claim - Add fields to the file Activity.etx. If this file does not exist, you need to create it. Follow the instructions in Step 1 to search for Activity.etx.
-
In the entity editor, add the following items to the Activity extension.
Element type Attribute Value foreignkey name TestClaimAssignable arrayentity TestClaimAssignable_Ext nullok true
What to do next
Step 3: Create new assignment type for extension entity type TestClaimAssignable_Ext
The AssignmentType class contains getter and setter methods that inform the round-robin mechanism of the location of fields in the AssignmentState entity types.
Before you begin
Procedure
-
Create a new class file in the package gw.assignment and name it
TestClaimAssignableExtAssignmentType.
- In Studio, navigate to .
- Right-click assignment and select .
-
Enter the name of the class in the text box.
For this example, enter the following class name.
TestClaimAssignableExtAssignmentTypeStudio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
-
Click OK.
Studio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
-
Enter the following code in the class file.
package gw.assignment uses gw.api.assignment.AssignmentType uses gw.entity.IEntityType uses gw.pl.persistence.core.Key class TestClaimAssignableExtAssignmentType extends AssignmentType { construct() { } override function getLastAssignedUser(groupState : GroupAssignmentState) : Key { return groupState.LastTCAUser.ID } override function getLastAssignedUser(dynamicState : DynamicAssignmentState) : Key { return dynamicState.LastTCAUser.ID } override function setLastAssignedUser(groupState : GroupAssignmentState, user : Key) { groupState.LastTCAUser = groupState.Bundle.loadBean(user) as User } override function setLastAssignedUser(dynamicState : DynamicAssignmentState, user : Key) { dynamicState.LastTCAUser = dynamicState.Bundle.loadBean(user) as User } override function getUserLoad(groupUserState : GroupUserAssignmentState) : int { return groupUserState.TCALoad } override function setUserLoad(groupUserState : GroupUserAssignmentState, load : int) { groupUserState.TCALoad = load } override function getLastAssignedGroup(groupState : GroupAssignmentState) : Key { return groupState.LastTCAGrp.ID } override function getLastAssignedGroup(dynamicState : DynamicAssignmentState) : Key { return dynamicState.LastTCAGrp.ID } override function setLastAssignedGroup(groupState : GroupAssignmentState, group : Key) { groupState.LastTCAGrp = groupState.Bundle.loadBean(group) as Group } override function setLastAssignedGroup(dynamicState : DynamicAssignmentState, group : Key) { dynamicState.LastTCAGrp = dynamicState.Bundle.loadBean(group) as Group } override function getGroupLoad(groupState : GroupAssignmentState) : int { return groupState.TCALoad } override function setGroupLoad(groupState : GroupAssignmentState, load : int) { groupState.TCALoad = load } protected override property get AssignableClass() : IEntityType { return TestClaimAssignable_Ext } }
What to do next
Step 4: Create enhancement class TestClaimAssignableExtEnhancement
Create an enhancement to the TestClaimAssignable_Ext entity type for use in creating entities of that type.
Before you begin
Procedure
-
Create a new enhancement file and name it
TestClaimAssignableExtEnhancement.
- In Studio, navigate to .
- Right-click assignment and select .
- Enter the TestClaimAssignable_Ext in the Enhanced type text box.
-
Enter the name of the class in the Type to enhance text box.
For this example, enter the following class name.
TestClaimAssignableExtEnhancementStudio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
- Click OK.
-
Enter the following code in the enhancement file.
package gw.assignment uses gw.api.assignment.AssignmentType enhancement TestClaimAssignableExtEnhancement : TestClaimAssignable_Ext { static property get ASSIGNMENT_TYPE() : AssignmentType { return new TestClaimAssignableExtAssignmentType() } }
What to do next
Step 5: Create delegate class TestClaimAssignableMethodsImpl
Any new assignable entity type must implement the CCAssignableMethods interface.
Before you begin
About this task
The TestClaimAssignable_Ext entity type that you created specified the delegate class TestClaimAssignableMethodsImpl to implement the CCAssignableMethods interface.
The following procedure defines a delegate class that provides an implementation of the methods in the
CCAssignableMethods interface. In this example, the
TestClaimAssignableMethodsImpl class extends the abstract superclass
CCAssignableMethodsBaseImpl. The CCAssignableMethodsBaseImpl abstract
superclass provides standard implementations of some of the functionality for which the
CCAssignableMethods interface provides method signatures.
Procedure
-
Create a new class file in the package gw.assignment and name it
TestClaimAssignableMethodsImpl.
- In Studio, navigate to .
- Right-click assignment and select .
-
Enter the name of the class in the text box.
For this example, enter the following class name.
TestClaimAssignableMethodsImpl -
Click OK.
Studio creates a skeleton class file in the assignment folder and opens the file in an editor tab.
-
Enter the following code in the file.
package gw.assignment uses gw.api.assignment.CCAssignableMethods uses gw.api.assignment.CCAssignableMethodsBaseImpl uses gw.entity.ILinkPropertyInfo uses gw.pl.persistence.core.Key /** * Example CCAssignableMethods implementation for an assignable entity that is related to a claim, * and which can be manually assigned, assigned to claim owner, or cascaded. Also creates a history * event as it is assigned. */ class TestClaimAssignableMethodsImpl extends CCAssignableMethodsBaseImpl { construct(testEntity : TestClaimAssignable_Ext) { super(testEntity) } override property get AssignmentReviewActivitySubject() : String { return "Test Claim Assignable Assignment Review" } override property get AssignmentReviewActivityLinkProperty() : ILinkPropertyInfo { return Activity.Type.TypeInfo.getProperty("TestClaimAssignable") as ILinkPropertyInfo } override property get Owner() : TestClaimAssignable_Ext { return super.Owner as TestClaimAssignable_Ext } override property get OwningClaim() : Claim { return Owner.Claim } override function pushAssignmentPopup(assignables : List<CCAssignableMethods>) { // Needed for user interface AssignmentPopupUtil.pushAssignTestClaimAssignables (assignables.whereTypeIs(TestClaimAssignable_Ext).toTypedArray()) } override property get ChildrenForCascadeAssignment() : List<CCAssignableMethods> { return null } override function createAssignmentHistoryEvent(assignable : Assignable) : History { var result = super.createAssignmentHistoryEvent(assignable) result.Description = "Test Claim Assignable History Event" return result } override function shouldCascadeAssignment(parent : Assignable, defaultOwnerUserId : Key, defaultGroupId : Key) : boolean { return true } }Studio indicates that your newly created class contains a serious error because there is no method definition for
AssignmentPopupUtil.pushAssignTestClaimAssignables. You need to provide at least a skeleton body of this method. The next step resolves this issue. -
Open gw.assignment.AssignmentPopupUtil for editing and add the following code.
static function pushAssignTestClaimAssignables(testclaimassignables : TestClaimAssignable_Ext[]) { // Implementation to do }
What to do next
Step 6: Add the necessary permission for the extension entity type
Each extension entity that has a foreign key to another entity must set up and handle the permissions for users to assign instances of this entity type.
Before you begin
About this task
The TestClaimAssignable_Ext extension entity type has foreign keys to the entity types
Claim and Activity. You must do the following tasks so that PolicyCenter can ensure that only authorized users assign
TestClaimAssignable_Ext instances.
- Define a permission of
permKey="own"in security-config.xml. - Add this permission to the SystemPermissionType typelist.
- Assign this permission to a user role.
- Assign this role to any user that needs to assign the new assignable entity.
If you do not perform these steps correctly, you see the following error if you attempt to assign your assignable entity:
com.guidewire.pl.system.exception.InsufficientPermissionException: No user defined at com.guidewire.pl.system.security.PermCheck.setAndCheckAssign(PermCheck.java:81) at com.guidewire.pl.domain.assignment.impl.AssignableImpl.assign(AssignableImpl.java:236) ...
Procedure
- Navigate to .
-
In this folder, double-click security-config.xml.
The file security-config.xml opens in an editor tab. You use this file to define system permissions for the data model entities.
-
Inside the
SecurityConfigelement, add the following code.This code defines a permission that you can assign to a user to enable that person to assign an entity instance of types TestClaimAssignable_Ext and UserAssignableEntity_Ext.<!-- Permission key needed for assigning extension entity in testing--> <StaticHandler entity="UserAssignableEntity_Ext" permKey="own"> <SystemPermType code="ownsensclaim"/> <SystemPermType code="InternalTools"/> <SystemPermType code="ext_entity_perms"/> </StaticHandler> <StaticHandler entity="TestClaimAssignable_Ext" permKey="own"> <SystemPermType code="ownsensclaim"/> <SystemPermType code="InternalTools"/> <SystemPermType code="ext_entity_perms"/> </StaticHandler> -
In Guidewire Studio, open SystemPermissionType.ttx
for editing.
You need to add the new system permission to the SystemPermissionType typelist.
-
Press Ctrl-N and start entering the typekey name.
Studio displays a number of matches because files with the name SystemPermissionType already exist.
-
Double-click the DynamicAssignmentState.etx file.
The typelist extension opens in the editor.
-
Press Ctrl-N and start entering the typekey name.
-
Add the following typecode.
Field
Entry
code
ext_entity_permsname
Own ext entitydesc
Permission to access extension entity -
To see your new system permission in Guidewire PolicyCenter, stop and restart
the application server.
- Stop the server, if it is running.
- Start the server from within Studio.
- Correct any problems that occur and repeat the previous steps until the server starts without errors.
-
Log into PolicyCenter, using an administrative account.
This example assumes the use of Guidewire ClaimCenter. You must be logged in as an administrator to be able to access the Administration tab. Additionally, that administrator account must have a role with the
Manage RolesandView Rolespermissions to be able to view and edit the Roles screen. - If you have not already done so, load the demonstration data into the database. The next step requires this data.
- Click the Administration tab and navigate to .
-
Assign the
Own ext entitysystem permission to a specific user role such as Adjuster. -
Assign that role with the necessary permission to a specific user such as
aapplegate.
What to do next
Step 7: Test assignment of the assignable entity type
After you create your assignable entity that uses a foreign key, you must test your work to verify that you have performed the previous steps correctly.
Before you begin
Procedure
- In Studio, click to open the Studio Gosu Scratchpad.
-
Enter the following code in the Gosu Scratchpad tab.
var _users = Query. make(User).join(User# Credential).compare(Credential# UserName, Equals, "aapplegate") var _usr = _users.select(). AtMostOneRow var _group = _usr. GroupUsers[ 0]. Group //Print out the members of the chosen group print("\nChosen group " + _group. DisplayName + " contains the following members:") _group. Users.each(\name -> print("\t" + name. User. DisplayName)) var _claim = gw.api.database.Query. make(Claim).compare(Claim# ClaimNumber, Equals, "235-53-365870").select(). AtMostOneRow print( "Claim number = " + _claim. ClaimNumber) Transaction.runWithNewBundle(\bundle -> { for (i in 1.. 5) { var testAssignable = new TestClaimAssignable_Ext() testAssignable = bundle.add(testAssignable) testAssignable.Claim = _claim testAssignable.assign(_group, _usr) print("Pass " + i + ": Assigning claim (with claim number = " + testAssignable. Claim + ") to the test assignment object ") print ("\tThe assigned user is " + testAssignable. AssignedUser) print ("\tThe assigned group is " + testAssignable. AssignedGroup) if (testAssignable.assignUserByRoundRobin( false, _group) != true) { print("Cannot perform round-robin assignment.") break } print("\tFor assignUserByRoundRobin, AssignedUser = " + testAssignable.AssignedUser) } }, "su") -
Click Run.
Output similar to the following lines appears in the Console tab.
Chosen group Auto1 - TeamA contains the following members: Elizabeth Lee Charles Shaw Heidi Johnson Cathy Clark Felicity Wagner Gary Wang Dan Henson Eugene Nyugen Betty Baker Chris Craft Andy Applegate Sue Smith Claim number = 235-53-365870 Pass 1: Assigning claim (with claim number = 235-53-365870) to the test assignment object The assigned user is Andy Applegate The assigned group is Auto1 - TeamA For assignUserByRoundRobin, AssignedUser = Dan Henson Pass 2: Assigning claim (with claim number = 235-53-365870) to the test assignment object The assigned user is Andy Applegate The assigned group is Auto1 - TeamA For assignUserByRoundRobin, AssignedUser = Eugene Nyugen Pass 3: Assigning claim (with claim number = 235-53-365870) to the test assignment object The assigned user is Andy Applegate The assigned group is Auto1 - TeamA For assignUserByRoundRobin, AssignedUser = Felicity Wagner Pass 4: Assigning claim (with claim number = 235-53-365870) to the test assignment object The assigned user is Andy Applegate The assigned group is Auto1 - TeamA For assignUserByRoundRobin, AssignedUser = Gary Wang Pass 5: Assigning claim (with claim number = 235-53-365870) to the test assignment object The assigned user is Andy Applegate The assigned group is Auto1 - TeamA For assignUserByRoundRobin, AssignedUser = Heidi Johnson
