001: package net.sourceforge.squirrel_sql.plugins.dbcopy.prefs;
002:
003: /*
004: * Copyright (C) 2005 Rob Manning
005: * manningr@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: import java.io.Serializable;
022:
023: /**
024: * A bean class to store preferences for the DB Copy plugin.
025: */
026: public class DBCopyPreferenceBean implements Cloneable, Serializable {
027: static final String UNSUPPORTED = "Unsupported";
028:
029: /** Client Name. */
030: private String _clientName;
031:
032: /** Client version. */
033: private String _clientVersion;
034:
035: /** whether or not to use a local file to stream bytes for copying blobs */
036: private boolean useFileCaching = true;
037:
038: /** How many bytes to read/write at a time from memory to disk and back */
039: private int fileCacheBufferSize = 8192;
040:
041: /** Use the truncate command instead of delete if the database supports it */
042: private boolean useTruncate = true;
043:
044: /** whether or not commit after each statement on the destination connection */
045: private boolean autoCommitEnabled = true;
046:
047: /** How many statements to issue before committing when auto-commit is off */
048: private int commitCount = 100;
049:
050: /** whether or not to write each SQL executed to a script file */
051: private boolean writeScript = false;
052:
053: /** whether or not to copy the records from the source to dest table */
054: private boolean copyData = true;
055:
056: /** whether or not to copy the index definitions */
057: private boolean copyIndexDefs = true;
058:
059: /** whether or not to copy the foreign keys */
060: private boolean copyForeignKeys = true;
061:
062: /** whether or not to copy the primary keys */
063: private boolean copyPrimaryKeys = true;
064:
065: /** whether or not to discard logically identical index defs */
066: private boolean pruneDuplicateIndexDefs = true;
067:
068: /** whether or not to commit after issuing a create table statement */
069: private boolean commitAfterTableDefs = true;
070:
071: /** whether to prompt the user for dest db dialect, or try to auto-detect */
072: private boolean promptForDialect = false;
073:
074: /** whether or not to check column names in source db for keywords in dest */
075: private boolean checkKeywords = true;
076:
077: /** whether or not to test column names in the destination database */
078: private boolean testColumnNames = true;
079:
080: /** default number of records to retrieve from the database in selects */
081: private int selectFetchSize = 1000;
082:
083: /** default for whether or not to delay between copying objects */
084: private boolean delayBetweenObjects = false;
085:
086: /** default number of milliseconds to wait between copying tables */
087: private long tableDelayMillis = 0;
088:
089: /** default number of milliseconds to wait between copying records */
090: private long recordDelayMillis = 0;
091:
092: public DBCopyPreferenceBean() {
093: super ();
094: }
095:
096: /**
097: * Return a copy of this object.
098: */
099: public Object clone() {
100: try {
101: return super .clone();
102: } catch (CloneNotSupportedException ex) {
103: throw new InternalError(ex.getMessage()); // Impossible.
104: }
105: }
106:
107: /**
108: * Retrieve the client to use. This is only
109: * used if <TT>useAnonymousClient</TT> is false.
110: *
111: * @return Client name.
112: */
113: public String getClientName() {
114: return _clientName;
115: }
116:
117: /**
118: * Set the client name.
119: *
120: * @param value Client name
121: */
122: public void setClientName(String value) {
123: _clientName = value;
124: }
125:
126: /**
127: * Retrieve the client version to use. This is only
128: * used if <TT>useAnonymousLogon</TT> is false.
129: *
130: * @return Client version.
131: */
132: public String getClientVersion() {
133: return _clientVersion;
134: }
135:
136: /**
137: * Set the client version.
138: *
139: * @param value Client version
140: */
141: public void setClientVersion(String value) {
142: _clientVersion = value;
143: }
144:
145: /**
146: * Sets whether or not to use a local file to stream bytes for copying blobs
147: * @param useFileCaching The useFileCaching to set.
148: */
149: public void setUseFileCaching(boolean useFileCaching) {
150: this .useFileCaching = useFileCaching;
151: }
152:
153: /**
154: * Returns a boolean value indicating whether or not to use a local file
155: * to stream bytes for copying blobs
156: *
157: * @return Returns the useFileCaching.
158: */
159: public boolean isUseFileCaching() {
160: return useFileCaching;
161: }
162:
163: /**
164: * @param fileCacheBufferSize The fileCacheBufferSize to set.
165: */
166: public void setFileCacheBufferSize(int fileCacheBufferSize) {
167: this .fileCacheBufferSize = fileCacheBufferSize;
168: }
169:
170: /**
171: * @return Returns the fileCacheBufferSize.
172: */
173: public int getFileCacheBufferSize() {
174: return fileCacheBufferSize;
175: }
176:
177: /**
178: * @param useTruncate The useTruncate to set.
179: */
180: public void setUseTruncate(boolean useTruncate) {
181: this .useTruncate = useTruncate;
182: }
183:
184: /**
185: * @return Returns the useTruncate.
186: */
187: public boolean isUseTruncate() {
188: return useTruncate;
189: }
190:
191: /**
192: * @param autoCommitEnabled The autoCommitEnabled to set.
193: */
194: public void setAutoCommitEnabled(boolean autoCommitEnabled) {
195: this .autoCommitEnabled = autoCommitEnabled;
196: }
197:
198: /**
199: * @return Returns the autoCommitEnabled.
200: */
201: public boolean isAutoCommitEnabled() {
202: return autoCommitEnabled;
203: }
204:
205: /**
206: * @param commitCount The commitCount to set.
207: */
208: public void setCommitCount(int commitCount) {
209: this .commitCount = commitCount;
210: }
211:
212: /**
213: * @return Returns the commitCount.
214: */
215: public int getCommitCount() {
216: return commitCount;
217: }
218:
219: /**
220: * @param writeScript The writeScript to set.
221: */
222: public void setWriteScript(boolean writeScript) {
223: this .writeScript = writeScript;
224: }
225:
226: /**
227: * @return Returns the writeScript.
228: */
229: public boolean isWriteScript() {
230: return writeScript;
231: }
232:
233: /**
234: * @param copyData The copyData to set.
235: */
236: public void setCopyData(boolean copyData) {
237: this .copyData = copyData;
238: }
239:
240: /**
241: * @return Returns the copyData.
242: */
243: public boolean isCopyData() {
244: return copyData;
245: }
246:
247: /**
248: * @param copyIndexDefs The copyIndexDefs to set.
249: */
250: public void setCopyIndexDefs(boolean copyIndexDefs) {
251: this .copyIndexDefs = copyIndexDefs;
252: }
253:
254: /**
255: * @return Returns the copyIndexDefs.
256: */
257: public boolean isCopyIndexDefs() {
258: return copyIndexDefs;
259: }
260:
261: /**
262: * @param copyForeignKeys The copyForeignKeys to set.
263: */
264: public void setCopyForeignKeys(boolean copyForeignKeys) {
265: this .copyForeignKeys = copyForeignKeys;
266: }
267:
268: /**
269: * @return Returns the copyForeignKeys.
270: */
271: public boolean isCopyForeignKeys() {
272: return copyForeignKeys;
273: }
274:
275: /**
276: * @param pruneDuplicateIndexDefs The pruneDuplicateIndexDefs to set.
277: */
278: public void setPruneDuplicateIndexDefs(
279: boolean pruneDuplicateIndexDefs) {
280: this .pruneDuplicateIndexDefs = pruneDuplicateIndexDefs;
281: }
282:
283: /**
284: * @return Returns the pruneDuplicateIndexDefs.
285: */
286: public boolean isPruneDuplicateIndexDefs() {
287: return pruneDuplicateIndexDefs;
288: }
289:
290: /**
291: * @param commitAfterTableDefs The commitAfterTableDefs to set.
292: */
293: public void setCommitAfterTableDefs(boolean commitAfterTableDefs) {
294: this .commitAfterTableDefs = commitAfterTableDefs;
295: }
296:
297: /**
298: * @return Returns the commitAfterTableDefs.
299: */
300: public boolean isCommitAfterTableDefs() {
301: return commitAfterTableDefs;
302: }
303:
304: /**
305: * @param promptForDialect The promptForDialect to set.
306: */
307: public void setPromptForDialect(boolean promptForDialect) {
308: this .promptForDialect = promptForDialect;
309: }
310:
311: /**
312: * @return Returns the promptForDialect.
313: */
314: public boolean isPromptForDialect() {
315: return promptForDialect;
316: }
317:
318: /**
319: * @param checkKeywords The checkKeywords to set.
320: */
321: public void setCheckKeywords(boolean checkKeywords) {
322: this .checkKeywords = checkKeywords;
323: }
324:
325: /**
326: * @return Returns the checkKeywords.
327: */
328: public boolean isCheckKeywords() {
329: return checkKeywords;
330: }
331:
332: /**
333: * @param testColumnNames The testColumnNames to set.
334: */
335: public void setTestColumnNames(boolean testColumnNames) {
336: this .testColumnNames = testColumnNames;
337: }
338:
339: /**
340: * @return Returns the testColumnNames.
341: */
342: public boolean isTestColumnNames() {
343: return testColumnNames;
344: }
345:
346: /**
347: * @param copyPrimaryKeys The copyPrimaryKeys to set.
348: */
349: public void setCopyPrimaryKeys(boolean copyPrimaryKeys) {
350: this .copyPrimaryKeys = copyPrimaryKeys;
351: }
352:
353: /**
354: * @return Returns the copyPrimaryKeys.
355: */
356: public boolean isCopyPrimaryKeys() {
357: return copyPrimaryKeys;
358: }
359:
360: /**
361: * @param selectFetchSize The selectFetchSize to set.
362: */
363: public void setSelectFetchSize(int selectFetchSize) {
364: this .selectFetchSize = selectFetchSize;
365: }
366:
367: /**
368: * @return Returns the selectFetchSize.
369: */
370: public int getSelectFetchSize() {
371: return selectFetchSize;
372: }
373:
374: /**
375: * @param tableDelayMillis The tableDelayMillis to set.
376: */
377: public void setTableDelayMillis(long tableDelayMillis) {
378: this .tableDelayMillis = tableDelayMillis;
379: }
380:
381: /**
382: * @return Returns the tableDelayMillis.
383: */
384: public long getTableDelayMillis() {
385: return tableDelayMillis;
386: }
387:
388: /**
389: * @param recordDelayMillis The recordDelayMillis to set.
390: */
391: public void setRecordDelayMillis(long recordDelayMillis) {
392: this .recordDelayMillis = recordDelayMillis;
393: }
394:
395: /**
396: * @return Returns the recordDelayMillis.
397: */
398: public long getRecordDelayMillis() {
399: return recordDelayMillis;
400: }
401:
402: /**
403: * @param delayBetweenObjects The delayBetweenObjects to set.
404: */
405: public void setDelayBetweenObjects(boolean delayBetweenObjects) {
406: this .delayBetweenObjects = delayBetweenObjects;
407: }
408:
409: /**
410: * @return Returns the delayBetweenObjects.
411: */
412: public boolean isDelayBetweenObjects() {
413: return delayBetweenObjects;
414: }
415:
416: }
|