public function addAction()
 {
     $ann = new Annotation();
     foreach ($_POST as $key => $value) {
         $ann->{$key} = $value;
     }
     $result = insert_annotation($ann);
     if ($result["success"] == TRUE) {
         echo "Annotation inserted successfully";
     } else {
         echo "Failed to insert annotation \n QUERY:{$result['sql']}";
     }
 }
Exemple #2
0
function setAnnotations($setAnnotationsRequest)
{
    global $conn, $ontology_default;
    //recupero i parametri in input
    $ontology_default = "25";
    $sessionId = $setAnnotationsRequest['sessionId'];
    $annotations_array = array();
    $count_added = 0;
    $count_updated = 0;
    if (is_array($setAnnotationsRequest['annotations']['annotation'][0])) {
        add_log('setAnnotations:start', "Multi annotation - Total annotation: " . count($setAnnotationsRequest['annotations']['annotation']) . " input: " . json_encode($setAnnotationsRequest));
        foreach ($setAnnotationsRequest['annotations']['annotation'] as $annotation) {
            $new_annotation = insert_annotation($annotation);
            if ($new_annotation) {
                $annotations_array[] = $new_annotation;
                if (@is_numeric($annotation['id'])) {
                    $count_updated++;
                } else {
                    $count_added++;
                }
            }
        }
    } else {
        $new_annotation = insert_annotation($setAnnotationsRequest['annotations']['annotation']);
        if ($new_annotation) {
            $annotations_array[] = $new_annotation;
            if (@is_numeric($setAnnotationsRequest['annotations']['annotation']['id'])) {
                $count_updated++;
            } else {
                $count_added++;
            }
        }
    }
    add_log('setAnnotations:annotations add complete', "Added {$count_added} annotation | Updated {$count_updated} annotations");
    $return_array = array('message' => 'Annotations added/updated', 'status' => 'STATUS_OK', 'annotations' => $annotations_array);
    return $return_array;
}