Problema al tipificar doc en Wizard entre paso y paso

cancel
Showing results for 
Search instead for 
Did you mean: 
magarcia_sm
Active Member II

Problema al tipificar doc en Wizard entre paso y paso

Hola gente

Tengo un problema con el Wizard que estoy haciendo. Los pasos son los siguientes, en el STEP1 escojo el Type que le quiero dar al documento, en el STEP2 con el documento ya tipificado aparecerían los campos de las propiedades para poder rellenar o cambiar y luego ya vendría el FINISH que guardaría los metadatos y saldría del Wizard.

El problema que tengo es que cuando paso del STEP1 al STEP2 y se tipifica el doc, los campos que aparecen no son los del documento ya tipificado, si no los que tenía antes. El documento tipifica bien porque ya terminado el Wizard cuando voy a los detalles del documento, si que aparecen las propiedades correspondientes al Type que se le ha dado.
La pregunta es la siguiente ¿Como tengo que hacer para que de un step a otro me pille los cambios realizados al tipificar el documento y los muestre?

Dejo aquí el código, a ver si da alguna pista.

Muchas Gracias!

web-client-config-custom.xml (Pongo solo el código del Wizard)
   
   <!– Wizards –>
   <config>
      <wizards>
         <!– Definition of the Interview Setup wizard –>
         <wizard
            name="tipificarDoc"
            managed-bean="tipificarDocWizard"
            title-id="wizard_title_id_tipificar_documento"
            description-id="wizard_description_id_tipificar_documento"
            icon="/images/icons/interview_setup_large.gif">
            
            <step name="establecerTipo" title-id="step_title_id_establecer_tipo" description-id="step_description_id_establecer_tipo">
               <page
                  path="/jsp/extension/wizards/step1-asignarTipo.jsp"
                  title-id="page_title_id_seleccionar_tipo"
                  description-id="page_description_id_seleccionar_tipo"
                  instruction-id="default_instruction" />
            </step>
                     
            <step name="añadirMetadatos" title-id="step_title_id_establecer_metadatos" description-id="step_description_id_establecer_metadatos">
               <page
                  path="/jsp/extension/wizards/step2-asignarMetadatos.jsp"
                  title-id="page_title_id_añadir_metadatos"
                  description-id="page_description_id_añadir_metadatos"
                  instruction-id="default_instruction" />
            </step>
            
         </wizard>
      </wizards>
   </config>


step1-asignarTipo.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %>


<h:outputText value="Escoje un tipo de la lista: " />

<h:selectOneMenu value="#{tipificarDocWizard.tipoDoc}">
   <f:selectItems value="#{tipificarDocWizard.listType}" />                       
</h:selectOneMenu>


step2-asignarMetadatos.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %>


<h:outputText value="Metadatos del documento: " />
<r:propertySheetGrid id="content-props" value="#{tipificarDocWizard.newNodeDOC}"                                     
                var="editContentProps" columns="1" externalConfig="true"
                     rendered="#{!empty tipificarDocWizard.newNodeDOC}"
                     finishButtonId="next-button" />


TipificarDocWizard.java

   @Override
   public void init(Map<String, String> parameters) {
      super.init(parameters);

      Object currentNode = this.getNode();

      if (this.listType != null) {
         this.listType.clear();
         this.cargarTipos();
      } else {
         this.cargarTipos();
      }
      this.newNodeDOC = null;
      this.newNodeDOC = this.getNode();
   }

   /************************************************************************************
    ************************************************************************************
    ************************************************************************************/

   public void setupContentAction(ActionEvent event) {
      this.browseBean.setupContentAction(event);

   }
   public void setContentService(ContentService contentService) {
      this.contentService = contentService;
   }
   protected ContentService getContentService() {
      if (contentService == null) {
         contentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance())
               .getContentService();
      }
      return contentService;
   }
   public void setAuthenticationService(AuthenticationService authenticationService) {
      this.authenticationService = authenticationService;
   }

   /***********************************************************************************
    * Método que al detectar el boton next, dependiendo del step donde esté
    * situado realizara el case que lo identifica.
    ***********************************************************************************/

   @Override
   public String next() {
      int step = Application.getWizardManager().getCurrentStep();
      switch (step) {
      case 2: {
         this.asignarTipo();
         System.out.println("STEP: " + step + "———TIPO ASIGNADO AL DOCUMENTO———");
         break;
      }
      case 3: {
         System.out.println("STEP: " + step + "———INTRODUCIR METADATOS———");
         break;
      }
      default: {
         System.out.println("Paso de Wizard Incorrecto" + step);
         break;
      }
      }
      return super.next();
   }

   /************************************************************************************
    * Método que nos asignará el tipo de documento dependiendo de si se ha
    * seleccionado Factura o Albarán
    *
    * @return
    ***********************************************************************************/

   public void asignarTipo() {
      if (this.tipoDoc.equals("Albaran")) {
         if (this.asignarAlbaran()) {
            System.out.println("Albaran tipificado");
         } else {
            System.out.println("Albarán no tipificado");
         }
      }
      if (this.tipoDoc.equals("Factura")) {
         if (this.asignarAlbaran()) {
            System.out.println("Factura tipificado");
         } else {
            System.out.println("Factura no tipificado");
         }
      }
   }

   /**********************************************************************************
    * Este proceso tipifica el documento como tipo Factura
    *
    * @return
    ***********************************************************************************/
   public void asignarFactura() {
      if (this.newNodeDOC == null) {
         return false;
      } else {
         QName MY_TYPE = QName.createQName("factura.model", "factura");
         getNodeService().setType(this.newNodeDOC.getNodeRef(), MY_TYPE);
         return true;
      }
   }

   /***********************************************************************************
    * Este proceso tipifica el documento como tipo Albarán
    *
    * @return
    ***********************************************************************************/

   public boolean asignarAlbaran() {
      if (this.newNodeDOC == null) {
         return false;
      } else {
         QName MY_TYPE = QName.createQName("albaran.model", "albaran");
         getNodeService().setType(this.newNodeDOC.getNodeRef(), MY_TYPE);
         return true;
      }
   }

   /******************************************************************************
    * función que carga el tipo de documentos
    ******************************************************************************/
   public void cargarTipos() {
      this.listType.add(new SelectItem("Factura"));
      this.listType.add(new SelectItem("Albaran"));
   }

   protected AuthenticationService getAuthenticationService() {
      if (authenticationService == null) {
         authenticationService = Repository
               .getServiceRegistry(FacesContext.getCurrentInstance())
               .getAuthenticationService();
      }
      return authenticationService;
   }

   /*******************************************************************************
    * Método que guarda los metadatos del documento introducidos en los campos.
    *******************************************************************************/
   private void guardarMetadatos() {

      NodeRef nodeRef = this.newNodeDOC.getNodeRef();
      Map<String, Object> editedProps = this.newNodeDOC.getProperties();
      Map<QName, Serializable> repoProps = this.getNodeService().getProperties(nodeRef);
      Iterator<String> iterProps = editedProps.keySet().iterator();
      while (iterProps.hasNext()) {
         String propName = iterProps.next();
         QName qname = QName.createQName(propName);
         Serializable propValue = (Serializable) editedProps.get(propName);
         
         if (propValue instanceof String) {
            PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
            if (((String) propValue).length() == 0) {
               if (propDef != null) {
                  if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.INT)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.LONG)) {
                     propValue = null;
                  }
               }
            }
            // handle locale strings to Locale objects
            else if (propDef != null
                  && propDef.getDataType().getName().equals(DataTypeDefinition.LOCALE)) {
               propValue = I18NUtil.parseLocale((String) propValue);
            }
         }

         repoProps.put(qname, propValue);
      }

      this.getNodeService().setProperties(nodeRef, repoProps);

      logger.info("Propiedades newNodeDoc: " + this.newNodeDOC.getProperties());
   }

   /*******************************************************************************
    * Método que finaliza el wizard
    *******************************************************************************/
   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception {
      // TODO Auto-generated method stub

      this.guardarMetadatos();
      System.out.println("——-METADATOS GUARDADOS—–FIN DEL WIZARD (finishImpl)——–");
      return null;
   }

   /*******************************************************************************
    *************************** GETTERS AND SETTERS *******************************
    *******************************************************************************/
     …….
     …….

1 Reply
venzia
Senior Member

Re: Problema al tipificar doc en Wizard entre paso y paso

Hola de nuevo!,
Por un lado tengo curiosidad por saber la razón por la que no se utiliza el wizard que trae Alfresco para tal efecto durante la creación/subida de contenidos.
Por otro, podrías compartir información de los outputs del logger/println al realizar el proceso?

Saludos!