src/snac/client/webui/util/ResourcePostMapper.php
/**
     * Serialize post data to Resource
     *
     * Takes the POST data from a SAVE operation and generates
     * a Resource object to be used by the rest of the system
     *
     * @param string[][] $postData The POST input data from the WebUI user interface
     * @return \snac\data\Resource
     */
Serialize post data to Resource
Takes the POST data from a SAVE operation and generates
a Resource object to be used by the rest of the system

@param string[][] $postData The POST input data from the WebUI user interface
@return \snac\data\Resource
Serialize post data to Resource Takes the POST data from a SAVE operation and generates a Resource object to be used by the rest of the system @param string [] [] $postData The POST input data from the WebUI user interface @return \ snac \ data \ Resource
public function serializeToResource($postData) {
        $this->resource = new \snac\data\Resource();
        foreach ($postData["resources"] as $k => $data) {
            $this->resource->setID($data["id"]);
            $this->resource->setVersion($data["version"]);
            $this->resource->setOperation($data["operation"]);
            $this->resource->setTitle($data["title"]);
            $this->resource->setAbstract($data["abstract"]);
            $this->resource->setExtent($data["extent"]);
            $this->resource->setDate($data["date"]);
            $this->resource->setDisplayEntry($data["displayEntry"]);
            $this->resource->setLink($data["link"]);
            $this->resource->setDocumentType($this->parseTerm($data["documentType"]));
            if (isset($data["repo"]) && $data["repo"] !== null) {
                $repo = new \snac\data\Constellation();
                $repo->setID($data["repo"]);
                $this->resource->setRepository($repo);
            }
            if (isset($data["originationName"])) {
                foreach ($data["originationName"] as $l => $oData) {
                    $part = new \snac\data\OriginationName();
                    $part->setID($oData["id"]);
                    $part->setVersion($oData["version"]);
                    if ($oData["operation"] == "insert" || $oData["operation"] == "delete")
                        $part->setOperation($this->getOperation($oData));
                    else {
                        $oData["operation"] = $this->getOperation($data);
                        $part->setOperation($this->getOperation($data));
                    }
                    $part->setName($oData["name"]);
                    $this->resource->addOriginationName($part);
                }
            }
            if (isset($data["languages"])) {
                foreach ($data["languages"] as $languages => $language) {
                    $newLanguage = new \snac\data\Language();
                    $lang = new \snac\data\Term();
                    $script = new \snac\data\Term();
                    if (isset($language['id']))
                        $newLanguage->setID($language["id"]);
                    if (isset($language['version']))
                        $newLanguage->setVersion($language["version"]);
                    $newLanguage->setOperation($language["operation"]);
                    if (!empty($language["language"]) || (!empty($language["script"]))) {
                        if (isset($language["language"]))
                            $lang->setID($language["language"]);
                            $newLanguage->setLanguage($lang);
                        if (isset($language["script"]))
                            $script->setID($language["script"]);
                            $newLanguage->setScript($script);
                        $this->resource->addLanguage($newLanguage);
                    }
                }
            }
        }
        return $this->resource;
    }
public function serializeToResource ( $ postData ) { $ this -> resource = new \ snac \ data \ Resource ( ) ; foreach ( $ postData [ " resources " ] as $ k => $ data ) { $ this -> resource -> setID ( $ data [ " id " ] ) ; $ this -> resource -> setVersion ( $ data [ " version " ] ) ; $ this -> resource -> setOperation ( $ data [ " operation " ] ) ; $ this -> resource -> setTitle ( $ data [ " title " ] ) ; $ this -> resource -> setAbstract ( $ data [ " abstract " ] ) ; $ this -> resource -> setExtent ( $ data [ " extent " ] ) ; $ this -> resource -> setDate ( $ data [ " date " ] ) ; $ this -> resource -> setDisplayEntry ( $ data [ " displayEntry " ] ) ; $ this -> resource -> setLink ( $ data [ " link " ] ) ; $ this -> resource -> setDocumentType ( $ this -> parseTerm ( $ data [ " documentType " ] ) ) ; if ( isset ( $ data [ " repo " ] ) && $ data [ " repo " ] !== null ) { $ repo = new \ snac \ data \ Constellation ( ) ; $ repo -> setID ( $ data [ " repo " ] ) ; $ this -> resource -> setRepository ( $ repo ) ; } if ( isset ( $ data [ " originationName " ] ) ) { foreach ( $ data [ " originationName " ] as $ l => $ oData ) { $ part = new \ snac \ data \ OriginationName ( ) ; $ part -> setID ( $ oData [ " id " ] ) ; $ part -> setVersion ( $ oData [ " version " ] ) ; if ( $ oData [ " operation " ] == " insert " || $ oData [ " operation " ] == " delete " ) $ part -> setOperation ( $ this -> getOperation ( $ oData ) ) ; else { $ oData [ " operation " ] = $ this -> getOperation ( $ data ) ; $ part -> setOperation ( $ this -> getOperation ( $ data ) ) ; } $ part -> setName ( $ oData [ " name " ] ) ; $ this -> resource -> addOriginationName ( $ part ) ; } } if ( isset ( $ data [ " languages " ] ) ) { foreach ( $ data [ " languages " ] as $ languages => $ language ) { $ newLanguage = new \ snac \ data \ Language ( ) ; $ lang = new \ snac \ data \ Term ( ) ; $ script = new \ snac \ data \ Term ( ) ; if ( isset ( $ language [ 'id' ] ) ) $ newLanguage -> setID ( $ language [ " id " ] ) ; if ( isset ( $ language [ 'version' ] ) ) $ newLanguage -> setVersion ( $ language [ " version " ] ) ; $ newLanguage -> setOperation ( $ language [ " operation " ] ) ; if ( ! empty ( $ language [ " language " ] ) || ( ! empty ( $ language [ " script " ] ) ) ) { if ( isset ( $ language [ " language " ] ) ) $ lang -> setID ( $ language [ " language " ] ) ; $ newLanguage -> setLanguage ( $ lang ) ; if ( isset ( $ language [ " script " ] ) ) $ script -> setID ( $ language [ " script " ] ) ; $ newLanguage -> setScript ( $ script ) ; $ this -> resource -> addLanguage ( $ newLanguage ) ; } } } } return $ this -> resource ; }
Serialize post data to Resource
 Takes the POST data from a SAVE operation and generates
 a Resource object to be used by the rest of the system
Serialize post data to Resource Takes the POST data from a SAVE operation and generates a Resource object to be used by the rest of the system
// Not currently using originationName