001: /*
002: * transformica 2
003: * Code generator
004: * Copyright (C) 2004 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.pavelvlasov.com/pv/content/menu.show@id=products.transformica.html
021: * e-Mail: support@hammurapi.biz
022: */
023: package biz.hammurapi.transformica.jdbc;
024:
025: import biz.hammurapi.sql.metadata.TableDescriptor;
026: import biz.hammurapi.transformica.Channel;
027: import biz.hammurapi.transformica.TransformSession;
028: import biz.hammurapi.util.Acceptor;
029: import biz.hammurapi.util.CompositeAcceptor;
030:
031: /**
032: * Transformation channel.
033: * @ant.element name="channel"
034: * @author Pavel Vlasov
035: * @version $Revision: 1.1 $
036: */
037: public class SchemaChannel extends Channel {
038:
039: private String catalog;
040: private String schema;
041:
042: /**
043: * @return Returns the catalog.
044: * @ant.ignore
045: */
046: public String getCatalog() {
047: return catalog;
048: }
049:
050: /**
051: * Process tables only from this catalog.
052: * @param catalog The catalog to set.
053: * @ant.non-required
054: */
055: public void setCatalog(String catalog) {
056: this .catalog = catalog;
057: }
058:
059: /**
060: * @return Returns the schema.
061: * @ant.ignore
062: */
063: public String getSchema() {
064: return schema;
065: }
066:
067: /**
068: * Schema name
069: * @param schema The schema to set.
070: * @ant.non-required
071: */
072: public void setSchema(String schema) {
073: this .schema = schema;
074: }
075:
076: /**
077: * Defines transformation channel.
078: * @ant.required
079: * @return
080: */
081: public SchemaChannel createTableChannel() {
082: SchemaChannel ret = new SchemaChannel(session);
083: channels.add(ret);
084: return ret;
085: }
086:
087: /**
088: * @param task
089: */
090: public SchemaChannel(TransformSession session) {
091: super (session);
092: }
093:
094: private boolean compositeAcceptorConfigured = false;
095:
096: public CompositeAcceptor getCompositeAcceptor() {
097: CompositeAcceptor ca = super .getCompositeAcceptor();
098: if (!compositeAcceptorConfigured) {
099: ca.addAcceptor(new Acceptor() {
100: public boolean accept(Object element) {
101: if (element instanceof TableDescriptor) {
102: TableDescriptor td = (TableDescriptor) element;
103: return (catalog == null || catalog.equals(td
104: .getCatalog()))
105: && (schema == null || schema.equals(td
106: .getSchema()));
107: } else {
108: return false;
109: }
110: }
111: });
112: compositeAcceptorConfigured = true;
113: }
114: return ca;
115: }
116:
117: /**
118: * Defines transformation channel.
119: * @ant.required
120: * @return
121: */
122: public SchemaChannel createSchemaChannel() {
123: SchemaChannel ret = new SchemaChannel(session);
124: channels.add(ret);
125: return ret;
126: }
127: }
|