public void nuevoEmplazamientoDescripcionExecuteLogic(
      ActionMapping mappings,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    EmplazamientoForm frm = (EmplazamientoForm) form;
    removeInTemporalSession(request, TransferenciasConstants.SOPORTA_BUSQUEDA_EXTENDIDA);
    try {
      // Obtener información del usuario conectado
      AppUser appUser = getAppUser(request);

      // Obtener la entidad para el usuario conectado
      Properties params = null;

      if ((appUser != null) && (StringUtils.isNotEmpty(appUser.getEntity()))) {
        params = new Properties();
        params.put(MultiEntityConstants.ENTITY_PARAM, appUser.getEntity());
      }

      GestorGeograficos gestorGeograficos = GestorGeograficosFactory.getConnector(params);
      setInTemporalSession(
          request,
          TransferenciasConstants.SOPORTA_BUSQUEDA_EXTENDIDA,
          new Boolean(gestorGeograficos.soportaBusquedaExtendida()));
    } catch (GestorGeograficosException gge) {
      obtenerErrores(request, true)
          .add(ActionErrors.GLOBAL_ERROR, new ActionError(Constants.ERROR_GESTOR_GEOGRAFICOS));
    }

    ServiceRepository services =
        ServiceRepository.getInstance(ServiceClient.create(getAppUser(request)));

    GestionInfoSistemaBI infoSistemaBI = services.lookupInfoSistemaBI();
    DatosGeograficosVO datosGeograficos = infoSistemaBI.getDatosGeograficosDefecto();

    frm.setPais(datosGeograficos.getNombrePais());
    frm.setCodigoPais(datosGeograficos.getCodigoPais());
    frm.setProvincia(datosGeograficos.getNombreProvincia());
    frm.setCodigoProvincia(datosGeograficos.getCodigoProvincia());

    // Establecer los Valores por Defecto
    frm.setPaisDefecto(datosGeograficos.getNombrePais());
    frm.setCodigoPaisDefecto(datosGeograficos.getCodigoPais());
    frm.setProvinciaDefecto(datosGeograficos.getNombreProvincia());
    frm.setCodigoProvinciaDefecto(datosGeograficos.getCodigoProvincia());

    frm.setContextPath(request.getContextPath());

    // Obtener las referencias
    leerReferenciasDescripcion(request, frm);

    setReturnActionFordward(request, mappings.findForward("edicion_emplazamiento_descripcion"));
  }
Пример #2
0
  /**
   * Guarda el documento electrónico.
   *
   * @param mapping {@link ActionMapping} con los mapeos asociado.
   * @param form {@link ActionForm} asociado al action.
   * @param request {@link HttpServletRequest}
   * @param response {@link HttpServletResponse}
   */
  protected void saveExecuteLogic(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    try {
      logger.info("Inicio de saveExecuteLogic");

      // Validar el formulario
      ActionErrors errores = form.validate(mapping, request);
      if ((errores == null) || errores.isEmpty()) {
        logger.info("Formulario validado");

        // Recoger la información del documento
        DocDocumentoExtVO documento = new DocDocumentoExtVO();
        ((DocumentoForm) form).populate(documento);
        if (logger.isDebugEnabled()) logger.debug("DocDocumentoVO:\n" + documento.toString());

        DocTCapturaVO tarea =
            (DocTCapturaVO) getFromTemporalSession(request, DocumentosConstants.TAREA_KEY);
        if (StringUtils.isBlank(documento.getId())) {
          if (tarea != null) {
            // Crear el documento
            ((DocumentoForm) form)
                .set(
                    getGestionDocumentosElectronicosBI(request)
                        .insertDocumentoDesdeTarea(documento));
          } else {
            // Crear el documento
            ((DocumentoForm) form)
                .set(
                    getGestionDocumentosElectronicosBI(request)
                        .insertDocumentoDesdeCuadro(documento));
          }

          // Eliminar la invocación anterior
          popLastInvocation(request);
        } else {
          if (tarea != null) {
            // Modificar el documento
            ((DocumentoForm) form)
                .set(
                    getGestionDocumentosElectronicosBI(request)
                        .updateDocumentoDesdeTarea(documento));
          } else {
            // Modificar el documento
            ((DocumentoForm) form)
                .set(
                    getGestionDocumentosElectronicosBI(request)
                        .updateDocumentoDesdeCuadro(documento));
          }
        }

        RelacionEntregaVO relacion =
            (RelacionEntregaVO)
                getFromTemporalSession(request, TransferenciasConstants.RELACION_KEY);
        if (relacion != null) {
          ServiceRepository services =
              ServiceRepository.getInstance(ServiceClient.create(getAppUser(request)));
          GestionRelacionesEntregaBI relacionBI = services.lookupGestionRelacionesBI();
          if (relacion.isRechazada()) {
            relacion.setEstado(EstadoREntrega.ABIERTA.getIdentificador());
            try {
              relacionBI.updateRelacion(relacion);
            } catch (ActionNotAllowedException e) {
              guardarError(request, e);
            }
          }
        }

        // Actualizar el árbol de documentos
        request.setAttribute(DocumentosConstants.REFRESH_VIEW_KEY, Boolean.TRUE);

        setReturnActionFordward(
            request,
            redirectForwardMethod(
                request,
                "/documento",
                "method",
                "retrieve"
                    + (documento.getId() != null ? "&id=" + documento.getId() : "")
                    + (documento.getIdObjeto() != null
                        ? "&idObjeto=" + documento.getIdObjeto()
                        : "")
                    + "&tipoObjeto="
                    + documento.getTipoObjeto()));
      } else {
        logger.info("Formulario inv\u00E1lido");

        // Añadir los errores al request
        obtenerErrores(request, true).add(errores);

        setReturnActionFordward(request, mapping.findForward("editar_documento"));
      }
    } catch (Exception e) {
      logger.error("Error al guardar el documento", e);
      obtenerErrores(request, true)
          .add(ActionErrors.GLOBAL_ERROR, new ActionError(Constants.ERROR_ALMACENAR_DOCUMENTO));

      setReturnActionFordward(request, mapping.findForward("editar_documento"));
    }
  }
Пример #3
0
  /**
   * Muestra el formulario del documento electrónico.
   *
   * @param mapping {@link ActionMapping} con los mapeos asociado.
   * @param form {@link ActionForm} asociado al action.
   * @param request {@link HttpServletRequest}
   * @param response {@link HttpServletResponse}
   */
  protected void formExecuteLogic(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    logger.info("Inicio de formExecuteLogic");

    // Leer el identificador del clasificador
    String id = request.getParameter(Constants.ID);
    if (logger.isInfoEnabled()) logger.info("Id Clasificador: " + id);

    // Leer el identificador del objeto
    String idObjeto = request.getParameter("idObjeto");
    if (logger.isInfoEnabled()) logger.info("Id Objeto: " + idObjeto);

    // Leer el tipo de objeto
    int tipoObjeto = TypeConverter.toInt(request.getParameter("tipoObjeto"), TipoObjeto.DESCRIPTOR);
    if (logger.isInfoEnabled()) logger.info("Tipo Objeto: " + tipoObjeto);

    // Leer el identificador del clasificador
    String idClfPadre = request.getParameter("idClfPadre");
    if (logger.isInfoEnabled()) logger.info("Id Clasificador Padre: " + idClfPadre);

    if (StringUtils.isNotBlank(id)) {
      // // Guardar el enlace a la página
      // saveCurrentInvocation(KeysClientsInvocations.DOCUMENTOS_ELECTRONICOS_DOCUMENTO_EDIT,
      // request, getCustomConfigureView(request));
      saveCurrentInvocation(KeysClientsInvocations.DOCUMENTOS_ELECTRONICOS_DOCUMENTO_EDIT, request);

      // Leer la información del documento
      DocDocumentoVO documento =
          getGestionDocumentosElectronicosBI(request).getDocumento(tipoObjeto, idObjeto, id);
      if (logger.isInfoEnabled()) logger.info("DocDocumentoVO: " + documento);

      // Guardar la información del formulario
      ((DocumentoForm) form).set(documento);
    } else {
      // // Guardar el enlace a la página
      // saveCurrentInvocation(KeysClientsInvocations.DOCUMENTOS_ELECTRONICOS_DOCUMENTO_FORM,
      // request, getCustomConfigureView(request));
      saveCurrentInvocation(KeysClientsInvocations.DOCUMENTOS_ELECTRONICOS_DOCUMENTO_FORM, request);

      ((DocumentoForm) form).setIdObjeto(idObjeto);
      ((DocumentoForm) form).setTipoObjeto(tipoObjeto);
    }

    try {
      DataClfDocYRepEcm dataClfDocYRepEcm = null;
      ServiceRepository services = ServiceRepository.getInstance(getServiceClient(request));

      // Información del objeto
      if (tipoObjeto == TipoObjeto.DESCRIPTOR) {
        // Obtener el identificador de la ficha de los clasificadores
        // por defecto
        dataClfDocYRepEcm =
            services
                .lookupGestionDocumentosElectronicosBI()
                .getIdFichaClfDocYRepEcmDescriptor(idObjeto);

        if (StringUtils.isEmpty(dataClfDocYRepEcm.getIdRepEcm()))
          throw new DocElectronicosException(
              DocElectronicosException
                  .XNO_SE_PUEDE_REALIZAR_OPERACION_FALTA_REPOSITORIO_ECM_DESCRIPTOR);

        request.setAttribute(
            DocumentosConstants.DESCRIPTOR_KEY,
            getGestionDescripcionBI(request).getDescriptorExt(idObjeto));

      } else // if (tipoObjeto == TipoObjeto.ELEMENTO_CF)
      {
        dataClfDocYRepEcm =
            getGestionDocumentosElectronicosBI(request).getIdFichaClfDocYRepEcmElementoCF(idObjeto);

        if (StringUtils.isEmpty(dataClfDocYRepEcm.getIdRepEcm()))
          throw new DocElectronicosException(
              DocElectronicosException
                  .XNO_SE_PUEDE_REALIZAR_OPERACION_FALTA_REPOSITORIO_ECM_ELEMENTO_CUADRO);

        ElementoCuadroClasificacionVO elemento =
            getGestionCuadroClasificacionBI(request).getElementoCuadroClasificacion(idObjeto);
        if (elemento != null) {
          switch (elemento.getTipo()) {
            case ElementoCuadroClasificacion.TIPO_UNIDAD_DOCUMENTAL:
              UnidadDocumentalToPO udocTransformer = new UnidadDocumentalToPO(services);
              UnidadDocumentalVO udoc =
                  getGestionUnidadDocumentalBI(request).getUnidadDocumental(idObjeto);
              request.setAttribute(
                  DocumentosConstants.UNIDAD_DOCUMENTAL_KEY,
                  udocTransformer.transform(udoc, getAppUser(request)));
              break;

            case ElementoCuadroClasificacion.TIPO_SERIE:
              SerieToPO serieTransformer = SerieToPO.getInstance(services);
              SerieVO serie = getGestionSeriesBI(request).getSerie(idObjeto);
              request.setAttribute(
                  DocumentosConstants.SERIE_KEY,
                  serieTransformer.transform(serie, getAppUser(request)));
              break;
          }
        }
      }

      setReturnActionFordward(request, mapping.findForward("editar_documento"));
    } catch (DocElectronicosException e) {
      guardarError(request, e);
      goBackExecuteLogic(mapping, form, request, response);
    }
  }
Пример #4
0
  public void retrieveCodeLogic(
      ActionMapping mappings,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response,
      String idDocumento,
      String idObjeto,
      String paramTipoObjeto) {
    if (logger.isInfoEnabled()) logger.info("Id Documento: " + idDocumento);

    ActionErrors errors = getErrors(request, true);

    // Leer el tipo de objeto
    int tipoObjeto = TypeConverter.toInt(paramTipoObjeto, -1);
    if (tipoObjeto < 0) {
      Integer tipoObjetoInteger =
          (Integer) getFromTemporalSession(request, DocumentosConstants.OBJECT_TYPE_KEY);
      tipoObjeto =
          (tipoObjetoInteger != null ? tipoObjetoInteger.intValue() : TipoObjeto.DESCRIPTOR);
    }
    if (logger.isInfoEnabled()) logger.info("Tipo Objeto: " + tipoObjeto);

    // Leo el parametro para saber si estoy en la descripcion de la ficha de
    // documentos con enlace interno.
    int descripcion = TypeConverter.toInt(request.getParameter("descripcion"), -1);

    ServiceRepository services = ServiceRepository.getInstance(getServiceClient(request));

    DocDocumentoVO documento = null;
    if (StringUtils.isNotBlank(idDocumento)) {

      // Servicio de gestión de documentos
      GestionDocumentosElectronicosBI docsBI = services.lookupGestionDocumentosElectronicosBI();

      // Leer la información del documento

      if (descripcion > 0)
        documento = docsBI.getDocumentoByIdInterno(tipoObjeto, idObjeto, idDocumento);
      else documento = docsBI.getDocumento(tipoObjeto, idObjeto, idDocumento);

      if (logger.isInfoEnabled()) logger.info("DocDocumentoVO: " + documento);

      // Guardar la información del documento
      ((DocumentoForm) form).set(documento);

      if (documento != null) {
        List listaDocumentos =
            getGestionDocumentosElectronicosBI(request)
                .getDocumentosVisiblesDesdeCuadro(
                    tipoObjeto, documento.getIdObjeto(), documento.getIdClfPadre());
        NavegadorElementosVO navegadorVO =
            new NavegadorElementosVO(listaDocumentos, documento.getId());

        request.setAttribute(DocumentosConstants.NAVEGADOR_DOCUMENTOS_KEY, navegadorVO);
      } else {
        errors.add(
            ActionErrors.GLOBAL_MESSAGE,
            new ActionError(DocumentosConstants.ERROR_DOC_ELECTRONICOS_DOCUMENTO_NO_ENCONTRADO));
      }

      // Carga la información del documento electrónico.
      request.setAttribute(DocumentosConstants.FILE_INFO_KEY, docsBI.getInfoFichero(documento));

      // Obtener la información del clasificador padre
      if (StringUtils.isNotBlank(documento.getIdClfPadre()))
        request.setAttribute(
            DocumentosConstants.FOLDER_KEY,
            docsBI.getClasificador(tipoObjeto, idObjeto, documento.getIdClfPadre()));
    } else {
      ((DocumentoForm) form).setIdObjeto(idObjeto);
      ((DocumentoForm) form).setTipoObjeto(tipoObjeto);
    }

    // Información del objeto
    if (tipoObjeto == TipoObjeto.DESCRIPTOR) {
      request.setAttribute(
          DocumentosConstants.DESCRIPTOR_KEY,
          getGestionDescripcionBI(request).getDescriptorExt(idObjeto));
    } else // if (tipoObjeto == TipoObjeto.ELEMENTO_CF)
    {
      ElementoCuadroClasificacionVO elemento =
          getGestionCuadroClasificacionBI(request)
              .getElementoCuadroClasificacion(documento.getIdObjeto());

      if (elemento != null) {
        switch (elemento.getTipo()) {
          case ElementoCuadroClasificacion.TIPO_UNIDAD_DOCUMENTAL:
            UnidadDocumentalToPO udocTransformer = new UnidadDocumentalToPO(services);
            UnidadDocumentalVO udoc =
                getGestionUnidadDocumentalBI(request).getUnidadDocumental(documento.getIdObjeto());
            request.setAttribute(
                DocumentosConstants.UNIDAD_DOCUMENTAL_KEY,
                udocTransformer.transform(udoc, getAppUser(request)));
            break;

          case ElementoCuadroClasificacion.TIPO_SERIE:
            SerieToPO serieTransformer = SerieToPO.getInstance(services);
            SerieVO serie = getGestionSeriesBI(request).getSerie(idObjeto);

            setInTemporalSession(
                request,
                DocumentosConstants.SERIE_KEY,
                serieTransformer.transform(serie, getAppUser(request)));
            break;
        }
      } else {
        errors.add(
            ActionErrors.GLOBAL_MESSAGE,
            new ActionError(DocumentosConstants.ERROR_DOC_ELECTRONICOS_DOCUMENTO_NO_ENCONTRADO));
      }
    }

    if (errors != null && !errors.isEmpty()) {
      ErrorsTag.saveErrors(request, errors);

      goBackExecuteLogic(mappings, form, request, response);
    } else {
      setReturnActionFordward(request, mappings.findForward("ver_documento"));
    }
  }