/**
  *
  */
 public function addAnnotation($ps_title, $pn_locale_id, $pn_user_id, $pa_properties, $pn_status, $pn_access, $pa_values = null, $pa_options = null)
 {
     if (!($vn_representation_id = $this->getPrimaryKey())) {
         return null;
     }
     if (!($o_coder = $this->getAnnotationPropertyCoderInstance($this->getAnnotationType()))) {
         // does not support annotations
         return null;
     }
     foreach ($o_coder->getPropertyList() as $vs_property) {
         if (!$o_coder->setProperty($vs_property, $pa_properties[$vs_property])) {
             // error setting values
             $this->errors = $o_coder->errors;
             return false;
         }
     }
     if (!$o_coder->validate()) {
         $this->errors = $o_coder->errors;
         return false;
     }
     $t_annotation = new ca_representation_annotations();
     $t_annotation->setMode(ACCESS_WRITE);
     $t_annotation->set('representation_id', $vn_representation_id);
     $t_annotation->set('type_code', $o_coder->getType());
     $t_annotation->set('locale_id', $pn_locale_id);
     $t_annotation->set('user_id', $pn_user_id);
     $t_annotation->set('status', $pn_status);
     $t_annotation->set('access', $pn_access);
     $t_annotation->insert();
     if ($t_annotation->numErrors()) {
         $this->errors = $t_annotation->errors;
         return false;
     }
     if (!$ps_title) {
         $ps_title = "[BLANK]";
     }
     $t_annotation->addLabel(array('name' => $ps_title), $pn_locale_id, null, true);
     if ($t_annotation->numErrors()) {
         $this->errors = $t_annotation->errors;
         return false;
     }
     foreach ($o_coder->getPropertyList() as $vs_property) {
         $t_annotation->setPropertyValue($vs_property, $o_coder->getProperty($vs_property));
     }
     $t_annotation->update();
     if ($t_annotation->numErrors()) {
         $this->errors = $t_annotation->errors;
         return false;
     }
     if (is_array($pa_values)) {
         foreach ($pa_values as $vs_element => $va_value) {
             if (is_array($va_value)) {
                 // array of values (complex multi-valued attribute)
                 $t_annotation->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
             } else {
                 // scalar value (simple single value attribute)
                 if ($va_value) {
                     $t_annotation->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                 }
             }
         }
     }
     $t_annotation->update();
     if ($t_annotation->numErrors()) {
         $this->errors = $t_annotation->errors;
         return false;
     }
     if (isset($pa_options['returnAnnotation']) && (bool) $pa_options['returnAnnotation']) {
         return $t_annotation;
     }
     return $t_annotation->getPrimaryKey();
 }