Skip to content

Commit

Permalink
services -> service
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Dec 23, 2022
1 parent f8f897f commit 86914e6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/main/java/fr/insee/knowledge/constants/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private Constants() {
public static final String idProductFiled = "products";
public static final String gsbpmField = "gsbpm";
public static final String labelField = "label";
public static final String serviceField = "services";
public static final String serviceField = "service";
public static final String descriptionField = "description";
public static final String dispoField = "dispo";
public static final String tasksField = "tasks";
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/fr/insee/knowledge/domain/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ public class Function extends GenericIDLabel {
private List<GenericIDLabel> users;
private List<ProductOrGsbpm> products;
private List<Task> tasks;
private Service service;

private Services servicesBpmn;

public Function(String id, String label, String description, int dispo, ProductOrGsbpm gsbpm, String idProduct, List<GenericIDLabel> users, List<ProductOrGsbpm> tools, List<Task> tasks, Services servicesBpmn) {
public Function(String id, String label, String description, int dispo, ProductOrGsbpm gsbpm, String idProduct, List<GenericIDLabel> users, List<ProductOrGsbpm> tools, List<Task> tasks, Service service) {
super(id, label);
this.description = description;
this.dispo = dispo;
Expand All @@ -22,7 +21,7 @@ public Function(String id, String label, String description, int dispo, ProductO
this.users = users;
this.products = products;
this.tasks = tasks;
this.servicesBpmn = servicesBpmn;
this.service = service;
}

public Function() {
Expand Down Expand Up @@ -85,11 +84,11 @@ public void setTasks(List<Task> tasks) {
this.tasks = tasks;
}

public Services getServiceBpmn() {
return servicesBpmn;
public Service getService() {
return service;
}

public void setServiceBpmn(Services services) {
this.servicesBpmn = services;
public void setService(Service service) {
this.service = service;
}
}
33 changes: 33 additions & 0 deletions src/main/java/fr/insee/knowledge/domain/Service.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package fr.insee.knowledge.domain;

public class Service extends GenericIDLabel {

private Service service;
private String description;

public Service(Service service, String description, String id, String label) {
super(id, label);
this.service = service;
this.description = description;
}

public Service() {
}

public Service getService() {
return service;
}

public void setService(Service service) {
this.service = service;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

}
33 changes: 0 additions & 33 deletions src/main/java/fr/insee/knowledge/domain/Services.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import fr.insee.knowledge.constants.Constants;
import fr.insee.knowledge.dao.FunctionDAO;
import fr.insee.knowledge.domain.Function;
import fr.insee.knowledge.domain.Services;
import fr.insee.knowledge.domain.Service;
import fr.insee.knowledge.service.ImportFunctionService;

import java.io.IOException;
Expand Down Expand Up @@ -37,31 +37,31 @@ private List<Function> getListFunctionsFromJsonNode(JsonNode rootNode) throws Js
List<Function> listFunction = new ArrayList<>();
if (rootNode.isArray()) {
for (JsonNode node : rootNode) {
recursiveMapping(listFunction, node, new Services());
recursiveMapping(listFunction, node, new Service());
}
}
return listFunction;
}

private void recursiveMapping(List<Function> functionList, JsonNode jsonNode, Services currentServices) throws JsonProcessingException {
currentServices.setId(jsonNode.get(Constants.idField).asText());
currentServices.setLabel(jsonNode.get(Constants.labelField).asText());
private void recursiveMapping(List<Function> functionList, JsonNode jsonNode, Service currentService) throws JsonProcessingException {
currentService.setId(jsonNode.get(Constants.idField).asText());
currentService.setLabel(jsonNode.get(Constants.labelField).asText());

JsonNode functionNodeArray = jsonNode.get(Constants.functionField);
if (functionNodeArray != null) {
for (JsonNode functionNode : functionNodeArray) {
Function function = mapper.treeToValue(functionNode, Function.class);
function.setServiceBpmn(currentServices);
function.setService(currentService);
functionList.add(function);
}
}
JsonNode node = jsonNode.get(Constants.serviceField);
if (node != null) {
for (JsonNode serviceNode : node) {
Services services = new Services();
Service service = new Service();
//TODO test if service exist in database
services.setService(currentServices);
recursiveMapping(functionList, serviceNode, services);
service.setService(currentService);
recursiveMapping(functionList, serviceNode, service);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/schema/schemaFunctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"users",
"products",
"tasks",
"serviceBpmn"
"services"
],
"properties": {
"_id": {
Expand Down Expand Up @@ -107,7 +107,7 @@
}
}
},
"serviceBpmn": {
"services": {
"bsonType": "object",
"items": {
"bsonType": "object",
Expand All @@ -122,7 +122,7 @@
"label": {
"bsonType": "string"
},
"serviceBpmn": {
"services": {
"bsonType": "object"
}
}
Expand Down

0 comments on commit 86914e6

Please sign in to comment.