Exemplo n.º 1
0
 /**
  * Sets up the Relation definitions on this BO.
  *
  * @since 1.0
  */
 private function setupRels()
 {
     // set up MANY-TO-MANY relation person2rights
     $this->members->setRelatedClass('Alpha\\Model\\Person', 'left');
     $this->members->setRelatedClassDisplayField('email', 'left');
     $this->members->setRelatedClass('Alpha\\Model\\Rights', 'right');
     $this->members->setRelatedClassDisplayField('name', 'right');
     $this->members->setRelationType('MANY-TO-MANY');
     $this->members->setValue($this->getOID());
 }
Exemplo n.º 2
0
 /**
  * Testing that getRelatedClassDisplayFieldValue() will fail to load an invalid class definition.
  *
  * @since 1.0
  */
 public function testGetRelatedClassDisplayFieldValueFail()
 {
     try {
         $this->rel1->setRelatedClass('NotThere');
         $this->rel1->setRelatedClassDisplayField('someField');
         $value = $this->rel1->getRelatedClassDisplayFieldValue();
         $this->fail('Testing that getRelatedClassDisplayFieldValue() will fail to load an invalid class definition');
     } catch (\Exception $e) {
         $this->assertEquals('The class [NotThere] is not defined anywhere!', $e->getMessage(), 'Testing that getRelatedClassDisplayFieldValue() will fail to load an invalid class definition');
     }
 }
Exemplo n.º 3
0
 /**
  * constructor for the class.
  *
  * @since 1.0
  */
 public function __construct()
 {
     self::$logger = new Logger('ArticleComment');
     // ensure to call the parent constructor
     parent::__construct();
     $this->articleOID = new Relation();
     $this->articleOID->setRelatedClass('Alpha\\Model\\Article');
     $this->articleOID->setRelatedClassField('OID');
     $this->articleOID->setRelatedClassDisplayField('description');
     $this->articleOID->setRelationType('MANY-TO-ONE');
     $this->content = new Text();
     $this->content->setAllowHTML(false);
 }
Exemplo n.º 4
0
 /**
  * Constructor for the class.
  *
  * @since 1.0
  */
 public function __construct()
 {
     self::$logger = new Logger('ArticleVote');
     // ensure to call the parent constructor
     parent::__construct();
     $this->articleOID = new Relation();
     $this->articleOID->setRelatedClass('Alpha\\Model\\Article');
     $this->articleOID->setRelatedClassField('OID');
     $this->articleOID->setRelatedClassDisplayField('description');
     $this->articleOID->setRelationType('MANY-TO-ONE');
     $this->personOID = new Relation();
     $this->personOID->setRelatedClass('Alpha\\Model\\Person');
     $this->personOID->setRelatedClassField('OID');
     $this->personOID->setRelatedClassDisplayField('email');
     $this->personOID->setRelationType('MANY-TO-ONE');
     $this->score = new Integer();
 }
Exemplo n.º 5
0
 /**
  * Sets up the Relation definitions on this record object.
  *
  * @since 2.0
  */
 protected function setupRels()
 {
     $this->comments->setValue($this->OID);
     $this->comments->setRelatedClass('Alpha\\Model\\ArticleComment');
     $this->comments->setRelatedClassField('articleOID');
     $this->comments->setRelatedClassDisplayField('content');
     $this->comments->setRelationType('ONE-TO-MANY');
     $this->votes->setValue($this->OID);
     $this->votes->setRelatedClass('Alpha\\Model\\ArticleVote');
     $this->votes->setRelatedClassField('articleOID');
     $this->votes->setRelatedClassDisplayField('score');
     $this->votes->setRelationType('ONE-TO-MANY');
     $this->tags->setRelatedClass('Alpha\\Model\\Tag');
     $this->tags->setRelatedClassField('taggedOID');
     $this->tags->setRelatedClassDisplayField('content');
     $this->tags->setRelationType('ONE-TO-MANY');
     $this->tags->setTaggedClass(get_class($this));
     $this->tags->setValue($this->OID);
 }
Exemplo n.º 6
0
 /**
  * Testing the getRelatedObject method.
  *
  * @since 1.2.1
  */
 public function testGetRelatedObject()
 {
     $oneToOneRel = new Relation();
     $oneToOneRel->setRelatedClass('Alpha\\Model\\Person');
     $oneToOneRel->setRelatedClassField('OID');
     $oneToOneRel->setRelatedClassDisplayField('displayName');
     $oneToOneRel->setRelationType('ONE-TO-ONE');
     $oneToOneRel->setValue($this->person->getOID());
     $this->assertEquals($this->person->getDisplayName(), $oneToOneRel->getRelatedObject()->get('displayName'), 'testing the getRelatedObject method');
 }
Exemplo n.º 7
0
 /**
  * Sets up the Relation definitions on this BO.
  *
  * @since 1.0
  */
 protected function setupRels()
 {
     // set up MANY-TO-MANY relation person2rights
     if (isset($this->rights)) {
         $this->rights->setRelatedClass('Alpha\\Model\\Person', 'left');
         $this->rights->setRelatedClassDisplayField('email', 'left');
         $this->rights->setRelatedClass('Alpha\\Model\\Rights', 'right');
         $this->rights->setRelatedClassDisplayField('name', 'right');
         $this->rights->setRelationType('MANY-TO-MANY');
         $this->rights->setValue($this->getID());
     }
     if (isset($this->actions)) {
         $this->actions->setValue($this->OID);
         $this->actions->setRelatedClass('Alpha\\Model\\ActionLog');
         $this->actions->setRelatedClassField('created_by');
         $this->actions->setRelatedClassDisplayField('message');
         $this->actions->setRelationType('ONE-TO-MANY');
     }
 }
Exemplo n.º 8
0
 /**
  * Handles get requests.
  *
  * @param Alpha\Util\Http\Request $request
  *
  * @return Alpha\Util\Http\Response
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\ResourceNotFoundException
  */
 public function doGet($request)
 {
     self::$logger->debug('>>doGet(request=[' . var_export($request, true) . '])');
     $params = $request->getParams();
     $relationObject = new Relation();
     $body = '';
     try {
         $relationType = $params['relationType'];
         $ActiveRecordOID = $params['ActiveRecordOID'];
         $field = $params['field'];
     } catch (\Exception $e) {
         self::$logger->error('Required param missing for RecordSelectorController controller[' . $e->getMessage() . ']');
         throw new ResourceNotFoundException('File not found');
     }
     if ($relationType == 'MANY-TO-MANY') {
         try {
             $relatedClassLeft = urldecode($params['relatedClassLeft']);
             $relatedClassLeftDisplayField = $params['relatedClassLeftDisplayField'];
             $relatedClassRight = urldecode($params['relatedClassRight']);
             $relatedClassRightDisplayField = $params['relatedClassRightDisplayField'];
             $accessingClassName = urldecode($params['accessingClassName']);
             $lookupOIDs = $params['lookupOIDs'];
         } catch (\Exception $e) {
             self::$logger->error('Required param missing for RecordSelectorController controller[' . $e->getMessage() . ']');
             throw new ResourceNotFoundException('File not found');
         }
         $relationObject->setRelatedClass($relatedClassLeft, 'left');
         $relationObject->setRelatedClassDisplayField($relatedClassLeftDisplayField, 'left');
         $relationObject->setRelatedClass($relatedClassRight, 'right');
         $relationObject->setRelatedClassDisplayField($relatedClassRightDisplayField, 'right');
         $relationObject->setRelationType($relationType);
         $relationObject->setValue($ActiveRecordOID);
         $recSelector = new RecordSelector($relationObject, '', $field, $accessingClassName);
         $body .= $recSelector->renderSelector($field, explode(',', $lookupOIDs));
     } else {
         try {
             $relatedClass = urldecode($params['relatedClass']);
             $relatedClassField = $params['relatedClassField'];
             $relatedClassDisplayField = $params['relatedClassDisplayField'];
         } catch (\Exception $e) {
             self::$logger->error('Required param missing for RecordSelectorController controller[' . $e->getMessage() . ']');
             throw new ResourceNotFoundException('File not found');
         }
         $relationObject->setRelatedClass($relatedClass);
         $relationObject->setRelatedClassField($relatedClassField);
         $relationObject->setRelatedClassDisplayField($relatedClassDisplayField);
         $relationObject->setRelationType($relationType);
         $relationObject->setValue($ActiveRecordOID);
         $recSelector = new RecordSelector($relationObject);
         $body .= $recSelector->renderSelector($field);
     }
     self::$logger->debug('<<__doGet');
     return new Response(200, $body, array('Content-Type' => 'text/html'));
 }