Parcourir la source

Merge branch 'charge-from-other-pam' of UV-APPS/UV_SAIC_CORE into master

Pablo Gómez il y a 4 semaines
Parent
commit
a60f4a3aba
1 fichiers modifiés avec 34 ajouts et 15 suppressions
  1. 34 15
      src/main/java/es/uv/saic/web/ProceduresController.java

+ 34 - 15
src/main/java/es/uv/saic/web/ProceduresController.java

@@ -590,33 +590,52 @@ public class ProceduresController {
 				
 				if(it.getText() == null) {
 					ObjectMapper mapper = new ObjectMapper();
-
 					Map<String, Object> opciones;
 					try {
 						opciones = mapper.readValue(it.getTasca().getOpcions(), 
 							new TypeReference<Map<String, Object>>() {});
+						
 						if(opciones != null) {
-							List<?> copiarDesdeList = (List<?>) opciones.get("copiar_desde");
-
-							if (!copiarDesdeList.isEmpty()) {
-								Map<?, ?> datosCopiar = (Map<?, ?>) copiarDesdeList.get(0);
-
-								if (datosCopiar.get("proces") != null && datosCopiar.get("curso") != null) {
-									String proces = datosCopiar.get("proces").toString();
-									Integer curso = Integer.parseInt(datosCopiar.get("curso").toString());
-									
-									PamMetadades pam = pms.findByNomProcesAndCursActivacio(proces, curso);
-									
-									String resultJson = addDefaultFieldsToJson(pam.getInstanciaTasca().getText(), false);
-									itt.setText(resultJson);
+							Object idPamRevObj = opciones.get("id_pam_rev");
+
+							int idPamRev = 0;
+							if (idPamRevObj != null) {
+								idPamRev = Integer.parseInt(idPamRevObj.toString());
+							}
+
+							String resultJson = "";
+
+							if (idPamRev != 0) {
+								InstanciaTasca itPam = its.findByInstanciaTascap(it.getInstancia().getIdInstancia(), idPamRev);
+								if (itPam != null && itPam.getText() != null) {
+									resultJson = addDefaultFieldsToJson(itPam.getText(), true);
+								}
+							} else {
+								List<?> copiarDesdeList = (List<?>) opciones.get("copiar_desde");
+
+								if (!copiarDesdeList.isEmpty()) {
+									Map<?, ?> datosCopiar = (Map<?, ?>) copiarDesdeList.get(0);
+
+									if (datosCopiar.get("proces") != null && datosCopiar.get("curso") != null) {
+										String proces = datosCopiar.get("proces").toString();
+										Integer curso = Integer.parseInt(datosCopiar.get("curso").toString());
+										
+										PamMetadades pam = pms.findByNomProcesAndCursActivacio(proces, curso);
+										if (pam != null && pam.getInstanciaTasca() != null && pam.getInstanciaTasca().getText() != null) {
+											resultJson = addDefaultFieldsToJson(pam.getInstanciaTasca().getText(), false);
+										}
+									}
 								}
 							}
+
+							itt.setText(resultJson);
 						}
 					} catch (JsonMappingException e) {
 						e.printStackTrace();
 					} catch (JsonProcessingException e) {
 						e.printStackTrace();
 					}
+					
 				} else {
 					String resultJson = addDefaultFieldsToJson(it.getText(), true);
 					itt.setText(resultJson);
@@ -634,7 +653,7 @@ public class ProceduresController {
 			}
 			else {
 				itt.setUsuariFet("");
-			}			
+			}           
 			itt.setAssignedToUser(its.isUserAuthorized(usuari, itt.getIdInstanciaTasca()));
 			itt.setOldEvidences(its.findOlderByProces(it.getInstancia().getCentre(), it.getInstancia().getTitulacio(), it.getInstancia().getProces().getNomProces(), i.getProces().getCursActivacio()));
 			itt.setVersions(its.findOlderVersions(it.getInstancia().getIdInstancia(), it.getTasca().getIdTasca(), it.getVersion()));