05-07-2015 03:24 AM
<!– 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>
<%@ 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>
<%@ 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" />
@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 *******************************
*******************************************************************************/
…….
…….
06-12-2015 05:35 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.