Skip to content
Snippets Groups Projects

Compare revisions

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

Source

Select target project
No results found

Target

Select target project
  • dad/cines-vitamui
1 result
Show changes
Commits on Source (4)
Showing
with 240 additions and 756 deletions
......@@ -5,8 +5,8 @@ stages:
- tata
.machine: &runner-shell
tags:
- vitamui, shell
tags:
- vitamui, shell
test_tata:
stage: tata
......@@ -14,7 +14,7 @@ test_tata:
- main
<<: *runner-shell
script:
# Pour éviter de faire des modifications à distance accidentellement, on supprime le lien vers le référentiel d'origine, on détache la branche de sa remote.
# Pour éviter de faire des modifications à distance accidentellement, on supprime le lien vers le référentiel d'origine, on détache la branche de sa remote.
- git remote rm origin
# La commande "git remote add" est utilisée pour créer un dépôt distant. Le premier argument est le nom du dépôt distant et le deuxième son URL
- git remote add origin https://$TOKEN:x-oauth-basic@$LIEN_CIBLE
......@@ -22,5 +22,5 @@ test_tata:
- git checkout -b $BRANCHE_CIBLE
# on met à jour la branche distante (Logiquement, elle devrait toujours être au même niveau que la master local)
- git pull origin $BRANCHE_CIBLE
# on push sur github sur la branche choisie
# on push sur github sur la branche choisie
- git push --set-upstream origin $BRANCHE_CIBLE
......@@ -204,14 +204,6 @@
<artifactId>simple-odf</artifactId>
</dependency>
<!-- APACHE ODFtoolKit-->
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7</version>
<scope>system</scope>
<systemPath>C:\Users\descamps\Java\java-8\lib\tools.jar</systemPath>
</dependency>
</dependencies>
<build>
......
......@@ -197,7 +197,8 @@ db.groups.insert({
"system_dsl",
"system_probative_value",
"system_logbook_operation",
"system_holding_filling_scheme_profile"
"system_holding_filling_scheme_profile",
"system_pastis"
],
"readonly": false,
"level": "",
......
......@@ -82,6 +82,33 @@ db.profiles.insert({
]
});
db.profiles.insert({
"_id" : "system_pastis",
"identifier" : NumberInt(maxIdProfile++),
"name" : "Pastis Profile",
"description" : "Pastis Profile",
"tenantIdentifier": NumberInt({{ vitamui_platform_informations.proof_tenant }}),
"applicationName" : "PASTIS_APP",
"enabled" : true,
"readonly" : true,
"level" : "",
"customerId" : "system_customer",
"roles" : [
{
"name": "ROLE_GET_PASTIS"
},
{
"name": "ROLE_CREATE_PASTIS"
},
{
"name": "ROLE_UPDATE_PASTIS"
},
{
"name": "ROLE_DELETE_PASTIS"
}
]
});
db.profiles.insert({
"_id" : "system_agencies",
"identifier" : NumberInt(maxIdProfile++),
......
......@@ -130,6 +130,22 @@ db.applications.insert({
"target" : "_self"
});
db.applications.insert({
"identifier" : "PASTIS_APP",
{% if vitamui.referential.base_url is defined %}
"url": "{{ vitamui.pastis.base_url }}/",
{% endif %}
"icon" : "vitamui-icon vitamui-icon-ontologie",
"name" : "Profils Documentaires",
"category" : "referential",
"position" : 1,
"hasCustomerList" : false,
"hasTenantList" : false,
"hasHighlight" : false,
"tooltip" : "Accéder, Créer, Modifier ou Supprimer les profils d'archivage et les profils d'unité archivistique",
"target" : "_self"
});
db.applications.insert({
"identifier" : "AUDIT_APP",
{% if vitamui.referential.base_url is defined %}
......
......@@ -23,7 +23,8 @@ db.contexts.insert({
"ROLE_GET_CONTEXTS", "ROLE_UPDATE_CONTEXTS", "ROLE_CREATE_CONTEXTS",
"ROLE_GET_SECURITY_PROFILES", "ROLE_UPDATE_SECURITY_PROFILES", "ROLE_CREATE_SECURITY_PROFILES", "ROLE_DELETE_SECURITY_PROFILES",
"ROLE_GET_OPERATIONS", "ROLE_RUN_AUDITS", "ROLE_RUN_PROBATIVE_VALUE",
"ROLE_LOGBOOKS"
"ROLE_LOGBOOKS",
"ROLE_GET_PASTIS", "ROLE_CREATE_PASTIS", "ROLE_UPDATE_PASTIS", "ROLE_DELETE_PASTIS"
]
});
......
......@@ -92,3 +92,5 @@ vitamui:
base_url: "https://dev.vitamui.com:4208"
archive_search:
base_url: "https://dev.vitamui.com:4209"
pastis:
base_url: "https://dev.vitamui.com:4251"
{
"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
}
{
"/referential-api": {
"target": "https://sandbox78-adm.cines.fr:9002/",
"target": "dev.vitamui.com:9002/",
"secure": false,
"pathRewrite": {},
"logLevel": "debug"
},
"/identity-api": {
"target": "https://sandbox78-adm.cines.fr:9001/",
"target": "dev.vitamui.com:9001/",
"secure": false,
"pathRewrite": {},
"logLevel": "debug"
},
"/portal-api": {
"target": "https://sandbox78-adm.cines.fr:9000/",
"target": "dev.vitamui.com:9000/",
"secure": false,
"pathRewrite": {},
"logLevel": "debug"
},
"/ingest-api": {
"target": "https://sandbox78-adm.cines.fr:9008/",
"target": "dev.vitamui.com:9008/",
"secure": false,
"pathRewrite": {},
"logLevel": "debug"
},
"/archive-search-api": {
"target": "https://sandbox78-adm.cines.fr:9009/",
"target": "dev.vitamui.com:9009/",
"secure": false,
"pathRewrite": {},
"logLevel": "debug"
......
......@@ -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>
......
......@@ -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 {
......
......@@ -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);
}
}
/*
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() {
......
/*
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 );
}
......
/*
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;
}
}
/*
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" +
"}";
}
}
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;
}
}
......@@ -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;
}
}
......@@ -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);
......
......@@ -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;
}
}