Beispiel #1
0
 public function __construct(SearchResultObjectBuilder $builder)
 {
     parent::__construct($builder->getObjectID(), $builder->getTargetID());
     $this->resultOwnerGID = $builder->getOwnerGID();
     $this->resultObjectID = $builder->getResultObjectID();
     $this->resultIndex = $builder->getResultIndex();
     $this->resultType = $builder->getResultType();
     $this->displayName = $builder->getDisplayName();
     $this->datetime = $builder->getDatetime();
 }
 public static function buildFromJSON($json)
 {
     // TODO parse and verify json
     $jsonObject = json_decode($json);
     $builder = (new SearchResultCollectionObjectBuilder())->objectID($jsonObject->objectID)->targetID($jsonObject->targetID)->platformGID($jsonObject->platformGID)->datetime($jsonObject->datetime);
     foreach ($jsonObject->results as $result) {
         $builder->result(SearchResultObjectBuilder::buildFromJSON(json_encode($result)));
     }
     return $builder->build();
 }
Beispiel #3
0
 public function testSearch()
 {
     $searchQuery = (new SearchQueryObjectBuilder())->initiatingGID(Sonic::getContextGlobalID())->query((new ESQueryBuilder())->type('profile')->match('displayName', 'alice')->build())->datetime()->build();
     $this->assertTrue($searchQuery->validate());
     $this->assertEquals($searchQuery, SearchQueryObjectBuilder::buildFromJSON($searchQuery->getJSONString()));
     $profile = (new ProfileObjectBuilder())->globalID(Sonic::getContextGlobalID())->displayName($this->aliceSocialRecord->getDisplayName())->param('x', 'y')->build();
     $searchResult = (new SearchResultObjectBuilder())->targetID($searchQuery->getObjectID())->resultOwnerGID($profile->getGlobalID())->resultObjectID($profile->getObjectID())->resultIndex($searchQuery->getQuery()->getIndex())->resultType($searchQuery->getQuery()->getType())->displayName($profile->getDisplayName())->datetime()->build();
     $this->assertTrue($searchResult->validate());
     $this->assertEquals($searchResult, SearchResultObjectBuilder::buildFromJSON($searchResult->getJSONString()));
     $searchResultCollection = (new SearchResultCollectionObjectBuilder())->objectID(UOID::createUOID($this->platformSocialRecord->getGlobalID()))->targetID($searchQuery->getObjectID())->platformGID($this->platformSocialRecord->getGlobalID())->datetime()->result($searchResult)->build();
     $this->assertTrue($searchResultCollection->validate());
     $this->assertEquals($searchResultCollection, SearchResultCollectionObjectBuilder::buildFromJSON($searchResultCollection->getJSONString()));
 }