diff --git a/ui/ui-frontend/projects/pastis/src/assets/config/config.json b/ui/ui-frontend/projects/pastis/src/assets/config/config.json index 6582d6b8f28533878fa42318063ea57768e981dc..c8d5fd53c19e576c2845ce6f83b83c6fc987e5ce 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/config/config.json +++ b/ui/ui-frontend/projects/pastis/src/assets/config/config.json @@ -1,10 +1,10 @@ { "apiPastisUrl": "http://vps795748.ovh.net:8080/rest", "getProfileUrl": "/createprofile", - "uploadProfileUrl": "/new", + "uploadProfileUrl": "/profile", "getFileUrl": "/getfile", "getAllProfilesUrl": "/getprofiles", "savePAasFileUrl": "/getarchiveprofile", "savePUAasFileUrl": "/getarchiveunitprofile", "editProfileUrl": "/edit" -} \ No newline at end of file +} diff --git a/ui/ui-pastis/pom.xml b/ui/ui-pastis/pom.xml index f67450eb92a1cffaef035dd30271a16f93260e55..44fd11c44b73417bddc14427b8064ae7b48d15da 100644 --- a/ui/ui-pastis/pom.xml +++ b/ui/ui-pastis/pom.xml @@ -55,6 +55,14 @@ <version>1.4.5</version> </dependency> + <!-- Lombok --> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + + <!-- Documentation --> <dependency> <groupId>org.springdoc</groupId> diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/configuration/PastisConfiguration.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/configuration/PastisConfiguration.java index ecd577b3bcdfb8244f1e79112ef86d9d8ce8288d..288d1e244262d9634c12133ee0a4500b853b703c 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/configuration/PastisConfiguration.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/configuration/PastisConfiguration.java @@ -37,7 +37,6 @@ knowledge of the CeCILL-C license and that you accept its terms. */ package fr.gouv.vitamui.pastis.configuration; -import fr.gouv.vitamui.pastis.model.profiles.PastisProfile; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; import org.springframework.context.annotation.Bean; @@ -46,9 +45,7 @@ import org.springframework.http.HttpStatus; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; @Configuration public class PastisConfiguration { diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/controller/ProfileController.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/controller/ProfileController.java index 2a4b4ec878cfa335ede0cf082a5f149be0b4b237..76bcc245659aa9d5011dca6e10ec597ad52276ed 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/controller/ProfileController.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/controller/ProfileController.java @@ -39,50 +39,38 @@ knowledge of the CeCILL-C license and that you accept its terms. package fr.gouv.vitamui.pastis.controller; 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.PastisProfile; -import fr.gouv.vitamui.pastis.model.profiles.Notice; 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.PastisCustomCharacterEscapeHandler; -import fr.gouv.vitamui.pastis.util.PastisGetXmlJsonTree; -import fr.gouv.vitamui.pastis.util.PastisSAX2Handler; -import fr.gouv.vitamui.pastis.util.PuaPastisValidator; -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 fr.gouv.vitamui.pastis.util.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.oas.annotations.servers.ServerVariable; +import io.swagger.v3.oas.annotations.tags.Tag; 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.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; 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; + +@OpenAPIDefinition(tags = { @Tag(name = "pastis") }, + info = @Info(title = "Pastis Rest Api", description = ""), + servers = { @Server(url = "dev.vitamui.com" , + variables = { @ServerVariable(name = "scheme", allowableValues = {"https", "http"}, defaultValue = "https"), + @ServerVariable(name = "port", description = "Api port",defaultValue = "8051")}) + , @Server(url = "localhost" , + variables = { @ServerVariable(name = "scheme", allowableValues ={"https", "http"}, defaultValue = "http"), + @ServerVariable(name = "port", description = "Api port", defaultValue = "8051")}) }) @RestController class ProfileController { @@ -90,256 +78,118 @@ class ProfileController { 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 ProfileController(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - private List<PastisProfile> pastisProfiles = new ArrayList<>(); - + private ProfileService profileService; + @Operation(summary = "method for test Api is running", + description = "method for test Api is running", + tags = {"pastis"}) @RequestMapping(value = "/test", method = RequestMethod.GET) - String test() { - return "Pastis API is listening..."; + ResponseEntity<String> test() { + if (profileService.test() != null) { + return new ResponseEntity<>(profileService.test(), HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } } + @Operation(summary = "Retrieve RNG representation of the JSON structure", + description = "Retrieve RNG representation of the JSON structure of archive profile", + tags = {"pastis"}) @RequestMapping(value = "/getarchiveprofile", method = RequestMethod.POST, consumes = APPLICATION_JSON_UTF8, produces = MediaType.APPLICATION_XML_VALUE) - String getArchiveProfile(@RequestBody 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 = os.toString("UTF-8"); - - } catch (IOException e1) { - e1.printStackTrace(); - } catch (JAXBException e1) { - e1.printStackTrace(); - } - finally { - writer.close(); + ResponseEntity<String> getArchiveProfile(@RequestBody final ElementProperties json) throws IOException { + if (profileService.getArchiveProfile(json) != null) { + return ResponseEntity.ok(profileService.getArchiveProfile(json)); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - - LOGGER.info("RNG profile generated successfully"); - return response; } + @Operation(summary = "Retrieve JSON representation of archive unit profile", + description = "Retrieve JSON representation of archive unit profile", + tags = {"pastis"}) @RequestMapping(value = "/getarchiveunitprofile", method = RequestMethod.POST, consumes = APPLICATION_JSON_UTF8, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<String> getArchiveUnitProfile(@RequestBody 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 ResponseEntity.ok(noticeAsString); + if (profileService.getArchiveUnitProfile(json) != null) { + return ResponseEntity.ok(profileService.getArchiveUnitProfile(json)); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } } @RequestMapping (value = "/getfile", method = RequestMethod.GET, produces = "text/plain") ResponseEntity<String> getFile() { - - InputStream rngFile = getClass().getClassLoader().getResourceAsStream("profile3.rng"); - if (rngFile != null) { - return new ResponseEntity<>(rngFile.toString(), HttpStatus.OK); + if (profileService.getFile() != null) { + return new ResponseEntity<>(profileService.getFile(), HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } + @Operation(summary = "Retrieve JSON representation of the RNG structure", + description = "Retrieve JSON representation of the RNG structure", + tags = {"pastis"}) @RequestMapping (value = "/createprofile", method = RequestMethod.GET) - ResponseEntity<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); + ResponseEntity<ElementProperties> createProfile() throws URISyntaxException { - InputStream inputStream = getClass().getClassLoader().getResourceAsStream(this.rngFile); - InputSource inputSource = new InputSource(inputStream); - - xmlReader.parse(inputSource); - - } catch (SAXException | IOException e ) { + if (profileService.createProfile() != null) { + return ResponseEntity.ok(profileService.createProfile()); + } else { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - - return ResponseEntity.ok(getJson.getJsonParsedTree(handler.elementRNGRoot)); } + @Operation(summary = "Load Profile", + description = "Load profile by Id", + tags = {"pastis"}) @RequestMapping (value = "/edit", method = RequestMethod.POST) ResponseEntity<ProfileResponse> loadProfile(@RequestParam(name = "id") 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 new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } catch (AssertionError ae) { - LOGGER.error("Failed to load pua with id {} and error message {}", id, ae.getMessage()); + if (profileService.loadProfile(id) != null) { + return ResponseEntity.ok(profileService.loadProfile(id)); + } else { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - - return ResponseEntity.ok(profileResponse); } - @RequestMapping (value = "/new", method = RequestMethod.POST, + @Operation(summary = "Upload profile PA or PUA", + description = "Upload profile PA or PUA", + tags = {"pastis"}) + @RequestMapping (value = "/profile", method = RequestMethod.POST, consumes = "multipart/form-data", produces = "application/json") ResponseEntity<ProfileResponse> loadProfileFromFile(@RequestParam 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 new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } catch (AssertionError ae) { - LOGGER.error("Failed to load pua : {}", ae.getMessage()); + if (profileService.loadProfileFromFile(file) != null) { + return ResponseEntity.ok(profileService.loadProfileFromFile(file)); + } else { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - - profileResponse.setId((Math.abs(new Random().nextLong()) / 1000)); - - return ResponseEntity.ok(profileResponse); } - + @Operation(summary = "Generate Json Struct from RNG file", + description = "Generate Json Struct from RNG file", + tags = {"pastis"}) @RequestMapping (value = "/createprofilefromfile", method = RequestMethod.POST,consumes = "multipart/form-data", produces = "application/json") - ResponseEntity<?> createprofilefromfile(@RequestParam 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) { - return new ResponseEntity<>("Error while processing file : ", HttpStatus.INTERNAL_SERVER_ERROR); - } catch (SAXException e) { - if (e instanceof SAXParseException) { - return ResponseEntity.badRequest().body("Erreur lors du chargement du profil, ligne " + ((SAXParseException) e).getLineNumber() + " colonne " + ((SAXParseException) e).getColumnNumber() + ": " + e.getMessage()); - } else { - return ResponseEntity.badRequest().body("Error while processing file : "); - } + ResponseEntity<ElementProperties> createProfileFromFile(@RequestParam MultipartFile file ) { + if (profileService.createProfileFromFile(file) != null) { + return ResponseEntity.ok(profileService.createProfileFromFile(file)); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - - return ResponseEntity.ok(getJson.getJsonParsedTree(handler.elementRNGRoot)); } + @Operation(summary = "Retrieve all profiles PA and PUA", + description = "Retrieve all profiles PA and PUA", + tags = {"pastis"}) @RequestMapping (value = "/getprofiles", method = RequestMethod.GET) ResponseEntity<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 ResponseEntity.ok(pastisProfiles); - } catch (Exception e) { - e.printStackTrace(); + if (profileService.getFiles() != null) { + return ResponseEntity.ok(profileService.getFiles()); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementProperties.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementProperties.java index be5b3bdbf4a8809e2ab87e9535eb13207ace1850..40e7a16aa5480b48ee4498ff1ba504414ac43806 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementProperties.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementProperties.java @@ -1,25 +1,25 @@ /* -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. @@ -40,21 +40,23 @@ package fr.gouv.vitamui.pastis.model; import com.fasterxml.jackson.annotation.JsonIgnore; import fr.gouv.vitamui.pastis.util.RNGConstants; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; - +@Data +@Getter +@Setter +@NoArgsConstructor public class ElementProperties implements Serializable { private static final long serialVersionUID = -5093112183496503253L; - - public ElementProperties() { - super(); - } - String name; String type; String cardinality; @@ -80,49 +82,6 @@ public class ElementProperties implements Serializable { PuaData puaData; - public List<ElementProperties> getChildren() { - return this.children; - } - - public void setChildren(List<ElementProperties> children) { - this.children = children; - } - - public List<ElementProperties> getChoices() { - return choices; - } - - public void setChoices(List<ElementProperties> choices) { - this.choices = choices; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getValueOrData() { - return this.valueOrData; - } - - public void setValueOrData(String dataType) { - this.valueOrData = dataType; - } - - public String getCardinality() { - return this.cardinality; - } public void setCardinality(String cardinality) { if(null != RNGConstants.CardinalityMap.get(cardinality)) { @@ -144,55 +103,6 @@ public class ElementProperties implements Serializable { } } - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getLevel() { - return this.level; - } - - public void setLevel(int level) { - this.level = level; - } - - public String getDataType() { - return this.dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - - public String getDocumentation() { - return this.documentation; - } - - public void setDocumentation(String documentation) { - this.documentation = documentation; - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getParentId() { - return this.parentId; - } - - public void setParentId(Long parentId) { - this.parentId = parentId; - } - @JsonIgnore public Object getSedaData() { return sedaData; @@ -213,14 +123,6 @@ public class ElementProperties implements Serializable { this.parent = parent; } - public PuaData getPuaData() { - return puaData; - } - - public void setPuaData(PuaData puaData) { - this.puaData = puaData; - } - public void init() { diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementRNG.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementRNG.java index 85104ebe9f078dc375052e9957a52548cffccd33..0c330c02c8b31ccb9c3c09f61bc5cf0b363980ec 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementRNG.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/ElementRNG.java @@ -1,25 +1,25 @@ /* -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,6 +38,9 @@ knowledge of the CeCILL-C license and that you accept its terms. package fr.gouv.vitamui.pastis.model; import fr.gouv.vitamui.pastis.util.RNGConstants; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,86 +55,65 @@ import static fr.gouv.vitamui.pastis.util.RNGConstants.TypesMap; */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) -public class ElementRNG { - - public ElementRNG() { - } - +@Data@NoArgsConstructor@Setter +public class ElementRNG { + + String name; String type; - - String dataType; - + + String dataType; + String value; - + ElementRNG parent; private static Logger LOGGER = LoggerFactory.getLogger(ElementRNG.class); public static ElementProperties elementStatic = new ElementProperties(); - + public static ElementProperties elementStaticRoot = new ElementProperties(); - + private static long idCounter = 0; - - List<ElementRNG> children = new ArrayList<ElementRNG>(); - - @XmlAttribute + + List<ElementRNG> children = new ArrayList<ElementRNG>(); + + @XmlAttribute public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - @XmlElement public String getType() { return type; } - public void setType(String type) { - this.type = type; - } @XmlAttribute (name="type") public String getDataType() { return dataType; } - public void setDataType(String dataType) { - this.dataType = dataType; - } @XmlElement(name="rng:value") public String getValue() { return value; } - public void setValue(String value) { - this.value = value; - } @XmlTransient public ElementRNG getParent() { return parent; } - public void setParent(ElementRNG parent) { - this.parent = parent; - } @XmlAnyElement public List<ElementRNG> getChildren() { return children; } - public void setChildren(List<ElementRNG> children) { - this.children = children; - } - public static void setDataForParentElementOrAttribute (ElementProperties parentNode, ElementRNG node) { if(null != parentNode.getType() && (RNGConstants.MetadaDataType.element.toString().equals(parentNode.getType()) || RNGConstants.MetadaDataType.attribute.toString().equals(parentNode.getType()))) { @@ -144,8 +126,8 @@ public class ElementRNG { setDataForParentElementOrAttribute(parentNode.getParent(), node); } } - - + + public static void setDocumentationForParentElement (ElementProperties parentNode, ElementRNG node) { if(null != parentNode.getType() && RNGConstants.MetadaDataType.element.toString().equals(parentNode.getType())) { parentNode.setDocumentation(node.getValue()); @@ -153,10 +135,10 @@ public class ElementRNG { setDocumentationForParentElement(parentNode.getParent(), node); } } - + public static void setElementsForGroupOrChoice(ElementProperties parentNode, ElementRNG node) { - - if(null != parentNode.getType() && (RNGConstants.GroupOrChoice.group.toString().equals(parentNode.getType()) + + if(null != parentNode.getType() && (RNGConstants.GroupOrChoice.group.toString().equals(parentNode.getType()) || RNGConstants.GroupOrChoice.choice.toString().equals(parentNode.getType()))) { parentNode.setGroupOrChoice(node.getType()); }else { @@ -165,14 +147,14 @@ public class ElementRNG { } // Build the a tree of properties given : // a node - //the level of the node + //the level of the node //the parent of the node public static ElementProperties buildElementPropertiesTree( ElementRNG node, int profondeur, ElementProperties parentNode ){ ElementProperties local = new ElementProperties(); LOGGER.info("Generating JSON element {}", node.getName()); if(null != node.getType() && RNGConstants.MetadaDataType.element.toString().equals(node.getType()) || RNGConstants.MetadaDataType.attribute.toString().equals(node.getType())) { - + local.setCardinality(elementStatic.getCardinality()); local.setGroupOrChoice(elementStatic.getGroupOrChoice()); local.setName(node.getName()); @@ -182,7 +164,7 @@ public class ElementRNG { elementStatic = new ElementProperties(); - + if(null != parentNode) { local.setParent(parentNode); local.setParentId(parentNode.getId()); @@ -194,14 +176,14 @@ public class ElementRNG { elementStaticRoot = local; } } - + else { if(RNGConstants.isValueOrData(node.getType())) { setDataForParentElementOrAttribute(parentNode, node); - }else if(RNGConstants.isCardinality(node.getType())) { + }else if(RNGConstants.isCardinality(node.getType())) { elementStatic.setCardinality(node.getType()); - }else if(RNGConstants.hasGroupOrChoice(node.getType())) { + }else if(RNGConstants.hasGroupOrChoice(node.getType())) { elementStatic.setGroupOrChoice(node.getType()); } else if("documentation".equals(node.getType())) { @@ -212,11 +194,11 @@ public class ElementRNG { local = parentNode; } - + for( ElementRNG next : node.getChildren() ) { if(null != next.getType() && (RNGConstants.MetadaDataType.element.toString().equals(next.getType()) || RNGConstants.MetadaDataType.attribute.toString().equals(next.getType()))) { - buildElementPropertiesTree( next, profondeur + 1, local ); + buildElementPropertiesTree( next, profondeur + 1, local ); }else { buildElementPropertiesTree( next, profondeur, local ); } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/JsonFromRng.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/JsonFromRng.java index 943eb94433ceb129940b2be5927611067b39b9e4..2eb980e53c9a0a6d8f381814d0f710be7b91df63 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/JsonFromRng.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/JsonFromRng.java @@ -1,25 +1,25 @@ /* -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,73 +39,40 @@ package fr.gouv.vitamui.pastis.model; import com.fasterxml.jackson.annotation.JsonIgnore; import fr.gouv.vitamui.pastis.util.RNGConstants; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; import java.util.ArrayList; import java.util.List; +@Data@Getter@Setter public class JsonFromRng { - + String name; String type; - + String cardinality; - + String valuleOrData; - + String dataType; - + String value; - + String documentation; - + int level; - + Long id; - + Long parentId; - + @JsonIgnore ElementProperties parent; - - List<ElementProperties> children = new ArrayList<ElementProperties>(); - - - public List<ElementProperties> getChildren() { - return this.children; - } - public void setChildren(List<ElementProperties> children) { - this.children = children; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getValuleOrData() { - return this.valuleOrData; - } - - public void setValuleOrData(String dataType) { - this.valuleOrData = dataType; - } - - public String getCardinality() { - return this.cardinality; - } + List<ElementProperties> children = new ArrayList<ElementProperties>(); public void setCardinality(String cardinality) { if(null != RNGConstants.CardinalityMap.get(cardinality)) { @@ -114,63 +81,4 @@ public class JsonFromRng { this.cardinality = cardinality; } } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getLevel() { - return this.level; - } - - public void setLevel(int level) { - this.level = level; - } - - public String getDataType() { - return this.dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - - public String getDocumentation() { - return this.documentation; - } - - public void setDocumentation(String documentation) { - this.documentation = documentation; - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getParentId() { - return this.parentId; - } - - public void setParentId(Long parentId) { - this.parentId = parentId; - } - - //@JsonIgnore - public ElementProperties getParent() { - return this.parent; - } - - //@JsonIgnore - public void setParent(ElementProperties parent) { - this.parent = parent; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/OntologyDSL.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/OntologyDSL.java deleted file mode 100644 index 0cc2c1327dda1667a785a7ac2f708e56577194b0..0000000000000000000000000000000000000000 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/OntologyDSL.java +++ /dev/null @@ -1,133 +0,0 @@ -/* -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.model; - -public class OntologyDSL { - - public OntologyDSL() { - } - - public String contrat_acces; - public String dsl_request; - public String query; - public String and; - public String eq; - public String filter; - public int limit; - public String projection; - public String tenant_id; - - - public String getContrat_acces() { - return contrat_acces; - } - public void setContrat_acces(String contrat_acces) { - this.contrat_acces = contrat_acces; - } - public String getDsl_request() { - return dsl_request; - } - public void setDsl_request(String dsl_request) { - this.dsl_request = dsl_request; - } - public String getQuery() { - return query; - } - public void setQuery(String query) { - this.query = query; - } - public String getAnd() { - return and; - } - public void setAnd(String and) { - this.and = and; - } - public String getEq() { - return eq; - } - public void setEq(String eq) { - this.eq = eq; - } - public String getFilter() { - return filter; - } - public void setFilter(String filter) { - this.filter = filter; - } - public int getLimit() { - return limit; - } - public void setLimit(int limit) { - this.limit = limit; - } - public String getProjection() { - return projection; - } - public void setProjection(String projection) { - this.projection = projection; - } - public String getTenant_id() { - return tenant_id; - } - public void setTenant_id(String tenant_id) { - this.tenant_id = tenant_id; - } - - public String toString() { - return "{\r\n" + - " \"contrat_acces\": \"CINES-1\",\r\n" + - " \"dsl_request\": {\r\n" + - " \"$query\": {\r\n" + - " \"$and\": [\r\n" + - " {\r\n" + - " \"$eq\": {\r\n" + - " \"SedaField\": \"DocumentType +\"\r\n" + - " }\r\n" + - " }\r\n" + - " ]\r\n" + - " },\r\n" + - " \"$filter\": {\r\n" + - " \"$limit\": 1\r\n" + - " },\r\n" + - " \"$projection\": {}\r\n" + - " },\r\n" + - " \"tenant_id\": \"1\"\r\n" + - "}"; - } - -} diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/PuaData.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/PuaData.java index 2b910e0162abfa623c52dfc42baa21a686345fdd..81a58364c06d1bd2249438b0cb573b4c7cf75c5f 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/PuaData.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/PuaData.java @@ -1,8 +1,13 @@ package fr.gouv.vitamui.pastis.model; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + import java.util.List; +@Data@Getter@Setter public class PuaData { Boolean AdditionalProperties; @@ -15,75 +20,4 @@ public class PuaData { Boolean ExclusiveMinimum; Boolean ExclusiveMaximum; - public Boolean getAdditionalProperties() { - return AdditionalProperties; - } - - public void setAdditionalProperties(Boolean additionalProperties) { - AdditionalProperties = additionalProperties; - } - - public List<String> getEnum() { - return Enum; - } - - public void setEnum(List<String> anEnum) { - Enum = anEnum; - } - - public String getPattern() { - return Pattern; - } - - public void setPattern(String pattern) { - Pattern = pattern; - } - - public Integer getMinLenght() { - return MinLenght; - } - - public void setMinLenght(Integer minLenght) { - MinLenght = minLenght; - } - - public Integer getMaxLenght() { - return MaxLenght; - } - - public void setMaxLenght(Integer maxLenght) { - MaxLenght = maxLenght; - } - - public Integer getMinimum() { - return Minimum; - } - - public void setMinimum(Integer minimum) { - Minimum = minimum; - } - - public Integer getMaximum() { - return Maximum; - } - - public void setMaximum(Integer maximum) { - Maximum = maximum; - } - - public Boolean getExclusiveMinimum() { - return ExclusiveMinimum; - } - - public void setExclusiveMinimum(Boolean exclusiveMinimum) { - ExclusiveMinimum = exclusiveMinimum; - } - - public Boolean getExclusiveMaximum() { - return ExclusiveMaximum; - } - - public void setExclusiveMaximum(Boolean exclusiveMaximum) { - ExclusiveMaximum = exclusiveMaximum; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/AnnotationTag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/AnnotationTag.java index 98f23fb7acf0628694b913b0b83e422f43cbb052..9930e9cf09162117a546279820ff377ebb909adb 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/AnnotationTag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/AnnotationTag.java @@ -38,10 +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.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="xsd:annotation") +@Setter public class AnnotationTag extends RngTag{ DocumentationTag documentationTag; @@ -49,8 +52,4 @@ public class AnnotationTag extends RngTag{ public DocumentationTag getDocumentationTag() { return documentationTag; } - - public void setDocumentationTag(DocumentationTag documentationTag) { - this.documentationTag = documentationTag; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DataTag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DataTag.java index f0ee29e605640c35722987f57f0f008afdb168b5..ef84be52363a91d5d95dd7a7261233caba9d0fad 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DataTag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DataTag.java @@ -39,15 +39,14 @@ knowledge of the CeCILL-C license and that you accept its terms. package fr.gouv.vitamui.pastis.model.factory; import fr.gouv.vitamui.pastis.util.RNGConstants; +import lombok.NoArgsConstructor; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="rng:data") +@NoArgsConstructor public class DataTag extends RngTag { - public DataTag(){ - } - public DataTag(RNGConstants.DataType dataType, RngTag parent){ this.setDataType(dataType.getLabel()); this.setParent(parent); diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DocumentationTag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DocumentationTag.java index 72ea4b255441952e0956194afb90d37da830e5f9..81f3f6d3d9a18238ceb2d3ed1e32250a180e4add 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DocumentationTag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/DocumentationTag.java @@ -38,8 +38,11 @@ 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.XmlElement; +@Setter public class DocumentationTag extends RngTag{ String documentation; @@ -48,8 +51,4 @@ public class DocumentationTag extends RngTag{ public String getDocumentation() { return documentation; } - - public void setDocumentation(String documentation) { - this.documentation = documentation; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/RngTag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/RngTag.java index 26fe2fd4d84f6b2afbb753c48127dbe8ba780bb7..26c373e69f71b610cc2e25182b55ef8fc4b77990 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/RngTag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/RngTag.java @@ -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/Tag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/Tag.java index d0749d72ae49f992adeb7b2b0cb21e4851fcdc16..433668ffe6dbcea550bd442faaa5bc290792d7db 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/Tag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/Tag.java @@ -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(); } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/ValueTag.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/ValueTag.java index 9880770269125e251fd005f6fe9ec07f59ecd7d9..1c58bd3bfd6dc8ac32fb225586c7ec9e175e7190 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/ValueTag.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/factory/ValueTag.java @@ -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; - } - } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AnnotationXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AnnotationXML.java index 176fbd48c4d2e4e1e2a8f1da6a566d93a5a2d6ad..eb690d8d950a23d5f659b0db6a8a163dfe8d7679 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AnnotationXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AnnotationXML.java @@ -1,25 +1,25 @@ /* -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; - } - } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AttributeXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AttributeXML.java index 8fa974dabab2e98717f0b74ee51fbd9cb23c0b90..dccdb55e413a00b89e1a2bcc3f6c074f00c56152 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AttributeXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/AttributeXML.java @@ -1,25 +1,25 @@ /* -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; - } - } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/BaliseXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/BaliseXML.java index 49325fce52bd42d9119ab7ac2d328dadf3128004..5c6cc3b9028cc2d4e2489f05259006967f0a5267 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/BaliseXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/BaliseXML.java @@ -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 diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DataXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DataXML.java index 466a6d967c8a2b5e93af30a2160ce9ad7ab606d5..90a817f531fc468586b00878fd551741f0a5a56e 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DataXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DataXML.java @@ -1,25 +1,25 @@ /* -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 +} diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DocumentationXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DocumentationXML.java index db0c1361990c6140c72ce1c2778af657942bcc28..f7018bfff39d7c03587992c4292fcb68bae88db4 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DocumentationXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/DocumentationXML.java @@ -1,25 +1,25 @@ /* -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ElementXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ElementXML.java index 800c39f5aa946021235f4db78f5826a4868b779a..6ed544c4f496631240c22558f79cde91c74c4e44 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ElementXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ElementXML.java @@ -1,25 +1,25 @@ /* -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/NsNameXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/NsNameXML.java index 7dd10db1008c9a305d7ba7da080f2d7271870752..2ac834cc4dca8ca0fc167df30b18009dcc479b56 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/NsNameXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/NsNameXML.java @@ -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ValueXML.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ValueXML.java index c2797f579fef42a06d339b7dc0d63b07f10ece2f..2b97712ba341805234a57a743765064566178ae1 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ValueXML.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/jaxb/ValueXML.java @@ -1,25 +1,25 @@ /* -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/Notice.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/Notice.java index 6bc2e4f9836b3f584d0b7adee2094f23ac4336fc..896cd976ce610928ed296fea53f0cd8631c59b34 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/Notice.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/Notice.java @@ -1,9 +1,13 @@ 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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/PastisProfile.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/PastisProfile.java index 1f54e674175c290977d63968b486b9d43da73ab3..04c14b7574cad192e0e698dcee8ed097b0c7d3ac 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/PastisProfile.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/PastisProfile.java @@ -1,8 +1,15 @@ 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")); + } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileNotice.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileNotice.java index 2a739b5f27db59d13da6297545663c41b1b70e6f..ea8ef0d91c9905befd63b3eacc7d69c8edc1830c 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileNotice.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileNotice.java @@ -1,25 +1,25 @@ /* -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; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/pua/PuaMetadataDetails.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/pua/PuaMetadataDetails.java index 884419543d6c0257b0ff7b0a4572782cba176b35..cc3b6ad8efc3025ef0c6d8dc6ccfbf2fc24e7ea9 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/pua/PuaMetadataDetails.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/pua/PuaMetadataDetails.java @@ -1,10 +1,13 @@ 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 +} diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/seda/SedaNode.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/seda/SedaNode.java index 01fc98c6516ff3e42dc0d2abea9d56be1cc42c52..ad55674eae205ea01adba12f2baeb55192d0e5c6 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/seda/SedaNode.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/seda/SedaNode.java @@ -1,10 +1,15 @@ 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( diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java new file mode 100644 index 0000000000000000000000000000000000000000..c7bb4fa939470e882d93f74723505a611555d5c3 --- /dev/null +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java @@ -0,0 +1,334 @@ +/* +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; + } + +} + diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/PuaPastisValidator.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/PuaPastisValidator.java index 801249e71f5d9a601a42e9a05ed44b3da4670983..4b75391f2fbc9acfa4939558143bd3f9eee30613 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/PuaPastisValidator.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/PuaPastisValidator.java @@ -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); } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/pua/JsonFromPUA.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/pua/JsonFromPUA.java index 605a66d9dfa385dbfb3426abb77cc5a1c3c00b4d..ced08b1b6bad041f729963a426fa2b2af72b75ef 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/pua/JsonFromPUA.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/pua/JsonFromPUA.java @@ -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(); diff --git a/ui/ui-pastis/src/test/java/fr/gouv/vitamui/pastis/ProfileControllerTest.java b/ui/ui-pastis/src/test/java/fr/gouv/vitamui/pastis/ProfileControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..831a01bd318495ab2c977afba0149bebc4b02c8f --- /dev/null +++ b/ui/ui-pastis/src/test/java/fr/gouv/vitamui/pastis/ProfileControllerTest.java @@ -0,0 +1,87 @@ +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++; + } + } + +} diff --git a/ui/ui-pastis/src/test/resources/application.properties b/ui/ui-pastis/src/test/resources/application.properties index b4af6f8a6568e0db99b34b07d33a55c557f8bd6f..965f795570469c0bb94c65eb11e0c259d6880491 100644 --- a/ui/ui-pastis/src/test/resources/application.properties +++ b/ui/ui-pastis/src/test/resources/application.properties @@ -1,3 +1,6 @@ #Pastis rest api rng.base.file=rng/Profil_seda_pastis_mvp.rng json.base.file=rng/ProfileJson.json +pua.definitions.file=pua_validation/ProfileJson.json + +cors.allowed-origins = https://dev.vitamui.com:4251, https://localhost, http://localhost diff --git a/ui/ui-pastis/src/test/resources/rng/profile3.rng b/ui/ui-pastis/src/test/resources/rng/profile3.rng new file mode 100644 index 0000000000000000000000000000000000000000..388fe650ea301fd413dc92410bdc0203efd89cd4 --- /dev/null +++ b/ui/ui-pastis/src/test/resources/rng/profile3.rng @@ -0,0 +1,831 @@ +<?xml version='1.0' encoding='utf-8' standalone='no'?> +<rng:grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" + xmlns:rng="http://relaxng.org/ns/structure/1.0" + xmlns:seda="fr:gouv:culture:archivesdefrance:seda:v2.1" xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="fr:gouv:culture:archivesdefrance:seda:v2.1" + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" + ns="fr:gouv:culture:archivesdefrance:seda:v2.1" seda:warnings=""> + <rng:start> + <rng:element name="ArchiveTransfer"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:element name="Comment"> + <xsd:annotation> + <xsd:documentation>Commentaire sur le versement</xsd:documentation> + </xsd:annotation> + <rng:data type="string"/> + </rng:element> + </rng:optional> + <rng:element name="Date"> + <rng:data type="dateTime"/> + </rng:element> + <rng:element name="MessageIdentifier"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ArchivalAgreement"> + <xsd:annotation> + <xsd:documentation>Déclaration du contrat d'entrée</xsd:documentation> + </xsd:annotation> + <rng:data type="token"/> + </rng:element> + <rng:element name="CodeListVersions"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + </rng:element> + <rng:element name="DataObjectPackage"> + <rng:element name="DataObjectGroup"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:zeroOrMore> + <rng:element name="BinaryDataObject"> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + <rng:optional> + <rng:element name="DataObjectGroupId"> + <xsd:annotation> + <xsd:documentation>Sert à lier un fichier à l'ArchiveUnit auquel il correspond. + Exemple: ID7</xsd:documentation> + </xsd:annotation> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DataObjectVersion"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:element name="Uri"> + <rng:data type="anyURI"/> + </rng:element> + <rng:element name="MessageDigest"> + <rng:data type="base64Binary"/> + <rng:attribute name="algorithm"> + <rng:data type="token"/> + </rng:attribute> + </rng:element> + <rng:element name="Size"> + <rng:data type="positiveInteger"/> + </rng:element> + <rng:element name="FormatIdentification"> + <rng:element name="FormatLitteral"> + <rng:data type="string"/> + </rng:element> + <rng:optional> + <rng:element name="MimeType"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="FormatId"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Encoding"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + </rng:element> + <rng:element name="FileInfo"> + <rng:element name="Filename"> + <xsd:annotation> + <xsd:documentation>Nom du fichier. Exemple: + 22100005200011_20091118_144251_1.pdf</xsd:documentation> + </xsd:annotation> + <rng:data type="string"/> + </rng:element> + </rng:element> + <rng:optional> + <rng:element name="Metadata"> + <rng:optional> + <rng:element name="Video"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Audio"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + </rng:element> + </rng:optional> + </rng:element> + </rng:zeroOrMore> + </rng:element> + <rng:element name="DescriptiveMetadata"> + <rng:zeroOrMore> + <rng:element name="ArchiveUnit"> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + <rng:optional> + <rng:element name="ArchiveUnitProfile"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:group> + <rng:element name="Management"> + <rng:optional> + <rng:element name="AppraisalRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + <rng:element name="FinalAction"> + <rng:data type="token"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="AccessRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DisseminationRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + </rng:element> + </rng:group> + <rng:group> + <rng:element name="Content"> + <rng:element name="DescriptionLevel"> + <rng:data type="token"/> + </rng:element> + <rng:oneOrMore> + <rng:element name="Title"> + <rng:optional> + <rng:attribute name="xml:lang"> + <rng:data type="language"/> + </rng:attribute> + </rng:optional> + <rng:data type="string"/> + </rng:element> + </rng:oneOrMore> + <rng:optional> + <rng:element name="FilePlanPosition"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="OriginatingAgencyArchiveUnitIdentifier"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="TransferringAgencyArchiveUnitIdentifier"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Description"> + <rng:optional> + <rng:attribute name="xml:lang"> + <rng:data type="language"/> + </rng:attribute> + </rng:optional> + <rng:data type="string"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="CustodialHistory"> + <rng:zeroOrMore> + <rng:element name="CustodialHistoryItem"> + <rng:data type="string"/> + </rng:element> + </rng:zeroOrMore> + </rng:element> + </rng:optional> + <rng:element name="Type"> + <rng:data type="string"/> + </rng:element> + <rng:oneOrMore> + <rng:element name="Language"> + <xsd:annotation> + <xsd:documentation>Langue du contenu du sous-ensemble de l'archive + exprimée au format ISO 639-3</xsd:documentation> + </xsd:annotation> + <rng:data type="language"/> + </rng:element> + </rng:oneOrMore> + <rng:optional> + <rng:element name="DescriptionLanguage"> + <rng:data type="language"/> + </rng:element> + </rng:optional> + <rng:zeroOrMore> + <rng:element name="Tag"> + <rng:data type="token"/> + </rng:element> + </rng:zeroOrMore> + <rng:zeroOrMore> + <rng:element name="Keyword"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="KeywordContent"> + <rng:data type="string"/> + </rng:element> + </rng:element> + </rng:zeroOrMore> + <rng:optional> + <rng:element name="OriginatingAgency"> + <xsd:annotation> + <xsd:documentation>Service producteur</xsd:documentation> + </xsd:annotation> + <rng:element name="Identifier"> + <rng:data type="string"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:element name="SubmissionAgency"> + <xsd:annotation> + <xsd:documentation>Service versant</xsd:documentation> + </xsd:annotation> + <rng:element name="Identifier"> + <rng:data type="string"/> + </rng:element> + </rng:element> + <rng:optional> + <rng:element name="RelatedObjectReference"> + <rng:zeroOrMore> + <rng:element name="IsVersionOf"> + <rng:choice> + <rng:element name="ArchiveUnitRefId"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:zeroOrMore> + <rng:optional> + <rng:element name="Replaces"> + <rng:choice> + <rng:element name="ArchiveUnitRefId"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="IsPartOf"> + <rng:choice> + <rng:element name="ArchiveUnitRefId"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="References"> + <rng:choice> + <rng:element name="ArchiveUnitRefId"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + </rng:element> + </rng:optional> + <rng:element name="StartDate"> + <xsd:annotation> + <xsd:documentation>Date du document le plus ancien dans + l'ArchiveUnit</xsd:documentation> + </xsd:annotation> + <rng:data type="date"/> + </rng:element> + <rng:element name="EndDate"> + <xsd:annotation> + <xsd:documentation>Date du document le plus récent dans + l'ArchiveUnit.</xsd:documentation> + </xsd:annotation> + <rng:data type="date"/> + </rng:element> + </rng:element> + <rng:zeroOrMore> + <rng:element name="ArchiveUnit"> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + <rng:optional> + <rng:group> + <rng:element name="Management"> + <rng:optional> + <rng:element name="AppraisalRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + <rng:element name="FinalAction"> + <rng:data type="token"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="AccessRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DisseminationRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + </rng:element> + </rng:group> + </rng:optional> + <rng:group> + <rng:element name="Content"> + <rng:element name="DescriptionLevel"> + <rng:data type="token"/> + </rng:element> + <rng:optional> + <rng:element name="Title"> + <rng:data type="string"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="FilePlanPosition"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="OriginatingAgencyArchiveUnitIdentifier"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="TransferringAgencyArchiveUnitIdentifier"> + <rng:data type="token"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Description"> + <rng:data type="string"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Type"> + <rng:data type="string"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Language"> + <rng:data type="language"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DescriptionLanguage"> + <rng:data type="language"/> + </rng:element> + </rng:optional> + <rng:zeroOrMore> + <rng:element name="Tag"> + <rng:data type="token"/> + </rng:element> + </rng:zeroOrMore> + <rng:optional> + <rng:element name="OriginatingAgency"> + <rng:element name="Identifier"> + <rng:data type="string"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="SubmissionAgency"> + <rng:element name="Identifier"> + <rng:data type="string"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="RelatedObjectReference"> + <rng:optional> + <rng:element name="IsVersionOf"> + <rng:choice> + <rng:element name="ArchiveUnitRefId" a:defaultValue="id76759"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" + a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="Replaces"> + <rng:choice> + <rng:element name="ArchiveUnitRefId" a:defaultValue="id76759"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" + a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="IsPartOf"> + <rng:choice> + <rng:element name="ArchiveUnitRefId" a:defaultValue="id76759"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" + a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="References"> + <rng:choice> + <rng:element name="ArchiveUnitRefId" a:defaultValue="id76759"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:element name="DataObjectReferenceId" + a:defaultValue="id76745"> + <rng:data type="NCName"/> + </rng:element> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:element> + <rng:element name="RepositoryArchiveUnitPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="RepositoryObjectPID"> + <rng:data type="token"/> + </rng:element> + <rng:element name="ExternalReference"> + <rng:data type="token"/> + </rng:element> + </rng:choice> + </rng:element> + </rng:optional> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="EndDate"> + <rng:data type="date"/> + </rng:element> + </rng:optional> + </rng:element> + </rng:group> + </rng:element> + </rng:zeroOrMore> + <rng:zeroOrMore> + <rng:element name="DataObjectReference"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:element name="DataObjectReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DataObjectGroupReferenceId"> + <rng:data type="NCName"/> + </rng:element> + </rng:optional> + </rng:element> + </rng:zeroOrMore> + </rng:group> + </rng:element> + </rng:zeroOrMore> + </rng:element> + <rng:element name="ManagementMetadata"> + <rng:element name="ArchivalProfile"> + <rng:data type="token"/> + </rng:element> + <rng:element name="OriginatingAgencyIdentifier"> + <rng:data type="token"/> + </rng:element> + <rng:element name="SubmissionAgencyIdentifier"> + <rng:data type="token"/> + </rng:element> + <rng:optional> + <rng:element name="AppraisalRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + <rng:element name="FinalAction"> + <rng:data type="token"/> + </rng:element> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="AccessRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + <rng:optional> + <rng:element name="DisseminationRule"> + <rng:group> + <rng:element name="Rule"> + <rng:optional> + <rng:attribute name="id"> + <rng:data type="ID"/> + </rng:attribute> + </rng:optional> + <rng:data type="token"/> + </rng:element> + <rng:element name="StartDate"> + <rng:data type="date"/> + </rng:element> + </rng:group> + </rng:element> + </rng:optional> + </rng:element> + </rng:element> + <rng:element name="ArchivalAgency"> + <rng:element name="Identifier"> + <rng:value>19341594000017</rng:value> + <rng:attribute name="schemeName"> + <rng:value>SIRET</rng:value> + </rng:attribute> + <rng:attribute name="schemeAgencyName"> + <rng:value>INSEE</rng:value> + </rng:attribute> + </rng:element> + </rng:element> + <rng:element name="TransferringAgency"> + <xsd:annotation> + <xsd:documentation> Doit permettre d'identifier l'opérateur technique réalisant le + versement de manière unique et non équivoque</xsd:documentation> + </xsd:annotation> + <rng:element name="Identifier"> + <rng:data type="token"/> + <rng:attribute name="schemeName"> + <rng:value>SIRET</rng:value> + </rng:attribute> + <rng:attribute name="schemeAgencyName"> + <rng:value>INSEE</rng:value> + </rng:attribute> + </rng:element> + </rng:element> + </rng:element> + </rng:start> +</rng:grammar>