You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by jo...@apache.org on 2008/07/31 04:14:43 UTC

svn commit: r681257 - in /labs/jaxmas/trunk/JaxMas: ./ src/main/java/org/apache/labs/jaxmas/registry/accessor/ src/main/java/org/apache/labs/jaxmas/registry/infomodel/ src/main/java/org/apache/labs/jaxmas/registry/schema/ src/main/java/org/apache/labs/...

Author: jochen
Date: Wed Jul 30 19:14:42 2008
New Revision: 681257

URL: http://svn.apache.org/viewvc?rev=681257&view=rev
Log:
- Added a macro processor for creating the initial schema.
- Concepts are now blocking deletion of their parent.

Added:
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/MacroProcessor.java
    labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/
    labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java   (with props)
Modified:
    labs/jaxmas/trunk/JaxMas/doap.rdf
    labs/jaxmas/trunk/JaxMas/pom.xml
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/accessor/ROAccessors.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/AssociationImpl.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ClassificationImpl.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptChildrenController.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptImpl.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/OwnedRegistryObject.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/RegistryObjectImpl.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/DbInitializer.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/schema-update.1.sql
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AbstractDbDriver.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AssociationSourcePredicate.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/OwnerPredicate.java
    labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/RegistryObjectLoader.java

Modified: labs/jaxmas/trunk/JaxMas/doap.rdf
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/doap.rdf?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/doap.rdf (original)
+++ labs/jaxmas/trunk/JaxMas/doap.rdf Wed Jul 30 19:14:42 2008
@@ -1,3 +1,21 @@
+<!-- 
+  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.
+-->
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns="http://usefulinc.com/ns/doap#"
          xmlns:foaf="http://xmlns.com/foaf/0.1/"

Modified: labs/jaxmas/trunk/JaxMas/pom.xml
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/pom.xml?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/pom.xml (original)
+++ labs/jaxmas/trunk/JaxMas/pom.xml Wed Jul 30 19:14:42 2008
@@ -112,4 +112,13 @@
       </plugin>
     </plugins>
   </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>rat-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
 </project>

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/accessor/ROAccessors.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/accessor/ROAccessors.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/accessor/ROAccessors.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/accessor/ROAccessors.java Wed Jul 30 19:14:42 2008
@@ -34,65 +34,65 @@
      */
     public enum ObjectTypes {
         /**
-         * An object type: Classification scheme.
-         */
-        CLASSIFICATION_SCHEME("00000000000000000000000000000011", LifeCycleManager.CLASSIFICATION_SCHEME), //$NON-NLS-1$
-        /**
-         * An object type: Concept.
-         */
-        CONCEPT("00000000000000000000000000000016", LifeCycleManager.CONCEPT), //$NON-NLS-1$
-        /**
          * An object type: Association.
          */
         ASSOCIATION("00000000000000000000000000000003", LifeCycleManager.ASSOCIATION), //$NON-NLS-1$
         /**
+         * An object type: AuditableEvent
+         */
+        AUDITABLE_EVENT("00000000000000000000000000000004", LifeCycleManager.AUDITABLE_EVENT), //$NON-NLS-1$
+        /**
          * An object type: Classification
          */
         CLASSIFICATION("00000000000000000000000000000005", LifeCycleManager.CLASSIFICATION), //$NON-NLS-1$
         /**
+         * An object type: ExternalIdentifier
+         */
+        EXTERNAL_IDENTIFIER("00000000000000000000000000000006", LifeCycleManager.EXTERNAL_IDENTIFIER), //$NON-NLS-1$
+        /**
+         * An object type: ExternalLink
+         */
+        EXTERNAL_LINK("00000000000000000000000000000007", LifeCycleManager.EXTERNAL_LINK), //$NON-NLS-1$
+        /**
          * An object type: RegistryEntry
          */
         REGISTRY_ENTRY("00000000000000000000000000000009", LifeCycleManager.REGISTRY_ENTRY), //$NON-NLS-1$
         /**
-         * An object type: Organization
+         * An object type: Service
          */
-        ORGANIZATION("00000000000000000000000000000010", LifeCycleManager.ORGANIZATION), //$NON-NLS-1$
+        SERVICE("000000000000000000000000000000010", LifeCycleManager.SERVICE), //$NON-NLS-1$
         /**
-         * An object type: User
+         * An object type: Classification scheme.
          */
-        USER("00000000000000000000000000000012", LifeCycleManager.USER), //$NON-NLS-1$
+        CLASSIFICATION_SCHEME("00000000000000000000000000000011", LifeCycleManager.CLASSIFICATION_SCHEME), //$NON-NLS-1$
         /**
-         * An object type: ExternalLink
+         * An object type: User
          */
-        EXTERNAL_LINK("00000000000000000000000000000007", LifeCycleManager.EXTERNAL_LINK), //$NON-NLS-1$
+        USER("00000000000000000000000000000012", LifeCycleManager.USER), //$NON-NLS-1$
         /**
-         * An object type: ExternalIdentifier
+         * An object type: Organization
          */
-        EXTERNAL_IDENTIFIER("00000000000000000000000000000006", LifeCycleManager.EXTERNAL_IDENTIFIER), //$NON-NLS-1$
+        ORGANIZATION("00000000000000000000000000000015", LifeCycleManager.ORGANIZATION), //$NON-NLS-1$
         /**
-         * An object type: AuditableEvent
+         * An object type: Concept.
          */
-        AUDITABLE_EVENT("00000000000000000000000000000004", LifeCycleManager.AUDITABLE_EVENT), //$NON-NLS-1$
+        CONCEPT("00000000000000000000000000000016", LifeCycleManager.CONCEPT), //$NON-NLS-1$
         /**
          * An object type: ServiceBinding
          */
-        SERVICE_BINDING("00000000000000000000000000000029", LifeCycleManager.SERVICE_BINDING), //$NON-NLS-1$
+        SERVICE_BINDING("00000000000000000000000000000017", LifeCycleManager.SERVICE_BINDING), //$NON-NLS-1$
         /**
-         * An object type: RegistryPackage
+         * An object type SpecificationLink
          */
-        REGISTRY_PACKAGE("00000000000000000000000000000031", LifeCycleManager.REGISTRY_PACKAGE), //$NON-NLS-1$
+        SPECIFICATION_LINK("00000000000000000000000000000018", LifeCycleManager.SPECIFICATION_LINK), //$NON-NLS-1$
         /**
-         * An object type: Service
+         * An object type: RegistryPackage
          */
-        SERVICE("000000000000000000000000000000010", LifeCycleManager.SERVICE), //$NON-NLS-1$
+        REGISTRY_PACKAGE("00000000000000000000000000000019", LifeCycleManager.REGISTRY_PACKAGE), //$NON-NLS-1$
         /**
          * An object type: ExtrinsicObject
          */
-        EXTRINSIC_OBJECT("000000000000000000000000000000010", LifeCycleManager.EXTRINSIC_OBJECT), //$NON-NLS-1$
-        /**
-         * An object type SpecificationLink
-         */
-        SPECIFICATION_LINK("00000000000000000000000000000030", LifeCycleManager.SPECIFICATION_LINK); //$NON-NLS-1$
+        EXTRINSIC_OBJECT("000000000000000000000000000000020", LifeCycleManager.EXTRINSIC_OBJECT);//$NON-NLS-1$
 
         private final String id;
         private final String ifaceName;
@@ -118,21 +118,21 @@
     }
 
     private static final ROAccessor<?>[] roAccessors = new ROAccessor[]{
-        ClassificationSchemeAccessor.getInstance(),
-        ConceptAccessor.getInstance(),
         AssociationAccessor.getInstance(),
+        AuditableEventAccessor.getInstance(),
         ClassificationAccessor.getInstance(),
+        ExternalIdentifierAccessor.getInstance(),
+        ExternalLinkAccessor.getInstance(),
         RegistryEntryAccessor.getInstance(),
-        OrganizationAccessor.getInstance(),
+        ServiceAccessor.getInstance(),
+        ClassificationSchemeAccessor.getInstance(),
         UserAccessor.getInstance(),
-        ExternalLinkAccessor.getInstance(),
-        ExternalIdentifierAccessor.getInstance(),
-        AuditableEventAccessor.getInstance(),
+        OrganizationAccessor.getInstance(),
+        ConceptAccessor.getInstance(),
         ServiceBindingAccessor.getInstance(),
-        RegistryPackageAccessor.getInstance(),
-        ServiceAccessor.getInstance(),
+        SpecificationLinkAccessor.getInstance(),
         ExtrinsicObjectAccessor.getInstance(),
-        SpecificationLinkAccessor.getInstance()
+        RegistryPackageAccessor.getInstance()
     };
 
     private static final Map<String,ROAccessor<?>> roAccessorsByInterfaceName = new HashMap<String,ROAccessor<?>>();

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/AssociationImpl.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/AssociationImpl.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/AssociationImpl.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/AssociationImpl.java Wed Jul 30 19:14:42 2008
@@ -149,4 +149,9 @@
 	public ROAccessor<Association> getROLoader() {
 	    return AssociationAccessor.getInstance();
 	}
+
+	@Override
+	public boolean isRestricting() {
+		return false;
+	}
 }

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ClassificationImpl.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ClassificationImpl.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ClassificationImpl.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ClassificationImpl.java Wed Jul 30 19:14:42 2008
@@ -116,4 +116,9 @@
     public ROAccessor<Classification> getROLoader() {
         return ClassificationAccessor.getInstance();
     }
+
+	@Override
+	public boolean isRestricting() {
+		return false;
+	}
 }

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptChildrenController.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptChildrenController.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptChildrenController.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptChildrenController.java Wed Jul 30 19:14:42 2008
@@ -70,7 +70,7 @@
 
 	private Collection<Concept> getChildren() throws JAXRException {
 		if (children == null) {
-		    final Predicate predicate = new OwnerPredicate(registryObject.getKey());
+		    final Predicate predicate = new OwnerPredicate(registryObject.getKey(), true);
 		    children = asConceptCollection(rol.getResultList(registryObject.getRegistryService(), Collections.singleton(predicate)));
 			initStoredChildren();
 		}

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptImpl.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptImpl.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptImpl.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/ConceptImpl.java Wed Jul 30 19:14:42 2008
@@ -134,4 +134,9 @@
     public ROAccessor<Concept> getROLoader() {
 		return ConceptAccessor.getInstance();
 	}
+
+	@Override
+	public boolean isRestricting() {
+		return true;
+	}
 }

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/OwnedRegistryObject.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/OwnedRegistryObject.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/OwnedRegistryObject.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/OwnedRegistryObject.java Wed Jul 30 19:14:42 2008
@@ -34,6 +34,11 @@
     private int position;
 
     /**
+     * Returns, whether this object blocks deleting the owner.
+     */
+    public abstract boolean isRestricting();
+    
+    /**
      * Returns the objects position within its parent objects list of childs.
      */
     public int getPosition() {

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/RegistryObjectImpl.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/RegistryObjectImpl.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/RegistryObjectImpl.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/infomodel/RegistryObjectImpl.java Wed Jul 30 19:14:42 2008
@@ -180,7 +180,7 @@
                     break;
                 case referenced:
                 case loaded:
-                    final Predicate predicate = new OwnerPredicate(getKey());
+                    final Predicate predicate = new OwnerPredicate(getKey(), false);
                     final Collection<Predicate> predicates = Collections.singleton(predicate);
                     final RegistryObjectLoader rol = ClassificationAccessor.getInstance().getRegistryObjectLoader();
                     loadedClassificationKeys = new HashSet<Key>();
@@ -206,7 +206,7 @@
                     break;
                 case referenced:
                 case loaded:
-                    final Predicate predicate = new OwnerPredicate(getKey());
+                    final Predicate predicate = new OwnerPredicate(getKey(), false);
                     final Collection<Predicate> predicates = Collections.singleton(predicate);
                     final RegistryObjectLoader rol = AssociationAccessor.getInstance().getRegistryObjectLoader();
                     loadedAssociationKeys = new HashSet<Key>();

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/DbInitializer.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/DbInitializer.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/DbInitializer.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/DbInitializer.java Wed Jul 30 19:14:42 2008
@@ -141,13 +141,16 @@
 	 */
 	protected void initialize(Connection pConnection, BufferedReader pReader)
 	        throws IOException, SQLException, JAXRException {
-		final StringBuilder sb = new StringBuilder();
+	    final StringBuilder sb = new StringBuilder();
 		for (;;) {
 			final String s = pReader.readLine();
 			if (s == null) {
 				sql(pConnection, sb.toString());
 				return;
 			}
+			if (s.trim().startsWith("--")) { //$NON-NLS-1$
+			    continue;
+			}
 			sb.append(s);
 			sb.append('\n');
 			if (endsWithSemicolon(sb)) {
@@ -169,7 +172,7 @@
 			conn.setAutoCommit(false);
 			stream = pSchemaFile.openStream();
 			reader = new InputStreamReader(stream, "UTF-8"); //$NON-NLS-1$
-			bReader = new BufferedReader(reader);
+			bReader = new BufferedReader(MacroProcessor.newInstance(reader));
 			if (pSchemaUpdater != null) {
 				pSchemaUpdater.beforeUpdate(conn, connection.getRegistryService());
 			}

Added: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/MacroProcessor.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/MacroProcessor.java?rev=681257&view=auto
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/MacroProcessor.java (added)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/MacroProcessor.java Wed Jul 30 19:14:42 2008
@@ -0,0 +1,285 @@
+/**
+ * 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.labs.jaxmas.registry.schema;
+
+import java.io.FilterReader;
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * The macro processor is processing macros like &{macro, ...}
+ * and allows to perform multiple or complex statements by specifying
+ * a simple macro call.
+ */
+public class MacroProcessor extends FilterReader {
+    private static class LineCountingReader extends FilterReader {
+    	private int lineNum, colNum;
+
+    	protected LineCountingReader(Reader pIn) {
+			super(pIn);
+		}
+
+		@Override
+		public int read(char[] pCbuf, int pOff, int pLen) throws IOException {
+	        int num = 0;
+	        for (int len = pLen;  len-- > 0;  ++num) {
+	            int c = read();
+	            if (c == -1) {
+	                return num == 0 ? -1 : num;
+	            }
+	            pCbuf[pOff+num] = (char) c;
+	        }
+	        return num;
+		}
+
+		@Override
+		public int read() throws IOException {
+			int res = super.read();
+			if (res == '\n') {
+				lineNum++;
+				colNum = 0;
+			} else {
+				colNum++;
+			}
+			return res;
+		}
+
+		public String format(String pMsg) {
+			return "At line " + lineNum + ", column " + colNum + ": " + pMsg; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		}
+    }
+
+    private LineCountingReader lcr;
+    private final Map<String,String[]> macros = new HashMap<String,String[]>();
+
+    /**
+     * Creates a new instance, which performs macro processing on the given
+     * readers output.
+     */
+    public static MacroProcessor newInstance(Reader pReader) {
+    	final LineCountingReader lcr = new LineCountingReader(pReader);
+    	final MacroProcessor mp = new MacroProcessor(lcr);
+    	mp.lcr = lcr;
+    	return mp;
+    }
+
+    private MacroProcessor(Reader pReader) {
+    	super(new PushbackReader(pReader, 8192));
+    }
+
+    private String processUnescapedParameter() throws IOException {
+        final StringBuilder sb = new StringBuilder();
+        for (;;) {
+            int c = super.read();
+            switch (c) {
+                case -1:
+                    throw new IllegalStateException(lcr.format("Unexpected EOF in input stream.")); //$NON-NLS-1$
+                case '}':
+                case ',':
+                    ((PushbackReader) in).unread(c);
+                    return sb.toString();
+                case '\'':
+                case '"':
+                	throw new IllegalStateException(lcr.format("Invalid character in input stream.")); //$NON-NLS-1$
+                case '\\':
+                    int c1 = super.read();
+                    if (c1 == -1) {
+                        throw new IllegalStateException(lcr.format("Unexpected EOF in input stream.")); //$NON-NLS-1$
+                    }
+                    if (c1 >= '0'  &&  c1 <= '9') {
+                        sb.append((char) c);
+                    }
+                    sb.append((char) c1);
+                    break;
+                default:
+                    if (Character.isWhitespace(c)) {
+                        return sb.toString();
+                    }
+                    sb.append((char) c);
+                    break;
+            }
+        }
+    }
+
+    private String processEscapedParameter(int pTerminator) throws IOException {
+        final StringBuilder sb = new StringBuilder();
+        for (;;) {
+            int c = super.read();
+            switch (c) {
+                case -1:
+                    throw new IllegalStateException(lcr.format("Unexpected EOF in input stream.")); //$NON-NLS-1$
+                case '\\':
+                    int c1 = super.read();
+                    if (c1 == -1) {
+                        throw new IllegalStateException(lcr.format("Unexpected EOF in input stream.")); //$NON-NLS-1$
+                    }
+                    if (c1 >= '0'  &&  c1 <= '9') {
+                        sb.append((char) c);
+                    }
+                    sb.append((char) c1);
+                    break;
+                default:
+                    if (c == pTerminator) {
+                        return ((char) pTerminator) + sb.toString() + ((char) pTerminator);
+                    }
+                    sb.append((char) c);
+                    break;
+            }
+        }
+    }
+
+    private String processParameters(String pStatement, String[] pArgs) throws IOException {
+        final StringBuilder sb = new StringBuilder();
+        for (int i = 0;  i < pStatement.length();  i++) {
+            int c = pStatement.charAt(i);
+            if (c == '\\'  &&  i < pStatement.length()-1) {
+                int c1 = pStatement.charAt(i+1);
+                if (c1 >= '0'  &&  c1 <= '9') {
+                    int num = c1 - '0';
+                    if (num >= pArgs.length) {
+                        throw new IllegalStateException(lcr.format("Invalid parameter reference \\" + num)); //$NON-NLS-1$
+                    }
+                    sb.append(pArgs[num]);
+                    i++;
+                } else {
+                    ((PushbackReader) in).unread(c1);
+                    sb.append((char) c);
+                }
+            } else {
+                sb.append((char) c);
+            }
+        }
+        return sb.toString();
+    }
+
+    private String unEscape(String pValue) {
+        if (pValue.length() > 2) {
+            int c = pValue.charAt(0);
+            if ((c == '\''  ||  c == '\"')  &&  pValue.charAt(pValue.length()-1) == c) {
+                return pValue.substring(1, pValue.length()-1);
+            }
+        }
+        return pValue;
+    }
+
+    private void processMacro(List<String> pArgs) throws IOException {
+        if (pArgs.size() == 0) {
+            throw new IllegalStateException(lcr.format("Invalid macro call: Missing macro name")); //$NON-NLS-1$
+        }
+        final String macroName = pArgs.remove(0);
+        if ("macro".equals(macroName)) { //$NON-NLS-1$
+            if (pArgs.size() == 0) {
+                throw new IllegalStateException(lcr.format("Invalid macro specification: Missing macro name")); //$NON-NLS-1$
+            }
+            final String newMacroName = pArgs.remove(0);
+            if (macros.containsKey(newMacroName)) {
+                throw new IllegalStateException(lcr.format("Macro redefined: " + newMacroName)); //$NON-NLS-1$
+            }
+            for (int i = 0;  i < pArgs.size();  i++) {
+                pArgs.set(i, unEscape(pArgs.get(i)));
+            }
+            final String[] args = pArgs.toArray(new String[pArgs.size()]);
+            macros.put(newMacroName, args);
+        } else {
+            final String[] statements = macros.get(macroName);
+            if (statements == null) {
+            	throw new IllegalStateException(lcr.format("Unknown macro: " + macroName)); //$NON-NLS-1$
+            }
+            final String[] args = pArgs.toArray(new String[pArgs.size()]);
+            for (int i = statements.length-1;  i >= 0;  i--) {
+                final String stmt = processParameters(statements[i], args);
+                ((PushbackReader) in).unread((stmt + ";\n").toCharArray()); //$NON-NLS-1$
+            }
+        }
+    }
+    
+    private void processMacro() throws IOException {
+        final List<String> parameters = new ArrayList<String>();
+        boolean commaExpected = false;
+        for (;;) {
+            int c = super.read();
+            if (Character.isWhitespace(c)) {
+                continue;
+            }
+            switch (c) {
+                case '}':
+                    processMacro(parameters);
+                    return;
+                case ',':
+                    if (!commaExpected) {
+                    	throw new IllegalStateException(lcr.format("Unexpected comma in input stream.")); //$NON-NLS-1$
+                    }
+                    commaExpected = false;
+                    break;
+                case '\'':
+                case '"':
+                    if (commaExpected) {
+                        throw new IllegalStateException(lcr.format("Expected comma, got parameter in input stream.")); //$NON-NLS-1$
+                    }
+                    parameters.add(processEscapedParameter(c));
+                    commaExpected = true;
+                    break;
+                default:
+                    if (commaExpected) {
+                    	throw new IllegalStateException(lcr.format("Expected comma, got parameter in input stream.")); //$NON-NLS-1$
+                    }
+                    ((PushbackReader) in).unread(c);
+                    parameters.add(processUnescapedParameter());
+                    commaExpected = true;
+                    break;
+            }
+        }
+    }
+
+    
+    @Override
+    public int read(char[] pCbuf, int pOff, int pLen) throws IOException {
+        int num = 0;
+        for (int len = pLen;  len-- > 0;  ++num) {
+            int c = read();
+            if (c == -1) {
+                return num == 0 ? -1 : num;
+            }
+            pCbuf[pOff+num] = (char) c;
+        }
+        return num;
+    }
+
+    @Override
+    public int read() throws IOException {
+        int res = super.read();
+        if (res == '&') {
+            int c = super.read();
+            if (c == '{') {
+                processMacro();
+                return read();
+            }
+            ((PushbackReader) in).unread(c);
+        }
+        return res;
+    }
+
+    
+}

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/schema-update.1.sql
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/schema-update.1.sql?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/schema-update.1.sql (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/schema/schema-update.1.sql Wed Jul 30 19:14:42 2008
@@ -17,6 +17,7 @@
 -- under the License.
 --
 
+
 DROP TABLE DbInfo;
 CREATE TABLE DbInfo (
     version INT NOT NULL
@@ -26,10 +27,12 @@
 DROP TABLE RegistryObjects;
 CREATE TABLE RegistryObjects (
     roKey VARCHAR(32) NOT NULL PRIMARY KEY,
-    roOwner VARCHAR(32),
+    roOwnerRestricting VARCHAR(32),
+    roOwnerCascading VARCHAR(32),
     pos INT,
     roType INT NOT NULL,
-    CONSTRAINT FK_RegistryObjects_Owner FOREIGN KEY (roOwner) REFERENCES RegistryObjects ON DELETE CASCADE
+    CONSTRAINT FK_RegistryObjects_OwnerCascading FOREIGN KEY (roOwnerCascading) REFERENCES RegistryObjects ON DELETE CASCADE,
+    CONSTRAINT FK_RegistryObjects_OwnerRestricting FOREIGN KEY (roOwnerRestricting) REFERENCES RegistryObjects ON DELETE RESTRICT
 );
 
 DROP TABLE LocalizedStrings;
@@ -104,134 +107,52 @@
 INSERT INTO Ids (name, nextValue) VALUES ('keys', 8000);
 INSERT INTO Ids (name, nextValue) VALUES ('Slots', 0);
 
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000001', null, 0, 0);
-INSERT INTO RegistryEntries (roKey, expiration, status, stability, majorVersion, minorVersion, userVersion) VALUES ('00000000000000000000000000000001', null, 0, 0, 1, 0, '1.0');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000001', 0, 'en', 'UTF-8', 'ObjectType');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000001', 1, 'en', 'UTF-8', 'The taxonomy of object types. Object types are categories below this taxonomy.');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000002', null, 0, 0);
-INSERT INTO RegistryEntries (roKey, expiration, status, stability, majorVersion, minorVersion, userVersion) VALUES ('00000000000000000000000000000002', null, 0, 0, 1, 0, '1.0');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000002', 0, 'en', 'UTF-8', 'AssociationType');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000002', 1, 'en', 'UTF-8', 'The taxonomy of association types. Association types are categories below this taxonomy.');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000003', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000003', 'Association');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000003', 0, 'en', 'UTF-8', 'Association');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000004', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000004', 'AuditableEvent');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000004', 0, 'en', 'UTF-8', 'AuditableEvent');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000005', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000005', 'Classification');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000005', 0, 'en', 'UTF-8', 'Classification');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000006', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000006', 'ExternalIdentifier');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000006', 0, 'en', 'UTF-8', 'ExternalIdentifier');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000007', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000007', 'ExternalLink');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000007', 0, 'en', 'UTF-8', 'ExternalLink');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000008', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000008', 'Package');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000008', 0, 'en', 'UTF-8', 'Package');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000009', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000009', 'RegistryEntry');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000009', 0, 'en', 'UTF-8', 'RegistryEntry');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000010', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000010', 'Service');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000010', 0, 'en', 'UTF-8', 'Service');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000011', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000011', 'Taxonomy');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000011', 0, 'en', 'UTF-8', 'Taxonomy');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000012', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000012', 'User');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000012', 0, 'en', 'UTF-8', 'User');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000013', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000013', 'WSDL');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000013', 0, 'en', 'UTF-8', 'WSDL');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000014', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000014', 'WSPolicy');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000014', 0, 'en', 'UTF-8', 'WSPolicy');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000015', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000015', 'Organization');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000015', 0, 'en', 'UTF-8', 'Organization');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000016', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000016', 'Category');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000016', 0, 'en', 'UTF-8', 'Category');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000017', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000017', 'BelongsTo');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000017', 0, 'en', 'UTF-8', 'BelongsTo');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000018', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000018', 'Contains');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000018', 0, 'en', 'UTF-8', 'Contains');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000019', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000019', 'EquivalentTo');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000019', 0, 'en', 'UTF-8', 'EquivalentTo');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000020', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000020', 'Extends');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000020', 0, 'en', 'UTF-8', 'Extends');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000021', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000021', 'HasChild');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000021', 0, 'en', 'UTF-8', 'HasChild');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000022', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000022', 'HasParent');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000022', 0, 'en', 'UTF-8', 'HasParent');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000023', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000023', 'Implements');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000023', 0, 'en', 'UTF-8', 'Implements');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000024', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000024', 'InstanceOf');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000024', 0, 'en', 'UTF-8', 'InstanceOf');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000025', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000025', 'IsCompositionOf');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000025', 0, 'en', 'UTF-8', 'IsCompositionOf');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000026', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000026', 'Replaces');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000026', 0, 'en', 'UTF-8', 'Replaces');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000027', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000027', 'RelatedTo');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000027', 0, 'en', 'UTF-8', 'RelatedTo');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000028', '00000000000000000000000000000002', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000028', 'Supersedes');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000028', 0, 'en', 'UTF-8', 'Supersedes');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000029', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000029', 'ServiceBinding');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000029', 0, 'en', 'UTF-8', 'ServiceBinding');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000030', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000030', 'SpecificationLink');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000030', 0, 'en', 'UTF-8', 'SpecificationLink');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000031', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000031', 'RegistryPackage');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000031', 0, 'en', 'UTF-8', 'RegistryPackage');
-
-INSERT INTO RegistryObjects (roKey, roOwner, pos, roType) VALUES ('00000000000000000000000000000032', '00000000000000000000000000000001', 0, 1);
-INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000032', 'ExtrinsicObject');
-INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000032', 0, 'en', 'UTF-8', 'ExtrinsicObject');
+&{macro, Taxonomy,
+    'INSERT INTO RegistryObjects (roKey, pos, roType) VALUES (\1, \0, 7)',
+    'INSERT INTO RegistryEntries (roKey, majorVersion, minorVersion, userVersion, status, stability) VALUES (\1, 1, 0, \'1.0\', 0, 0)',
+    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\1, 0, \'en\', \'UTF-8\', \2)',
+    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\1, 1, \'en\', \'UTF-8\', \3)'
+}
+
+&{Taxonomy, 0, '00000000000000000000000000000001', 'ObjectType', 'The taxonomy of object types. Object types are categories below this taxonomy.'}
+&{Taxonomy, 1, '00000000000000000000000000000002', 'AssociationType', 'The taxonomy of association types. Association types are categories below this taxonomy.'}
+
+&{macro, Concept,
+    'INSERT INTO RegistryObjects (roKey, roOwnerRestricting, pos, roType) VALUES (\1, \2, \0, 10)',
+    'INSERT INTO Concepts (roKey, value) VALUES (\1, \3)',
+    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\1, 0, \'en\', \'UTF-8\', \3)'
+}
+
+&{Concept, 0, '00000000000000000000000000000003', '00000000000000000000000000000001', 'Association'}
+&{Concept, 1, '00000000000000000000000000000004', '00000000000000000000000000000001', 'AuditableEvent'}
+&{Concept, 2, '00000000000000000000000000000005', '00000000000000000000000000000001', 'Classification'}
+&{Concept, 3, '00000000000000000000000000000006', '00000000000000000000000000000001', 'ExternalIdentifier'}
+&{Concept, 4, '00000000000000000000000000000007', '00000000000000000000000000000001', 'ExternalLink'}
+&{Concept, 5, '00000000000000000000000000000008', '00000000000000000000000000000001', 'Package'}
+&{Concept, 6, '00000000000000000000000000000009', '00000000000000000000000000000001', 'RegistryEntry'}
+&{Concept, 7, '00000000000000000000000000000010', '00000000000000000000000000000001', 'Service'}
+&{Concept, 8, '00000000000000000000000000000011', '00000000000000000000000000000001', 'Taxonomy'}
+&{Concept, 9, '00000000000000000000000000000012', '00000000000000000000000000000001', 'User'}
+&{Concept, 10, '00000000000000000000000000000013', '00000000000000000000000000000001', 'WSDL'}
+&{Concept, 11, '00000000000000000000000000000014', '00000000000000000000000000000001', 'WSPolicy'}
+&{Concept, 12, '00000000000000000000000000000015', '00000000000000000000000000000001', 'Organization'}
+&{Concept, 13, '00000000000000000000000000000016', '00000000000000000000000000000001', 'Category'}
+&{Concept, 14, '00000000000000000000000000000017', '00000000000000000000000000000001', 'ServiceBinding'}
+&{Concept, 15, '00000000000000000000000000000018', '00000000000000000000000000000001', 'SpecificationLink'}
+&{Concept, 16, '00000000000000000000000000000019', '00000000000000000000000000000001', 'RegistryPackage'}
+&{Concept, 17, '00000000000000000000000000000020', '00000000000000000000000000000001', 'ExtrinsicObject'}
+
+&{Concept, 0, '00000000000000000000000000000021', '00000000000000000000000000000002', 'BelongsTo'}
+&{Concept, 1, '00000000000000000000000000000022', '00000000000000000000000000000002', 'Contains'}
+&{Concept, 2, '00000000000000000000000000000023', '00000000000000000000000000000002', 'EquivalentTo'}
+&{Concept, 3, '00000000000000000000000000000024', '00000000000000000000000000000002', 'Extends'}
+&{Concept, 4, '00000000000000000000000000000025', '00000000000000000000000000000002', 'HasChild'}
+&{Concept, 5, '00000000000000000000000000000026', '00000000000000000000000000000002', 'HasParent'}
+&{Concept, 6, '00000000000000000000000000000027', '00000000000000000000000000000002', 'Implements'}
+&{Concept, 7, '00000000000000000000000000000028', '00000000000000000000000000000002', 'InstanceOf'}
+&{Concept, 8, '00000000000000000000000000000029', '00000000000000000000000000000002', 'IsCompositionOf'}
+&{Concept, 9, '00000000000000000000000000000030', '00000000000000000000000000000002', 'Replaces'}
+&{Concept, 10, '00000000000000000000000000000031', '00000000000000000000000000000002', 'RelatedTo'}
+&{Concept, 11, '00000000000000000000000000000032', '00000000000000000000000000000002', 'Supersedes'}
 
 INSERT INTO DbInfo (version) VALUES (1);

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AbstractDbDriver.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AbstractDbDriver.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AbstractDbDriver.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AbstractDbDriver.java Wed Jul 30 19:14:42 2008
@@ -264,19 +264,26 @@
 		final RegistryObjectImpl<?> ro = (RegistryObjectImpl<?>) pObject;
 		assert(ro.getState() == ROState.created);
 		final Key key = pObject.getKey();
-		final Key owner;
+		final Key ownerRestricting, ownerCascading;
 		final Integer pos;
 		if (ro instanceof OwnedRegistryObject) {
 		    final OwnedRegistryObject<?> oro = (OwnedRegistryObject<?>) ro;
 		    final RegistryObject roOwner = oro.getOwner();
-		    owner = roOwner == null ? null : roOwner.getKey();
+		    final Key owner = roOwner == null ? null : roOwner.getKey();
+		    if (oro.isRestricting()) {
+		    	ownerCascading = null;
+		    	ownerRestricting = owner;
+		    } else {
+		    	ownerCascading = owner;
+		    	ownerRestricting = null;
+		    }
 		    pos = Integer.valueOf(oro.getPosition());
 		} else {
-		    owner = null;
+		    ownerRestricting = ownerCascading = null;
 		    pos = null;
 		}
-		final String s = "INSERT INTO RegistryObjects (roKey, roType, pos, roOwner) VALUES (?, ?, ?, ?)"; //$NON-NLS-1$
-		run(s, key, Integer.valueOf(pRegistryObjectType), pos, owner);
+		final String s = "INSERT INTO RegistryObjects (roKey, roType, pos, roOwnerRestricting, roOwnerCascading) VALUES (?, ?, ?, ?, ?)"; //$NON-NLS-1$
+		run(s, key, Integer.valueOf(pRegistryObjectType), pos, ownerRestricting, ownerCascading);
 
 		final InternationalStringController name = ro.getNameController();
         name.save();

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AssociationSourcePredicate.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AssociationSourcePredicate.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AssociationSourcePredicate.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/AssociationSourcePredicate.java Wed Jul 30 19:14:42 2008
@@ -30,7 +30,7 @@
      * the given source id.
      */
     public AssociationSourcePredicate(Key pKey) {
-        super(pKey);
+        super(pKey, false);
     }
 
     /**
@@ -38,6 +38,6 @@
      * the given source id.
      */
     public AssociationSourcePredicate(String pKey) {
-        super(pKey);
+        super(pKey, false);
     }
 }

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/OwnerPredicate.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/OwnerPredicate.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/OwnerPredicate.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/OwnerPredicate.java Wed Jul 30 19:14:42 2008
@@ -30,26 +30,33 @@
  */
 public class OwnerPredicate implements Predicate {
     private final Object key;
+    private final boolean restricting;
 
     /**
      * Creates a new instance with the given owners key.
      */
-    public OwnerPredicate(Key pKey) {
+    public OwnerPredicate(Key pKey, boolean pRestricting) {
         assert(pKey != null);
         key = pKey;
+        restricting = pRestricting;
     }
 
     /**
      * Creates a new instance with the given owners key.
      */
-    public OwnerPredicate(String pKey) {
+    public OwnerPredicate(String pKey, boolean pRestricting) {
         assert(pKey != null);
         key = pKey;
+        restricting = pRestricting;
     }
 
     @Override
     public void add(StringBuilder pBuffer, List<Object> pParameters) throws SQLException, JAXRException {
-        pBuffer.append("ro.roOwner=?"); //$NON-NLS-1$
+    	if (restricting) {
+    		pBuffer.append("ro.roOwnerRestricting=?"); //$NON-NLS-1$
+    	} else {
+    		pBuffer.append("ro.roOwnerCascading=?"); //$NON-NLS-1$
+    	}
         pParameters.add(key);
     }
 }

Modified: labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/RegistryObjectLoader.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/RegistryObjectLoader.java?rev=681257&r1=681256&r2=681257&view=diff
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/RegistryObjectLoader.java (original)
+++ labs/jaxmas/trunk/JaxMas/src/main/java/org/apache/labs/jaxmas/registry/sql/RegistryObjectLoader.java Wed Jul 30 19:14:42 2008
@@ -51,7 +51,7 @@
  */
 public class RegistryObjectLoader {
     private static final ExtensionHandler[] EXTENSION_HANDLERS_ASSOCIATION = new ExtensionHandler[]{
-                        new ClassificationExtensionHandler(ROAccessors.ObjectTypes.ASSOCIATION)
+                        new AssociationExtensionHandler(ROAccessors.ObjectTypes.ASSOCIATION)
                     };
     private static final ExtensionHandler[] EXTENSION_HANDLERS_CLASSIFICATION = new ExtensionHandler[]{
                         new ClassificationExtensionHandler(ROAccessors.ObjectTypes.CLASSIFICATION)
@@ -347,12 +347,12 @@
         objectType = getObjectType(pObjectType, pPredicates);
         extensionHandlers = getExtensionHandlers(objectType);
         final StringBuilder sb = new StringBuilder();
-        sb.append("SELECT ro.roKey, ro.roOwner, ro.pos, ro.roType"); //$NON-NLS-1$
+        sb.append("SELECT ro.roKey, ro.roOwnerRestricting, ro.roOwnerCascading, ro.pos, ro.roType"); //$NON-NLS-1$
         if (extensionHandlers == null) {
             indexes = null;
         } else {
             indexes = new int[extensionHandlers.length];
-            int index = 5;
+            int index = 6;
             for (int i = 0;  i < extensionHandlers.length;  i++) {
                 indexes[i] = index;
                 index = extensionHandlers[i].addColumns(sb, index);
@@ -445,7 +445,7 @@
             protected void action(ResultSet pResultSet) throws JAXRException,
                     SQLException {
                 while (pResultSet.next()) {
-                    int type = pResultSet.getInt(4);
+                    int type = pResultSet.getInt(5);
                     assert(!pResultSet.wasNull());
                     final ROAccessor<?> roAcc = ROAccessors.getROAccessor(type);
                     final String key = pResultSet.getString(1);
@@ -499,7 +499,7 @@
             protected void action(ResultSet pResultSet) throws JAXRException,
                     SQLException {
                 if (pResultSet.next()) {
-                    final int type = pResultSet.getInt(4);
+                    final int type = pResultSet.getInt(5);
                     assert(!pResultSet.wasNull());
                     final ROAccessor<?> roAcc = asROAccessor(ROAccessors.getROAccessor(type));
                     final String key = pResultSet.getString(1);
@@ -520,10 +520,13 @@
 
         if (pRegistryObject instanceof OwnedRegistryObject) {
             final OwnedRegistryObject<?> oro = (OwnedRegistryObject<?>) ro;
-            final String ownerKey = pResultSet.getString(2);
+            final String ownerKeyRestricting = pResultSet.getString(2);
+            final String ownerKeyCascading = pResultSet.getString(3);
+            assert(ownerKeyRestricting == null  ||  ownerKeyCascading == null);
+            final String ownerKey = ownerKeyCascading == null ? ownerKeyRestricting : ownerKeyCascading;
             assert(ownerKey != null);
             oro.setOwner(new KeyImpl(ownerKey));
-            int pos = pResultSet.getInt(3);
+            int pos = pResultSet.getInt(4);
             assert(!pResultSet.wasNull());
             oro.setPosition(pos);
         }
@@ -550,7 +553,7 @@
                 if (!pResultSet.next()) {
                     throw new IllegalStateException("Object not found: " + pRegistryObject.getKey()); //$NON-NLS-1$
                 }
-                final int type = pResultSet.getInt(4);
+                final int type = pResultSet.getInt(5);
                 assert(!pResultSet.wasNull()  &&  type == objectType.ordinal());
                 load(pRegistryObject, pResultSet);
                 if (pResultSet.next()) {

Added: labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java
URL: http://svn.apache.org/viewvc/labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java?rev=681257&view=auto
==============================================================================
--- labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java (added)
+++ labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java Wed Jul 30 19:14:42 2008
@@ -0,0 +1,101 @@
+/**
+ * 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.labs.jaxmas.registry.schema;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import org.apache.labs.jaxmas.registry.schema.MacroProcessor;
+import org.junit.Test;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test case for the {@link MacroProcessor}.
+ */
+public class MacroProcessorTest extends TestCase {
+    private static final String document =
+        "&{macro, Taxonomy,\n" //$NON-NLS-1$
+        + "    'INSERT INTO RegistryObjects (roKey, pos, roType) VALUES (\\1, \\0, 7)',\n" //$NON-NLS-1$
+        + "    'INSERT INTO RegistryEntries (roKey, majorVersion, minorVersion, userVersion) VALUES (\\1, 1, 0, \\'1.0\\')',\n" //$NON-NLS-1$
+        + "    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\\1, 0, \\'en\\', \\'UTF-8\\', \\2)',\n" //$NON-NLS-1$
+        + "    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\\1, 1, \\'en\\', \\'UTF-8\\', \\3)'\n" //$NON-NLS-1$
+        + "}\n" //$NON-NLS-1$
+        + "&{macro, Concept,\n" //$NON-NLS-1$
+        + "    'INSERT INTO RegistryObjects (roKey, roOwnerRestricting, pos, roType) VALUES (\\1, \\2, \\0, 10)',\n" //$NON-NLS-1$
+        + "    'INSERT INTO Concepts (roKey, value) VALUES (\\1, \\3)',\n" //$NON-NLS-1$
+        + "    'INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES (\\1, 0, \\'en\\', \\'UTF-8\\', \\3)'\n" //$NON-NLS-1$
+        + "}\n" //$NON-NLS-1$
+        + "&{Taxonomy, 0, '00000000000000000000000000000001', 'ObjectType', 'The taxonomy of object types. Object types are categories below this taxonomy.'}\n" //$NON-NLS-1$
+        + "&{Taxonomy, 1, '00000000000000000000000000000002', 'AssociationType', 'The taxonomy of association types. Association types are categories below this taxonomy.'}\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "&{Concept, 0, '00000000000000000000000000000003', '00000000000000000000000000000001', 'Association'}\n" //$NON-NLS-1$
+        + "&{Concept, 1, '00000000000000000000000000000004', '00000000000000000000000000000001', 'AuditableEvent'}\n" //$NON-NLS-1$
+        + "&{Concept, 2, '00000000000000000000000000000005', '00000000000000000000000000000001', 'Classification'}\n"; //$NON-NLS-1$
+
+    private static final String processedDocument =
+        "\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryObjects (roKey, pos, roType) VALUES ('00000000000000000000000000000001', 0, 7);\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryEntries (roKey, majorVersion, minorVersion, userVersion) VALUES ('00000000000000000000000000000001', 1, 0, '1.0');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000001', 0, 'en', 'UTF-8', 'ObjectType');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000001', 1, 'en', 'UTF-8', 'The taxonomy of object types. Object types are categories below this taxonomy.');\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryObjects (roKey, pos, roType) VALUES ('00000000000000000000000000000002', 1, 7);\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryEntries (roKey, majorVersion, minorVersion, userVersion) VALUES ('00000000000000000000000000000002', 1, 0, '1.0');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000002', 0, 'en', 'UTF-8', 'AssociationType');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000002', 1, 'en', 'UTF-8', 'The taxonomy of association types. Association types are categories below this taxonomy.');\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryObjects (roKey, roOwnerRestricting, pos, roType) VALUES ('00000000000000000000000000000003', '00000000000000000000000000000001', 0, 10);\n" //$NON-NLS-1$
+        + "INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000003', 'Association');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000003', 0, 'en', 'UTF-8', 'Association');\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryObjects (roKey, roOwnerRestricting, pos, roType) VALUES ('00000000000000000000000000000004', '00000000000000000000000000000001', 1, 10);\n" //$NON-NLS-1$
+        + "INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000004', 'AuditableEvent');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000004', 0, 'en', 'UTF-8', 'AuditableEvent');\n" //$NON-NLS-1$
+        + "\n" //$NON-NLS-1$
+        + "INSERT INTO RegistryObjects (roKey, roOwnerRestricting, pos, roType) VALUES ('00000000000000000000000000000005', '00000000000000000000000000000001', 2, 10);\n" //$NON-NLS-1$
+        + "INSERT INTO Concepts (roKey, value) VALUES ('00000000000000000000000000000005', 'Classification');\n" //$NON-NLS-1$
+        + "INSERT INTO LocalizedStrings (roKey, lsType, locale, charset, val) VALUES ('00000000000000000000000000000005', 0, 'en', 'UTF-8', 'Classification');\n" //$NON-NLS-1$
+        + "\n"; //$NON-NLS-1$
+
+    /**
+     * Test for the &{macro, ...} definition.
+     */
+    @Test
+    public void testMacroDefinition() throws IOException {
+        final StringReader sr = new StringReader(document);
+        final MacroProcessor mp = MacroProcessor.newInstance(sr);
+        final StringWriter sw = new StringWriter();
+        final char[] buffer = new char[1024];
+        for (;;) {
+            int res = mp.read(buffer);
+            if (res == -1) {
+                break;
+            }
+            if (res > 0) {
+                sw.write(buffer, 0, res);
+            }
+        }
+        assertEquals(processedDocument, sw.toString());
+    }
+}

Propchange: labs/jaxmas/trunk/JaxMas/src/test/java/org/apache/labs/jaxmas/registry/schema/MacroProcessorTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org