001: /*
002: * Copyright (C) 2007 Rob Manning
003: * manningr@users.sourceforge.net
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019: package net.sourceforge.squirrel_sql.fw.dialects;
020:
021: import java.sql.DatabaseMetaData;
022:
023: /**
024: * A simple object to store user preferences regarding contraint info.
025: * When we are generating a create script, we want to take into account the
026: * user's preferences. However, when showing the source for constraints, we
027: * want to show exactly what is in the database.
028: *
029: * @author manningr
030: */
031: public class CreateScriptPreferences {
032:
033: /*
034: public static final int NO_ACTION = 0;
035:
036: public static final int CASCADE_DELETE = 1;
037:
038: public static final int SET_DEFAULT = 2;
039:
040: public static final int SET_NULL = 3;
041: */
042:
043: private int deleteAction = DatabaseMetaData.importedKeyNoAction;
044:
045: private int updateAction = DatabaseMetaData.importedKeyNoAction;
046:
047: /**
048: * whether or not to override the delete referential action for FK defs.
049: */
050: private boolean deleteRefAction = false;
051:
052: /**
053: * whether or not to override the update referential action for FK defs.
054: */
055: private boolean updateRefAction = false;
056:
057: private boolean constraintsAtEnd;
058:
059: private boolean includeExternalReferences;
060:
061: private boolean qualifyTableNames;
062:
063: public void setDeleteRefAction(boolean deleteRefAction) {
064: this .deleteRefAction = deleteRefAction;
065: }
066:
067: public boolean isDeleteRefAction() {
068: return deleteRefAction;
069: }
070:
071: public void setDeleteAction(int action) {
072: this .deleteAction = action;
073: }
074:
075: public int getDeleteAction() {
076: return deleteAction;
077: }
078:
079: public void setUpdateAction(int updateAction) {
080: this .updateAction = updateAction;
081: }
082:
083: public int getUpdateAction() {
084: return updateAction;
085: }
086:
087: public void setUpdateRefAction(boolean updateRefAction) {
088: this .updateRefAction = updateRefAction;
089: }
090:
091: public boolean isUpdateRefAction() {
092: return updateRefAction;
093: }
094:
095: public String getRefActionByType(int type) {
096: switch (type) {
097: case DatabaseMetaData.importedKeyNoAction:
098: return "NO ACTION";
099: case DatabaseMetaData.importedKeyCascade:
100: return "CASCADE";
101: case DatabaseMetaData.importedKeySetDefault:
102: return "SET DEFAULT";
103: case DatabaseMetaData.importedKeySetNull:
104: return "SET NULL";
105: default:
106: return "NO ACTION";
107: }
108: }
109:
110: /**
111: * @param constraintsAtEnd the constraintsAtEnd to set
112: */
113: public void setConstraintsAtEnd(boolean constraintsAtEnd) {
114: this .constraintsAtEnd = constraintsAtEnd;
115: }
116:
117: /**
118: * @return the constraintsAtEnd
119: */
120: public boolean isConstraintsAtEnd() {
121: return constraintsAtEnd;
122: }
123:
124: /**
125: * @param includeExternalReferences the includeExternalReferences to set
126: */
127: public void setIncludeExternalReferences(
128: boolean includeExternalReferences) {
129: this .includeExternalReferences = includeExternalReferences;
130: }
131:
132: /**
133: * @return the includeExternalReferences
134: */
135: public boolean isIncludeExternalReferences() {
136: return includeExternalReferences;
137: }
138:
139: /**
140: * @param qualifyTableNames the qualifyTableNames to set
141: */
142: public void setQualifyTableNames(boolean qualifyTableNames) {
143: this .qualifyTableNames = qualifyTableNames;
144: }
145:
146: /**
147: * @return the qualifyTableNames
148: */
149: public boolean isQualifyTableNames() {
150: return qualifyTableNames;
151: }
152:
153: }
|