コード例 #1
0
 /**
  * checks the object to make sure it does not have any dependant active objects
  * @param string $id id of document
  * @param string $documentClassName document class name
  * @param Boolean $omitSelf omitself if not self
  * @param User id $userid login in user
  * @return boolean
  */
 protected function dependencies($id, $documentClassName, $omitSelf = false, $userid = null)
 {
     // find dependent mappings
     $mapping = $fieldMapping = $this->_dm->getRepository($documentClassName)->getClassMetadata()->fieldMappings;
     foreach ($mapping as $field) {
         if (isset($documentClassName, $field['mappedBy'])) {
             $qb = $this->_dm->createQueryBuilder($field['targetDocument']);
             $formatId = strpos($field['mappedBy'], ".") > 0 ? "\$id" : "id";
             $qb->field($field['mappedBy'] . ".{$formatId}")->equals($this->formatIdForQuery($field['targetDocument'], $id));
             $qb->field('deleted')->equals(false);
             $query = $qb->getQuery();
             $activeReferences = $query->execute();
             $skipDependencyCheck = false;
             if ($omitSelf == "true") {
                 foreach ($activeReferences as $row) {
                     if ($field['targetDocument'] == 'MoveIn4User\\Document\\UserDocument' && $row->getId() == $userid) {
                         $skipDependencyCheck = true;
                     } else {
                         $skipDependencyCheck = false;
                     }
                 }
             }
             if ($skipDependencyCheck == false && count($activeReferences) > 0) {
                 $pe = new PlatformException('dependancyFault');
                 $doc = explode('\\', $field['targetDocument']);
                 $pe->setFaultDatails($field['name']);
                 throw $pe;
             }
         }
     }
     return false;
 }
コード例 #2
0
 /**
  * @param \SimpleXMLIterator $ids input
  * @return multitype:boolean
  */
 private function _checkDependency($ids)
 {
     $query = $this->_dm->createQueryBuilder('MoveIn4Person\\Document\\PersonDocument');
     $exp1 = $query->expr()->field('attribute.$id')->in($ids);
     $exp1->field('value')->exists(true);
     $exp2 = $query->expr()->field('customAttributes')->elemMatch($exp1);
     $query->addAnd($exp2);
     $result = $query->getQuery()->execute();
     if (count($result) > 0) {
         $pe = new PlatformException('dependancyFault');
         $pe->setFaultDatails('Person');
         throw $pe;
     }
     return array('status' => false);
 }
コード例 #3
0
 /**
  * Import the csv lead and person data into the system
  * @param unknown $data data
  * @throws \Exception
  * @return multitype:multitype:multitype:Ambigous <>
  */
 public function validateMapping($data)
 {
     $temp = (array) $data;
     $id = $temp['id'];
     $mapping = $temp['mapping'];
     $lang = $temp['lang'];
     $duplicateHandle = $temp['duplicateHandle'];
     $fullPath = (string) $temp['fullPath'];
     $attributeIds = [];
     $csvField = 0;
     $defaultField = 0;
     // xml to array conversion of mapping
     foreach ($mapping as $map) {
         if ((string) $map->attributes->type == 'customAttribute') {
             $attributeIds[] = new \MongoId((string) (string) $map->attributes->propertyId);
         }
     }
     $customAttributes = $this->_dm->createQueryBuilder('MoveIn4CustomAttribute\\Document\\CustomAttributeDocument')->field('id')->in($attributeIds)->field('deleted')->equals(true)->getQuery()->execute();
     if (count($customAttributes) > 0) {
         $resultArray = [];
         foreach ($customAttributes as $row) {
             $fields = array();
             $displayNameKey = $row->getDisplayNameKey();
             foreach (['id', 'name'] as $fieldName) {
                 $this->documentSetup($row);
                 $getter = 'get' . ucfirst($fieldName);
                 // count the number of required prrams
                 $reflection = new \ReflectionClass($row);
                 $count = $reflection->getMethod($getter)->getNumberOfParameters();
                 if ($count) {
                     $fields[$fieldName] = $row->{$getter}($data);
                 } else {
                     $fields[$fieldName] = $row->{$getter}();
                 }
             }
             $resultArray[] = $this->cleanResult($fields, true, (string) $data->auth->language);
         }
         $fault = new PlatformException('fieldListInvalid');
         $fault->setFaultDatails(array('data' => $resultArray));
         throw $fault;
     }
     return ['status' => true];
 }
コード例 #4
0
 /**
  * check and gets duplicate email persons pefered person data
  * @param array $data array
  * @return array
  */
 public function checkDuplicates($data)
 {
     $emails = (array) $data->emails;
     if (isset($emails)) {
         $query = $this->_dm->createQueryBuilder($this->_documentClassName)->field('email.email')->in($emails);
         $result = $query->getQuery()->getSingleResult();
     } else {
         throw new \Exception('Search criteria is required');
     }
     if (is_null($result)) {
         return array("status", "false");
     }
     $returnData = array();
     foreach ((array) $data->fields as $field) {
         if (count($field) > 1) {
             $fieldName = (string) $field->getName();
         } else {
             $fieldName = (string) $field;
         }
         $method = 'get' . ucfirst($fieldName);
         if (!method_exists($result, $method)) {
             $fault = new PlatformException('documentMethodNotFound');
             $fault->setFaultDatails(array('method' => '"' . $method . '"'));
             throw $fault;
         }
         $reflection = new \ReflectionClass($result);
         $count = $reflection->getMethod($method)->getNumberOfParameters();
         // do not get fileds that need arguments
         if ($count === 0) {
             $returnData['fields'][$fieldName] = $result->{$method}();
         }
     }
     $returnData = $this->cleanResult($returnData['fields'], false, (string) $data->auth->language);
     $fault = new PlatformException('duplicateFound');
     $fault->setFaultDatails(array('data' => $returnData));
     throw $fault;
 }