cancel
Showing results for 
Search instead for 
Did you mean: 

Is the function PHP getProperty of a document not yet implemented?

olaf_
Champ on-the-rise
Champ on-the-rise

Am I correct that this function in the PHP library/client for REST automation has not been implemented yet?

$docVersion = $this->documents[$index]->getProperty('dc:version') ;

Where documents[] is the resultset of a call : $this->answer = $this->session->newRequest("Document.Query") ->set('params', 'query', $query) ->setSchema($this->propertiesSchema) ->sendRequest();

8 REPLIES 8

Pierre-Gildas_M
Confirmed Champ
Confirmed Champ

Hi Olaf,

Try :

$this->documents[$index]->getProperty('uid:major_version');
$this->documents[$index]->getProperty('uid:minor_version');

olaf_
Champ on-the-rise
Champ on-the-rise

Thanks for the feedback. I did some further testing.

Function:

    /**
      *  Generialised PropertyGet function
      *
      *  @param string propertyName
      *  @param string propertyDescription
      *  @param int index
      *
      *  @return string value
      *  or
      *  @return boolean false
      */
    private function getDocumentProperty($name, $desc, $index) {
        global $logdebug;
        if ($index > $this->getNumberOfDocumentsInResultset() ) {
            if ($logdebug) {
                $this->logger->addInfo($desc . " : the index provided (".$index.") is beyond the scope of the document list (".$this->getNumberOfDocumentsInResultset().")");
            }
            $value = false ;
        }
        else {
            $value = $this->documents[$index]->getProperty($name) ; // deviation from regular property queries
            //$value = $this->documents[$index]->getProperty("'".$name."'") ;
            //$value = $this->documents[$index]->getProperty("'dc:creator'") ;
            if ($logdebug) {
                $this->logger->addInfo("Get property ".$name);
                $docname = $this->getDocumentTitle($index);
                $this->logger->addInfo("Getting property from document titled '" . $docname . "'");
            }
            if ($logdebug) {
                $this->logger->addDebug("Get ".$desc . " index = ".$index);
                $this->logger->addDebug("Get ".$desc . " resultsetsize = ".$this->getNumberOfDocumentsInResultset());
                $this->logger->addDebug($desc . " = ".$value);
            }
        }
        return ($value) ;
    }

It should be called like: $this->getDocumentProperty('dc:creator', "DocumentCreator", 0) Result is an empty string. This is regardless of the property. This is a bit weird as a direct call like: $this->documents[$index]->getTitle() produces a proper result.

This is especially hard to debug as I see no exceptions or errors, just an empty result string. Any pointers much appreciated.

This code works fine for me.

olaf_
Champ on-the-rise
Champ on-the-rise

I added the following line to my code the make my monolog debugging more verbose

Have you tried to perform the query manually or at least debug the raw response of the Nuxeo server ?

olaf_
Champ on-the-rise
Champ on-the-rise

I did test on/with the local nuxeo playground. But that was not an exact test of the querry so I did some further testing which provided more questions than answers

About your original question and a), make sure to query for at least any schema (*) to get the properties (setSchema method with the PHP Client) as I don't see it in your python sample.

olaf_
Champ on-the-rise
Champ on-the-rise

Thanks. It turned out that in the PHP code the headers were not set properly. $schema='"'"; versus $schema=''; made the difference. Obviously the schema was not set at all in the Python code.