|
|
@@ -606,9 +606,10 @@ public class ProceduresController {
|
|
|
Integer curso = Integer.parseInt(datosCopiar.get("curso").toString());
|
|
|
|
|
|
PamMetadades pam = pms.findByNomProcesAndCursActivacio(proces, curso);
|
|
|
-
|
|
|
- itt.setText(pam.getInstanciaTasca().getText());
|
|
|
- }
|
|
|
+
|
|
|
+ String resultJson = addDefaultFieldsToJson(pam.getInstanciaTasca().getText(), false);
|
|
|
+ itt.setText(resultJson);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (JsonMappingException e) {
|
|
|
@@ -617,7 +618,8 @@ public class ProceduresController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
- itt.setText(it.getText());
|
|
|
+ String resultJson = addDefaultFieldsToJson(it.getText(), true);
|
|
|
+ itt.setText(resultJson);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
@@ -648,6 +650,29 @@ public class ProceduresController {
|
|
|
return date.format(formatter);
|
|
|
}
|
|
|
|
|
|
+ private String addDefaultFieldsToJson(String jsonOriginal, Boolean borrador) {
|
|
|
+ if (jsonOriginal == null || jsonOriginal.trim().isEmpty()) {
|
|
|
+ return jsonOriginal;
|
|
|
+ }
|
|
|
+
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> listaElementos = mapper.readValue(jsonOriginal, new TypeReference<List<Map<String, Object>>>() {});
|
|
|
+
|
|
|
+ for (Map<String, Object> elemento : listaElementos) {
|
|
|
+ elemento.put("borrador", borrador);
|
|
|
+ elemento.putIfAbsent("editable", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return mapper.writeValueAsString(listaElementos);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return jsonOriginal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/*
|
|
|
* Get all drafts for a given task instance
|