001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.storage.sql;
013
014/**
015 * The different types of selections available, and information about what they correspond to in the database.
016 */
017public enum SelectionType {
018
019    /**
020     * Selection for the children of a given parent id.
021     */
022    CHILDREN(Model.HIER_TABLE_NAME, Model.HIER_PARENT_KEY, Model.HIER_CHILD_NAME_KEY, Model.HIER_CHILD_ISPROPERTY_KEY,
023            Invalidations.PARENT),
024
025    /**
026     * Selection for the versions of a given version series.
027     */
028    SERIES_VERSIONS(Model.VERSION_TABLE_NAME, Model.VERSION_VERSIONABLE_KEY, null, null, "__SERIES_VERSIONS__"),
029
030    /**
031     * Selection for the proxies of a given version series.
032     */
033    SERIES_PROXIES(Model.PROXY_TABLE_NAME, Model.PROXY_VERSIONABLE_KEY, null, null, Invalidations.SERIES_PROXIES),
034
035    /**
036     * Selection for the proxies of a given target.
037     */
038    TARGET_PROXIES(Model.PROXY_TABLE_NAME, Model.PROXY_TARGET_KEY, null, null, Invalidations.TARGET_PROXIES);
039
040    /**
041     * The table name for this selection.
042     */
043    public final String tableName;
044
045    /**
046     * The key for the selection id.
047     * <p>
048     * For instance for a children selection this is the parent id.
049     */
050    public final String selKey;
051
052    /**
053     * The key to use to additionally filter on fragment values.
054     * <p>
055     * For instance for a children selection this is the child name.
056     */
057    public final String filterKey;
058
059    /**
060     * The key to use to additionally filter on criterion.
061     * <p>
062     * For instance for a children selection this is the complex property flag.
063     * <p>
064     * This can be {@code null} for no criterion filtering.
065     */
066    public final String criterionKey;
067
068    /**
069     * Pseudo-table to use to notify about selection invalidation.
070     */
071    public final String invalidationTableName;
072
073    private SelectionType(String tableName, String selKey, String filterKey, String criterionKey,
074            String invalidationTableName) {
075        this.tableName = tableName;
076        this.selKey = selKey;
077        this.filterKey = filterKey;
078        this.criterionKey = criterionKey;
079        this.invalidationTableName = invalidationTableName;
080    }
081}