Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • dad/cines-vitamui
1 result
Show changes
Showing
with 589 additions and 487 deletions
......@@ -38,6 +38,8 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.factory;
import lombok.Getter;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -49,6 +51,7 @@ import javax.xml.bind.annotation.XmlSeeAlso;
@XmlRootElement
@XmlSeeAlso({GrammarTag.class,StartTag.class,ElementTag.class,CardinalityTag.class,DataTag.class,AttributeTag.class,
ValueTag.class, DocumentationTag.class,AnnotationTag.class,GroupTag.class,ChoiceTag.class })
@Setter@Getter
public class RngTag extends Tag{
private static final Logger LOGGER = LoggerFactory.getLogger(RngTag.class);
......@@ -63,33 +66,17 @@ public class RngTag extends Tag{
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlAttribute(name="type")
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getGroupOrChoice() {
return groupOrChoice;
}
public void setGroupOrChoice(String groupOrChoice) {
this.groupOrChoice = groupOrChoice;
}
@XmlElement(name="rng:value")
public ValueTag getValueTag() {
return valueTag;
}
public void setValueTag(ValueTag valueTag) {
this.valueTag = valueTag;
}
}
......
......@@ -38,11 +38,13 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.factory;
import lombok.Setter;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlTransient;
import java.util.ArrayList;
import java.util.List;
@Setter
public abstract class Tag {
Tag parent;
......@@ -53,20 +55,11 @@ public abstract class Tag {
public Tag getParent() {
return parent;
}
public void setParent(Tag parent) {
this.parent = parent;
}
@XmlAnyElement
public List<Tag> getChildren() {
return children;
}
public void setChildren(List<Tag> children) {
this.children = children;
}
String getTagName(){
return this.getClass().getSimpleName();
}
......
......@@ -38,10 +38,12 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.factory;
import lombok.Setter;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlValue;
@Setter
public class ValueTag {
private String dataType;
......@@ -52,26 +54,14 @@ public class ValueTag {
@XmlAttribute (name="type")
public String getDataType() {return dataType; }
public void setDataType(String dataType) {
this.dataType = dataType;
}
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@XmlTransient
public Tag getParent() {
return parent;
}
public void setParent(Tag parent) {
this.parent = parent;
}
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -41,12 +41,15 @@ knowledge of the CeCILL-C license and that you accept its terms.
*/
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement (name="xsd:annotation")
@Setter
public class AnnotationXML extends BaliseXML{
DocumentationXML documentationXML;
@XmlElement (name="xsd:documentation")
......@@ -54,8 +57,4 @@ public class AnnotationXML extends BaliseXML{
return documentationXML;
}
public void setDocumentationXML(DocumentationXML documentationXML) {
this.documentationXML = documentationXML;
}
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -41,12 +41,15 @@ knowledge of the CeCILL-C license and that you accept its terms.
*/
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement (name="rng:attribute")
public class AttributeXML extends BaliseXML{
@Setter
public class AttributeXML extends BaliseXML{
ValueXML valueXML;
@XmlElement (name="rng:value")
......@@ -54,8 +57,4 @@ public class AttributeXML extends BaliseXML{
return valueXML;
}
public void setValueXML(ValueXML valueXML) {
this.valueXML = valueXML;
}
}
......@@ -40,6 +40,10 @@ package fr.gouv.vitamui.pastis.model.jaxb;
import fr.gouv.vitamui.pastis.model.ElementProperties;
import fr.gouv.vitamui.pastis.util.RNGConstants;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -50,13 +54,10 @@ import java.util.List;
@XmlRootElement
@Getter@Setter@Data@NoArgsConstructor
public class BaliseXML{
public BaliseXML() {
super();
}
String name;
String dataType;
String cardinality;
......@@ -75,19 +76,11 @@ public class BaliseXML{
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlAttribute (name="type")
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
//@XmlTransient to avoid circular loop parent <-> child
@XmlTransient
......@@ -95,9 +88,6 @@ public class BaliseXML{
return parent;
}
public void setParent(BaliseXML parent) {
this.parent = parent;
}
// XmlAnyElement pour etre le plus generique
@XmlAnyElement
......@@ -105,36 +95,15 @@ public class BaliseXML{
return children;
}
public void setChildren(List<BaliseXML> children) {
this.children = children;
}
public String getCardinality() {
return cardinality;
}
public String setCardinality(RNGConstants.Cardinality cardinality) {
return this.cardinality = cardinality.getLabel();
}
public String getGroupOrChoice() {
return groupOrChoice;
}
@XmlElement(name="rng:value")
public ValueXML getValueXML() {
return valueXML;
}
public void setValueXML(ValueXML valueXML) {
this.valueXML = valueXML;
}
public void setGroupOrChoice(RNGConstants.GroupOrChoice groupOrChoice) {
this.groupOrChoice = groupOrChoice.getLabel();
}
@Override
public String toString() {
// TODO Auto-generated method stub
......
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -42,16 +42,17 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.jaxb;
import fr.gouv.vitamui.pastis.util.RNGConstants;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement (name="rng:data")
@Data@NoArgsConstructor
public class DataXML extends BaliseXML{
public DataXML(){
}
public DataXML(RNGConstants.DataType dataType, BaliseXML parent){
this.setDataType(dataType.getLabel());
this.setParent(parent);
}
}
\ No newline at end of file
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -38,30 +38,25 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlValue;
@Setter
public class DocumentationXML {
String documentation;
@XmlValue
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
BaliseXML parent;
@XmlTransient
public BaliseXML getParent() {
return parent;
}
public void setParent(BaliseXML parent) {
this.parent = parent;
}
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -38,22 +38,21 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement (name="rng:element")
public class ElementXML extends BaliseXML{
@Setter
public class ElementXML extends BaliseXML{
ValueXML valueXML;
@XmlElement (name="rng:value")
public ValueXML getValueXML() {
return valueXML;
}
public void setValueXML(ValueXML valueXML) {
this.valueXML = valueXML;
}
}
......@@ -38,16 +38,15 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="rng:nsName")
@Setter
public class NsNameXML extends BaliseXML{
@XmlAttribute(name = "ns")
String ns;
public void setNs(String ns) {
this.ns = ns;
}
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -38,44 +38,34 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.jaxb;
import lombok.Setter;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlValue;
@Setter
public class ValueXML {
String value;
String dataType;
BaliseXML parent;
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
String dataType;
BaliseXML parent;
@XmlTransient
public BaliseXML getParent() {
return parent;
}
public void setParent(BaliseXML parent) {
this.parent = parent;
}
@XmlAttribute (name="type")
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
}
package fr.gouv.vitamui.pastis.model.profiles;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Data@Getter@Setter
public class Notice {
String _id;
......@@ -20,117 +24,54 @@ public class Notice {
String _v;
List<String> fields;
public String get_id() {
return _id;
}
public void set_id(String _id) {
this._id = _id;
}
@JsonProperty("Identifier")
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
@JsonProperty("Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@JsonProperty("Description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@JsonProperty("Status")
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@JsonProperty("CreationDate")
public String getCreationDate() {
return creationDate;
}
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
@JsonProperty("LastUpdate")
public String getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}
@JsonProperty("ActivationDate")
public String getActivationDate() {
return activationDate;
}
public void setActivationDate(String activationDate) {
this.activationDate = activationDate;
}
@JsonProperty("DeactivationDate")
public String getDeactivationDate() {
return deactivationDate;
}
public void setDeactivationDate(String deactivationDate) {
this.deactivationDate = deactivationDate;
}
@JsonProperty("ControlSchema")
public String getControlSchema() {
return controlSchema;
}
public void setControlSchema(String controlSchema) {
this.controlSchema = controlSchema;
}
public String get_tenant() {
return _tenant;
}
public void set_tenant(String _tenant) {
this._tenant = _tenant;
}
public String get_v() {
return _v;
}
public void set_v(String _v) {
this._v = _v;
}
@JsonProperty("Fields")
public List<String> getFields() {
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
}
package fr.gouv.vitamui.pastis.model.profiles;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.json.JSONObject;
import java.sql.Timestamp;
import java.util.Random;
@Data@Getter@Setter@NoArgsConstructor
public class PastisProfile {
String type;
......@@ -21,54 +28,6 @@ public class PastisProfile {
this.lastModified = new Timestamp(lastModified).toString();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getBaseName() {
return baseName;
}
public void setBaseName(String baseName) {
this.baseName = baseName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getLastModified() {
return lastModified;
}
public void setLastModified(String lastModified) {
this.lastModified = lastModified;
}
private String getFileType(String fileName){
String[] tokens = fileName.split("\\.(?=[^\\.]+$)");
return tokens[1].equals("rng") ? "PA" : "PUA";
......@@ -80,5 +39,14 @@ public class PastisProfile {
}
public void deserialise(JSONObject jsonObject) {
this.setId((Long) jsonObject.get("id"));
this.setStatus((String) jsonObject.get("status"));
this.setLastModified( (String) jsonObject.get("lastModified"));
this.setFileName( (String) jsonObject.get("fileName"));
this.setBaseName( (String) jsonObject.get("baseName"));
this.setType( (String) jsonObject.get("type"));
}
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
......@@ -28,9 +28,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
......@@ -39,27 +39,15 @@ knowledge of the CeCILL-C license and that you accept its terms.
package fr.gouv.vitamui.pastis.model.profiles;
import fr.gouv.vitamui.pastis.model.ElementProperties;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data@Getter@Setter
public class ProfileNotice {
public ProfileNotice(){super();}
ElementProperties elementProperties;
Notice notice;
public ElementProperties getElementProperties() {
return elementProperties;
}
public void setElementProperties(ElementProperties elementProperties) {
this.elementProperties = elementProperties;
}
public Notice getNotice() {
return notice;
}
public void setNotice(Notice notice) {
this.notice = notice;
}
}
package fr.gouv.vitamui.pastis.model.pua;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.json.JSONObject;
import java.util.List;
@Data@Getter@Setter
public class PuaMetadataDetails {
String type;
......@@ -16,76 +19,4 @@ public class PuaMetadataDetails {
List<String> required;
PuaMetadata items;
List<String> enums;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getMinItems() {
return minItems;
}
public void setMinItems(Integer minItems) {
this.minItems = minItems;
}
public Integer getMaxItems() {
return maxItems;
}
public void setMaxItems(Integer maxItems) {
this.maxItems = maxItems;
}
public Boolean getAdditionalProperties() {
return additionalProperties;
}
public void setAdditionalProperties(Boolean additionalProperties) {
this.additionalProperties = additionalProperties;
}
public PuaMetadata getItems() {
return items;
}
public void setItems(PuaMetadata items) {
this.items = items;
}
public JSONObject getProperties() {
return properties;
}
public void setProperties(JSONObject properties) {
this.properties = properties;
}
public List<String> getRequired() {
return required;
}
public void setRequired(List<String> required) {
this.required = required;
}
public List<String> getEnumerations() {
return enums;
}
public void setEnumerations(List<String> enumerations) {
this.enums = enumerations;
}
}
\ No newline at end of file
}
package fr.gouv.vitamui.pastis.model.seda;
import fr.gouv.vitamui.pastis.model.ElementProperties;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.stream.Stream;
@Data
@Getter
@Setter
public class SedaNode {
private String Name;
private String Element;
......@@ -17,85 +22,6 @@ public class SedaNode {
private String Collection;
private List<SedaNode> Children;
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getElement() {
return Element;
}
public void setElement(String element) {
Element = element;
}
public String getCardinality() {
return Cardinality;
}
public void setCardinality(String cardinality) {
Cardinality = cardinality;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getChoice() {
return Choice;
}
public void setChoice(String choice) {
Choice = choice;
}
public String getExtensible() {
return Extensible;
}
public void setExtensible(String extensible) {
Extensible = extensible;
}
public List<String> getEnumeration() {
return Enumeration;
}
public void setEnumeration(List<String> enumeration) {
Enumeration = enumeration;
}
public String getDefinition() {
return Definition;
}
public void setDefinition(String definition) {
Definition = definition;
}
public String getCollection() {
return Collection;
}
public void setCollection(String collection) {
Collection = collection;
}
public List<SedaNode> getChildren() {
return Children;
}
public void setChildren(List<SedaNode> children) {
Children = children;
}
public Stream<SedaNode> flattened() {
return Stream.concat(
......
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
*/
package fr.gouv.vitamui.pastis.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.gouv.vitamui.pastis.model.ElementProperties;
import fr.gouv.vitamui.pastis.model.jaxb.*;
import fr.gouv.vitamui.pastis.model.profiles.Notice;
import fr.gouv.vitamui.pastis.model.profiles.PastisProfile;
import fr.gouv.vitamui.pastis.model.profiles.ProfileNotice;
import fr.gouv.vitamui.pastis.model.profiles.ProfileResponse;
import fr.gouv.vitamui.pastis.util.pua.JsonFromPUA;
import fr.gouv.vitamui.pastis.util.pua.NoticeFromPUA;
import fr.gouv.vitamui.pastis.util.pua.PuaFromJSON;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.*;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
@Service
public class ProfileService {
private static final Logger LOGGER = LoggerFactory.getLogger(ProfileService.class);
private static final String APPLICATION_JSON_UTF8 = "application/json; charset=utf-8";
@Value("${rng.base.file}")
private String rngFile;
private final ResourceLoader resourceLoader;
@Autowired
private PuaPastisValidator puaPastisValidator;
@Autowired
private JsonFromPUA jsonFromPUA;
@Autowired
private NoticeFromPUA noticeFromPUA;
@Autowired
private PuaFromJSON puaFromJSON;
@Autowired
public ProfileService(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
private List<PastisProfile> pastisProfiles = new ArrayList<>();
public String test() {
return "Pastis API is listening...";
}
public String getArchiveProfile(final ElementProperties json) throws IOException {
// Recover a statically generated BaliseXML by buildBaliseXMLTree
json.initTree(json);
BaliseXML.buildBaliseXMLTree(json,0, null);
// Add Recip struct to xml balises tree
BaliseXML.addRecipTags();
BaliseXML eparentRng = BaliseXML.baliseXMLStatic;
String response = null;
Writer writer = null;
try {
JAXBContext contextObj = JAXBContext.newInstance(AttributeXML.class, ElementXML.class, DataXML.class,
ValueXML.class, OptionalXML.class, OneOrMoreXML.class,
ZeroOrMoreXML.class, AnnotationXML.class, DocumentationXML.class,
StartXML.class, GrammarXML.class,ChoiceXml.class,AnyNameXML.class,ExceptXML.class,NsNameXML.class);
Marshaller marshallerObj = contextObj.createMarshaller();
marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshallerObj.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler",
new PastisCustomCharacterEscapeHandler());
ByteArrayOutputStream os = new ByteArrayOutputStream();
writer = new OutputStreamWriter(os, "UTF-8");
marshallerObj.marshal(eparentRng, writer);
response = new String (os.toByteArray(), "UTF-8");
} catch (IOException e1) {
e1.printStackTrace();
} catch (JAXBException e1) {
e1.printStackTrace();
}
finally {
writer.close();
}
LOGGER.info("RNG profile generated successfully");
return response;
}
public String getArchiveUnitProfile(final ProfileNotice json) throws IOException {
Notice notice = new Notice();
if(json.getNotice() != null){
notice = json.getNotice();
} else {
notice.set_id("12133411121213");
}
String controlSchema = puaFromJSON.getControlSchemaFromElementProperties(json.getElementProperties());
notice.setControlSchema(controlSchema);
ObjectMapper objectMapper = new ObjectMapper();
String noticeAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(notice);
return noticeAsString;
}
public String getFile() {
InputStream rngFile = getClass().getClassLoader().getResourceAsStream("rng/AUP_default_PASTIS.json");
if (rngFile != null) {
return rngFile.toString();
} else {
return null;
}
}
public ElementProperties createProfile() throws URISyntaxException {
PastisSAX2Handler handler = new PastisSAX2Handler();
PastisGetXmlJsonTree getJson = new PastisGetXmlJsonTree();
try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
LOGGER.info("Starting rng edition profile with base file : {}", this.rngFile);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(this.rngFile);
InputSource inputSource = new InputSource(inputStream);
xmlReader.parse(inputSource);
} catch (SAXException | IOException e ) {
return null;
}
return getJson.getJsonParsedTree(handler.elementRNGRoot);
}
public ProfileResponse loadProfile(String id) throws JsonProcessingException {
PastisSAX2Handler handler = new PastisSAX2Handler();
PastisGetXmlJsonTree getJson = new PastisGetXmlJsonTree();
PastisProfile profileToEdit;
ProfileResponse profileResponse = new ProfileResponse();
try {
profileToEdit = pastisProfiles.stream()
.filter(p -> Long.toString(p.getId()).equals(id))
.collect(Collectors.toList()).get(0);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("rng/" +
profileToEdit.getFileName());
InputSource inputSource = new InputSource(inputStream);
profileResponse.setId(profileToEdit.getId());
profileResponse.setType(profileToEdit.getType());
if (profileResponse.getType().equals("PA")) {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.parse(inputSource);
profileResponse.setProfile(getJson.getJsonParsedTree(handler.elementRNGRoot));
LOGGER.info("Starting editing Archive Profile with id : {}", id);
} else if (profileToEdit.getType().equals("PUA")) {
JSONTokener tokener = new JSONTokener(new InputStreamReader(inputStream));
JSONObject profileJson = new JSONObject(tokener);
puaPastisValidator.validatePUA(profileJson);
profileResponse.setProfile(jsonFromPUA.getProfileFromPUA(profileJson));
profileResponse.setNotice(noticeFromPUA.getNoticeFromPUA(profileJson));
}
} catch (SAXException | IOException e ) {
LOGGER.error("Failed to load profile with id : {}", id);
return null;
} catch (AssertionError ae) {
LOGGER.error("Failed to load pua with id {} and error message {}", id, ae.getMessage());
return null;
}
return profileResponse;
}
public ProfileResponse loadProfileFromFile(MultipartFile file) {
PastisSAX2Handler handler = new PastisSAX2Handler();
PastisGetXmlJsonTree getJson = new PastisGetXmlJsonTree();
ProfileResponse profileResponse = new ProfileResponse();
try {
String fileExtension = file.getOriginalFilename().split("\\.")[1];
profileResponse.setType(fileExtension.equals("rng") ? "PA":"PUA");
InputStream fileInputStream = file.getInputStream();
InputSource inputSource = new InputSource(file.getInputStream());
if (profileResponse.getType().equals("PA")) {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.parse(inputSource);
profileResponse.setProfile(getJson.getJsonParsedTree(handler.elementRNGRoot));
LOGGER.info("Starting editing Archive Profile from file : {}",file.getOriginalFilename());
} else {
JSONTokener tokener = new JSONTokener(new InputStreamReader(fileInputStream));
JSONObject profileJson = new JSONObject(tokener);
puaPastisValidator.validatePUA(profileJson);
profileResponse.setProfile(jsonFromPUA.getProfileFromPUA(profileJson));
profileResponse.setNotice(noticeFromPUA.getNoticeFromPUA(profileJson));
LOGGER.info("Starting editing Archive Unit Profile with name : {}", file.getOriginalFilename());
}
} catch (SAXException | IOException e ) {
LOGGER.error("Failed to load profile '{}' : " + e.getMessage(), file.getOriginalFilename());
return null;
} catch (AssertionError ae) {
LOGGER.error("Failed to load pua : {}", ae.getMessage());
return null;
}
profileResponse.setId((Math.abs(new Random().nextLong()) / 1000));
return profileResponse;
}
public ElementProperties createProfileFromFile(MultipartFile file ) {
PastisSAX2Handler handler = new PastisSAX2Handler();
PastisGetXmlJsonTree getJson = new PastisGetXmlJsonTree();
try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.parse(new InputSource(file.getInputStream()));
} catch (IOException e) {
LOGGER.error("Error while processing file : " + HttpStatus.INTERNAL_SERVER_ERROR);
return null;
} catch (SAXException e) {
if (e instanceof SAXParseException) {
LOGGER.error("Erreur lors du chargement du profil, ligne "+ ((SAXParseException) e).getLineNumber() + " colonne " + ((SAXParseException) e).getColumnNumber() + ": " + e.getMessage() + HttpStatus.INTERNAL_SERVER_ERROR);
return null;
} else {
LOGGER.error("Error while processing file : ");
return null;
}
}
return getJson.getJsonParsedTree(handler.elementRNGRoot);
}
public List<PastisProfile> getFiles() throws IOException {
Resource[] resources = ResourcePatternUtils
.getResourcePatternResolver(resourceLoader)
.getResources("classpath*:rng/*.*");
try {
if (pastisProfiles.isEmpty()) {
for (Resource r : resources) {
pastisProfiles.add(new PastisProfile(r.getFilename(), "active", r.lastModified()));
}
}
return pastisProfiles;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
......@@ -484,12 +484,12 @@ public class PuaPastisValidator {
puaMetadataDetails.setMaxItems(1);
}
if(!sedaElement.getEnumeration().isEmpty() && el.getValue() == null){
puaMetadataDetails.setEnumerations(sedaElement.getEnumeration());
puaMetadataDetails.setEnums(sedaElement.getEnumeration());
}
if(el.getValue() != null){
ArrayList list = new ArrayList();
list.add(el.getValue());
puaMetadataDetails.setEnumerations(list);
puaMetadataDetails.setEnums(list);
}
}
......
......@@ -184,44 +184,44 @@ public class JsonFromPUA {
for (String k : childPua.keySet()){
switch (k){
case "$ref":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
addRefToElement(childProfile, childPua.getString(k));
break;
case "enum":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
List<String> enume = childPua.getJSONArray(k).toList().stream().map(o->(String)o).collect(Collectors.toList());
childProfile.getPuaData().setEnum(enume);
break;
case "pattern":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setPattern(childPua.getString(k));
break;
case "minLength":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setMinLenght(childPua.getInt(k));
break;
case "maxLength":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setMaxLenght(childPua.getInt(k));
break;
case "minimum":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setMinimum(childPua.getInt(k));
break;
case "maximum":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setMaximum(childPua.getInt(k));
break;
case "additionalProperties":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setAdditionalProperties(childPua.getBoolean(k));
break;
case "exclusiveMinimum":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setExclusiveMinimum(childPua.getBoolean(k));
break;
case "exclusiveMaximum":
addPuadDataToElementIfNotPresent(childProfile);
addPuaDataToElementIfNotPresent(childProfile);
childProfile.getPuaData().setExclusiveMaximum(childPua.getBoolean(k));
break;
case "description":
......@@ -259,7 +259,7 @@ public class JsonFromPUA {
}
}
private void addPuadDataToElementIfNotPresent(ElementProperties childProfile) {
private void addPuaDataToElementIfNotPresent(ElementProperties childProfile) {
if (childProfile.getPuaData() == null) {
childProfile.setPuaData(new PuaData());
}
......@@ -270,6 +270,12 @@ public class JsonFromPUA {
el.getPuaData().setPattern(ref);
}
/**
*
* @param parent tree of {@link ElementProperties}
* @param name name of new {@link ElementProperties}
* @return new child of {@link ElementProperties}
*/
private ElementProperties createChildren(ElementProperties parent, String name){
String realName = sanitizeNodeName(name);
ElementProperties children = new ElementProperties();
......
package fr.gouv.vitamui.pastis;
import fr.gouv.vitamui.pastis.model.profiles.PastisProfile;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "/application.properties")
@AutoConfigureMockMvc
@SpringBootTest
public class ProfileControllerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ProfileControllerTest.class);
@Autowired
private MockMvc mockMvc;
private MockHttpServletResponse mockHttpServletResponse;
@Test
public void getProfiles() throws Exception {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/getprofiles");
mockHttpServletResponse = mockMvc.perform(requestBuilder).andReturn().getResponse();
String resBody = mockHttpServletResponse.getContentAsString();
LOGGER.info("response = {}", resBody);
Assertions.assertEquals(200, mockHttpServletResponse.getStatus());
}
@Test
public void test() throws Exception {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/test");
mockHttpServletResponse = mockMvc.perform(requestBuilder).andReturn().getResponse();
String resBody = mockHttpServletResponse.getContentAsString();
LOGGER.info("response = {}", resBody);
Assertions.assertEquals(200, mockHttpServletResponse.getStatus());
Assertions.assertEquals("Pastis API is listening...", resBody);
}
@Test
public void getFile() throws Exception {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/getfile");
mockHttpServletResponse = mockMvc.perform(requestBuilder).andReturn().getResponse();
String resBody = mockHttpServletResponse.getContentAsString();
LOGGER.info("response = {}", resBody);
Assertions.assertEquals(200, mockHttpServletResponse.getStatus());
}
@Test
public void testProfiles() throws Exception {
int i=0;
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/getprofiles");
mockHttpServletResponse = mockMvc.perform(requestBuilder).andReturn().getResponse();
String resBody = mockHttpServletResponse.getContentAsString();
JSONArray jsonArray= new JSONArray(resBody);
while (i<jsonArray.length()-1){
JSONObject jsonObject = jsonArray.getJSONObject(i);
PastisProfile pastisProfile = new PastisProfile();
pastisProfile.deserialise(jsonObject);
List profilesNok = Arrays.asList("ProfileJson.json");
if(!profilesNok.contains(pastisProfile.getFileName())){
requestBuilder = MockMvcRequestBuilders.post("/edit").param("id", pastisProfile.getId().toString());
mockHttpServletResponse = mockMvc.perform(requestBuilder).andReturn().getResponse();
resBody = mockHttpServletResponse.getContentAsString();
LOGGER.info("response = {}", resBody);
Assertions.assertEquals(200, mockHttpServletResponse.getStatus());
}
i++;
}
}
}