<?php
/**
* @version 1.0.0
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://www.anahitapolis.com
*/
class AnModelEdge extends AnDomainModelAbstract
{
static function describe($model)
{
$model->useTable('socialengine_edges AS edge');
$model->property('id', array('field'=>'edge.socialengine_edge_id', 'unique'=>true));
$model->belongsTo('application', array('required'=>true,'model'=>'lib.anahita.model.application', 'child_key'=>'edge.component', 'parent_key'=>'component'));
$model->belongsTo('author', array('required'=> true, 'model'=>'lib.anahita.model.actor' , 'child_key'=>'edge.created_by'));
$model->property('creationTime', array('required'=>true, 'class'=>'lib.anahita.type.date', 'initialize_with'=>array('date'=>"edge.created_on")));
$model->belongsTo('editor', array('model'=>'lib.anahita.model.actor' , 'child_key'=>'edge.modified_by'));
$model->property('lastUpdateTime', array('default'=>0, 'class'=>'lib.anahita.type.date', 'initialize_with'=>array('date'=>"edge.modified_on")));
$model->belongsTo('nodeA', array('required'=>true, 'model'=>'lib.anahita.model.actor', 'child_key'=>'edge.node_a_id' ));
$model->belongsTo('nodeB', array('required'=>true, 'model'=>'lib.anahita.model.node', 'child_key'=>'edge.node_b_id' ));
$model->property('type', array('required'=>true, 'field'=>'edge.type'));
$model->property('meta', array('field'=>'edge.meta'));
$model->property('directed', array('field'=>'edge.directed'));
$model->setRepository('lib.anahita.model.edge.repository');
}
/**
*
* @return
* @param $author Object
*/
public function setAuthor($author)
{
if ( $this->_get('author') && !$this->isNew() )
throw new AnModelEdgeException("author is already set");
$this->_set('author', $author);
$this->editor = $author;
$this->lastUpdateTime = KFactory::tmp('lib.anahita.type.date');
}
/**
*
* @return
* @param $editor Object
*/
public function setEditor($editor)
{
$this->_set('editor', $editor);
$this->_set('lastUpdateTime', KFactory::tmp('lib.anahita.type.date'));
}
}