Revision: 3612
Author: [email protected]
Date: Mon Jun 14 07:57:56 2010
Log: NEW - bug 2458: Create Critic Manager
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2458

Added in a critic to warn users if their objects physical names do not contain only alpha-numeric characters or underscores.
http://code.google.com/p/power-architect/source/detail?r=3612

Added:
/trunk/src/main/java/ca/sqlpower/architect/ddl/critic/impl/AlphaNumericNameCritic.java
Modified:
 /trunk/src/main/java/ca/sqlpower/architect/ddl/critic/CriticManager.java

=======================================
--- /dev/null
+++ /trunk/src/main/java/ca/sqlpower/architect/ddl/critic/impl/AlphaNumericNameCritic.java Mon Jun 14 07:57:56 2010
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.ddl.critic.impl;
+
+import java.util.regex.Pattern;
+
+/**
+ * A generic critic that creates criticisms if the name of an object is not made
+ * of alpha-numeric characters.
+ */
+public class AlphaNumericNameCritic extends PhysicalNameCritic {
+
+    public AlphaNumericNameCritic() {
+        super(StarterPlatformTypes.GENERIC.getName(),
+ Pattern.compile("^[a-z_][a-z0-9_]*$", Pattern.CASE_INSENSITIVE),
+                Integer.MAX_VALUE);
+        setName("Non-alpha-numeric physical names");
+    }
+
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ddl/critic/CriticManager.java Mon Jun 14 07:39:24 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ddl/critic/CriticManager.java Mon Jun 14 07:57:56 2010
@@ -26,6 +26,7 @@

 import ca.sqlpower.architect.ddl.critic.CriticAndSettings.Severity;
import ca.sqlpower.architect.ddl.critic.CriticAndSettings.StarterPlatformTypes;
+import ca.sqlpower.architect.ddl.critic.impl.AlphaNumericNameCritic;
 import ca.sqlpower.architect.ddl.critic.impl.EmptyRelationshipCritic;
 import ca.sqlpower.architect.ddl.critic.impl.MySQLCommentCritic;
 import ca.sqlpower.architect.ddl.critic.impl.OraclePhysicalNameCritic;
@@ -58,6 +59,7 @@
                 new PrimaryKeyCritic(),
                 new RelationshipMappingTypeCritic(),
                 new EmptyRelationshipCritic(),
+                new AlphaNumericNameCritic(),
                 new OraclePhysicalNameCritic(),
                 new MySQLCommentCritic()
                 ));

Reply via email to