[teiid-commits] teiid SVN: r2038 - in trunk: client/src/main/java/org/teiid/adminapi/impl and 2 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Apr 8 16:56:34 EDT 2010


Author: rareddy
Date: 2010-04-08 16:56:33 -0400 (Thu, 08 Apr 2010)
New Revision: 2038

Added:
   trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
Removed:
   trunk/common-core/src/main/java/com/metamatrix/core/vdb/ModelType.java
Modified:
   trunk/client/src/main/java/org/teiid/adminapi/Model.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
Log:
TEIID-998: Since the Model type is not a enumeration in the VDB.xml file, the Model.Type enum class and ModelMetadata classes need to be written to accept any "string" as model type and try to match the known types, if not found treat it as a type "OTHER" model.

Modified: trunk/client/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Model.java	2010-04-08 15:33:59 UTC (rev 2037)
+++ trunk/client/src/main/java/org/teiid/adminapi/Model.java	2010-04-08 20:56:33 UTC (rev 2038)
@@ -32,7 +32,7 @@
  */
 public interface Model extends AdminObject {
 	
-	enum Type {PHYSICAL, VIRTUAL, FUNCTION};
+	enum Type {PHYSICAL, VIRTUAL, FUNCTION, OTHER};
 	
 	/**
 	 * Description about the model

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2010-04-08 15:33:59 UTC (rev 2037)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2010-04-08 20:56:33 UTC (rev 2038)
@@ -39,9 +39,7 @@
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.teiid.adminapi.Model;
 
-import com.metamatrix.core.vdb.ModelType;
 
-
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlType(name = "", propOrder = {
 	"description",
@@ -102,7 +100,7 @@
 	@Override
 	@ManagementProperty(description = "Is Model Source model")
     public boolean isSource() {
-		return ModelType.parseString(modelType.toUpperCase()) == ModelType.PHYSICAL;
+		return getModelType() == Model.Type.PHYSICAL;
 	}
 
 	@Override
@@ -114,7 +112,11 @@
 	@Override
 	@ManagementProperty(description = "Model Type")
 	public Type getModelType() {
-		return Type.valueOf(modelType);
+		try {
+			return Type.valueOf(modelType.toUpperCase());
+		} catch(IllegalArgumentException e) {
+			return Type.OTHER;
+		}
 	}
 	
 	@ManagementProperty(description = "Path to model file inside the archive")

Added: trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java	                        (rev 0)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java	2010-04-08 20:56:33 UTC (rev 2038)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.teiid.adminapi.Model;
+
+public class TestModelMetaData {
+
+	@Test
+	public void testModelType() {
+		
+		ModelMetaData model = new ModelMetaData();
+		model.modelType = "physical";
+		
+		assertTrue(model.getModelType() == Model.Type.PHYSICAL);
+		assertTrue(model.isSource());
+		
+		model.modelType = "VIRTUAL";
+		assertTrue(model.getModelType() == Model.Type.VIRTUAL);
+		
+		model.modelType = "TYPE";
+		assertTrue(model.getModelType() == Model.Type.OTHER);
+		assertTrue(!model.isSource());
+	}
+	
+	@Test
+	public void testSupportMultiSource() {
+		ModelMetaData model = new ModelMetaData();
+		assertFalse(model.isSupportsMultiSourceBindings());
+		model.setSupportsMultiSourceBindings(true);
+		
+		assertTrue(model.isSupportsMultiSourceBindings());
+		
+		assertTrue(!model.getProperties().isEmpty());
+	}
+}


Property changes on: trunk/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/common-core/src/main/java/com/metamatrix/core/vdb/ModelType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/vdb/ModelType.java	2010-04-08 15:33:59 UTC (rev 2037)
+++ trunk/common-core/src/main/java/com/metamatrix/core/vdb/ModelType.java	2010-04-08 20:56:33 UTC (rev 2038)
@@ -1,114 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.core.vdb;
-
-/**
- * Fix me: these contants come from com.metamatrix.metamodels.relational.ModelType
- */
-public final class ModelType {
-
-    /**
-     * The '<em><b>PHYSICAL</b></em>' literal value.>
-     */
-    public static final int PHYSICAL = 0;
-
-    /**
-     * The '<em><b>VIRTUAL</b></em>' literal value.
-     */
-    public static final int VIRTUAL = 1;
-
-    /**
-     * The '<em><b>TYPE</b></em>' literal value.
-     */
-    public static final int TYPE = 2;
-
-    /**
-     * The '<em><b>VDB ARCHIVE</b></em>' literal value.
-     */
-    public static final int VDB_ARCHIVE = 3;
-
-    /**
-     * The '<em><b>UNKNOWN</b></em>' literal value.ed
-     */
-    public static final int UNKNOWN = 4;
-
-    /**
-     * The '<em><b>FUNCTION</b></em>' literal value.
-     */
-    public static final int FUNCTION = 5;
-
-    /**
-     * The '<em><b>CONFIGURATION</b></em>' literal value.
-     */
-    public static final int CONFIGURATION = 6;
-
-    /**
-     * The '<em><b>METAMODEL</b></em>' literal value.
-     */
-    public static final int METAMODEL = 7;
-
-    /**
-     * The '<em><b>EXTENSION</b></em>' literal value.d
-     */
-    public static final int EXTENSION = 8;
-
-    /**
-     * The '<em><b>LOGICAL</b></em>' literal value.
-     */
-    public static final int LOGICAL = 9;
-
-    /**
-     * The '<em><b>MATERIALIZATION</b></em>' literal value.
-     */
-    public static final int MATERIALIZATION = 10;
-
-    public static final String[] MODEL_NAMES = {
-        "PHYSICAL", //$NON-NLS-1$
-        "VIRTUAL", //$NON-NLS-1$
-        "TYPE", //$NON-NLS-1$
-        "VDB_ARCHIVE", //$NON-NLS-1$
-        "UNKNOWN", //$NON-NLS-1$
-        "FUNCTION", //$NON-NLS-1$
-        "CONFIGURATION", //$NON-NLS-1$
-        "METAMODEL", //$NON-NLS-1$
-        "EXTENSION", //$NON-NLS-1$
-        "LOGICAL", //$NON-NLS-1$
-        "MATERIALIZATION" //$NON-NLS-1$
-    };
-
-    public static int parseString(String s) {
-    	for(int i = PHYSICAL; i <= MATERIALIZATION; i++ ) {
-    		if (MODEL_NAMES[i].equals(s)) {
-    			return i;
-    		}
-    	}
-    	throw new IllegalArgumentException("Unknown model type"); //$NON-NLS-1$
-    }
-    
-    public static String getString(int modelType) {
-    	if (modelType < 0 || modelType >= MODEL_NAMES.length) {
-    		throw new IllegalArgumentException("Unknown model type"); //$NON-NLS-1$
-    	}
-    	return MODEL_NAMES[modelType];
-    }
-}



More information about the teiid-commits mailing list