/**
  * Build the entity detail.
  * 
  * @param ObjectModel $object create by the entity
  * @param int $depth the depth for the tree diagram
  * @return string
  */
 public function renderEntity($object, $depth)
 {
     $output = '';
     $ws_params = $object->getWebserviceParameters();
     foreach ($this->wsParamOverrides as $p) {
         $o = $p['object'];
         $ws_params = $o->{$p['method']}($ws_params);
     }
     $output .= $this->setIndent($depth) . $this->objectRender->renderNodeHeader($ws_params['objectNodeName'], $ws_params);
     if ($object->id != 0) {
         // This to add virtual Fields for a particular entity.
         $virtual_fields = $this->addVirtualFields($ws_params['objectsNodeName'], $object);
         if (!empty($virtual_fields)) {
             $ws_params['fields'] = array_merge($ws_params['fields'], $virtual_fields);
         }
         foreach ($ws_params['fields'] as $field_name => $field) {
             if ($this->fieldsToDisplay === 'full' || array_key_exists($field_name, $this->fieldsToDisplay)) {
                 $field['object_id'] = $object->id;
                 $field['entity_name'] = $ws_params['objectNodeName'];
                 $field['entities_name'] = $ws_params['objectsNodeName'];
                 $output .= $this->renderField($object, $ws_params, $field_name, $field, $depth);
             }
         }
     }
     $subexists = false;
     if (is_array($this->fieldsToDisplay)) {
         foreach ($this->fieldsToDisplay as $fields) {
             if (is_array($fields)) {
                 $subexists = true;
             }
         }
     }
     if (isset($ws_params['associations']) && ($this->fieldsToDisplay == 'full' || $subexists)) {
         $output .= $this->renderAssociations($object, $depth, $ws_params['associations'], $ws_params);
     }
     $output .= $this->setIndent($depth) . $this->objectRender->renderNodeFooter($ws_params['objectNodeName'], $ws_params);
     return $output;
 }