1   /*
2    * org.riverock.dbrevision - Database revision engine
3    * For more information about DbRevision, please visit project site
4    * http://www.riverock.org
5    *
6    * Copyright (C) 2006-2006, Riverock Software, All Rights Reserved.
7    *
8    * Riverock - The Open-source Java Development Community
9    * http://www.riverock.org
10   *
11   *
12   * This library is free software; you can redistribute it and/or
13   * modify it under the terms of the GNU Lesser General Public
14   * License as published by the Free Software Foundation; either
15   * version 2.1 of the License, or (at your option) any later version.
16   *
17   * This library is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20   * Lesser General Public License for more details.
21   *
22   * You should have received a copy of the GNU Lesser General Public
23   * License along with this library; if not, write to the Free Software
24   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25   */
26  package org.riverock.dbrevision.system;
27  
28  import java.io.FileInputStream;
29  
30  import org.riverock.dbrevision.annotation.schema.db.DbSchema;
31  import org.riverock.dbrevision.annotation.schema.db.DbTable;
32  import org.riverock.dbrevision.annotation.schema.db.DbView;
33  import org.riverock.dbrevision.utils.Utils;
34  
35  /**
36   * Author: mill
37   * Date: Nov 28, 2002
38   * Time: 3:10:19 PM
39   *
40   * $Id: CheckLengthName.java 1141 2006-12-14 14:43:29Z serg_main $
41   */
42  /**
43   * Проверка имен таблиц и view на превышение 18 символов. Данное ограничение есть в IBM DB2,
44   * в остальных базах длина имен таблиц и view может быть больше
45   */
46  public class CheckLengthName {
47  
48      public CheckLengthName() {
49      }
50  
51      public static void main(String args[]) throws Exception {
52  
53          System.out.println("Unmarshal data from file");
54          FileInputStream stream = new FileInputStream("webmill-schema.xml");
55          DbSchema millSchema = Utils.getObjectFromXml(DbSchema.class, stream);
56  
57          for (DbTable table : millSchema.getTables()) {
58              if (table.getName().length() > 18)
59                  System.out.println("Name of table '" + table.getName() +
60                      "' is wrong. Exceed " + (table.getName().length() - 18) + " of chars");
61          }
62  
63          for (DbView view : millSchema.getViews()) {
64              if (view.getName().length() > 18)
65                  System.out.println("Name of view '" + view.getName() +
66                      "' is wrong. Exceed " + (view.getName().length() - 18) + " of chars");
67          }
68      }
69  }