Ejemplo n.º 1
0
 private function setup_tag($id, $tag)
 {
     $error = -1;
     $result = tag_item('algorithm_setup', $id, $tag, $this->user_id, $error);
     //update index
     $this->elasticsearch->index('setup', $id);
     if ($result == false) {
         $this->returnError($error, $this->version);
     } else {
         $this->xmlContents('entity-tag', $this->version, array('id' => $id, 'type' => 'setup'));
     }
 }
Ejemplo n.º 2
0
function insertImplementationFromXML($xml, $configuration, $implementation_base = array())
{
    $ci =& get_instance();
    $implementation_objects = all_tags_from_xml($xml, array_custom_filter($configuration, array('plain', 'array')));
    $implementation = all_tags_from_xml($xml, array_custom_filter($configuration, array('string', 'csv')), $implementation_base);
    // insert the implementation itself
    $version = $ci->Implementation->incrementVersionNumber($implementation['name']);
    $implementation['fullName'] = $implementation['name'] . '(' . $version . ')';
    $implementation['version'] = $version;
    if (array_key_exists('source_md5', $implementation)) {
        if (array_key_exists('external_version', $implementation) === false) {
            $implementation['external_version'] = $implementation['source_md5'];
        }
    } elseif (array_key_exists('binary_md5', $implementation)) {
        if (array_key_exists('external_version', $implementation) === false) {
            $implementation['external_version'] = $implementation['binary_md5'];
        }
    }
    if (array_key_exists('implements', $implementation)) {
        if (in_array($implementation['implements'], $ci->supportedMetrics) == false && in_array($implementation['implements'], $ci->supportedAlgorithms == false)) {
            return false;
        }
    }
    // information illegal to insert
    unset($implementation['source_md5']);
    unset($implementation['binary_md5']);
    // tags also not insertable. but handled differently.
    $tags = array();
    if (array_key_exists('tag', $implementation)) {
        $tags = str_getcsv($implementation['tag']);
        unset($implementation['tag']);
    }
    $res = $ci->Implementation->insert($implementation);
    if ($res === false) {
        return false;
    }
    foreach ($tags as $tag) {
        $error = -1;
        tag_item('implementation', $res, $tag, $implementation_base['uploader'], $error);
    }
    // add to elastic search index.
    $ci->elasticsearch->index('flow', $res);
    // insert all important "components"
    foreach ($implementation_objects as $key => $value) {
        if ($key == 'component') {
            foreach ($value as $entry) {
                $component = $entry->implementation->children('oml', true);
                $similarComponent = $ci->Implementation->compareToXml($entry->implementation);
                if ($similarComponent === false) {
                    $component->version = $ci->Implementation->incrementVersionNumber($component->name);
                    $componentFullName = $component->name . '(' . $component->version . ')';
                    $succes = insertImplementationFromXML($component, $configuration, array('uploadDate' => now(), 'uploader' => $implementation['uploader']));
                    if ($succes == false) {
                        return false;
                    }
                    $ci->Implementation->addComponent($res, $succes, trim($entry->identifier));
                } else {
                    $ci->Implementation->addComponent($res, $similarComponent, trim($entry->identifier));
                }
            }
        } elseif ($key == 'bibliographical_reference') {
            foreach ($value as $entry) {
                $children = $entry->children('oml', true);
                $children->implementation_id = $res;
                $succes = $ci->Bibliographical_reference->insert($children);
            }
        } elseif ($key == 'parameter') {
            foreach ($value as $entry) {
                $children = $entry->children('oml', true);
                $succes = $ci->Input->insert(array('fullName' => $implementation['fullName'] . '_' . $children->name, 'implementation_id' => $res, 'name' => trim($children->name), 'defaultValue' => property_exists($children, 'default_value') ? trim($children->default_value) : null, 'description' => property_exists($children, 'description') ? trim($children->description) : null, 'dataType' => property_exists($children, 'data_type') ? trim($children->data_type) : null, 'recommendedRange' => property_exists($children, 'recommended_range') ? trim($children->recommendedRange) : null));
            }
        }
    }
    return $res;
}
Ejemplo n.º 3
0
 private function _openml_setup_tag()
 {
     $id = $this->input->get('setup_id');
     $tag = $this->input->get('tag');
     $error = -1;
     $result = tag_item('algorithm_setup', $id, $tag, $this->user_id, $error);
     //update index
     $this->elasticsearch->index('setup', $id);
     if ($result == false) {
         $this->_returnError($error);
     } else {
         $this->_xmlContents('entity-tag', array('id' => $id, 'type' => 'setup'));
     }
 }