Ir al contenido
Otras versiones

Cargando…

Crear su propio plugin NodeProperties (personalizar los objetos de resultados de búsqueda)

Para crear sus propios resultados NodeProperties debe crear una nueva clase que implemente la interfaz NodeProperties: 

package com.openkm.plugin.properties;
import net.xeoh.plugins.base.Plugin;
import com.openkm.bean.Document;
import com.openkm.bean.Folder;
import com.openkm.bean.Mail;
import com.openkm.bean.Record;
import com.openkm.core.DatabaseException;
import com.openkm.core.PathNotFoundException;
import com.openkm.dao.bean.NodeDocument;
import com.openkm.dao.bean.NodeFolder;
import com.openkm.dao.bean.NodeMail;
import com.openkm.dao.bean.NodeRecord;
/**
* NodeProperties
*/
public interface NodeProperties extends Plugin {
/**
* Get document properties
*/
Document getProperties(String user, NodeDocument nDocument) throws PathNotFoundException, DatabaseException;
/**
* Get folder properties
*/
Folder getProperties(String user, NodeFolder nFolder) throws PathNotFoundException, DatabaseException;
/**
* Get mail properties
*/
Mail getProperties(String user, NodeMail nMail) throws PathNotFoundException, DatabaseException;
/**
* Get record properties
*/
Record getProperties(String user, NodeRecord nRecord) throws PathNotFoundException, DatabaseException;
}

La nueva clase debe cargarse en el paquete com.openkm.plugin.properties, porque el sistema de plugins de la aplicación intentará cargarla desde ahí. Consulte el ejemplo a continuación:

Método Tipo Descripción
getProperties(String user, NodeDocument nDocument) Document Define qué valores se cargan en el objeto Document devuelto por el motor de búsqueda.
getProperties(String user, NodeFolder nFolder) Return Define qué valores se cargan en el objeto Folder devuelto por el motor de búsqueda.
getProperties(String user, NodeMail nMail) Mail Define qué valores se cargan en el objeto Mail devuelto por el motor de búsqueda.
getProperties(String user, NodeRecord nRecord) Record Define qué valores se cargan en el objeto Record devuelto por el motor de búsqueda.

Ejemplo de implementación de NodeProperties

Sección titulada «Ejemplo de implementación de NodeProperties»
/**
* OpenKM, Open Document Management System (http://www.openkm.com)
* Copyright (c) 2006-2015 Paco Avila & Josep Llort
*
* No bytes were intentionally harmed during the development of this application.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.openkm.plugin.properties;
import com.openkm.bean.Document;
import com.openkm.bean.Folder;
import com.openkm.bean.Mail;
import com.openkm.bean.Record;
import com.openkm.core.DatabaseException;
import com.openkm.core.PathNotFoundException;
import com.openkm.dao.bean.NodeDocument;
import com.openkm.dao.bean.NodeFolder;
import com.openkm.dao.bean.NodeMail;
import com.openkm.dao.bean.NodeRecord;
import net.xeoh.plugins.base.annotations.PluginImplementation;
/**
*
* @author agallego
*
*/
@PluginImplementation
public class UuidNodeProperties implements NodeProperties {
/**
* Get document properties
*/
@Override
public Document getProperties(String user, NodeDocument nDocument) throws PathNotFoundException, DatabaseException {
Document node = new Document();
node.setUuid(nDocument.getUuid());
return node;
}
/**
* Get folder properties
*/
@Override
public Folder getProperties(String user, NodeFolder nFolder) throws PathNotFoundException, DatabaseException {
Folder node = new Folder();
node.setUuid(nFolder.getUuid());
return node;
}
/**
* Get mail properties
*/
@Override
public Mail getProperties(String user, NodeMail nMail) throws PathNotFoundException, DatabaseException {
Mail node = new Mail();
node.setUuid(nMail.getUuid());
return node;
}
/**
* Get record properties
*/
@Override
public Record getProperties(String user, NodeRecord nRecord) throws PathNotFoundException, DatabaseException {
Record node = new Record();
node.setUuid(nRecord.getUuid());
return node;
}
}