Working With Resource Relations

This chapter discusses the following:

Introduction

Since version 6.10.0, ConSol CM offers the module CM.Resource Pool and with it the possibility to establish relations between resource objects and other objects. A resource relation can connect a resource to

Figure 150: Resource relation types

To be able to work with resource relations, you have to have a profound knowledge of the resource data model. Please refer to the ConSol CM Administrator Manual (versions 6.10 and up), section CM. Resource Pool - Resource Relations for a detailed introduction.

The following Java classes are essential for working with resources, but of course they represent only a small subset of Java classes which form the Resource Pool. Please refer to the ConSol CM Java API Doc for a comprehensive description of all classes and methods.

Object Java class Admin Tool description Explanation
resource Resource Resource An object of the defined Resource Type.
resourceRelationService Interface ResourceRelationService - the service which offers a lot of helpful methods for dealing with resources
ResourceRelation xy ResourceRelation Resource (type) relation Relation between a resource and another object
  ResourceRelationWithTargetResourceCriteria
ResourceRelationWithTargetTicketCriteria
ResourceRelationWithTargetUnitCriteria
- Stores the criteria which are the basis for a search, performed by the resourceRelationService

Example: Calculating the Reaction Time of a Ticket

A company can have a relation to a resource of type SLA. In this resource, SLA data are stored, e.g., the reaction time. The desired deadline for a service ticket is calculated by extracting the value of the reaction time from the resource object. With this value, the deadline for the service ticket is calculated and the result is entered in the Desired deadline data field of the ticket.

///Take SLA (resource) from company of main customer and calculate deadline from it

def maincust = ticket.mainContact

def unit_type = maincust.definition.type

println 'TYPE is now : ' + unit_type

def comp

if(unit_type.equals('CONTACT')) {

comp = maincust.get("company()")

} else if (unit_type.equals('COMPANY')){

comp = maincust

}

 

// find SLA relation from SLA resource to the main customer (if company) or the company of the main customer (if contact)

def crit = new ResourceRelationWithTargetUnitCriteria()

crit.setUnit(comp)

crit.setResourceTypeName("SLAs")

List<ResourceRelationWithTargetUnit> myrelations = resourceRelationService.getByCriteria(crit)

println 'myrelations size is now ' + myrelations.size()

if (myrelations.size() > 0) {

// one unit can have only one SLA as relation, see AT definition

def my_sla = myrelations[0].getSourceResource()

def sla_name = my_sla.get("SLA_Fields_basic.SLA_Name")

println 'SLA name is now ' + sla_name

def react_days = my_sla.get("SLA_Fields_basic.ReactionTime")

// calculate reaction time

def now = new Date()

def deadline = now + 1

ticket.set("serviceDesk_fields.desiredDeadline",deadline)

}

Code example 76: Calculate ticket deadline from SLA. SLA as resource which is linked to the ticket.