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

Plat 9889 : Add support in eSearch aggregations #8504

Merged
merged 38 commits into from Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
07eec49
PLAT-9879:add storage support for tumbnails
MosheMaorKaltura May 21, 2019
bc44b0f
PLAT-9879:add storage support for tumbnails
MosheMaorKaltura May 21, 2019
bd92c19
PLAT-9879:add storage support for tumbnails
MosheMaorKaltura May 21, 2019
59dcd64
PLAT-9879:add storage support for tumbnails
MosheMaorKaltura May 21, 2019
79c65b3
PLAT-9879:add storage support for tumbnails
MosheMaorKaltura May 21, 2019
8b67086
PLAT-9889
MosheMaorKaltura May 25, 2019
ce58b8f
PLAT-9889
MosheMaorKaltura May 25, 2019
a88dc7e
PLAT-9889
MosheMaorKaltura May 25, 2019
8801a98
PLAT-9889
MosheMaorKaltura May 25, 2019
0865a7c
PLAT-9889
MosheMaorKaltura May 25, 2019
28e0ca6
PLAT-9889
MosheMaorKaltura May 25, 2019
be57d68
PLAT-9889
MosheMaorKaltura May 25, 2019
9f1c660
Merge branch 'Orion-15.1.0' of https://github.com/kaltura/server into…
MosheMaorKaltura May 25, 2019
eeb1218
Merge branch 'Orion-15.1.0' of https://github.com/kaltura/server into…
MosheMaorKaltura Jun 3, 2019
d95998d
merge
MosheMaorKaltura Jun 3, 2019
2431412
merge
MosheMaorKaltura Jun 3, 2019
57ec449
merge
MosheMaorKaltura Jun 3, 2019
e6d733e
merge
MosheMaorKaltura Jun 3, 2019
14e6a3b
merge
MosheMaorKaltura Jun 3, 2019
3517895
merge
MosheMaorKaltura Jun 3, 2019
d12449d
merge
MosheMaorKaltura Jun 3, 2019
92a3489
merge
MosheMaorKaltura Jun 3, 2019
b76e10e
integration
MosheMaorKaltura Jun 4, 2019
b0009fd
integration
MosheMaorKaltura Jun 4, 2019
0c2df08
testing
MosheMaorKaltura Jun 4, 2019
12e7129
testing
MosheMaorKaltura Jun 4, 2019
9950419
testing
MosheMaorKaltura Jun 4, 2019
7a91360
Changing values coreToApi
MosheMaorKaltura Jun 5, 2019
5bd1ab5
testing
MosheMaorKaltura Jun 5, 2019
a69d456
testing
MosheMaorKaltura Jun 5, 2019
9cb8bcd
testing
MosheMaorKaltura Jun 5, 2019
d7ab99f
integration tests
MosheMaorKaltura Jun 6, 2019
e160a3d
integration tests
MosheMaorKaltura Jun 6, 2019
b928ebf
integration tests
MosheMaorKaltura Jun 6, 2019
53175ea
Merge branch 'Orion-15.3.0' of https://github.com/kaltura/server into…
Jul 10, 2019
68a7d1a
PLAT-9889: code review remarks
Jul 10, 2019
3482c16
PLAT-9889: code review remarks
MosheMaorKaltura Jul 10, 2019
83d86e1
PLAT-9889: code review remarks
MosheMaorKaltura Jul 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,10 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.enum
*/

class KalturaESearchCategoryAggregateByFieldName extends KalturaStringEnum
{
const CATEGORY_NAME = 'category_name';
}
@@ -0,0 +1,11 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.enum
*/

class KalturaESearchCuePointAggregateByFieldName extends KalturaStringEnum
{
const TAGS = 'tags';
const TYPE = 'type';
}
@@ -0,0 +1,13 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.enum
*/

class KalturaESearchEntryAggregateByFieldName extends KalturaStringEnum
{
const ENTRY_TYPE = 'entry_type';
const MEDIA_TYPE = 'media_type';
const TAGS = 'tags';
const ACCESS_CONTROL_PROFILE = 'access_control_profile_id';
}
@@ -0,0 +1,10 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.enum
*/

class KalturaESearchMetadataAggregateByFieldName extends KalturaStringEnum
{

}
Expand Up @@ -10,9 +10,15 @@ class KalturaESearchEntryParams extends KalturaESearchParams
*/
public $searchOperator;

/**
* @var KalturaESearchAggregation
*/
public $aggregations;


private static $mapBetweenObjects = array
(
"searchOperator",
"searchOperator","aggregations"
);

protected function initStatuses()
Expand Down
Expand Up @@ -20,11 +20,12 @@ abstract class KalturaESearchParams extends KalturaObject
*/
public $orderBy;


private static $mapBetweenObjects = array
(
"objectStatuses",
"objectId",
"orderBy",
"orderBy"
);

public function getMapBetweenObjects()
Expand Down
@@ -0,0 +1,29 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/

class KalturaESearchAggregation extends KalturaObject
{
/**
* @var KalturaESearchAggregationsArray
*/
public $aggregations;

private static $map_between_objects = array(
'aggregations',
);

public function getMapBetweenObjects()
{
return array_merge(parent::getMapBetweenObjects(), self::$map_between_objects);
}

public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$object_to_fill)
$object_to_fill = new ESearchAggregations();
return parent::toObject($object_to_fill, $props_to_skip);
}
}
@@ -0,0 +1,10 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.errors
*/

class KalturaESearchAggregationErrors extends KalturaESearchErrors
{
const AGGREGATION_FIELD_NAME_MUST_BE_SUPPLIED = 'AGGREGATION_FIELD_NAME_MUST_BE_SUPPLIED;;Aggregation field name must be supplied';
}
@@ -0,0 +1,54 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/

abstract class KalturaESearchAggregationItem extends KalturaObject
{
/**
* @var int
*/
public $size;

public $fieldName;

private static $map_between_objects = array(
'size',
'fieldName'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$fieldName doesn't exists in this class

);

abstract public function getFieldEnumMap();

public function getMapBetweenObjects()
{
return array_merge(parent::getMapBetweenObjects(), self::$map_between_objects);
}

public function toObject($object_to_fill = null, $props_to_skip = array())
{
if($object_to_fill)
{
$fieldEnumMap = $this->getFieldEnumMap();
if (isset($fieldEnumMap[$this->fieldName]))
{
$coreFieldName = $fieldEnumMap[$this->fieldName];
$object_to_fill->setFieldName($coreFieldName);
$props_to_skip[] = 'fieldName';
}
}

return parent::toObject($object_to_fill, $props_to_skip);
}

abstract public function coreToApiResponse($coreResponse, $fieldName = null);

public function validateForUsage($sourceObject, $propertiesToSkip = array())
{
if(is_null($this->fieldName))
{
throw new KalturaAPIException(KalturaESearchAggregationErrors::AGGREGATION_FIELD_NAME_MUST_BE_SUPPLIED);
}
parent::validateForUsage($sourceObject, $propertiesToSkip);
}
}
@@ -0,0 +1,13 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/

class KalturaESearchAggregationsArray extends KalturaTypedArray
{
public function __construct()
{
return parent::__construct("KalturaESearchAggregationItem");
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/


class KalturaESearchCategoryAggregationItem extends KalturaESearchAggregationItem
{
/**
* @var KalturaESearchCategoryAggregateByFieldName
*/
public $fieldName;

public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$object_to_fill)
{
$object_to_fill = new ESearchCategoryAggregationItem();
}
return parent::toObject($object_to_fill, $props_to_skip);
}

public function getFieldEnumMap()
{
return array (KalturaESearchCategoryAggregateByFieldName::CATEGORY_NAME => ESearchCategoryAggregationFieldName::CATEGORY_NAME);
}

public function coreToApiResponse($coreResponse, $fieldName = null)
{
$agg = new KalturaESearchAggregationResponseItem();
$agg->fieldName = $fieldName;
$agg->name = ESearchCategoryAggregationItem::KEY;
$bucketsArray = new KalturaESearchAggregationBucketsArray();
$buckets = $coreResponse[ESearchAggregations::BUCKETS];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$coreResponse should be validated.

if ($buckets)
{
foreach ($buckets as $bucket)
{
$responseBucket = new KalturaESearchAggregationBucket();
$responseBucket->fromArray($bucket);
list(,$categoryName) = elasticSearchUtils::reverseFormatCategoryNameStatus($responseBucket->value);
MosheMaorKaltura marked this conversation as resolved.
Show resolved Hide resolved
$responseBucket->value = $categoryName;
$bucketsArray[] = $responseBucket;
}

}
$agg->buckets = $bucketsArray;
return array($agg);
}

}
@@ -0,0 +1,54 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/

class KalturaESearchCuepointsAggregationItem extends KalturaESearchAggregationItem
{
/**
* @var KalturaESearchCuePointAggregateByFieldName
*/
public $fieldName;

public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$object_to_fill)
{
$object_to_fill = new ESearchCuepointsAggregationItem();
}
return parent::toObject($object_to_fill, $props_to_skip);
}

public function getFieldEnumMap()
{
return array(
KalturaESearchCuePointAggregateByFieldName::TAGS => ESearchCuePointsAggregationFieldName::TAGS,
KalturaESearchCuePointAggregateByFieldName::TYPE => ESearchCuePointsAggregationFieldName::TYPE);
}

public function coreToApiResponse($coreResponse, $fieldName = null)
{
$agg = new KalturaESearchAggregationResponseItem();
$agg->fieldName = $fieldName;
$agg->name = ESearchCuepointsAggregationItem::KEY;

$bucketsArray = new KalturaESearchAggregationBucketsArray();
$buckets = $coreResponse[ESearchAggregationItem::NESTED_BUCKET][ESearchAggregations::BUCKETS];
if ($buckets)
{
foreach ($buckets as $bucket)
{
$responseBucket = new KalturaESearchAggregationBucket();
$responseBucket->fromArray($bucket);
if($fieldName === ESearchCuePointsAggregationFieldName::TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should compare $fieldName to the API enum, not to the core enum as it seems to be API since we assign it to aggs->fieldName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the returned value from the core.

{
$responseBucket->value = kPluginableEnumsManager::coreToApi('CuePointType' ,$responseBucket->value);
}
$bucketsArray[] = $responseBucket;
}
}
$agg->buckets = $bucketsArray;
return array($agg);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* @package plugins.elasticSearch
* @subpackage api.objects
*/


class KalturaESearchEntryAggregationItem extends KalturaESearchAggregationItem
{

/**
* @var KalturaESearchEntryAggregateByFieldName
*/
public $fieldName;


public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$object_to_fill)
{
$object_to_fill = new ESearchEntryAggregationItem();
}
return parent::toObject($object_to_fill, $props_to_skip);
}

public function getFieldEnumMap()
{
return array (
KalturaESearchEntryAggregateByFieldName::ENTRY_TYPE => ESearchEntryAggregationFieldName::ENTRY_TYPE,
KalturaESearchEntryAggregateByFieldName::MEDIA_TYPE => ESearchEntryAggregationFieldName::MEDIA_TYPE,
KalturaESearchEntryAggregateByFieldName::TAGS => ESearchEntryAggregationFieldName::TAGS,
KalturaESearchEntryAggregateByFieldName::ACCESS_CONTROL_PROFILE => ESearchEntryAggregationFieldName::ACCESS_CONTROL_PROFILE);
}

public function coreToApiResponse($coreResponse, $fieldName = null)
{
$agg = new KalturaESearchAggregationResponseItem();
$agg->fieldName = $fieldName;
$agg->name = ESearchEntryAggregationItem::KEY;
$bucketsArray = new KalturaESearchAggregationBucketsArray();
$buckets = $coreResponse[ESearchAggregations::BUCKETS];
if ($buckets)
{
foreach ($buckets as $bucket)
{
$responseBucket = new KalturaESearchAggregationBucket();
$responseBucket->fromArray($bucket);
$bucketsArray[] = $responseBucket;
}
}
$agg->buckets = $bucketsArray;
return array($agg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why array in here? it's different from the other returns

}


}