You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2011/03/08 00:09:50 UTC

svn commit: r1079016 - in /portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils: io/DatabaseIO.java io/mapping.xml model/ model/ForeignKey.java

Author: ate
Date: Mon Mar  7 23:09:49 2011
New Revision: 1079016

URL: http://svn.apache.org/viewvc?rev=1079016&view=rev
Log:
JS2-1245: Update some external artifact dependencies to more recent and general available versions
See: https://issues.apache.org/jira/browse/JS2-1245
(continuation of previous svn commit r1079014 which "broke in half" because of incorrect end-of-lines in the mapping.xml file which was copied/modified from ddlutils mapping.xml)
- Replace the ddlutils svn r551445 build artifact patched with http://issues.apache.org/jira/browse/DDLUTILS-75#action_12521579 with a CGLIB runtime instrumented ddlutils-1.0.jar instead.
  ddlutils trunk (1.1-SNAPSHOT) does have DDLUTILS-75 fixed, however it is long time in coming to a release of that.
  Instead, this alternative runtime "patch" does the same trick based on the ddlutils-1.0 release, and should be good until ddltuils eventually might come out with a newer version.

Added:
    portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java   (with props)
    portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml   (with props)
    portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/
    portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java   (with props)

Added: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java?rev=1079016&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java (added)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java Mon Mar  7 23:09:49 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins.db.ddlutils.io;
+
+import org.xml.sax.InputSource;
+
+/**
+ * DatabaseIO extension to override the betwixt mapping.xml to allow overriding ddlutils 1.0 behavior at runtime for 
+ * https://issues.apache.org/jira/browse/DDLUTILS-75 which is fixed in ddlutils 1.1 but hasn't been released yet.
+ * @version $Id$
+ *
+ */
+public class DatabaseIO extends org.apache.ddlutils.io.DatabaseIO {
+
+	public DatabaseIO() {
+	}
+
+    /**
+     * Returns the commons-betwixt mapping file as an {@link org.xml.sax.InputSource} object.
+     * Per default, this will be classpath resource under the path <code>/mapping.xml</code>.
+     *  
+     * @return The input source for the mapping
+     */
+    protected InputSource getBetwixtMapping()
+    {
+        return new InputSource(getClass().getResourceAsStream("mapping.xml"));
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/DatabaseIO.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml?rev=1079016&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml (added)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml Mon Mar  7 23:09:49 2011
@@ -0,0 +1,99 @@
+<?xml version='1.0'?>
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+Patched version of original ddlutils 1.0 mapping.xml to allow overriding ddlutils 1.0 behavior at runtime for 
+https://issues.apache.org/jira/browse/DDLUTILS-75 which is fixed in ddlutils 1.1 but hasn't been released yet.
+
+-->
+<betwixt-config>
+  <class name="org.apache.ddlutils.model.Database">
+    <element name="database">
+      <attribute name="name"            property="name"/>
+      <attribute name="defaultIdMethod" property="idMethod"/>
+      <attribute name="version"         property="version"/>
+
+      <element property="tables" updater="addTable"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.Table">
+    <element name="table">
+      <attribute name="name"        property="name"/>
+      <attribute name="description" property="description"/>
+
+      <element property="columns"     updater="addColumn"/>
+      <element property="foreignKeys" updater="addForeignKey"/>
+      <element property="indices"     updater="addIndex"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.Column">
+    <element name="column">
+      <attribute name="name"          property="name"/>
+      <attribute name="primaryKey"    property="primaryKey"/>
+      <attribute name="required"      property="required"/>
+      <attribute name="type"          property="type"/>
+      <attribute name="size"          property="size"/>
+      <attribute name="default"       property="defaultValue"/>
+      <attribute name="autoIncrement" property="autoIncrement"/>
+      <attribute name="description"   property="description"/>
+      <attribute name="javaName"      property="javaName"/>
+    </element>
+  </class>
+
+  <class name="org.apache.jetspeed.maven.plugins.db.ddlutils.model.ForeignKey">
+    <element name="foreign-key">
+      <attribute name="foreignTable" property="foreignTableName"/>
+      <attribute name="name"         property="name"/>
+
+      <attribute name="onDelete"     property="onDelete"/>
+      <element property="references" updater="addReference"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.Reference">
+    <element name="reference">
+      <attribute name="local"   property="localColumnName"/>
+      <attribute name="foreign" property="foreignColumnName"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.NonUniqueIndex">
+    <element name="index">
+      <attribute name="name" property="name"/>
+
+      <element name="index-column" property="columns" updater="addColumn"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.IndexColumn">
+    <element name="index-column">
+      <attribute name="name" property="name"/>
+      <attribute name="size" property="size"/>
+    </element>
+  </class>
+
+  <class name="org.apache.ddlutils.model.UniqueIndex">
+    <element name="unique">
+      <attribute name="name" property="name"/>
+
+      <element name="unique-column" property="columns" updater="addColumn"/>
+    </element>
+  </class>
+</betwixt-config>
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/io/mapping.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java?rev=1079016&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java (added)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java Mon Mar  7 23:09:49 2011
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins.db.ddlutils.model;
+
+import java.sql.DatabaseMetaData;
+
+/**
+ * ForeignKey extension to allow overriding ddlutils 1.0 behavior at runtime for 
+ * https://issues.apache.org/jira/browse/DDLUTILS-75 which is fixed in ddlutils 1.1 but hasn't been released yet.
+ * @version $Id$
+ *
+ */
+public class ForeignKey extends org.apache.ddlutils.model.ForeignKey
+{
+    /** The DELETE_RULE type {@link java.sql.DatabaseMetaData#getImportedKeys} */
+    private int _deleteRuleCode;
+    /** The attribute for the onDelete clause in the schema XML */
+    private String _onDelete;
+	
+	public ForeignKey()
+	{
+		super();
+	}
+
+	public ForeignKey(String name)
+	{
+		super(name);
+        // If the _deleteRuleCode not set explicitly, default is no action
+        _deleteRuleCode = DatabaseMetaData.importedKeyNoAction;
+        _onDelete = "none";
+	}
+
+    /**
+     * Sets the action to take on a delete of the referenced primary key. Maps
+     * the code from DatabaseMetaData constant to the Torque database.dtd.
+     * 
+     * @param deleteRuleCode
+     *            The action to take.
+     * @see java.sql.DatabaseMetaData#getImportedKeys
+     */
+    public void setDeleteRuleCode(int deleteRuleCode)
+    {
+        _deleteRuleCode = deleteRuleCode;
+        switch (_deleteRuleCode)
+        {
+            case DatabaseMetaData.importedKeyCascade:
+                _onDelete = "cascade";
+                break;
+            case DatabaseMetaData.importedKeyRestrict:
+                _onDelete = "restrict";
+                break;
+            case DatabaseMetaData.importedKeySetNull:
+                _onDelete = "setnull";
+                break;
+            case DatabaseMetaData.importedKeyNoAction: // fall-through
+            default:
+                _onDelete = "none";
+        }
+    }
+    
+
+    /**
+     * The action to take when a delete occurs of the parent key in a this
+     * foreign key. Constant form
+     * 
+     * @return The delete rule action to take.
+     * @see java.sql.DatabaseMetaData#getImportedKeys
+     */
+    public int getDeleteRuleCode()
+    {
+        return _deleteRuleCode;
+    }
+
+    /**
+     * The action to take when a delete occurs of the parent key in a this
+     * foreign key.
+     * 
+     * @return The value for the "onDelete" attribute of the <foreign-key> tag.
+     */
+    public String getOnDelete()
+    {
+        return _onDelete;
+    }
+
+    /**
+     * Set the action to take when a delete occurs of the parent key in a this
+     * foreign key.
+     * 
+     * @param onDelete
+     *            The value for the "onDelete" attribute of the <foreign-key>
+     *            tag.
+     */
+    public void setOnDelete(String onDelete)
+    {
+        _onDelete = onDelete;
+        if (onDelete.equals("none"))
+        {
+            _deleteRuleCode = DatabaseMetaData.importedKeyNoAction;
+        }
+        else if (onDelete.equals("cascade"))
+        {
+            _deleteRuleCode = DatabaseMetaData.importedKeyCascade;
+        }
+        else if (onDelete.equals("restrict"))
+        {
+            _deleteRuleCode = DatabaseMetaData.importedKeyRestrict;
+        }
+        else if (onDelete.equals("setnull"))
+        {
+            _deleteRuleCode = DatabaseMetaData.importedKeySetNull;
+        }
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/db/ddlutils/model/ForeignKey.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org