Esempio n. 1
0
  private String getSubstitutesRespString() throws ISPACException {
    if (StringUtils.isEmpty(resp)) {

      TreeSet respList = new TreeSet();
      DbCnt cnt = context.getConnection();

      try {
        Responsible user = context.getUser();
        respList.addAll(user.getRespList());

        if (mWorkMode == IWorklistAPI.SUPERVISOR) {

          SecurityMgr security = new SecurityMgr(cnt);

          // Sustituir (sustituidos por el usuario y por los grupos a los que pertenece el usuario)
          IItemCollection collection = security.getAllSubstitutes(user);
          addRespListFromEntryUID(respList, collection, "UID_SUSTITUIDO");
        }
      } finally {
        context.releaseConnection(cnt);
      }

      resp = "'" + StringUtils.join(respList, "','") + "'";
    }
    if (logger.isDebugEnabled()) {
      logger.debug("getSubstitutesRespString:" + resp);
    }
    return resp;
  }
Esempio n. 2
0
  public ActionForward executeAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response,
      SessionAPI session)
      throws Exception {

    // Comprobar si el usuario tiene asignadas las funciones adecuadas
    FunctionHelper.checkFunctions(
        request, session.getClientContext(), new int[] {ISecurityAPI.FUNC_PUB_RULES_EDIT});

    IInvesflowAPI invesFlowAPI = session.getAPI();
    IPublisherAPI publisherAPI = invesFlowAPI.getPublisherAPI();

    // Formulario asociado a la regla
    EntityForm defaultForm = (EntityForm) form;

    int keyId = Integer.parseInt(defaultForm.getKey());

    // Información de la regla
    IItem rule = publisherAPI.getRule(keyId);

    // Eliminar la regla
    publisherAPI.deleteRule(keyId);

    String pcdId = request.getParameter("pcdId");
    if (!StringUtils.isEmpty(pcdId)) {

      return new ActionForward(
          new StringBuffer()
              .append("/showPubRulesList.do?pcdId=")
              .append(pcdId)
              .append("&stageId=")
              .append(rule.getString("ID_FASE"))
              .append("&taskId=")
              .append(rule.getString("ID_TRAMITE"))
              .append("&typeDoc=")
              .append(rule.getString("TIPO_DOC"))
              .toString(),
          true);
    } else {
      return new ActionForward("/showPubRulesGroupList.do", true);
    }
  }
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
  public void setItem(IItem item) throws ISPACException {

    IEntitiesAPI entitiesAPI = mContext.getAPI().getEntitiesAPI();

    if (!(item instanceof EntityDAO)) {
      throw new ISPACException("El objeto item no es una instancia de EntityDAO.");
    }
    EntityDAO mainEntityDAO = (EntityDAO) item;

    // Tabla y clave de la entidad principal
    mPrefixMainEntity = mainEntityDAO.getTableName();
    mKeyMainEntity = mainEntityDAO.getKeyName();

    // TODO Incorporar al EntityDAO campo NUMEXP y DEFINICION de la entidad para no tener que
    // consultar la definición que ya se consulta para crear el EntityDAO
    // Obtener la definición de la entidad principal
    mainEntityDef = (IEntityDef) entitiesAPI.getCatalogEntity(mMainEntityId);

    // Crear un CompositeItem al que se le añadiran las entidades secundarias de
    // de sustituto, composición y relación múltiple cuando existan en los parámetros del formulario
    CompositeItem composite = new CompositeItem(mPrefixMainEntity + ":" + mKeyMainEntity);
    composite.addItem(item, mPrefixMainEntity + ":");
    this.mitem = composite;

    // El número de expediente se establece inicialmente por parámetro en el EntityAppFactory
    // sino se busca en el item de la entidad principal a partir de su definición
    if (StringUtils.isEmpty(msExpedient)) {
      msExpedient = item.getString(mainEntityDef.getKeyNumExp());
    }

    /*
    // El identificador del procedimiento se establece inicialmente por parámetro en el EntityAppFactory
    // sino se busca en el item del expediente
    if (mPcdId == ISPACEntities.ENTITY_NULLREGKEYID) {
    	mPcdId = entitiesAPI.getExpedient(msExpedient).getInt("ID_PCD");
    }
    */

    // Obtener los campos obligatorios para la entidad principal
    EntityDef entityDefinicion = getRequiredData(mainEntityDef);

    // Obtener la definición de los campos para la entidad principal
    setFieldDefs(mainEntityDef.getName(), entityDefinicion);
  }
Esempio n. 5
0
  /* (non-Javadoc)
   * @see ieci.tdw.ispac.api.IWorklistAPI#getRespString()
   */
  public String getRespString() throws ISPACException {

    if (StringUtils.isEmpty(resp)) {

      TreeSet respList = new TreeSet();
      DbCnt cnt = context.getConnection();

      try {
        Responsible user = context.getUser();
        List respListUser = user.getRespList();
        respList.addAll(respListUser);
        if (mWorkMode == IWorklistAPI.SUPERVISOR) {
          SecurityMgr securityMgr = new SecurityMgr(cnt);

          // Comprobar si el usuario tiene asignada la función de Supervisor
          if (securityMgr.isSupervisor(user.getUID())) {
            return Responsible.SUPERVISOR;
          }

          // Supervisar (supervisados del usuario, del departamento y de los grupos a los que
          // pertenece el usuario)
          IItemCollection collection = securityMgr.getAllSuperviseds(user);
          addRespListFromEntryUID(respList, collection, "UID_SUPERVISADO");
          // Sustituir (sustituidos por el usuario, por el departamento y por los grupos a los que
          // pertenece el usuario)
          collection = securityMgr.getAllSubstitutes(user);
          addRespListFromEntryUID(respList, collection, "UID_SUSTITUIDO");
        }
      } finally {
        context.releaseConnection(cnt);
      }

      resp = "'" + StringUtils.join(respList, "','") + "'";
    }
    if (logger.isDebugEnabled()) {
      logger.debug("getRespString:" + resp);
    }
    return resp;
  }
Esempio n. 6
0
  /**
   * Establece los campos requeridos para una entidad a partir de las validaciones de obligatoriedad
   * de su definición.
   *
   * @param entityDef Definición de la entidad.
   * @return La definición parseada de la entidad.
   * @throws ISPACException Si se produce algún error.
   */
  public EntityDef getRequiredData(IEntityDef entityDef) throws ISPACException {

    // Obtener la definición de la entidad
    String xmlDefinicion = entityDef.getDefinition();
    if (!StringUtils.isEmpty(xmlDefinicion)) {

      // Parsear la definición de la entidad
      EntityDef entityDefinicion = EntityDef.parseEntityDef(xmlDefinicion);
      if (entityDefinicion != null) {

        // Obtener las validaciones
        List validations = entityDefinicion.getValidations();
        if ((validations != null) && (!validations.isEmpty())) {

          Map fields = entityDefinicion.fieldsToMap();
          Iterator it = validations.iterator();
          while (it.hasNext()) {

            // Validación de campo obligatorio
            EntityValidation entityValidation = (EntityValidation) it.next();
            if (entityValidation.isMandatory()) {

              // Establecer el campo como requerido
              EntityField field =
                  (EntityField) fields.get(new Integer(entityValidation.getFieldId()));
              if (field != null) {

                setRequired(entityDef.getName() + ":" + field.getPhysicalName().toUpperCase());
              }
            }
          }
        }
      }

      return entityDefinicion;
    }

    return null;
  }
  public ActionForward executeAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response,
      SessionAPI session)
      throws Exception {

    ClientContext cct = session.getClientContext();

    // Comprobar si el usuario tiene asignadas las funciones adecuadas
    FunctionHelper.checkFunctions(
        request, session.getClientContext(), new int[] {ISecurityAPI.FUNC_COMP_ENTITIES_EDIT});

    IInvesflowAPI invesFlowAPI = session.getAPI();
    ICatalogAPI catalogAPI = invesFlowAPI.getCatalogAPI();

    Upload2Form upload2Form = (Upload2Form) form;
    String upload = request.getParameter("upload");

    try {

      if (upload.equals("design")) {

        FormFile formfile = upload2Form.getUploadFile();
        String htmlCode = new String(formfile.getFileData());

        if (!StringUtils.isEmpty(htmlCode)) {

          // Obtener el formulario JSP de la aplicación
          IItem application =
              catalogAPI.getCTEntity(
                  ICatalogAPI.ENTITY_CT_APP, Integer.parseInt(upload2Form.getKey()));
          if (application != null) {

            List entities = new ArrayList();

            // Entidad principal
            entities.add(application.getString("ENT_PRINCIPAL_NOMBRE"));

            // Entidades de composición y de relación múltiple
            String parameters = application.getString("PARAMETROS");
            if (!StringUtils.isEmpty(parameters)) {

              ParametersDef xmlParameters = ParametersDef.parseParametersDef(parameters);
              List compositeEntities = xmlParameters.getCompositeMultipleRelationEntities();
              Iterator it = compositeEntities.iterator();
              while (it.hasNext()) {

                EntityParameterDef entityParameterDef = (EntityParameterDef) it.next();
                entities.add(entityParameterDef.getTable());
              }
            }

            String frm_jsp = application.getString("FRM_JSP");
            String jspCode = HTMLBuilder.updateHTML(htmlCode, frm_jsp, entities);
            if (jspCode != null) {

              application.set("FRM_JSP", jspCode);

              // Incrementar la versión del formulario
              int version = 1;
              String sVersion = application.getString("FRM_VERSION");
              if (!StringUtils.isEmpty(sVersion)) {
                version += Integer.parseInt(sVersion);
              }
              application.set("FRM_VERSION", version);

              application.store(cct);
            }
          }
        } else {
          throw new ISPACInfo("exception.uploadfile.empty");
        }
      } else if (upload.equals("code")) {

        FormFile formfile2 = upload2Form.getUploadFile2();
        String jspCode = new String(formfile2.getFileData());

        if (!StringUtils.isEmpty(jspCode)) {

          // Obtener la aplicación
          IItemCollection itemcol =
              catalogAPI.queryCTEntities(
                  ICatalogAPI.ENTITY_CT_APP, "where ID =" + upload2Form.getKey());
          if (itemcol.next()) {

            IItem application = itemcol.value();
            application.set("FRM_JSP", jspCode);

            // Incrementar la versión del formulario
            int version = 1;
            String sVersion = application.getString("FRM_VERSION");
            if (!StringUtils.isEmpty(sVersion)) {
              version += Integer.parseInt(sVersion);
            }
            application.set("FRM_VERSION", version);

            application.store(cct);
          }
        } else {
          throw new ISPACInfo("exception.uploadfile.empty");
        }
      }
    } catch (IOException e) {
      throw new ISPACInfo("exception.uploadfile.error");
    }

    return mapping.findForward("success");

    /*
    request.setAttribute("refresh", "true");
    return mapping.findForward("success_upload");
    */
  }