public function applyAttributes(Resource $entity, $data)
    {
        $this->validateData($data);
        $meta = $this->em->getMetadataFor($entity->getType());
        foreach ($meta->getAttributes() as $key => $attribute) {
            if (!isset($data[$key])) {
                continue;
            }
            $this->applyAttribute($entity, $key, $data[$key]);
        }
        return $this;
    }