Package ar.com.AmberSoft.iEvenTask.services

Source Code of ar.com.AmberSoft.iEvenTask.services.UpdateTaskService

package ar.com.AmberSoft.iEvenTask.services;

import java.util.Map;

import org.hibernate.Query;

import ar.com.AmberSoft.iEvenTask.backend.entities.Entity;
import ar.com.AmberSoft.iEvenTask.backend.entities.Tarea;
import ar.com.AmberSoft.iEvenTask.backend.entities.Visible;
import ar.com.AmberSoft.util.ParamsConst;

public class UpdateTaskService extends CreateTaskService {

  @SuppressWarnings("rawtypes")
  @Override
  public Entity getEntity(Map paramsthrows Exception {
    Tarea tarea = (Tarea) super.getEntity(params);
    tarea.setId((Integer) params.get(ParamsConst.ID));
    return tarea;
  }
  @SuppressWarnings("rawtypes")
  @Override
  public Map onExecute(Map paramsthrows Exception {
   
    deleteOldVisible((Integer) params.get(ParamsConst.ID));
   
    GetTaskService getTaskService = new GetTaskService();
    params.put(ParamsConst.TRANSACTION_CONTROL, Boolean.FALSE);
    params.putAll(getTaskService.execute(params));
   
    Tarea tarea = (Tarea) getEntity(params);

    getSession().saveOrUpdate(tarea);
    return null;
  }
  public void deleteOldVisible(Integer id) {
    StringBuffer queryText = new StringBuffer();
    queryText.append("DELETE ");
    queryText.append(Visible.class.getName());
    queryText.append(" WHERE  tarea.id = ?");
   
    Query query = getSession().createQuery(queryText.toString());
    query.setInteger(0, id);
   
    query.executeUpdate();
  }

}
TOP

Related Classes of ar.com.AmberSoft.iEvenTask.services.UpdateTaskService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.