Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Bulk Event Scheduling - Add option to specify resource by ID #9164

Merged
merged 3 commits into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ protected function createUploadResult($values, $columns)

if (count($columns) != count($values))
{
$this->setResultError($result, 'The number of values is not equal to the number of columns. Event wll not be created.');
$this->setResultError($result, 'The number of values is not equal to the number of columns. Event will not be created.');
$this->addBulkUploadResult($result);
return;
}
Expand Down Expand Up @@ -316,27 +316,38 @@ protected function createUploadResult($values, $columns)
return;
}

if (isset($row['resource']) && $row['resource'])

$resourceFilter = new KalturaScheduleResourceFilter();
$resourceFilter->statusEqual = KalturaScheduleResourceStatus::ACTIVE;
if (isset($row['resourceID']) && $row['resourceID'])
{
$resourceFilter->idEqual = $row['resourceID'];
}
elseif (isset($row['resource']) && $row['resource'])
{
$resourceFilter = new KalturaScheduleResourceFilter();
$resourceFilter->systemNameEqual = $row['resource'];
$resourceFilter->statusEqual = KalturaScheduleResourceStatus::ACTIVE;

KBatchBase::impersonate($this->getCurrentPartnerId());
$resourceResults = $this->schedulePlugin->scheduleResource->listAction($resourceFilter);
KBatchBase::unimpersonate();

if (!$resourceResults->totalCount)
{
//If the resource could not be found - input validation error must be set on the bulk upload result.
$this->setResultError($result, 'Invalid resource system name ' . $row['resource'] . ' passed. Event was not created.');
$this->addBulkUploadResult($result);
return;
}
else
{
$result->resourceId = $resourceResults->objects[0]->id;
}
}
else
{
$this->setResultError($result, 'Neither the resource system name nor the resource ID were specified. Event was not created.');
$this->addBulkUploadResult($result);
return;
}

KBatchBase::impersonate($this->getCurrentPartnerId());
$resourceResults = $this->schedulePlugin->scheduleResource->listAction($resourceFilter);
KBatchBase::unimpersonate();

if (!$resourceResults->totalCount)
{
//If the resource could not be found - input validation error must be set on the bulk upload result.
$this->setResultError($result, 'Invalid resource system name or ID passed. Event was not created.');
$this->addBulkUploadResult($result);
return;
}
else
{
$result->resourceId = $resourceResults->objects[0]->id;
}


Expand Down Expand Up @@ -445,7 +456,6 @@ protected function getRequiredValueColumns ()
'action',
'eventType',
'title',
'resource',
'startTime',
'eventOrganizerId',
'contentOwnerId',
Expand All @@ -463,6 +473,7 @@ protected function getColumns()
'categoryIds',
'categoryPaths',
'resource',
'resourceID',
hilak marked this conversation as resolved.
Show resolved Hide resolved
'startTime',
'duration',
'endTime',
Expand All @@ -488,4 +499,4 @@ public function getObjectTypeTitle()
{
return self::OBJECT_TYPE_TITLE;
}
}
}