001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.storage.sql;
020
021/**
022 * Abstract representation of the database-level column types.
023 */
024public enum ColumnSpec {
025
026    // ----- schema-based columns -----
027    STRING(), // may be VARCHAR or CLOB depending on length
028    BOOLEAN(), //
029    LONG(), //
030    DOUBLE(), //
031    TIMESTAMP(), //
032    BLOBID(), // attached files
033    BLOB, // byte array, for key/value store column
034    ARRAY_STRING(), // may be VARCHAR or CLOB array depending on length
035    ARRAY_BOOLEAN(), //
036    ARRAY_LONG(), //
037    ARRAY_DOUBLE(), //
038    ARRAY_TIMESTAMP(), //
039    ARRAY_BLOBID(), // attached files array
040    ARRAY_INTEGER(),
041    // ----- system columns -----
042    NODEID, // node id primary generated key
043    NODEIDFK, // fk to main node id, not nullable (frag id)
044    NODEIDFKNP, // fk to main node id, not nullable, not primary
045    NODEIDFKMUL, // fk to main node id, not nullable, non-unique
046    NODEIDFKNULL, // fk to main node id, nullable
047    NODEIDPK, // node id primary key, but not a fk (locks)
048    NODEVAL, // same type as node id, not a fk (versionable, cluster...)
049    NODEARRAY, // array of node if supported
050    SYSNAME, // system names (type names etc)
051    SYSNAMEARRAY, // system names array (mixins), string if not suppported
052    TINYINT, // cluster inval kind
053    INTEGER, // complex prop order, ordered doc
054    AUTOINC, // auto-incremented integer (identity, serial, etc.)
055    FTINDEXED, // summary ft column being indexed
056    FTSTORED, // individual ft column
057    CLUSTERNODE, // cluster node id
058    CLUSTERFRAGS; // list of fragments impacted, for clustering
059
060    /**
061     * Checks if this spec holds a Nuxeo unique id (usually UUID).
062     */
063    public boolean isId() {
064        switch (this) {
065        case NODEID:
066        case NODEIDFK:
067        case NODEIDFKNP:
068        case NODEIDFKMUL:
069        case NODEIDFKNULL:
070        case NODEIDPK:
071        case NODEVAL:
072            return true;
073        default:
074            return false;
075        }
076    }
077
078}