001/*
002 * (C) Copyright 2010-2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thierry Delprat
016 *     Florent Guillaume
017 */
018package org.nuxeo.ecm.directory.sql;
019
020import java.io.Serializable;
021
022import org.nuxeo.common.xmap.annotation.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024import org.nuxeo.ecm.core.storage.sql.jdbc.db.Column;
025import org.nuxeo.ecm.core.storage.sql.jdbc.db.Table;
026import org.nuxeo.ecm.directory.DirectoryException;
027
028@XObject(value = "staticFilter")
029public class SQLStaticFilter implements Serializable {
030
031    private static final long serialVersionUID = 1L;
032
033    @XNode("column")
034    protected String column;
035
036    @XNode("operator")
037    protected String operator = "=";
038
039    @XNode("value")
040    protected String value;
041
042    @XNode("type")
043    protected String type = "string";
044
045    public String getType() {
046        return type;
047    }
048
049    public String getColumn() {
050        return column;
051    }
052
053    public String getOperator() {
054        return operator;
055    }
056
057    public String getValue() {
058        return value;
059    }
060
061    public Column getDirectoryColumn(Table table, boolean nativeCase) throws DirectoryException {
062        return table.getColumn(column);
063    }
064
065    public SQLStaticFilter clone() {
066        SQLStaticFilter clone = new SQLStaticFilter();
067        clone.column = column;
068        clone.operator = operator;
069        clone.value = value;
070        clone.type = type;
071        return clone;
072    }
073
074}