Exemplo 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;
  }
Exemplo n.º 2
0
  public void run(ClientContext cs, TXTransactionDataContainer dtc, ITXTransaction itx)
      throws ISPACException {
    EventManager eventmgr = new EventManager(cs);
    TXTramiteDAO task = null;
    TXFaseDAO stage = null;
    TXProcesoDAO exped = null;

    // Se construye el contexto de ejecución de scripts.
    if (mnIdTask != 0) {
      task = dtc.getTask(mnIdTask);
      eventmgr.getRuleContextBuilder().addContext(task);
    }

    if (mnIdStage != 0) {
      stage = dtc.getStage(mnIdStage);
      eventmgr.getRuleContextBuilder().addContext(stage);
    }

    if (mnIdProc != 0) {
      exped = dtc.getProcess(mnIdProc);
      eventmgr.getRuleContextBuilder().addContext(exped);
    }

    RuleContextBuilder rulebuilder = eventmgr.getRuleContextBuilder();
    rulebuilder.addContext(mparammap);

    if (mrctxparam != null) rulebuilder.addContext(mrctxparam);

    //		Iterator it=mparammap.entrySet().iterator();
    //		while (it.hasNext())
    //        {
    //		    Map.Entry var = (Map.Entry) it.next();
    //		    rulebuilder.addContext(var.getKey().toString(),var.getValue().toString());
    //        }

    mresult = eventmgr.processRule(mnIdRule);
  }
Exemplo 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");
    }
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
0
 public void lock(ClientContext cs, TXTransactionDataContainer dtc) throws ISPACException {
   TXFaseDAO stage = dtc.getStage(mnIdStage);
   dtc.getLockManager().lockProcess(stage.getInt("ID_EXP"));
 }