Автор: Elliot Levin (elliot@aanet.com.au)
Пример #1
0
 public function __construct($EntityOrType, array $AssignmentExpressions, Object\ICriterion $Criterion = null)
 {
     if (count($AssignmentExpressions) === 0) {
         throw new Object\ObjectException('Procedure must contain atleast one assignment expression: none given');
     }
     $this->EntityType = is_object($EntityOrType) ? get_class($EntityOrType) : $EntityOrType;
     $this->AssignmentExpressions = $AssignmentExpressions;
     $this->Criterion = $Criterion ?: new Criterion($this->EntityType);
     if ($this->Criterion->GetEntityType() !== $this->EntityType) {
         throw new Object\TypeMismatchException('The supplied criterion must be for %s, %s given', $this->EntityType, $this->Criterion->GetEntityType());
     }
 }
Пример #2
0
 public function __construct($EntityOrType, array $Properties, $IsSingleEntity, Object\ICriterion $Criterion = null)
 {
     if (is_object($EntityOrType)) {
         $EntityOrType = get_class($EntityOrType);
     }
     $this->EntityType = $EntityOrType;
     foreach ($Properties as $Property) {
         $this->AddProperty($Property);
     }
     $this->IsSingleEntity = $IsSingleEntity;
     $this->Criterion = $Criterion ?: new Criterion($this->EntityType);
     if ($this->Criterion->GetEntityType() !== $this->EntityType) {
         throw new Object\TypeMismatchException('The supplied criterion must be for %s, %s given', $this->EntityType, $this->Criterion->GetEntityType());
     }
 }
Пример #3
0
 /**
  * Adds an entity or criterion to the discardence queue. 
  * If AutoSave is enabled, the action will be commited.
  * 
  * @param object|Fluent\CriterionBuilder|Object\ICriterion $EntityOrCriterion The entity or criterion to discard
  * @return void
  */
 public function Discard($EntityOrCriterion)
 {
     if ($EntityOrCriterion instanceof Fluent\CriterionBuilder) {
         $this->DiscardedCriterionQueue[] = $EntityOrCriterion->BuildCriterion();
     } else {
         if ($EntityOrCriterion instanceof Object\ICriterion) {
             $this->DiscardedCriterionQueue[] = $EntityOrCriterion;
         } else {
             $this->VerifyEntity(__METHOD__, $EntityOrCriterion);
             $this->IdentityMap->RemoveFromCache($EntityOrCriterion);
             $this->DiscardedQueue[] = $EntityOrCriterion;
         }
     }
     $this->AutoSave();
 }
Пример #4
0
 /**
  * @access private
  * 
  * Maps the supplied object criterion the the relational equivalent.
  * 
  * @param IEntityRelationalMap $EntityRelationalMap The relational map of the object criterion
  * @param Object\ICriterion $ObjectCriterion The object criterion to map
  * @param Relational\Criterion $RelationalCriterion The relational criterion to map to
  * @return void
  */
 private function MapCriterion(IEntityRelationalMap $EntityRelationalMap, Object\ICriterion $ObjectCriterion, Relational\Criterion $RelationalCriterion)
 {
     if ($ObjectCriterion->IsConstrained()) {
         foreach ($this->MapExpressions($EntityRelationalMap, $ObjectCriterion->GetPredicateExpressions()) as $PredicateExpression) {
             $RelationalCriterion->AddPredicateExpression($PredicateExpression);
         }
     }
     if ($ObjectCriterion->IsOrdered()) {
         $ExpressionAscendingMap = $ObjectCriterion->GetOrderByExpressionsAscendingMap();
         foreach ($ExpressionAscendingMap as $Expression) {
             $IsAscending = $ExpressionAscendingMap[$Expression];
             $Expressions = $this->MapExpression($EntityRelationalMap, $Expression);
             foreach ($Expressions as $Expression) {
                 $RelationalCriterion->AddOrderByExpression($Expression, $IsAscending);
             }
         }
     }
     if ($ObjectCriterion->IsGrouped()) {
         foreach ($this->MapExpressions($EntityRelationalMap, $ObjectCriterion->GetGroupByExpressions()) as $GroupByExpression) {
             $RelationalCriterion->AddGroupByExpression($GroupByExpression);
         }
     }
     if ($ObjectCriterion->IsRanged()) {
         $RelationalCriterion->SetRangeOffset($ObjectCriterion->GetRangeOffset());
         $RelationalCriterion->SetRangeAmount($ObjectCriterion->GetRangeAmount());
     }
 }