001: /*
002: * Copyright 2006 Le Duc Bao, Ralf Joachim
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * 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, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package org.castor.ddlgen.engine.sapdb;
017:
018: import java.util.Date;
019:
020: import org.castor.ddlgen.AbstractGenerator;
021: import org.castor.ddlgen.Configuration;
022: import org.castor.ddlgen.DDLGenConfiguration;
023: import org.castor.ddlgen.DDLWriter;
024: import org.castor.ddlgen.MappingHelper;
025:
026: /**
027: * Generator for SapDB.
028: *
029: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
030: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
031: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
032: * @since 1.1
033: */
034: public final class SapdbGenerator extends AbstractGenerator {
035: //--------------------------------------------------------------------------
036:
037: /** Name of database engine. */
038: public static final String NAME = "sapdb";
039:
040: /** Path to specific configuration for generator. */
041: public static final String ENGINE_CONFIG_PATH = "org/castor/ddlgen/engine/"
042: + NAME + "/";
043:
044: /** Filename of specific configuration for generator. */
045: public static final String ENGINE_CONFIG_NAME = NAME
046: + ".properties";
047:
048: //--------------------------------------------------------------------------
049:
050: /**
051: * Constructor for SapdbGenerator.
052: *
053: * @param configuration Configuration to use by the generator.
054: */
055: public SapdbGenerator(final DDLGenConfiguration configuration) {
056: super (configuration);
057: }
058:
059: /**
060: * {@inheritDoc}
061: */
062: public void initialize() {
063: setMappingHelper(new MappingHelper());
064: setTypeMapper(new SapdbTypeMapper(getConfiguration()));
065: setSchemaFactory(new SapdbSchemaFactory());
066: }
067:
068: //--------------------------------------------------------------------------
069:
070: /**
071: * {@inheritDoc}
072: */
073: public String getEngineName() {
074: return NAME;
075: }
076:
077: /**
078: * {@inheritDoc}
079: */
080: public String getEngineConfigPath() {
081: return ENGINE_CONFIG_PATH;
082: }
083:
084: /**
085: * {@inheritDoc}
086: */
087: public String getEngineConfigName() {
088: return ENGINE_CONFIG_NAME;
089: }
090:
091: //--------------------------------------------------------------------------
092:
093: /**
094: * {@inheritDoc}
095: */
096: public void generateHeader(final DDLWriter writer) {
097: Configuration conf = getConfiguration();
098:
099: writer.println("/* ");
100: writer.println(new Date());
101: writer.println("Castor DDL Generator from mapping for SapDB");
102: writer.println(conf.getStringValue(
103: DDLGenConfiguration.HEADER_COMMENT_KEY, ""));
104: writer.println("*/");
105: }
106:
107: //--------------------------------------------------------------------------
108: }
|