diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 00000000..fedd96bf
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,30 @@
+version: "2" # required to adjust maintainability checks
+checks:
+ argument-count:
+ enabled: false
+ complex-logic:
+ config:
+ threshold: 9
+ file-lines:
+ config:
+ threshold: 1000
+ method-complexity:
+ config:
+ threshold: 10
+ method-count:
+ config:
+ threshold: 20
+ method-lines:
+ config:
+ threshold: 250
+ nested-control-flow:
+ config:
+ threshold: 4
+ return-statements:
+ enabled: false
+ similar-code:
+ config:
+ threshold: 75
+ identical-code:
+ config:
+ threshold: 55
\ No newline at end of file
diff --git a/cypress/fixtures/example-ffas.xml b/cypress/fixtures/example-ffas.xml
index c90f6eb1..7847bd92 100644
--- a/cypress/fixtures/example-ffas.xml
+++ b/cypress/fixtures/example-ffas.xml
@@ -427,6 +427,14 @@
DEVRAIT ETRE
IGNORE
+
+ testChild 132
+
+ Top, Jean Frédéric
+ val1
+ val2
+
+
diff --git a/cypress/integration/recipes.js b/cypress/integration/recipes.js
index d85a4059..418a6a5e 100644
--- a/cypress/integration/recipes.js
+++ b/cypress/integration/recipes.js
@@ -359,4 +359,19 @@ describe("Recipe unit test", function () {
expect(matchesAfter[0].getAttribute("role")).to.be.equal("notaire");
expect(matchesAfter[1].getAttribute("role")).to.be.equal("notaire");
});
+ it("deplacer_genreform_physdesc", function () {
+ const xpathExpr = '//c[@id="test-genreform-physdesc"]/did/physdesc/genreform';
+ const matchesBefore = xpathFilter(doc, xpathExpr);
+ expect(matchesBefore.length).to.be.equal(0);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/did/physdesc').length).to.be.equal(0);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/controlaccess/*').length).to.be.equal(3);
+
+ doc = recipes.deplacer_genreform_physdesc()(doc);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/did/physdesc').length).to.be.equal(1);
+ const matchesAfter = xpathFilter(doc, xpathExpr);
+ expect(matchesAfter.length).to.be.equal(2);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/controlaccess/*').length).to.be.equal(1);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/did/physdesc/genreform[@role="test"]').length).to.be.equal(1);
+ expect(xpathFilter(doc, '//c[@id="test-genreform-physdesc"]/did/physdesc/genreform[@source="genreform"]').length).to.be.equal(2);
+ });
});
diff --git a/package-lock.json b/package-lock.json
index 3f3b0a9e..98ddaf0f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "cuisine-ead",
- "version": "1.3.0",
+ "version": "1.4.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "cuisine-ead",
- "version": "1.3.0",
+ "version": "1.4.0",
"license": "SEE LICENCE IN LICENCE",
"dependencies": {
"@babel/preset-react": "^7.18.6",
diff --git a/package.json b/package.json
index a1c42084..f408e5fa 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cuisine-ead",
- "version": "1.3.0",
+ "version": "1.4.0",
"description": "",
"main": "public/index.html",
"scripts": {
diff --git a/src/lib/recipes/index.js b/src/lib/recipes/index.js
index f8492f2e..cc31ea54 100644
--- a/src/lib/recipes/index.js
+++ b/src/lib/recipes/index.js
@@ -76,6 +76,7 @@ import extraireDaoFromDaodesc from "./individual-recipes/extraire-dao-daodesc.js
import remplaceDaoHref from "./individual-recipes/remplace-dao-href.js";
import separerControlaccessLb from "./individual-recipes/separer-controlaccess-lb.js";
import separerControlaccessSeparator from "./individual-recipes/separer-controlaccess-separator.js";
+import deplacerGenreformPhysdesc from "./individual-recipes/deplacer-genreform-physdesc.js";
import insertIntoDocument from "./insert-into-document.js";
/**
@@ -121,6 +122,7 @@ export const getRecipes = () => {
{ key: "corriger_source_contexte", fn: corrigerSubjectContexteHisto },
{ key: "corriger_mat_spec_donnees", fn: corrigerMatSpecDonnees },
{ key: "corriger_deplacer_genreform", fn: corrigerGenreformPhysdesc },
+ { key: "deplacer_genreform_physdesc", fn: deplacerGenreformPhysdesc },
{ key: "pack_ligeo", fn: traitementsLigeo },
{ key: "suppr_mnesys_internal", fn: supprimerMnesysInternal },
{ key: "suppr_accessrestrict_formate", fn: supprimerAccessRestrictFormate },
diff --git a/src/lib/recipes/individual-recipes/deplacer-genreform-physdesc.js b/src/lib/recipes/individual-recipes/deplacer-genreform-physdesc.js
new file mode 100644
index 00000000..9b6f4393
--- /dev/null
+++ b/src/lib/recipes/individual-recipes/deplacer-genreform-physdesc.js
@@ -0,0 +1,38 @@
+//@flow
+import { xpathFilter } from "../../xml.js";
+import { each } from "../utils.js";
+import { last } from "ramda";
+
+/**
+ * Ligeo
+ * Déplacer tous les //controlaccess/genreform dans physdesc.
+ * C'est une version moins spécifique de ./corriger-genreform-physdesc.js
+ */
+export default () => (doc: Document): Document => {
+ const CAs = xpathFilter(doc, "//controlaccess");
+ each(CAs, (elem) => {
+ const genreforms = xpathFilter(doc, elem, "genreform");
+ if (genreforms.length <= 0) return;
+ const existingPhysdesc = last(xpathFilter(doc, elem, "(parent::c/did/physdesc)|(parent::archdesc/did/physdesc)"));
+ const newPhysdesc = !existingPhysdesc;
+ const physdesc = existingPhysdesc ? existingPhysdesc : doc.createElement("physdesc");
+ each(genreforms, (el) => {
+ if (!el.hasAttribute("source")) {
+ el.setAttribute("source", "genreform");
+ }
+ if (!el.hasAttribute("type")) {
+ el.setAttribute("type", "genre");
+ }
+ physdesc.appendChild(el);
+ });
+ if (newPhysdesc && physdesc.hasChildNodes()) {
+ const did = last(xpathFilter(doc, elem, "(parent::c/did)|(parent::archdesc/did)"));
+ if (!did) {
+ console.log("Pas de did pour créer le physdesc.");
+ return;
+ }
+ did.appendChild(physdesc);
+ }
+ });
+ return doc;
+};
diff --git a/src/lib/recipes/recipes-lib.js b/src/lib/recipes/recipes-lib.js
index 8e844a86..a12d2d26 100644
--- a/src/lib/recipes/recipes-lib.js
+++ b/src/lib/recipes/recipes-lib.js
@@ -291,6 +291,14 @@ const availables: Array<[string, RecipeInfo]> = [
"corriger_deplacer_genreform",
{
label: "Déplacer certains genreform dans physdesc",
+ complement: "Uniquement les valeurs : matrice cadastrale, état de sections, tableau d'assemblage, plan-minute de conservation, liste, iconographie, nomenclature des propriétaires",
+ category: "Spécifique",
+ },
+ ],
+ [
+ "deplacer_genreform_physdesc",
+ {
+ label: "Déplacer TOUS les genreform dans physdesc",
category: "Spécifique",
},
],
diff --git a/src/sw.js b/src/sw.js
index 3d4ec256..49dd4d8f 100644
--- a/src/sw.js
+++ b/src/sw.js
@@ -6,7 +6,7 @@ const { CacheableResponsePlugin } = workbox.cacheableResponse;
const { ExpirationPlugin } = workbox.expiration;
const { skipWaiting, clientsClaim, setCacheNameDetails } = workbox.core;
-var VERSION = "v1.3.0";
+var VERSION = "v1.4.0";
setCacheNameDetails({
prefix: "cuisine-ead",
suffix: VERSION,