Browse Source

doleance graphql (not tested)

bach 1 year ago
parent
commit
ed3c3f9f00

+ 56 - 0
src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls

@@ -17,6 +17,7 @@ type Concernement implements NodeInterface {
   recit: Filefield
   entites: [Entiteintegre]
   besoins: [Besoin]
+  doleances: [Doleance]
 }
 
 type Entiteintegre {
@@ -72,6 +73,61 @@ type Reponse implements NodeInterface {
   avec: String
 }
 
+type Doleance implements NodeInterface {
+  id: Int!
+  path: String!
+  uuid: String!
+  bundle: String!
+  title: String!
+  author: String
+  #1
+  leprobleme: String
+  lenquete: String
+  groupesinterets: [GroupeInterets]
+  #2
+  entite_addresse_doleance: String
+  comment_ennonce_doleance: String
+  aqui_addresse_doleance: String
+  reception_traitement: [ReceptionTraitement]
+  #3
+  entites_decisionnaires: String
+  decision_formule: String
+  mise_en_oeuvre_decision: [MiseEnoeuvreDecision] 
+  #4
+  entite_addresse_application: String
+  aqui_adresse_decision: String
+  comment_formule_decision: String
+  receptions_et_applications: [ReceptionsApplications]
+  probleme_initial_resolu: Int
+  oui_nouvelle_situation: String
+  non_adresse_doleance: String
+}
+
+type GroupeInterets {
+  groupe_interets: String
+  accorder_interets: String
+  formuler: String
+}
+
+type ReceptionTraitement {
+  entite_adressee: String
+  doleance_formulee: String
+  traite_doleance: String
+  entite_recoit_doleance: String
+}
+
+type MiseEnoeuvreDecision {
+  entite_adresse_decision: String
+  formule_decision: String
+  entite_metenoeuvre_decisio: String
+}
+
+type ReceptionsApplications {
+  applique_decision: String
+  formule_decision_applic: String
+  entite_recoit_decision: String
+}
+
 type Static implements NodeInterface {
   id: Int!
   uuid: String!

+ 12 - 0
src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.extension.graphqls

@@ -63,6 +63,18 @@ extend type Query {
   reponse(id: Int!): Reponse
 }
 
+extend type Query {
+  alldoleances: [Doleance]
+}
+
+extend type Query {
+  doleances(ids: [Int]): [Doleance]
+}
+
+extend type Query {
+  doleance(id: Int!): Doleance
+}
+
 extend type Query {
   user(id: Int!): User
 }

+ 352 - 1
src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php

@@ -42,6 +42,16 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
     // 
     $this->addReponse($registry, $builder);
     // 
+    $this->addDoleance($registry, $builder);
+    // 
+    $this->addGroupeInterets($registry, $builder);
+    // 
+    $this->addReceptionTraitement($registry, $builder);
+    // 
+    $this->addMiseEnoeuvreDecision($registry, $builder);
+    // 
+    $this->addReceptionsApplications($registry, $builder);
+    // 
     $this->addStatic($registry, $builder);
     // 
     $this->addGroup($registry, $builder);
@@ -226,6 +236,13 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
         ->map('entity', $builder->fromParent())
         ->map('field', $builder->fromValue('field_besoin'))
     );
+
+    // doleances: [Doleance]
+    $registry->addFieldResolver('Concernement', 'doleances',
+      $builder->produce('entity_reference')
+        ->map('entity', $builder->fromParent())
+        ->map('field', $builder->fromValue('field_doleancer'))
+    );
   }
 
   //   _____       _   _ _    __        ___       _    __             __           
@@ -572,7 +589,7 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
           $builder->callback(function($parent, $arg){
             $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
             $query = $entity_storage->getQuery()
-              ->condition('type', ['reponse'], 'IN')
+              ->condition('type', ['cercle_politique'], 'IN')
               ->accessCheck(TRUE);
             $results = $query->execute();
             return $results;
@@ -674,6 +691,340 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
 
   }
 
+  //   ____        _                           
+  //  |  _ \  ___ | | ___  __ _ _ __   ___ ___ 
+  //  | | | |/ _ \| |/ _ \/ _` | '_ \ / __/ _ \
+  //  | |_| | (_) | |  __/ (_| | | | | (_|  __/
+  //  |____/ \___/|_|\___|\__,_|_| |_|\___\___|
+  protected function addDoleance(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
+    $registry->addFieldResolver('Query', 'alldoleances',
+      $builder->compose(
+          $builder->callback(function($parent, $arg){
+            $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
+            $query = $entity_storage->getQuery()
+              ->condition('type', ['cercle_politique'], 'IN')
+              ->accessCheck(TRUE);
+            $results = $query->execute();
+            return $results;
+          }),
+          $builder->produce('entity_load_multiple')
+          ->map('type', $builder->fromValue('node'))
+          ->map('ids', $builder->fromParent())
+        )
+    );
+
+    $registry->addFieldResolver('Query', 'doleances',
+      $builder->compose(
+          $builder->callback(function($parent, $arg){
+            $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
+            $query = $entity_storage->getQuery()
+              ->condition('type', ['cercle_politique'], 'IN')
+              ->accessCheck(TRUE);
+            $results = $query->execute();
+            return $results;
+          }),
+          $builder->produce('entity_load_multiple')
+          ->map('type', $builder->fromValue('node'))
+          ->map('ids', $builder->fromArgument('ids'))
+        )
+    );
+
+    $registry->addFieldResolver('Query', 'doleance',
+      $builder->produce('entity_load')
+        ->map('type', $builder->fromValue('node'))
+        ->map('id', $builder->fromArgument('id'))
+    );
+
+    $registry->addFieldResolver('Doleance', 'id',
+      $builder->produce('entity_id')
+        ->map('entity', $builder->fromParent())
+      );
+
+    $registry->addFieldResolver('Doleance', 'path',
+        $builder->compose(
+          $builder->produce('entity_url')
+            ->map('entity', $builder->fromParent()),
+          $builder->produce('url_path')
+            ->map('url', $builder->fromParent())
+        )
+      );
+
+    $registry->addFieldResolver('Doleance', 'uuid',
+      $builder->produce('entity_uuid')
+        ->map('entity', $builder->fromParent())
+      );
+
+    $registry->addFieldResolver('Doleance', 'bundle',
+      $builder->compose(
+        $builder->produce('entity_bundle')
+          ->map('entity', $builder->fromParent())
+      ));
+
+    $registry->addFieldResolver('Doleance', 'title',
+      $builder->compose(
+        $builder->produce('entity_label')
+          ->map('entity', $builder->fromParent())
+      ));
+
+    $registry->addFieldResolver('Entite', 'author',
+      $builder->compose(
+        $builder->produce('entity_owner')
+          ->map('entity', $builder->fromParent()),
+        $builder->produce('entity_label')
+          ->map('entity', $builder->fromParent())
+      ));
+
+      // #1
+      // leprobleme: String
+      $registry->addFieldResolver('Doleance', 'leprobleme',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_le_probleme.value'))
+        );
+      // lenquete: String
+      $registry->addFieldResolver('Doleance', 'lenquete',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_enquete_terraindevie.value'))
+        );
+      // groupesinterets: [GroupeInterets]
+      $registry->addFieldResolver('Doleance', 'groupesinterets',
+        $builder->produce('entity_reference_revisions')
+          ->map('entity', $builder->fromParent())
+          ->map('field', $builder->fromValue('field_groupes'))
+        );
+
+
+      // #2
+      // entite_addresse_doleance: String
+      $registry->addFieldResolver('Doleance', 'entite_addresse_doleance',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_entite_adresse_doleance.value'))
+        );
+      // comment_ennonce_doleance: String
+      $registry->addFieldResolver('Doleance', 'comment_ennonce_doleance',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_comment_enonce_doleance.value'))
+        );
+      // aqui_addresse_doleance: String
+      $registry->addFieldResolver('Doleance', 'aqui_addresse_doleance',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_a_qui_adresse_doleance.value'))
+        );
+      // reception_traitement: [ReceptionTraitement]
+      $registry->addFieldResolver('Doleance', 'reception_traitement',
+        $builder->produce('entity_reference_revisions')
+          ->map('entity', $builder->fromParent())
+          ->map('field', $builder->fromValue('field_receptions_et_traitements'))
+        );
+
+      // #3
+      // entites_decisionnaires: String
+      $registry->addFieldResolver('Doleance', 'entites_decisionnaires',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_entites_decisionnaires.value'))
+        );
+      // decision_formule: String
+      $registry->addFieldResolver('Doleance', 'decision_formule',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_decision_formulee.value'))
+        );
+      // mise_en_oeuvre_decision: [MiseEnoeuvreDecision] 
+      $registry->addFieldResolver('Doleance', 'mise_en_oeuvre_decision',
+        $builder->produce('entity_reference_revisions')
+          ->map('entity', $builder->fromParent())
+          ->map('field', $builder->fromValue('field_mise_en_oeuvre_decision'))
+        );
+      
+      // #4
+      // entite_addresse_application: String
+      $registry->addFieldResolver('Doleance', 'entite_addresse_application',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_entite_addresse_application.value'))
+        );
+      // aqui_adresse_decision: String
+      $registry->addFieldResolver('Doleance', 'aqui_adresse_decision',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_aqui_adresse_decision.value'))
+        );
+      // comment_formule_decision: String
+      $registry->addFieldResolver('Doleance', 'comment_formule_decision',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_comment_formule_decision.value'))
+        );
+      // receptions_et_applications: [ReceptionsApplications] 
+      $registry->addFieldResolver('Doleance', 'receptions_et_applications',
+        $builder->produce('entity_reference_revisions')
+          ->map('entity', $builder->fromParent())
+          ->map('field', $builder->fromValue('field_receptions_et_applications'))
+        );
+      // probleme_initial_resolu: Int
+      $registry->addFieldResolver('Doleance', 'probleme_initial_resolu',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_probleme_initial_resolu.value'))
+        );
+      // oui_nouvelle_situation: String
+      $registry->addFieldResolver('Doleance', 'oui_nouvelle_situation',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_oui_nouvelle_situation.value'))
+        );
+      // non_adresse_doleance: String
+      $registry->addFieldResolver('Doleance', 'non_adresse_doleance',
+        $builder->produce('property_path')
+          ->map('type', $builder->fromValue('entity:node'))
+          ->map('value', $builder->fromParent())
+          ->map('path', $builder->fromValue('field_non_adresse_doleance.value'))
+        );
+  }
+  
+  //    ____                              ___       _                _       
+  //   / ___|_ __ ___  _   _ _ __   ___  |_ _|_ __ | |_ ___ _ __ ___| |_ ___ 
+  //  | |  _| '__/ _ \| | | | '_ \ / _ \  | || '_ \| __/ _ \ '__/ _ \ __/ __|
+  //  | |_| | | | (_) | |_| | |_) |  __/  | || | | | ||  __/ | |  __/ |_\__ \
+  //   \____|_|  \___/ \__,_| .__/ \___| |___|_| |_|\__\___|_|  \___|\__|___/
+  //                        |_|                                              
+  protected function addGroupeInterets(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
+    // groupe_interets: String
+    $registry->addFieldResolver('GroupeInterets', 'groupe_interets',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_groupe_interets.value'))
+      );
+    // accorder_interets: String
+    $registry->addFieldResolver('GroupeInterets', 'accorder_interets',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_accorder_interets.value'))
+      );
+    // formuler: String
+    $registry->addFieldResolver('GroupeInterets', 'formuler',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_formuler.value'))
+      );
+  }
+
+  //   ____                     _   _               _____          _ _                            _   
+  //  |  _ \ ___  ___ ___ _ __ | |_(_) ___  _ __   |_   _| __ __ _(_) |_ ___ _ __ ___   ___ _ __ | |_ 
+  //  | |_) / _ \/ __/ _ \ '_ \| __| |/ _ \| '_ \    | || '__/ _` | | __/ _ \ '_ ` _ \ / _ \ '_ \| __|
+  //  |  _ <  __/ (_|  __/ |_) | |_| | (_) | | | |   | || | | (_| | | ||  __/ | | | | |  __/ | | | |_ 
+  //  |_| \_\___|\___\___| .__/ \__|_|\___/|_| |_|   |_||_|  \__,_|_|\__\___|_| |_| |_|\___|_| |_|\__|
+  //                     |_|                                                                          
+  protected function addReceptionTraitement(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
+    // entite_adressee: String
+    $registry->addFieldResolver('GroupeInterets', 'entite_adressee',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_entite_adressee.value'))
+      );
+    // doleance_formulee: String
+    $registry->addFieldResolver('GroupeInterets', 'doleance_formulee',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_doleance_formulee.value'))
+      );
+    // traite_doleance: String
+    $registry->addFieldResolver('GroupeInterets', 'traite_doleance',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_traite_doleance.value'))
+      );
+    // entite_recoit_doleance: String
+    $registry->addFieldResolver('GroupeInterets', 'entite_recoit_doleance',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_entite_recoit_doleance.value'))
+      );
+  }
+
+  //   __  __ _            _____                                         ____            _     _             
+  //  |  \/  (_)___  ___  | ____|_ __   ___   ___ _   ___   ___ __ ___  |  _ \  ___  ___(_)___(_) ___  _ __  
+  //  | |\/| | / __|/ _ \ |  _| | '_ \ / _ \ / _ \ | | \ \ / / '__/ _ \ | | | |/ _ \/ __| / __| |/ _ \| '_ \ 
+  //  | |  | | \__ \  __/ | |___| | | | (_) |  __/ |_| |\ V /| | |  __/ | |_| |  __/ (__| \__ \ | (_) | | | |
+  //  |_|  |_|_|___/\___| |_____|_| |_|\___/ \___|\__,_| \_/ |_|  \___| |____/ \___|\___|_|___/_|\___/|_| |_|
+  protected function addMiseEnoeuvreDecision(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
+    // entite_adresse_decision: String
+    $registry->addFieldResolver('MiseEnoeuvreDecision', 'entite_adresse_decision',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_entite_adresse_decision.value'))
+      );
+    // formule_decision: String
+    $registry->addFieldResolver('MiseEnoeuvreDecision', 'formule_decision',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_formule_decision.value'))
+      );
+    // entite_metenoeuvre_decisio: String
+    $registry->addFieldResolver('MiseEnoeuvreDecision', 'entite_metenoeuvre_decisio',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_entite_metenoeuvre_decisio.value'))
+      );
+  }
+  
+  //   ____                     _   _                      _                _ _           _   _                 
+  //  |  _ \ ___  ___ ___ _ __ | |_(_) ___  _ __  ___     / \   _ __  _ __ | (_) ___ __ _| |_(_) ___  _ __  ___ 
+  //  | |_) / _ \/ __/ _ \ '_ \| __| |/ _ \| '_ \/ __|   / _ \ | '_ \| '_ \| | |/ __/ _` | __| |/ _ \| '_ \/ __|
+  //  |  _ <  __/ (_|  __/ |_) | |_| | (_) | | | \__ \  / ___ \| |_) | |_) | | | (_| (_| | |_| | (_) | | | \__ \
+  //  |_| \_\___|\___\___| .__/ \__|_|\___/|_| |_|___/ /_/   \_\ .__/| .__/|_|_|\___\__,_|\__|_|\___/|_| |_|___/
+  //                     |_|                                   |_|   |_|                                        
+  protected function addReceptionsApplications(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
+    // applique_decision: String
+    $registry->addFieldResolver('ReceptionsApplications', 'applique_decision',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_applique_decision.value'))
+      );
+      // formule_decision_applic: String
+    $registry->addFieldResolver('ReceptionsApplications', 'formule_decision_applic',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_formule_decision_applic.value'))
+      );
+      // entite_recoit_decision: String
+    $registry->addFieldResolver('ReceptionsApplications', 'entite_recoit_decision',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_entite_recoit_decision.value'))
+      );
+    
+  }
   //  ___ _        _   _
   // / __| |_ __ _| |_(_)__ ___
   // \__ \  _/ _` |  _| / _(_-<