Esempio n. 1
0
 /**
  *
  * @param \TYPO3\Flow\Persistence\Generic\Qom\Constraint $constraint
  * @return mixed
  * @author Felix Oertel <*****@*****.**>
  * @author Christopher Hlubek <*****@*****.**>
  */
 protected function buildStatementForConstraint(\TYPO3\Flow\Persistence\Generic\Qom\Constraint $constraint)
 {
     if ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\Comparison) {
         if ($constraint->getOperator() === \TYPO3\Flow\Persistence\QueryInterface::OPERATOR_LIKE || $constraint->getOperator() === \TYPO3\Flow\Persistence\QueryInterface::OPERATOR_EQUAL_TO) {
             $operandValue = $this->buildKeyForOperand($constraint->getOperand2());
             if (strpos($operandValue, ' ') !== FALSE) {
                 $operandValue = $this->phrase($operandValue);
             } else {
                 $allowWildcard = $constraint->getOperator() === \TYPO3\Flow\Persistence\QueryInterface::OPERATOR_LIKE;
                 $operandValue = $this->escape($operandValue, $allowWildcard);
             }
             return $this->buildNameForOperand($constraint->getOperand1()) . ':' . $operandValue;
         } else {
             throw new \InvalidArgumentException('Comparison operator ' . get_class($constraint->getOperator()) . ' is not supported by CouchDB QueryIndex', 1300895208);
         }
     } elseif ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\LogicalAnd) {
         return '(' . $this->buildStatementForConstraint($constraint->getConstraint1()) . ' AND ' . $this->buildStatementForConstraint($constraint->getConstraint2()) . ')';
     } elseif ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\LogicalOr) {
         return '(' . $this->buildStatementForConstraint($constraint->getConstraint1()) . ' OR ' . $this->buildStatementForConstraint($constraint->getConstraint2()) . ')';
     } elseif ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\LogicalNot) {
         return '(NOT ' . $this->buildStatementForConstraint($constraint->getConstraint()) . ')';
     } else {
         throw new \InvalidArgumentException('Constraint ' . get_class($constraint) . ' is not supported by CouchDB QueryIndex', 1299689061);
     }
     return NULL;
 }
Esempio n. 2
0
 /**
  *
  * @param \TYPO3\Flow\Persistence\Generic\Qom\Constraint $constraint
  * @throws \InvalidArgumentException
  * @return mixed
  */
 protected function buildKeyForConstraint(\TYPO3\Flow\Persistence\Generic\Qom\Constraint $constraint)
 {
     if ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\Comparison) {
         if ($constraint->getOperator() === \TYPO3\Flow\Persistence\QueryInterface::OPERATOR_EQUAL_TO) {
             return $this->buildKeyForOperand($constraint->getOperand2());
         }
     } elseif ($constraint instanceof \TYPO3\Flow\Persistence\Generic\Qom\LogicalAnd) {
         return array($this->buildKeyForConstraint($constraint->getConstraint1()), $this->buildKeyForConstraint($constraint->getConstraint2()));
     } else {
         throw new \InvalidArgumentException('Constraint ' . get_class($constraint) . ' is not supported by CouchDB QueryView', 1288606305);
     }
     return NULL;
 }