diff --git a/api/api-pastis/pastis-commons/generated_test.xml b/api/api-pastis/pastis-commons/generated_test.xml index 4ab995cdbcb..2fd2d84b776 100644 --- a/api/api-pastis/pastis-commons/generated_test.xml +++ b/api/api-pastis/pastis-commons/generated_test.xml @@ -14,7 +14,7 @@ - + diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/jaxb/BaliseXML.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/jaxb/BaliseXML.java index 5c6f5700a22..fb9ffd724ff 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/jaxb/BaliseXML.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/jaxb/BaliseXML.java @@ -45,6 +45,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; + import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -55,7 +56,8 @@ @XmlRootElement -@Getter@Setter +@Getter +@Setter @NoArgsConstructor public class BaliseXML { @@ -115,7 +117,7 @@ public static void buildBaliseXMLTree(ElementProperties node, int profondeur, Ba } } - private static void setValueAndDataRNG(ElementProperties node, boolean presenceChildrenNode){ + private static void setValueAndDataRNG(ElementProperties node, boolean presenceChildrenNode) { // If the node has a value if (null != node.getValue() && !node.getValue().equals(UNDEFINED)) { valueRNG = new ValueXML(); @@ -132,14 +134,18 @@ private static void setValueAndDataRNG(ElementProperties node, boolean presenceC // When a value is declared in a profile element, the tag must be suppressed // to assure that the generated profile is successfully imported by VITAM if (null != node.getValueOrData() && !node.getValueOrData().equals(UNDEFINED) && - node.getValueOrData().equals("data") && !node.getName().equals("CodeListVersions") && null == node.getValue()) { + node.getValueOrData().equals("data") && !node.getName().equals("CodeListVersions") && + null == node.getValue()) { dataRNG = new DataXML(); } - if ((node.getName() != null && ((node.getName().equals("CodeListVersions")&& presenceChildrenNode) || presenceChildrenNode) && null == node.getValue()) + if ((node.getName() != null + && ((node.getName().equals("CodeListVersions") && presenceChildrenNode) || presenceChildrenNode) + && null == node.getValue()) && (valueRNG == null && RNGConstants.getTypesMap().containsKey(node.getName()))) { dataRNG = new DataXML(); dataRNG.setDataType(RNGConstants.getTypesMap().get(node.getName()).getLabel()); + } // Sets the type of data (if value or data) @@ -153,11 +159,12 @@ private static void setValueAndDataRNG(ElementProperties node, boolean presenceC } } - private static void buildBaliseXmlTreeFin(ElementProperties node, int profondeur, BaliseXML parentNode){ + private static void buildBaliseXmlTreeFin(ElementProperties node, int profondeur, BaliseXML parentNode) { BaliseXML currentXmlTag = null; // 1. Check if it is an element if (null != elementOrAttributeRNG) { - currentXmlTag = implementAndReturnCurrentXmlTag(parentNode, valueRNG, dataRNG, cardinalityRNG, elementOrAttributeRNG); + currentXmlTag = + implementAndReturnCurrentXmlTag(parentNode, valueRNG, dataRNG, cardinalityRNG, elementOrAttributeRNG); } if (null != currentXmlTag) { currentTagExist(parentNode, currentXmlTag); @@ -169,7 +176,7 @@ private static void buildBaliseXmlTreeFin(ElementProperties node, int profondeur } } - private static void setDocumentationAnnotationElementAttribute(ElementProperties node){ + private static void setDocumentationAnnotationElementAttribute(ElementProperties node) { setAnnotationDocumentationXML(node); @@ -185,11 +192,11 @@ private static void setDocumentationAnnotationElementAttribute(ElementProperties } if (elementOrAttributeRNG != null) { - if(null != documentationXML){ + if (null != documentationXML) { elementOrAttributeRNG.getChildren().add(annotationXML); annotationXML.setParent(elementOrAttributeRNG); } - if(annotationCommentXML != null){ + if (annotationCommentXML != null) { elementOrAttributeRNG.getChildren().add(annotationCommentXML); annotationCommentXML.setParent(elementOrAttributeRNG); } @@ -205,25 +212,28 @@ public static void setAnnotationDocumentationXML(ElementProperties node) { annotationXML.setDocumentationXML(documentationXML); } - if(node.getName().equals("ArchiveUnit") && node.getEditName() != null){ + if (node.getName().equals("ArchiveUnit") && node.getEditName() != null) { annotationCommentXML = new AnnotationXML(); documentationCommentXML = new DocumentationXML(); documentationCommentXML.setDocumentation(node.getEditName()); annotationCommentXML.setDocumentationXML(documentationCommentXML); - if(node.getDocumentation() != null){ + if (node.getDocumentation() != null) { documentationXML.setDocumentation("Commentaire : " + node.getDocumentation()); annotationXML.setDocumentationXML(documentationXML); } } } + /** * Set Cardinality to element or attribute Rng + * * @param node * @param cardinalityRNG * @param elementOrAttributeRNG * @return */ - private static BaliseXML defineElementOrAttributeCardinality(ElementProperties node, BaliseXML cardinalityRNG, BaliseXML elementOrAttributeRNG) { + private static BaliseXML defineElementOrAttributeCardinality(ElementProperties node, BaliseXML cardinalityRNG, + BaliseXML elementOrAttributeRNG) { if (node.getCardinality().equals(RNGConstants.Cardinality.ZERO_OR_MORE.getLabel())) { cardinalityRNG = new ZeroOrMoreXML(); if (elementOrAttributeRNG != null) { @@ -245,6 +255,7 @@ private static BaliseXML defineElementOrAttributeCardinality(ElementProperties n /** * if element exist, implement it and return + * * @param parentNode * @param valueRNG * @param dataRNG @@ -252,7 +263,8 @@ private static BaliseXML defineElementOrAttributeCardinality(ElementProperties n * @param elementOrAttributeRNG * @return */ - private static BaliseXML implementAndReturnCurrentXmlTag(BaliseXML parentNode, ValueXML valueRNG, DataXML dataRNG, BaliseXML cardinalityRNG, BaliseXML elementOrAttributeRNG) { + private static BaliseXML implementAndReturnCurrentXmlTag(BaliseXML parentNode, ValueXML valueRNG, DataXML dataRNG, + BaliseXML cardinalityRNG, BaliseXML elementOrAttributeRNG) { BaliseXML currentXmlTag; LOGGER.debug(BaliseXML.class.getName(), "Parsing %s", elementOrAttributeRNG.getName()); // 1.1 Check if the element has cardinality @@ -271,6 +283,7 @@ private static BaliseXML implementAndReturnCurrentXmlTag(BaliseXML parentNode, V /** * Define valueRNG + * * @param valueRNG * @param elementOrAttributeRNG * @param currentXmlTag @@ -283,7 +296,7 @@ private static void valueRng(ValueXML valueRNG, BaliseXML elementOrAttributeRNG, valueRNG.setParent(currentXmlTag); } // If children is Element or Attribute, set accordingly - } else if (currentXmlTag instanceof ElementXML|| currentXmlTag instanceof AttributeXML) { + } else if (currentXmlTag instanceof ElementXML || currentXmlTag instanceof AttributeXML) { currentXmlTag.setValueXML(valueRNG); valueRNG.setParent(currentXmlTag); } else { @@ -295,6 +308,7 @@ private static void valueRng(ValueXML valueRNG, BaliseXML elementOrAttributeRNG, /** * Define DataRNG of current XML TAG + * * @param dataRNG * @param currentXmlTag */ @@ -313,12 +327,14 @@ private static void dataRNG(DataXML dataRNG, BaliseXML currentXmlTag) { /** * Define current Xml Tag according to element cardinality + * * @param parentNode * @param cardinalityRNG * @param elementOrAttributeRNG * @return */ - private static BaliseXML defineCurrentXmlTag(BaliseXML parentNode, BaliseXML cardinalityRNG, BaliseXML elementOrAttributeRNG) { + private static BaliseXML defineCurrentXmlTag(BaliseXML parentNode, BaliseXML cardinalityRNG, + BaliseXML elementOrAttributeRNG) { BaliseXML currentXmlTag; if (null != cardinalityRNG) { cardinalityRNG.getChildren().add(elementOrAttributeRNG); @@ -341,11 +357,13 @@ private static BaliseXML defineCurrentXmlTag(BaliseXML parentNode, BaliseXML car /** * If current xml tag not a GrammarXML Object + * * @param node * @param profondeur * @param currentXmlTag */ - private static void currentTagNotInstanceOfGrammarXML(ElementProperties node, int profondeur, BaliseXML currentXmlTag) { + private static void currentTagNotInstanceOfGrammarXML(ElementProperties node, int profondeur, + BaliseXML currentXmlTag) { for (ElementProperties next : node.getChildren()) { if (currentXmlTag instanceof OptionalXML || currentXmlTag instanceof OneOrMoreXML || currentXmlTag instanceof ZeroOrMoreXML) { @@ -359,6 +377,7 @@ private static void currentTagNotInstanceOfGrammarXML(ElementProperties node, in /** * Implement current tag if exist + * * @param parentNode * @param currentXmlTag */ @@ -371,7 +390,8 @@ private static void currentTagExist(BaliseXML parentNode, BaliseXML currentXmlTa .findAny() .orElse(null); - Boolean optionalHasAlreadyCurrentTag = optionalWithChildren != null && optionalWithChildren.children.contains(currentXmlTag); + Boolean optionalHasAlreadyCurrentTag = + optionalWithChildren != null && optionalWithChildren.children.contains(currentXmlTag); if (Boolean.FALSE.equals(optionalHasAlreadyCurrentTag)) { currentXmlTag.setParent(parentNode); diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGConstants.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGConstants.java index 59dd89ea20b..06cf1d2fc8c 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGConstants.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGConstants.java @@ -82,7 +82,7 @@ public class RNGConstants { private static final Map TypesMap = new HashMap<>(); static { - TypesMap.put("CodeListVersions", DataType.TOKEN); + TypesMap.put("CodeListVersions", DataType.STRING); TypesMap.put("Comment", DataType.STRING); TypesMap.put("Date", DataType.TOKEN); TypesMap.put("MessageIdentifier", DataType.TOKEN); diff --git a/api/api-pastis/pastis-commons/src/main/resources/profiles_new/Profil_seda_pastis_mvp.rng b/api/api-pastis/pastis-commons/src/main/resources/profiles_new/Profil_seda_pastis_mvp.rng index aeb8a1ee433..93f04f71cf2 100644 --- a/api/api-pastis/pastis-commons/src/main/resources/profiles_new/Profil_seda_pastis_mvp.rng +++ b/api/api-pastis/pastis-commons/src/main/resources/profiles_new/Profil_seda_pastis_mvp.rng @@ -19,7 +19,7 @@ - + diff --git a/api/api-pastis/pastis-commons/src/test/resources/manifests/jsonProfile.json b/api/api-pastis/pastis-commons/src/test/resources/manifests/jsonProfile.json index 3089ba29b23..67af295daa2 100644 --- a/api/api-pastis/pastis-commons/src/test/resources/manifests/jsonProfile.json +++ b/api/api-pastis/pastis-commons/src/test/resources/manifests/jsonProfile.json @@ -70,7 +70,7 @@ "cardinality": null, "groupOrChoice": null, "valueOrData": "data", - "dataType": "token", + "dataType": "string", "value": null, "documentation": null, "level": 1, diff --git a/api/api-pastis/pastis-commons/src/test/resources/manifests/rngProfile.rng b/api/api-pastis/pastis-commons/src/test/resources/manifests/rngProfile.rng index dd585b22cbe..77bc1367bc9 100644 --- a/api/api-pastis/pastis-commons/src/test/resources/manifests/rngProfile.rng +++ b/api/api-pastis/pastis-commons/src/test/resources/manifests/rngProfile.rng @@ -18,7 +18,7 @@ IN-UPPA-0 - + diff --git a/api/api-pastis/pastis-commons/src/test/resources/profiles/profile_ok.rng b/api/api-pastis/pastis-commons/src/test/resources/profiles/profile_ok.rng index c36988a1152..eb97cbe42a7 100644 --- a/api/api-pastis/pastis-commons/src/test/resources/profiles/profile_ok.rng +++ b/api/api-pastis/pastis-commons/src/test/resources/profiles/profile_ok.rng @@ -35,7 +35,7 @@ - + diff --git a/api/api-pastis/pastis-commons/src/test/resources/rng/Profil_seda_pastis_mvp.rng b/api/api-pastis/pastis-commons/src/test/resources/rng/Profil_seda_pastis_mvp.rng index aeb8a1ee433..93f04f71cf2 100644 --- a/api/api-pastis/pastis-commons/src/test/resources/rng/Profil_seda_pastis_mvp.rng +++ b/api/api-pastis/pastis-commons/src/test/resources/rng/Profil_seda_pastis_mvp.rng @@ -19,7 +19,7 @@ - +