/**
  * Arma un valor para buscar en las muestras donde las ordenes estan confirmadas
  *@return FilterValue $filterValue
  */
 public function sampleOrderStateConfirmed()
 {
     $filterValue = new FilterValue();
     $searchCriteria = new ToOneRelationPropertyFilter();
     $searchCriteria->setCriteriaAttribute('Order');
     $criteriaProperty = LaboratorySystem::getInstance()->findSearchCriteriaByCode('ORST');
     //ver fixture filter.yml
     $searchCriteria->setSearchCriteria($criteriaProperty);
     $filterType = $searchCriteria->getSearchFilterType();
     $code = "";
     $filterData = $filterType->newData($code);
     $state = OrderState::confirmed();
     $arrayValue = array();
     $arrayValue[0] = $state->getId();
     $filterData->unserializeData($arrayValue, $filterType->getSearchDataType());
     $filterValue->setSearchCriteria($searchCriteria);
     $filterValue->setFilterData($filterData);
     return $filterValue;
 }
 /**
  * Adds a display field
  * to the collection $titleFields
  *
  * @param string or array $field the field name
  * @param string $label the field label
  */
 public function addTitleField($field, $label)
 {
     if (gettype($field) == 'array') {
         if (count($field) == 0) {
             throw new InvalidArgumentException('Invalid field');
         }
         $criteriaCollection = new SearchableReadonlyCollection();
         $searchCriteriaProperty = new ToOneRelationPropertyFilter();
         $searchCriteriaProperty->setCriteriaAttribute($field[0]);
         $titleField = new AsyncSearchCriteriaTitleField($field[0], $label);
         for ($i = 1; $i < count($field); $i++) {
             if ($i == count($field) - 1) {
                 $searchCriteria = new SearchCriteria();
                 $searchCriteria->setCriteriaAttribute($field[$i]);
                 $criteriaCollection->add($searchCriteria);
             } else {
                 $searchCriteriaPropertyAux = new ToOneRelationPropertyFilter();
                 $searchCriteriaPropertyAux->setCriteriaAttribute($field[$i]);
                 $criteriaCollection->add($searchCriteriaPropertyAux);
             }
         }
         $i = 1;
         foreach ($criteriaCollection as $criteria) {
             if ($i < $criteriaCollection->count()) {
                 $collectionAux = $criteriaCollection->sliceFrom($i);
                 $criteria->setSearchCriteria($collectionAux->first());
                 $i++;
             }
         }
         $searchCriteriaProperty->setSearchCriteria($criteriaCollection->first());
         $criteriaCollection->reverse();
         $searchCriteria = $criteriaCollection->first();
     } else {
         $searchCriteria = new SearchCriteria();
         $searchCriteria->setCriteriaAttribute($field);
         $titleField = new AsyncSearchCriteriaTitleField($field, $label);
     }
     $filterType = new OrStringFilterType();
     $dataType = new SearchDataTypeString();
     $filterType->setSearchDataType($dataType);
     $searchCriteria->setSearchFilterType($filterType);
     if (gettype($field) == 'array') {
         $titleField->setSearchCriteria($searchCriteriaProperty);
     } else {
         $titleField->setSearchCriteria($searchCriteria);
     }
     $this->titleFields[] = $titleField;
 }