Commit 45afe2fc authored by Cristian Aguirre's avatar Cristian Aguirre

Update ETL Delete Sensible Data

parent a5e47903
...@@ -11,6 +11,7 @@ import com.bytesw.bytebot.etl.model.DeleteDataSensibleControl; ...@@ -11,6 +11,7 @@ import com.bytesw.bytebot.etl.model.DeleteDataSensibleControl;
import com.bytesw.bytebot.etl.model.DeleteDataSensibleLog; import com.bytesw.bytebot.etl.model.DeleteDataSensibleLog;
import com.bytesw.bytebot.etl.model.Intent; import com.bytesw.bytebot.etl.model.Intent;
import com.bytesw.bytebot.etl.utils.JsonUtils; import com.bytesw.bytebot.etl.utils.JsonUtils;
import com.bytesw.xdf.exception.NotFoundException;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage; import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
import com.bytesw.bytebot.etl.services.DeleteSensMessageService; import com.bytesw.bytebot.etl.services.DeleteSensMessageService;
import com.jayway.jsonpath.PathNotFoundException; import com.jayway.jsonpath.PathNotFoundException;
...@@ -27,6 +28,7 @@ import org.springframework.beans.BeanUtils; ...@@ -27,6 +28,7 @@ import org.springframework.beans.BeanUtils;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -66,6 +68,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio ...@@ -66,6 +68,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
String json = (String) dynaBean.get("data"); String json = (String) dynaBean.get("data");
String event = (String) JsonUtils.getFieldFromJson(json, "$.event"); String event = (String) JsonUtils.getFieldFromJson(json, "$.event");
String sender_id; String sender_id;
boolean update_control = false;
// Transform present Date // Transform present Date
String presentDate = OffsetDateTime.now().toString().replace('T', ' '); String presentDate = OffsetDateTime.now().toString().replace('T', ' ');
String timeZone = presentDate.substring(presentDate.length() - 6); String timeZone = presentDate.substring(presentDate.length() - 6);
...@@ -89,9 +92,17 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio ...@@ -89,9 +92,17 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
sender_id = (String) JsonUtils.getFieldFromJson(json, "$.metadata.sender_id"); sender_id = (String) JsonUtils.getFieldFromJson(json, "$.metadata.sender_id");
} }
List<DeleteDataSensRegistryBean> deleteSensibleBean = service.deleteMessage(agent.getAgenId() List<DeleteDataSensRegistryBean> deleteSensibleBean = new ArrayList<>();
, SmSMessageSid, intenId.get().getId(), sender_id);
try{
deleteSensibleBean = service.deleteMessage(agent.getAgenId()
, SmSMessageSid, intenId.get().getId(), sender_id);
update_control = true;
} catch (NotFoundException e){
update_control = true;
} catch (Exception e){
update_control = false;
}
for (DeleteDataSensRegistryBean registry : deleteSensibleBean) { for (DeleteDataSensRegistryBean registry : deleteSensibleBean) {
DeleteDataSensibleLog reg = new DeleteDataSensibleLog(); DeleteDataSensibleLog reg = new DeleteDataSensibleLog();
reg.setIntenId(registry.getInten_id()); reg.setIntenId(registry.getInten_id());
...@@ -106,6 +117,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio ...@@ -106,6 +117,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
} }
DeleteDataSensibleControl control = new DeleteDataSensibleControl(); DeleteDataSensibleControl control = new DeleteDataSensibleControl();
Optional<DeleteDataSensibleControl> controlBd = deleteDataSensibleControlRepository.findEventIdByAgentId(agent.getAgenId()); Optional<DeleteDataSensibleControl> controlBd = deleteDataSensibleControlRepository.findEventIdByAgentId(agent.getAgenId());
if (update_control){
if (controlBd.isPresent()) { if (controlBd.isPresent()) {
// Update // Update
control.setId(controlBd.get().getId()); control.setId(controlBd.get().getId());
...@@ -122,6 +134,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio ...@@ -122,6 +134,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
} }
} }
} }
}
@Override @Override
public void beforeStep(StepExecution stepExecution) { public void beforeStep(StepExecution stepExecution) {
......
...@@ -39,8 +39,6 @@ public class DeleteSensMessageService { ...@@ -39,8 +39,6 @@ public class DeleteSensMessageService {
throw new Exception("Parámetros vacíos"); throw new Exception("Parámetros vacíos");
} }
log.debug("RESPUESTA: "+data);
DeleteDataSensRegistryBean registry = new DeleteDataSensRegistryBean(); DeleteDataSensRegistryBean registry = new DeleteDataSensRegistryBean();
if(data.get("status") != null){ if(data.get("status") != null){
...@@ -60,16 +58,13 @@ public class DeleteSensMessageService { ...@@ -60,16 +58,13 @@ public class DeleteSensMessageService {
deleteMessages.add(registry); deleteMessages.add(registry);
} }
} }
return deleteMessages;
}catch (NotFoundException e){ }catch (NotFoundException e){
log.debug(e); log.debug(e);
log.debug("Imagen no encontrada"); throw new NotFoundException(e.getMessage());
}catch (Exception e ){ }catch (Exception e ){
log.debug(e); log.debug(e);
log.debug("Error consumiento servicio de Proveedor"); throw new Exception(e.getMessage());
}finally {
return deleteMessages;
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment