Skip to content

Commit

Permalink
feat(publi-service-metadata): 2 champs distincts type de ressource et…
Browse files Browse the repository at this point in the history
… généalogie de la ressource #528
  • Loading branch information
ocruze committed Nov 21, 2024
1 parent 4f262e8 commit 8ff9685
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 43 deletions.
9 changes: 8 additions & 1 deletion assets/@types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ export type TypeInfosWithBbox =
| ConfigurationWmsVectorDetailsContent
| ConfigurationWmtsTmsDetailsContent;

export enum MetadataHierarchyLevel {
Dataset = "dataset",
Series = "series",
}

export type MetadataFormValuesType = {
metadata_file_content?: FileList;
identifier?: string;
Expand All @@ -199,6 +204,7 @@ export type MetadataFormValuesType = {
email_contact?: string;
creation_date?: string;
resource_genealogy?: string;
hierarchy_level?: MetadataHierarchyLevel;
organization?: string;
organization_email?: string;
category?: string[];
Expand Down Expand Up @@ -304,7 +310,8 @@ export type CswDocument = {

export type CswMetadata = {
file_identifier?: string;
hierarchy_level?: string;
hierarchy_level?: MetadataHierarchyLevel;
resource_genealogy?: string;
language?: LanguageType;
charset?: string;
title?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Tag from "@codegouvfr/react-dsfr/Tag";
import { useQuery, UseQueryResult } from "@tanstack/react-query";
import { FC, useMemo } from "react";

import type { DatasheetDetailed, Metadata, StoredData } from "../../../../../@types/app";
import { MetadataHierarchyLevel, type DatasheetDetailed, type Metadata, type StoredData } from "../../../../../@types/app";
import ExtentMap from "../../../../../components/Utils/ExtentMap";
import LoadingText from "../../../../../components/Utils/LoadingText";
import TextCopyToClipboard from "../../../../../components/Utils/TextCopyToClipboard";
Expand Down Expand Up @@ -138,7 +138,6 @@ const MetadataTab: FC<MetadataTabProps> = ({ datastoreId, datasheet, metadataQue
hintText={"Valeur identifiant la ressource de manière unique sur le catalogue"}
content={metadata.csw_metadata?.file_identifier}
/>
<MetadataField title={"Fréquence de mise à jour"} content={frequencyCode} />
<MetadataField
title={"Catégories thématiques"}
content={
Expand Down Expand Up @@ -177,19 +176,13 @@ const MetadataTab: FC<MetadataTabProps> = ({ datastoreId, datasheet, metadataQue
/>
</Accordion>

<Accordion titleAs="h2" defaultExpanded={true} label={"Qualité"}>
<MetadataField title={"Généalogie de la ressource"} content={metadata.csw_metadata?.resource_genealogy} />
</Accordion>

<Accordion titleAs="h2" defaultExpanded={true} label={"Référence temporelle"}>
<MetadataField title={"Date de la création de la ressource"} content={metadata.csw_metadata?.creation_date} />
<MetadataField
title={"Généalogie de la ressource"}
content={(() => {
switch (metadata.csw_metadata?.hierarchy_level) {
case "series":
return "Produit";
case "dataset":
return "Lot";
}
})()}
/>
<MetadataField title={"Fréquence de mise à jour"} content={frequencyCode} />
</Accordion>

<Accordion titleAs="h2" defaultExpanded={true} label={"Contact sur les métadonnées"}>
Expand Down Expand Up @@ -275,6 +268,17 @@ const MetadataTab: FC<MetadataTabProps> = ({ datastoreId, datasheet, metadataQue
</Accordion>

<Accordion titleAs="h2" defaultExpanded={true} label={"Informations sur les métadonnées"}>
<MetadataField
title={"Type de ressource"}
content={(() => {
switch (metadata.csw_metadata?.hierarchy_level) {
case MetadataHierarchyLevel.Series:
return "Produit";
case MetadataHierarchyLevel.Dataset:
return "Lot";
}
})()}
/>
<MetadataField
title={"Langue des métadonnées"}
hintText={"Langue utilisée pour décrire les métadonnées"}
Expand Down
7 changes: 4 additions & 3 deletions assets/entrepot/pages/service/default-values.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { format as datefnsFormat } from "date-fns";

import { EndpointTypeEnum, Metadata, MetadataFormValuesType, Service, StoredData } from "../../../@types/app";
import { EndpointTypeEnum, Metadata, MetadataFormValuesType, MetadataHierarchyLevel, Service, StoredData } from "../../../@types/app";
import { ConfigurationWfsDetailsContent, ConfigurationWmsVectorDetailsContent, ConfigurationWmtsTmsDetailsContent } from "../../../@types/entrepot";
import { getProjectionCode, removeDiacritics } from "../../../utils";
import { getEndpointSuffix } from "./metadatas/Description";
import { PyramidVectorTmsServiceFormValuesType } from "./tms/PyramidVectorTmsServiceForm";
import { WfsServiceFormValuesType, WfsTableInfos } from "./wfs/WfsServiceForm";
import { WmsVectorServiceFormValuesType } from "./wms-vector/WmsVectorServiceForm";
import { PyramidVectorTmsServiceFormValuesType } from "./tms/PyramidVectorTmsServiceForm";

const DEFAULT_CHARSET = "utf8";
const DEFAULT_LANGUAGE = { language: "français", code: "fre" };
Expand All @@ -15,7 +15,8 @@ const getMetadataFormDefaultValues = (metadata?: Metadata): MetadataFormValuesTy
return {
languages: metadata?.csw_metadata?.language ? [metadata?.csw_metadata?.language] : [DEFAULT_LANGUAGE],
creation_date: metadata?.csw_metadata?.creation_date,
resource_genealogy: metadata?.csw_metadata?.hierarchy_level,
resource_genealogy: metadata?.csw_metadata?.resource_genealogy,
hierarchy_level: metadata?.csw_metadata?.hierarchy_level ?? MetadataHierarchyLevel.Dataset,
email_contact: metadata?.csw_metadata?.contact_email,
organization: metadata?.csw_metadata?.organisation_name,
organization_email: metadata?.csw_metadata?.organisation_email,
Expand Down
27 changes: 26 additions & 1 deletion assets/entrepot/pages/service/metadatas/AdditionalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { fr } from "@codegouvfr/react-dsfr";
import Input from "@codegouvfr/react-dsfr/Input";
import RadioButtons from "@codegouvfr/react-dsfr/RadioButtons";
import Select from "@codegouvfr/react-dsfr/Select";
import { Select as SelectNext } from "@codegouvfr/react-dsfr/SelectNext";
import { FC, useMemo } from "react";
import { Controller, UseFormReturn } from "react-hook-form";

import type { Pyramid, ServiceFormValuesBaseType, VectorDb } from "../../../../@types/app";
import { MetadataHierarchyLevel, type Pyramid, type ServiceFormValuesBaseType, type VectorDb } from "../../../../@types/app";
import AutocompleteSelect from "../../../../components/Input/AutocompleteSelect";
import resolutions from "../../../../data/md_resolutions.json";
import { getTranslation } from "../../../../i18n/i18n";
Expand Down Expand Up @@ -87,6 +88,30 @@ const AdditionalInfo: FC<AdditionalInfoProps> = ({ /*storedData, datastoreId,*/
}}
/>
<h3>{t("metadata.additionnal_infos_form.metadata_information_title")}</h3>
<RadioButtons
legend={t("metadata.additionnal_infos_form.hierarchy_level")}
state={errors.hierarchy_level ? "error" : "default"}
stateRelatedMessage={errors.hierarchy_level?.message}
orientation="vertical"
options={[
{
label: t(`metadata.additionnal_infos_form.hierarchy_level_${MetadataHierarchyLevel.Dataset}`),
hintText: t(`metadata.additionnal_infos_form.hierarchy_level_${MetadataHierarchyLevel.Dataset}_hint`),
nativeInputProps: {
...register("hierarchy_level"),
value: MetadataHierarchyLevel.Dataset,
},
},
{
label: t("metadata.additionnal_infos_form.hierarchy_level_series"),
hintText: t("metadata.additionnal_infos_form.hierarchy_level_series_hint"),
nativeInputProps: {
...register("hierarchy_level"),
value: MetadataHierarchyLevel.Series,
},
},
]}
/>
<Controller
control={control}
name="languages"
Expand Down
31 changes: 15 additions & 16 deletions assets/entrepot/pages/service/metadatas/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { XMLParser } from "fast-xml-parser";
import { FC, useEffect } from "react";
import { Controller, UseFormReturn } from "react-hook-form";

import { EndpointTypeEnum, type ServiceFormValuesBaseType } from "../../../../@types/app";
import AutocompleteSelect from "../../../../components/Input/AutocompleteSelect";
import MarkdownEditor from "../../../../components/Input/MarkdownEditor";
import frequencyCodes from "../../../../data/maintenance_frequency.json";
import categories from "../../../../data/topic_categories.json";
import { getTranslation } from "../../../../i18n/i18n";
import { EndpointTypeEnum, ServiceFormValuesBaseType } from "../../../../@types/app";
import { getInspireKeywords, regex } from "../../../../utils";
import categories from "../../../../data/topic_categories.json";
import frequencyCodes from "../../../../data/maintenance_frequency.json";

const keywords = getInspireKeywords();

Expand Down Expand Up @@ -179,6 +179,18 @@ const Description: FC<DescriptionProps> = ({ visible, form, editMode }) => {
}}
/>

<h3>{t("metadata.description_form.quality_title")}</h3>
<Input
label={t("metadata.description_form.resource_genealogy")}
hintText={t("metadata.description_form.hint_resource_genealogy")}
state={errors.resource_genealogy ? "error" : "default"}
stateRelatedMessage={errors?.resource_genealogy?.message?.toString()}
nativeTextAreaProps={{
...register("resource_genealogy"),
}}
textArea={true}
/>

<h3>{t("metadata.description_form.time_reference_title")}</h3>
<Input
label={t("metadata.description_form.creation_date")}
Expand All @@ -189,19 +201,6 @@ const Description: FC<DescriptionProps> = ({ visible, form, editMode }) => {
type: "date",
}}
/>
<Select
label={t("metadata.description_form.resource_genealogy")}
hint={t("metadata.description_form.hint_resource_genealogy")}
state={errors.resource_genealogy ? "error" : "default"}
stateRelatedMessage={errors?.resource_genealogy?.message?.toString()}
nativeSelectProps={{
...register("resource_genealogy"),
}}
>
<option value="">{tCommon("none")}</option>
<option value="dataset">Lot</option>
<option value="series">Produit</option>
</Select>
<Select
label={t("metadata.description_form.frequency_code")}
state={errors.frequency_code ? "error" : "default"}
Expand Down
34 changes: 27 additions & 7 deletions assets/entrepot/pages/service/metadatas/metadatas-form-tr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export const { i18n } = declareComponentKeys<
| "metadata.description_form.hint_free_keywords"
| "metadata.description_form.contact_email"
| "metadata.description_form.hint_contact_email"
| "metadata.description_form.time_reference_title"
| "metadata.description_form.creation_date"
| "metadata.description_form.quality_title"
| "metadata.description_form.resource_genealogy"
| "metadata.description_form.hint_resource_genealogy"
| "metadata.description_form.time_reference_title"
| "metadata.description_form.creation_date"
| "metadata.description_form.frequency_code"
| "metadata.description_form.resource_manager_title"
| "metadata.description_form.organization"
Expand All @@ -38,6 +39,11 @@ export const { i18n } = declareComponentKeys<
| "attribution_form.url"
| "attribution_form.hint_url"
| "metadata.additionnal_infos_form.metadata_information_title"
| "metadata.additionnal_infos_form.hierarchy_level"
| "metadata.additionnal_infos_form.hierarchy_level_dataset"
| "metadata.additionnal_infos_form.hierarchy_level_dataset_hint"
| "metadata.additionnal_infos_form.hierarchy_level_series"
| "metadata.additionnal_infos_form.hierarchy_level_series_hint"
| "metadata.additionnal_infos_form.language"
| "metadata.additionnal_infos_form.hint_language"
| "metadata.additionnal_infos_form.charset"
Expand Down Expand Up @@ -74,18 +80,26 @@ export const MetadatasFormFrTranslations: Translations<"fr">["MetadatasForm"] =
"metadata.description_form.hint_free_keywords": "Saisissez librement des mots clés en appuyant sur Entrée après chaque mot",
"metadata.description_form.contact_email": "Email de contact sur les métadonnées",
"metadata.description_form.hint_contact_email": "E-mail auprès duquel des compléments d’information peuvent être obtenus",
"metadata.description_form.quality_title": "Qualité",
"metadata.description_form.resource_genealogy": "Généalogie de la ressource (optionnelle)",
"metadata.description_form.hint_resource_genealogy":
"La généalogie de la ressource décrit l’historique d’un jeu de données et, s’il est connu, le cycle de vie de celui-ci, depuis l’acquisition et la saisie de l’information jusqu’à sa compilation, avec d’autres jeux et les variantes de sa forme actuelle.",
"metadata.description_form.frequency_code": "Fréquence de mise à jour",
"metadata.description_form.time_reference_title": "Référence temporelle",
"metadata.description_form.creation_date": "Date de la création de la ressource",
"metadata.description_form.resource_genealogy": "Généalogie de la ressource (optionnel)",
"metadata.description_form.hint_resource_genealogy": "Description du mode de production de la ressource",
"metadata.description_form.frequency_code": "Fréquence de mise à jour",
"metadata.description_form.resource_manager_title": "Responsable de la ressource",
"metadata.description_form.organization": "Organisme",
"metadata.description_form.hint_organization":
"Nom de l’organisme responsable de la ressource qui prend la responsabilité de la diffuser ou qui est légitime pour rendre celle-ci visible et décider de son mode de diffusion",
"metadata.description_form.organization_email": "Email",
"metadata.description_form.hint_organization_email": "Email de contact de l’organisme",
"metadata.additionnal_infos_form.metadata_information_title": "Informations sur les métadonnées",
"metadata.additionnal_infos_form.hierarchy_level": "Type de ressource",
"metadata.additionnal_infos_form.hierarchy_level_dataset": "Lot ou série",
"metadata.additionnal_infos_form.hierarchy_level_dataset_hint":
"Toute donnée faisant directement ou indirectement référence à un lieu ou une zone géographique spécifique",
"metadata.additionnal_infos_form.hierarchy_level_series": "Produit ou ensemble de séries",
"metadata.additionnal_infos_form.hierarchy_level_series_hint": "Compilation identifiable de données géographiques",
"attribution.title": "Attribution",
"attribution.explain":
"L’attribution est une mention que les consommateurs de ce service doivent afficher de manière visible sur les cartes qui l’utilise. Elle est généralement brève et désigne la source des données tout en pointant vers une page web qui décrit ses conditions d’utilisation ou la page d’accueil de l’organisme producteur. ll est généralement choisi de faire figurer cette attribution en petits caractères au bas des cartes.",
Expand Down Expand Up @@ -136,10 +150,11 @@ export const MetadatasFormEnTranslations: Translations<"en">["MetadatasForm"] =
"metadata.description_form.hint_free_keywords": undefined,
"metadata.description_form.contact_email": "Metadata contact email",
"metadata.description_form.hint_contact_email": "Email from which additional information can be obtained",
"metadata.description_form.quality_title": "Quality",
"metadata.description_form.resource_genealogy": undefined,
"metadata.description_form.hint_resource_genealogy": undefined,
"metadata.description_form.time_reference_title": "Time reference",
"metadata.description_form.creation_date": "Resource creation date",
"metadata.description_form.resource_genealogy": "Genealogy of the resource (optional)",
"metadata.description_form.hint_resource_genealogy": "Description of the resource production mode",
"metadata.description_form.frequency_code": "Update frequency",
"metadata.description_form.resource_manager_title": "Resource manager",
"metadata.description_form.organization": "Organization",
Expand All @@ -148,6 +163,11 @@ export const MetadatasFormEnTranslations: Translations<"en">["MetadatasForm"] =
"metadata.description_form.organization_email": "Email",
"metadata.description_form.hint_organization_email": "Contact email of the organization",
"metadata.additionnal_infos_form.metadata_information_title": "Metadata informations",
"metadata.additionnal_infos_form.hierarchy_level": undefined,
"metadata.additionnal_infos_form.hierarchy_level_dataset": undefined,
"metadata.additionnal_infos_form.hierarchy_level_dataset_hint": undefined,
"metadata.additionnal_infos_form.hierarchy_level_series": undefined,
"metadata.additionnal_infos_form.hierarchy_level_series_hint": undefined,
"attribution.title": "Attribution",
"attribution.explain": "[TODO]",
"attribution_form.text": "Text to display",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const createFormData = async (formValues: WmsVectorServiceFormValuesType) => {
fd.set("public_name", formValues.public_name!);
fd.set("resolution", formValues.resolution!);
fd.set("resource_genealogy", formValues.resource_genealogy!);
fd.set("hierarchy_level", formValues.hierarchy_level!);
fd.set("frequency_code", formValues.frequency_code!);
fd.set("share_with", formValues.share_with!);
fd.set("technical_name", formValues.technical_name!);
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/CswMetadata/CswMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CswMetadata
public ?string $abstract;
public ?string $creationDate;
public ?string $updateDate;
public ?string $resourceGenealogy;

/** @var array<string> */
public ?array $inspireKeywords;
Expand Down Expand Up @@ -58,6 +59,7 @@ public static function createEmpty(): self
$empty->thumbnailUrl = null;
$empty->resolution = null;
$empty->frequencyCode = 'unknown';
$empty->resourceGenealogy = '';

$empty->topicCategories = [];
$empty->inspireKeywords = [];
Expand Down
Loading

0 comments on commit 8ff9685

Please sign in to comment.