Esempio n. 1
0
  protected TXHitoDAO insertMilestone(
      TXTransactionDataContainer dtc, TXProcesoDAO process, int nIdPCDStage) throws ISPACException {

    int milestoneType = TXConstants.MILESTONE_STAGE_END_RELOCATED;
    if (process.isSubProcess()) milestoneType = TXConstants.MILESTONE_ACTIVITY_END_RELOCATED;

    TXHitoDAO hito = dtc.newMilestone(process.getKeyInt(), nIdPCDStage, 0, milestoneType);
    return hito;
  }
Esempio n. 2
0
 /**
  * Obtiene la lista de expedientes enviados a la papelera
  *
  * @fechaInicio Fecha de creación del expediente
  * @fechaEliminacion Fecha de eliminación del expediente
  * @procedimiento Procedimiento al que pertenece el expediente
  * @return
  * @throws ISPACException
  */
 public IItemCollection getExpedientsSentToTrash(
     String fechaInicio, String fechaEliminacion, int procedimiento) throws ISPACException {
   DbCnt cnt = mcontext.getConnection();
   try {
     String sMaxResultados =
         ISPACConfiguration.getInstance().get(ISPACConfiguration.MAX_EXPS_SHOW_TRASH);
     int max = 0;
     if (StringUtils.isNotBlank(sMaxResultados)) {
       max = TypeConverter.parseInt(sMaxResultados.trim(), 0);
     }
     return TXProcesoDAO.getExpedients(
         cnt,
         "PROCESOS.TIPO="
             + IProcess.PROCESS_TYPE
             + " AND PROCESOS.ESTADO="
             + TXConstants.STATUS_DELETED,
         max,
         fechaInicio,
         fechaEliminacion,
         procedimiento);
   } catch (ISPACException ie) {
     throw new ISPACException("Error en invesflowAPI:getExpedientsSentToTrash()", ie);
   } finally {
     mcontext.releaseConnection(cnt);
   }
 }
Esempio n. 3
0
  protected void validate(
      ClientContext cs, TXTransactionDataContainer dtc, TXProcesoDAO process, TXFaseDAO stage)
      throws ISPACException {

    IBPMAPI bpmAPI = dtc.getBPMAPI();
    TXProcedure procedure = TXProcedureMgr.getInstance().getProcedure(cs, process.getIdProcedure());
    // PFaseDAO pStage = procedure.getStageDAO(stage.getInt("ID_FASE"));
    PNodoDAO pNode = procedure.getNode(cs.getConnection(), stage.getInt("ID_FASE"));

    String previousStageUID =
        bpmAPI.getPreviousStage(
            process.getString("ID_PROCESO_BPM"), pNode.getString("ID_NODO_BPM"));
    if (StringUtils.isEmpty(previousStageUID)) {
      if (stage.getInt("TIPO") == IStage.STAGE_TYPE)
        throw new ISPACInfo("exception.expedients.previousStage.noStage");
      else throw new ISPACInfo("exception.subprocess.previousActivitiy.noActivity");
    }
  }
Esempio n. 4
0
 /**
  * Cuenta el número de expedientes enviados a la papelera. Solamente el supervisor(consulta o
  * total) podrá visualizar la lista de procesos enviados a la papelera
  *
  * @return
  * @throws ISPACException
  */
 public int countExpedientsSentToTrash() throws ISPACException {
   DbCnt cnt = mcontext.getConnection();
   try {
     return TXProcesoDAO.countProcess(
         cnt, "", "ESTADO=" + TXConstants.STATUS_DELETED + "AND TIPO=" + IProcess.PROCESS_TYPE);
   } catch (ISPACException ie) {
     throw new ISPACException("Error en invesflowAPI:countExpedientsSentToTrash()", ie);
   } finally {
     mcontext.releaseConnection(cnt);
   }
 }
Esempio n. 5
0
 public IItemCollection getSubProcess(String numExp) throws ISPACException {
   DbCnt cnt = null;
   try {
     cnt = mcontext.getConnection();
     return TXProcesoDAO.getSubProcess(cnt, numExp, mcontext);
   } catch (ISPACException e) {
     throw new ISPACException("Error en InvesflowAPI:getSubProcess(" + numExp + ")", e);
   } finally {
     mcontext.releaseConnection(cnt);
   }
 }
Esempio n. 6
0
  public IItemCollection getProcessesByProcedure(int idProcedimiento) throws ISPACException {

    DbCnt cnt = null;
    try {
      cnt = mcontext.getConnection();
      return TXProcesoDAO.getProcesses(cnt, idProcedimiento, mcontext);
    } catch (ISPACException e) {
      throw new ISPACException(
          "Error en InvesflowAPI:ProcessesByProcedure(" + idProcedimiento + ")", e);
    } finally {
      mcontext.releaseConnection(cnt);
    }
  }
Esempio n. 7
0
  public IProcess getProcess(String numExp) throws ISPACException {
    DbCnt cnt = null;
    try {
      cnt = mcontext.getConnection();
      IItemCollection itemcol = TXProcesoDAO.getProcess(cnt, numExp, mcontext);
      if (!itemcol.next())
        //				throw new ISPACNullObject(
        //						"No se ha encontrado el proceso con número de expediente ["
        //								+ numExp + "]");

        throw new ISPACNullObject("exception.expedients.unknown", new Object[] {numExp});

      return (IProcess) itemcol.value();
    } catch (ISPACException e) {
      if (e instanceof ISPACNullObject) {
        throw new ISPACInfo(e.getMessage(), e.getArgs(), false);
      }
      throw new ISPACException("Error en InvesflowAPI:getProcess(" + numExp + ")", e);
    } finally {
      mcontext.releaseConnection(cnt);
    }
  }
Esempio n. 8
0
  public void run(ClientContext cs, TXTransactionDataContainer dtc, ITXTransaction itx)
      throws ISPACException {

    EventManager eventmgr = new EventManager(cs, mparams);
    TXDAOGen genDAO = new TXDAOGen(cs, eventmgr);

    TXFaseDAO stage = dtc.getStage(mnIdStage);
    int nIdProc = stage.getInt("ID_EXP");
    int nIdPCDStage = stage.getInt("ID_FASE");

    TXProcesoDAO process = dtc.getProcess(nIdProc);
    TXProcedure procedure = TXProcedureMgr.getInstance().getProcedure(cs, process.getIdProcedure());

    PTramiteDAO pcdtask = procedure.getTaskDAO(mnIdTaskPCD);

    if (process.getInt("ESTADO") == TXConstants.STATUS_CLOSED) {
      throw new ISPACInfo(
          "exception.expedients.createTask.statusClosed",
          new String[] {pcdtask.getString("NOMBRE"), process.getString("NUMEXP")});
    } else if (process.getInt("ESTADO") == TXConstants.STATUS_CANCELED) {
      throw new ISPACInfo(
          "exception.expedients.createTask.statusCanceled",
          new String[] {pcdtask.getString("NOMBRE"), process.getString("NUMEXP")});
    } else if (process.getInt("ESTADO") == TXConstants.STATUS_ARCHIVED) {
      throw new ISPACInfo(
          "exception.expedients.createTask.statusArchived",
          new String[] {pcdtask.getString("NOMBRE"), process.getString("NUMEXP")});
    }

    // -----
    // BPM
    // ----
    IBPMAPI bpmAPI = dtc.getBPMAPI();
    IInvesflowAPI invesFlowAPI = cs.getAPI();
    IRespManagerAPI respManagerAPI = invesFlowAPI.getRespManagerAPI();
    // Se calcula el responsable del trámite
    String taskRespId = ResponsibleHelper.calculateTaskResp(eventmgr, pcdtask, stage, process, cs);

    String nombreRespId = ((Responsible) respManagerAPI.getResp(taskRespId)).getName();
    String taskActivityRespId = null;

    // boolean isSubProcess = false;
    boolean isSubProcess = mnIdProcedure != 0;
    int taskType = ITask.SIMPLE_TASK_TYPE;
    String idSubPcdBPM = null;
    // Si el tramite es complejo se calcula el responsable a asignar a la actividad inicial del
    // subproceso
    // if (StringUtils.isNotEmpty(pcdtask.getString("ID_PCD_SUB")) &&
    // !StringUtils.equals(pcdtask.getString("ID_PCD_SUB"), "0")){
    if (isSubProcess) {
      taskType = ITask.COMPLEX_TASK_TYPE;

      TXProcedure subProcess = TXProcedureMgr.getInstance().getProcedure(cs, mnIdProcedure);
      Iterator it = subProcess.getStateTable().getStartStages().iterator();

      if (!it.hasNext())
        throw new ISPACException(
            "No se han encontrado actividades para el subproceso '"
                + pcdtask.getString("ID_PCD_SUB")
                + "'");
      int activityId = ((Integer) it.next()).intValue();
      PFaseDAO pActivity = subProcess.getStageDAO(activityId);
      taskActivityRespId =
          ResponsibleHelper.calculateTaskActivityResp(
              eventmgr, pActivity, pcdtask, process, cs, taskRespId);

      IItem itemSubprocedure = invesFlowAPI.getProcedure(pcdtask.getInt("ID_PCD_SUB"));
      idSubPcdBPM = itemSubprocedure.getString("ID_PCD_BPM");
    }

    // BpmUIDs bpmUIDs = bpmAPI.instanceTask(pcdtask.getString("ID_TRAMITE_BPM"),
    // pcdtask.getString("ID_PCD_SUB"), taskRespId,
    // taskActivityRespId,String.valueOf(stage.getKeyInt()));
    BpmUIDs bpmUIDs =
        bpmAPI.instanceTask(
            pcdtask.getString("ID_TRAMITE_BPM"),
            idSubPcdBPM,
            taskRespId,
            taskActivityRespId,
            stage.getString("ID_FASE_BPM"));

    // Identificador de tramite creado
    String taskUID = bpmUIDs.getTaskUID();
    // Identificador de subproceso instanciado
    String subProcessUID = bpmUIDs.getSubProcessUID();
    // Identificador de actividad creada
    String activityUID = bpmUIDs.getActivityUID();

    TXTramiteDAO task = dtc.newTask();
    genDAO.instance(pcdtask, task, stage, process);

    // Establecemos el UID del tramite instanciado retornado por el BPM
    if (taskUID == null) taskUID = "" + task.getKeyInt();
    task.set("ID_TRAMITE_BPM", taskUID);
    task.set("ID_RESP", taskRespId);
    task.set("RESP", nombreRespId);
    task.set("TIPO", taskType);
    // Si es un tramite complejo (subproceso) habrá que instanciar el subproceso
    if (isSubProcess) {
      int[] ids =
          itx.createSubProcess(
              pcdtask.getInt("ID_PCD_SUB"),
              mnumexp,
              subProcessUID,
              activityUID,
              taskRespId,
              taskActivityRespId);
      task.set("ID_SUBPROCESO", (int) ids[0]);
      mnIdActivity = (int) ids[1];
      //			//Obtenemos la actividad inicia
      //			Iterator it =dtc.getStages();
      //			while (it.hasNext()){
      //				TXFaseDAO _stage = (TXFaseDAO)((Map.Entry)it.next()).getValue();
      //				if (_stage.getInt("ID_EXP") == idSubProcess){
      //					mnIdActivity = _stage.getKeyInt();
      //					break;
      //				}

      eventmgr.getRuleContextBuilder().addContext(RuleProperties.RCTX_SUBPROCESS, "" + ids[0]);
    }

    // Guardar la información del trámite
    task.store(cs);

    dtc.createTaskEntity(task);

    mnIdTask = task.getKeyInt();

    // Insertar el hito
    TXHitoDAO hito =
        dtc.newMilestone(
            process.getKeyInt(), nIdPCDStage, mnIdTaskPCD, TXConstants.MILESTONE_TASK_START);
    hito.set("INFO", composeInfo());

    // Se construye el contexto de ejecución de scripts.
    eventmgr.getRuleContextBuilder().addContext(process);
    eventmgr.getRuleContextBuilder().addContext(task);

    // Ejecutar eventos de sistema de creación de trámite.
    eventmgr.processSystemEvents(EventsDefines.EVENT_OBJ_TASK, EventsDefines.EVENT_EXEC_START);

    // Ejecutar evento al cancelar trámite.
    eventmgr.processEvents(
        EventsDefines.EVENT_OBJ_TASK, mnIdTaskPCD, EventsDefines.EVENT_EXEC_START);
  }