We would like to search specific contributing resources. To do this we like to use the same mechanism as to search (eligible) normal resources by mapping capabilities.
This means we need to add capabilities + set the value to the contributing resource.
How can this be done?
I was able to make it work using the "Contributing Config" property on the Service definition (used for the contributing) itself.
This property value (Json format) can contain a Script indication.
For example:
{"Script":"Script:SRM-UpdateContributingRxResource||Reservation ID=[RESERVATIONID]","LifeCycle":"Locked","ParentSystemFunction":"4a0277fc-cd2a-4828-b16e-d1831b5f3e1c","ReservationAppendixName":"RX_Reuse","ResourcePool":"Reusable RX","ConvertToContributing":"True", "Concurrency": 5}
Within this script I retrieve the Contributing booking reservation from which I can get the contributing resource and the FunctionData.
var reservationID = engine.GetScriptParam("Reservation ID")?.Value;
if (!(SrmManagers.ResourceManager.GetReservationInstance(new Guid(reservationID)) is ServiceReservationInstance reservation))
{
engine.GenerateInformation(string.Format("ERROR|Reservation not found for Reservation ID {0} ", reservationID));
return;
}
if (reservation.TryGetContributingResource(out Resource contributingResource))
{
var reservationFunctions = reservation.GetFunctionData();...
Via this data I can get all the required info for the capability that is available within the parameters of each Node in the contributing booking.
Adding the capability is done via this code:
public static Resource AddOrUpdateCapabilityOnResource(Resource resource, ResourceCapability resourceCapability)
{
resource.Capabilities = resource.Capabilities ?? new List<ResourceCapability>();
resource.Capabilities.Add(resourceCapability);
return SrmManagers.ResourceManager.AddOrUpdateResources(resource).First();
}