public static function createFromJSON($json_data, $type = null)
 {
     $class = self::className();
     $parent = parent::createFromJSON($json_data, get_called_class());
     foreach (DTOMapper::collectionFields($class) as $field) {
         if (!empty($parent->{$field})) {
             $parent->{$field} = DTOMapper::mapCollection($parent->{$field}, $class, $field);
         }
     }
     return $parent;
 }
 /**
  * Move a resource from one location to another location within the repository
  *
  * @param string $resourceUri URI of resource to be copied
  * @param string $destinationFolderUri URI of folder the resource is to be copied to
  * @param boolean $createFolders Should folders be created if they do not already exist?
  * @param boolean $overwrite Should files be overwritten while performing this operation?
  * @return \Jaspersoft\Dto\Resource\Resource
  */
 public function moveResource($resourceUri, $destinationFolderUri, $createFolders = true, $overwrite = false)
 {
     $url = self::makeUrl(null, $destinationFolderUri);
     $url .= '?' . Util::query_suffix(array("createFolders" => $createFolders, "overwrite" => $overwrite));
     $response = $this->service->makeRequest($url, array(200), 'PUT', null, true, 'application/json', 'application/json', array("Content-Location: " . $resourceUri));
     $data = $response['body'];
     $headers = $response['headers'];
     $content_type = array_values(preg_grep("#repository\\.(.*)\\+#", $headers));
     preg_match("#repository\\.(.*)\\+#", $content_type[0], $resource_type);
     $class = RESOURCE_NAMESPACE . '\\' . ucfirst($resource_type[1]);
     if (class_exists($class) && is_subclass_of($class, RESOURCE_NAMESPACE . '\\Resource')) {
         return $class::createFromJSON(json_decode($data, true), $class);
     } else {
         return Resource::createFromJSON(json_decode($data, true));
     }
 }
 /** This function takes an array of elements provided by a decoded response from the server and uses
  * it to create a DTO representing the resource being deserialized.
  *
  *
  * @param $json_data array
  * @param $type string The class type to be created
  * @return array
  */
 public static function createFromJSON($json_data, $type = null)
 {
     $className = explode('\\', $type);
     $className = lcfirst(end($className));
     $allFields = parent::createFromJSON($json_data, $type);
     $compositeFields = CompositeDTOMapper::compositeFields(get_class($allFields));
     foreach ($compositeFields as $key) {
         if (isset($allFields->{$key})) {
             $allFields->{$key} = self::synthesizeSubresource($key, $json_data[$key], $className);
         }
     }
     return $allFields;
 }