2021-01-28 13:53:18 +01:00
|
|
|
class SerializerService
|
|
|
|
def self.dossier(dossier)
|
2023-01-18 18:45:47 +01:00
|
|
|
Sentry.with_scope do |scope|
|
|
|
|
scope.set_tags(dossier_id: dossier.id)
|
|
|
|
|
|
|
|
data = execute_query('serializeDossier', { number: dossier.id })
|
|
|
|
data && data['dossier']
|
|
|
|
end
|
2021-01-28 13:53:18 +01:00
|
|
|
end
|
|
|
|
|
2022-07-21 12:21:59 +02:00
|
|
|
def self.dossiers(procedure)
|
2023-01-18 18:45:47 +01:00
|
|
|
Sentry.with_scope do |scope|
|
2023-03-08 13:48:44 +01:00
|
|
|
scope.set_tags(procedure: procedure.id)
|
2023-01-18 18:45:47 +01:00
|
|
|
|
|
|
|
data = execute_query('serializeDossiers', { number: procedure.id })
|
|
|
|
data && data['demarche']['dossiers']
|
|
|
|
end
|
2022-07-21 12:21:59 +02:00
|
|
|
end
|
|
|
|
|
2022-07-21 12:41:30 +02:00
|
|
|
def self.demarches_publiques(after: nil)
|
|
|
|
data = execute_query('serializeDemarchesPubliques', { after: after })
|
|
|
|
data && data['demarchesPubliques']
|
|
|
|
end
|
|
|
|
|
2021-01-28 13:53:18 +01:00
|
|
|
def self.avis(avis)
|
|
|
|
data = execute_query('serializeAvis', { number: avis.dossier_id, id: avis.to_typed_id })
|
|
|
|
data && data['dossier']['avis'].first
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.champ(champ)
|
2023-01-18 18:45:47 +01:00
|
|
|
Sentry.with_scope do |scope|
|
|
|
|
scope.set_tags(champ_id: champ.id)
|
|
|
|
|
|
|
|
if champ.private?
|
|
|
|
data = execute_query('serializeAnnotation', { number: champ.dossier_id, id: champ.to_typed_id })
|
|
|
|
data && data['dossier']['annotations'].first
|
|
|
|
else
|
|
|
|
data = execute_query('serializeChamp', { number: champ.dossier_id, id: champ.to_typed_id })
|
|
|
|
data && data['dossier']['champs'].first
|
|
|
|
end
|
2021-01-28 13:53:18 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-20 16:15:18 +02:00
|
|
|
def self.message(commentaire)
|
|
|
|
Sentry.with_scope do |scope|
|
|
|
|
scope.set_tags(dossier_id: commentaire.dossier_id)
|
|
|
|
|
|
|
|
data = execute_query('serializeMessage', { number: commentaire.dossier_id, id: commentaire.to_typed_id })
|
|
|
|
data && data['dossier']["messages"].first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-28 13:53:18 +01:00
|
|
|
def self.execute_query(operation_name, variables)
|
|
|
|
result = API::V2::Schema.execute(QUERY,
|
|
|
|
variables: variables,
|
|
|
|
context: { internal_use: true },
|
|
|
|
operation_name: operation_name)
|
|
|
|
if result['errors'].present?
|
|
|
|
raise result['errors'].first['message']
|
|
|
|
end
|
|
|
|
result['data']
|
|
|
|
end
|
|
|
|
|
|
|
|
QUERY = <<-'GRAPHQL'
|
2022-07-21 12:21:59 +02:00
|
|
|
query serializeDossiers($number: Int!, $after: String) {
|
|
|
|
demarche(number: $number) {
|
|
|
|
dossiers(after: $after) {
|
|
|
|
nodes {
|
|
|
|
...DossierFragment
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
hasNextPage
|
|
|
|
endCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 12:41:30 +02:00
|
|
|
query serializeDemarchesPubliques($after: String) {
|
|
|
|
demarchesPubliques(after: $after) {
|
|
|
|
nodes {
|
|
|
|
...DemarcheDescriptorFragment
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
hasNextPage
|
|
|
|
endCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 13:53:18 +01:00
|
|
|
query serializeDossier($number: Int!) {
|
|
|
|
dossier(number: $number) {
|
|
|
|
...DossierFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
query serializeAvis($number: Int!, $id: ID!) {
|
|
|
|
dossier(number: $number) {
|
|
|
|
avis(id: $id) {
|
|
|
|
...AvisFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
query serializeChamp($number: Int!, $id: ID!) {
|
|
|
|
dossier(number: $number) {
|
|
|
|
champs(id: $id) {
|
2021-05-25 12:59:11 +02:00
|
|
|
...ChampFragment
|
|
|
|
...RepetitionChampFragment
|
|
|
|
...CarteChampFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
query serializeAnnotation($number: Int!, $id: ID!) {
|
|
|
|
dossier(number: $number) {
|
|
|
|
annotations(id: $id) {
|
2021-05-25 12:59:11 +02:00
|
|
|
...ChampFragment
|
|
|
|
...RepetitionChampFragment
|
|
|
|
...CarteChampFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-20 16:15:18 +02:00
|
|
|
query serializeMessage($number: Int!, $id: ID!) {
|
|
|
|
dossier(number: $number) {
|
|
|
|
messages(id: $id) {
|
|
|
|
...MessageFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 13:53:18 +01:00
|
|
|
fragment DossierFragment on Dossier {
|
|
|
|
id
|
|
|
|
number
|
|
|
|
archived
|
|
|
|
state
|
|
|
|
dateDerniereModification
|
|
|
|
datePassageEnConstruction
|
|
|
|
datePassageEnInstruction
|
|
|
|
dateTraitement
|
2022-06-11 12:41:47 +02:00
|
|
|
dateDepot
|
2022-03-10 18:19:31 +01:00
|
|
|
dateSuppressionParUsager
|
|
|
|
dateSuppressionParAdministration
|
2021-01-28 13:53:18 +01:00
|
|
|
instructeurs {
|
|
|
|
email
|
|
|
|
}
|
|
|
|
groupeInstructeur {
|
|
|
|
label
|
|
|
|
}
|
|
|
|
champs {
|
2021-05-25 12:59:11 +02:00
|
|
|
...ChampFragment
|
|
|
|
...RepetitionChampFragment
|
|
|
|
...CarteChampFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
annotations {
|
2021-05-25 12:59:11 +02:00
|
|
|
...ChampFragment
|
|
|
|
...RepetitionChampFragment
|
|
|
|
...CarteChampFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
avis {
|
|
|
|
...AvisFragment
|
|
|
|
}
|
|
|
|
demandeur {
|
2021-05-25 12:59:11 +02:00
|
|
|
...PersonnePhysiqueFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
...PersonneMoraleFragment
|
|
|
|
}
|
|
|
|
motivation
|
|
|
|
motivationAttachment {
|
2021-05-25 12:59:11 +02:00
|
|
|
...FileFragment
|
|
|
|
}
|
2022-06-11 12:41:47 +02:00
|
|
|
demarche {
|
|
|
|
number
|
|
|
|
revision {
|
|
|
|
id
|
|
|
|
}
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment AvisFragment on Avis {
|
|
|
|
id
|
|
|
|
question
|
|
|
|
reponse
|
|
|
|
dateQuestion
|
|
|
|
dateReponse
|
2021-03-22 10:25:47 +01:00
|
|
|
claimant {
|
2021-01-28 13:53:18 +01:00
|
|
|
email
|
|
|
|
}
|
|
|
|
expert {
|
|
|
|
email
|
|
|
|
}
|
|
|
|
attachment {
|
2021-05-25 12:59:11 +02:00
|
|
|
...FileFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment ChampFragment on Champ {
|
|
|
|
id
|
|
|
|
label
|
|
|
|
stringValue
|
|
|
|
... on SiretChamp {
|
|
|
|
etablissement {
|
|
|
|
...PersonneMoraleFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
... on LinkedDropDownListChamp {
|
|
|
|
primaryValue
|
|
|
|
secondaryValue
|
|
|
|
}
|
|
|
|
... on MultipleDropDownListChamp {
|
|
|
|
values
|
|
|
|
}
|
|
|
|
... on PieceJustificativeChamp {
|
|
|
|
file {
|
2021-05-25 12:59:11 +02:00
|
|
|
...FileFragment
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
... on AddressChamp {
|
|
|
|
address {
|
|
|
|
...AddressFragment
|
|
|
|
}
|
|
|
|
}
|
2022-12-21 09:24:37 +01:00
|
|
|
... on CommuneChamp {
|
|
|
|
commune {
|
|
|
|
name
|
|
|
|
code
|
|
|
|
}
|
|
|
|
departement {
|
|
|
|
name
|
|
|
|
code
|
|
|
|
}
|
|
|
|
}
|
|
|
|
... on DepartementChamp {
|
|
|
|
departement {
|
|
|
|
name
|
|
|
|
code
|
|
|
|
}
|
|
|
|
}
|
|
|
|
... on RegionChamp {
|
|
|
|
region {
|
|
|
|
name
|
|
|
|
code
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
|
2021-05-25 12:59:11 +02:00
|
|
|
fragment RepetitionChampFragment on RepetitionChamp {
|
2022-11-01 14:51:34 +01:00
|
|
|
rows {
|
|
|
|
champs {
|
|
|
|
...ChampFragment
|
|
|
|
}
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
2021-05-25 12:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fragment CarteChampFragment on CarteChamp {
|
|
|
|
geoAreas {
|
|
|
|
source
|
|
|
|
description
|
|
|
|
geometry {
|
|
|
|
type
|
|
|
|
coordinates
|
|
|
|
}
|
|
|
|
... on ParcelleCadastrale {
|
|
|
|
prefixe
|
|
|
|
numero
|
|
|
|
commune
|
|
|
|
section
|
|
|
|
surface
|
2021-01-28 13:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 12:59:11 +02:00
|
|
|
fragment PersonnePhysiqueFragment on PersonnePhysique {
|
|
|
|
civilite
|
|
|
|
nom
|
|
|
|
prenom
|
|
|
|
dateDeNaissance
|
|
|
|
}
|
|
|
|
|
2021-01-28 13:53:18 +01:00
|
|
|
fragment PersonneMoraleFragment on PersonneMorale {
|
|
|
|
siret
|
|
|
|
siegeSocial
|
|
|
|
naf
|
|
|
|
libelleNaf
|
|
|
|
address {
|
|
|
|
...AddressFragment
|
|
|
|
}
|
|
|
|
entreprise {
|
|
|
|
siren
|
|
|
|
capitalSocial
|
|
|
|
numeroTvaIntracommunautaire
|
|
|
|
formeJuridique
|
|
|
|
formeJuridiqueCode
|
|
|
|
nomCommercial
|
|
|
|
raisonSociale
|
|
|
|
siretSiegeSocial
|
|
|
|
codeEffectifEntreprise
|
|
|
|
dateCreation
|
|
|
|
nom
|
|
|
|
prenom
|
|
|
|
}
|
|
|
|
association {
|
|
|
|
rna
|
|
|
|
titre
|
|
|
|
objet
|
|
|
|
dateCreation
|
|
|
|
dateDeclaration
|
|
|
|
datePublication
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment AddressFragment on Address {
|
|
|
|
label
|
|
|
|
type
|
|
|
|
streetAddress
|
|
|
|
streetNumber
|
|
|
|
streetName
|
|
|
|
postalCode
|
|
|
|
cityName
|
|
|
|
cityCode
|
|
|
|
departmentName
|
|
|
|
departmentCode
|
|
|
|
regionName
|
|
|
|
regionCode
|
|
|
|
}
|
2021-05-25 12:59:11 +02:00
|
|
|
|
|
|
|
fragment FileFragment on File {
|
|
|
|
filename
|
|
|
|
checksum
|
2021-06-02 15:16:35 +02:00
|
|
|
byteSize: byteSizeBigInt
|
2021-05-25 12:59:11 +02:00
|
|
|
contentType
|
|
|
|
}
|
2022-07-21 12:41:30 +02:00
|
|
|
|
|
|
|
fragment ChampDescriptorFragment on ChampDescriptor {
|
2022-11-24 13:16:37 +01:00
|
|
|
__typename
|
2022-07-21 12:41:30 +02:00
|
|
|
label
|
|
|
|
description
|
|
|
|
required
|
2022-11-24 13:16:37 +01:00
|
|
|
... on DropDownListChampDescriptor {
|
|
|
|
options
|
|
|
|
otherOption
|
|
|
|
}
|
|
|
|
... on MultipleDropDownListChampDescriptor {
|
|
|
|
options
|
|
|
|
}
|
|
|
|
... on LinkedDropDownListChampDescriptor {
|
2022-07-21 12:41:30 +02:00
|
|
|
options
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment DemarcheDescriptorFragment on DemarcheDescriptor {
|
|
|
|
number
|
|
|
|
title
|
|
|
|
description
|
2022-11-24 13:16:37 +01:00
|
|
|
tags
|
|
|
|
zones
|
2022-07-21 12:41:30 +02:00
|
|
|
datePublication
|
|
|
|
service { nom organisme typeOrganisme }
|
2022-11-24 13:16:37 +01:00
|
|
|
demarcheUrl
|
|
|
|
dpoUrl
|
|
|
|
noticeUrl
|
|
|
|
siteWebUrl
|
|
|
|
cadreJuridiqueUrl
|
|
|
|
logo { ...FileFragment }
|
|
|
|
notice { ...FileFragment }
|
|
|
|
deliberation { ...FileFragment }
|
2022-07-21 12:41:30 +02:00
|
|
|
dossiersCount
|
|
|
|
revision {
|
2022-11-24 13:16:37 +01:00
|
|
|
champDescriptors {
|
|
|
|
...ChampDescriptorFragment
|
|
|
|
... on RepetitionChampDescriptor {
|
|
|
|
champDescriptors {
|
|
|
|
...ChampDescriptorFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 12:41:30 +02:00
|
|
|
}
|
|
|
|
}
|
2023-06-20 16:15:18 +02:00
|
|
|
|
|
|
|
fragment MessageFragment on Message {
|
|
|
|
id
|
|
|
|
email
|
|
|
|
body
|
|
|
|
createdAt
|
|
|
|
attachments {
|
|
|
|
...FileFragment
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 13:53:18 +01:00
|
|
|
GRAPHQL
|
|
|
|
end
|