Skip to content

Commit

Permalink
TEIID-2449 allowing for non-Designer vdb zips
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Mar 28, 2013
1 parent 6f96e47 commit 19d945d
Show file tree
Hide file tree
Showing 56 changed files with 886 additions and 2,480 deletions.
14 changes: 9 additions & 5 deletions admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
Expand Up @@ -51,7 +51,7 @@ public class VDBMetaData extends AdminObjectImpl implements VDB, Cloneable {

private int version = 1;
private String description;
private boolean dynamic = false;
private boolean xmlDeployment = false;
private volatile VDB.Status status = VDB.Status.ACTIVE;
private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
private long queryTimeout = Long.MIN_VALUE;
Expand Down Expand Up @@ -191,12 +191,16 @@ public ModelMetaData getModel(String modelName) {
return this.models.get(modelName);
}

public boolean isDynamic() {
return dynamic;
/**
* If this is a *-vdb.xml deployment
* @return
*/
public boolean isXmlDeployment() {
return xmlDeployment;
}

public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
public void setXmlDeployment(boolean dynamic) {
this.xmlDeployment = dynamic;
}

@Override
Expand Down
Expand Up @@ -49,7 +49,7 @@ public class VDBMetadataMapper implements MetadataMapper<VDBMetaData> {
private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
private static final String VDB_DESCRIPTION = "vdb-description"; //$NON-NLS-1$
private static final String PROPERTIES = "properties"; //$NON-NLS-1$
private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
private static final String XML_DEPLOYMENT = "xml-deployment"; //$NON-NLS-1$
private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
private static final String ENTRIES = "entries"; //$NON-NLS-1$
Expand All @@ -68,7 +68,7 @@ public ModelNode wrap(VDBMetaData vdb, ModelNode node) {
if (vdb.getDescription() != null) {
node.get(VDB_DESCRIPTION).set(vdb.getDescription());
}
node.get(DYNAMIC).set(vdb.isDynamic());
node.get(XML_DEPLOYMENT).set(vdb.isXmlDeployment());

//PROPERTIES
Properties properties = vdb.getProperties();
Expand Down Expand Up @@ -148,8 +148,8 @@ public VDBMetaData unwrap(ModelNode node) {
if(node.has(VDB_DESCRIPTION)) {
vdb.setDescription(node.get(VDB_DESCRIPTION).asString());
}
if (node.has(DYNAMIC)) {
vdb.setDynamic(node.get(DYNAMIC).asBoolean());
if (node.has(XML_DEPLOYMENT)) {
vdb.setXmlDeployment(node.get(XML_DEPLOYMENT).asBoolean());
}

//PROPERTIES
Expand Down Expand Up @@ -242,7 +242,7 @@ public ModelNode describe(ModelNode node) {

addAttribute(node, VERSION, ModelType.INT, true);
addAttribute(node, VDB_DESCRIPTION, ModelType.STRING, false);
addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
addAttribute(node, XML_DEPLOYMENT, ModelType.BOOLEAN, false);

ModelNode props = node.get(PROPERTIES);
props.get(TYPE).set(ModelType.LIST);
Expand Down
Expand Up @@ -7,7 +7,7 @@ connection-type.describe=Allowable Connections: 1) NONE - disallow new connectio
status.describe=The Virtual Database Status
vdb-version.describe=The Virtual Database Version
url.describe=The Virtual Database URL
dynamic.describe=Dynamic Virtual Database
xml-deployment.describe=If the deployment is only the vdb.xml file.
property-name.describe=Name
property-value.describe=Property value
visible.describe=Visibility of the model
Expand Down
Expand Up @@ -251,9 +251,9 @@ public void testVDBMetaDataDescribe() throws Exception {
@Test
public void testClone() {
VDBMetaData vdb = buildVDB();
vdb.setDynamic(true);
vdb.setXmlDeployment(true);
VDBMetaData clone = vdb.clone();
assertTrue(clone.isDynamic());
assertTrue(clone.isXmlDeployment());
assertEquals(1, vdb.getVDBImports().size());
assertNotSame(clone.getModelMetaDatas(), vdb.getModelMetaDatas());
}
Expand Down
4 changes: 2 additions & 2 deletions admin/src/test/resources/vdb-describe.txt
Expand Up @@ -45,11 +45,11 @@
"description" : "Description of the Virtual Database",
"required" : false
},
"dynamic" : {
"xml-deployment" : {
"type" : {
"TYPE_MODEL_VALUE" : "BOOLEAN"
},
"description" : "Dynamic Virtual Database",
"description" : "If the deployment is only the vdb.xml file.",
"required" : false
},
"properties" : {
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/org/teiid/metadata/MetadataFactory.java
Expand Up @@ -72,6 +72,7 @@ public class MetadataFactory implements Serializable {
protected int count;
private transient Parser parser;
private transient ModelMetaData model;
private transient Map<String, ? extends VDBResource> vdbResources;

public static final String SF_URI = "{http://www.teiid.org/translator/salesforce/2012}"; //$NON-NLS-1$
public static final String WS_URI = "{http://www.teiid.org/translator/ws/2012}"; //$NON-NLS-1$
Expand Down Expand Up @@ -637,4 +638,12 @@ public void setModel(ModelMetaData model) {
public Parser getParser() {
return parser;
}

public Map<String, ? extends VDBResource> getVDBResources() {
return this.vdbResources;
}

public void setVdbResources(Map<String, ? extends VDBResource> vdbResources) {
this.vdbResources = vdbResources;
}
}
Expand Up @@ -22,16 +22,37 @@

package org.teiid.metadata;


import java.io.IOException;
import java.io.InputStream;

/**
* Constants used for VDB processing.
* Represents a resource available with the VDB deployment.
*/
public interface VdbConstants {
public interface VDBResource {

/**
* Open an {@link InputStream} to the resource
* @return
* @throws IOException
*/
InputStream openStream() throws IOException;

/**
* Get the size in bytes
* @return
*/
long getSize();

/**
* Get the resource name.
* @return
*/
String getName();

/**
* If the resource if visible in system metadata
* @return
*/
boolean isVisible();

public static final String DEPLOYMENT_FILE = "vdb.xml"; // !!! DO NOT CHANGE VALUE as this would cause problems with existing VDBs having DEF files !!! //$NON-NLS-1$
public static final String VDB_ARCHIVE_EXTENSION = ".vdb"; //$NON-NLS-1$
public final static String INDEX_EXT = ".INDEX"; //$NON-NLS-1$
public final static String SEARCH_INDEX_EXT = ".SEARCH_INDEX"; //$NON-NLS-1$
public final static String MODEL_EXT = ".xmi"; //$NON-NLS-1$
}
8 changes: 7 additions & 1 deletion build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Expand Up @@ -29,16 +29,22 @@ <H2><A NAME="Highlights"></A>Highlights</H2>
<li>TEIID-2429 Improved sort performance for large data sets especially under heavy load.
<li>TEIID-2423 Added an xml deployment option for Teiid Embedded.
<li>TEIID-1092 Added the teiid_session_set and teiid_session_get methods to maintain session variables.
<li>TEIID-2449 Added the ability to deploy non-Designer based vdb zip artifacts with the ability to place DDL outside of the VDB.xml via the DDL-FILE metadata repository.
</ul>

<h2><a name="Compatibility">Compatibility Issues</a></h2>
<ul>
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
<li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
<li>The custom appenders for command and audit logging has been changed, now they need to be developed for java.util.logging based Handler.(TEIID-2267)
<li>TEIID-2267 The custom appenders for command and audit logging has been changed, now they need to be developed for java.util.logging based Handler.
</ul>

<h4>from 8.2</h4>
<ul>
<li>TEIID-2429 Sorts over data sets over a single batch are not guaranteed to be sorted in a stable manor to improve performance. The sort will still be correct with respect to the sort keys.
</ul>

<h4>from 8.2</h4>
<ul>
<li>TEIID-2253 the multi-source implementation logic was significantly altered the following changes were introduced.
Expand Down
Expand Up @@ -234,6 +234,9 @@ protected long getSize(Object obj, Class<?> type, boolean updateEstimate, boolea
if (length >= 0) {
return 40 + alignMemory(length);
}
} else if (isf.getStorageMode() == StorageMode.PERSISTENT) {
long length = isf.getLength();
return 40 + alignMemory(Math.min(DataTypeManager.MAX_LOB_MEMORY_BYTES, length));
}
}
} catch (Exception e) {
Expand Down
3 changes: 2 additions & 1 deletion engine/src/main/java/org/teiid/query/QueryPlugin.java
Expand Up @@ -548,6 +548,7 @@ public static enum Event implements BundleUtil.Event{
TEIID31133,
TEIID31134,
TEIID31135,
TEIID31136,
TEIID31136,
TEIID31137,
}
}
@@ -0,0 +1,65 @@
/*
* 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.query.metadata;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

import org.teiid.metadata.MetadataException;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.MetadataRepository;
import org.teiid.metadata.VDBResource;
import org.teiid.query.QueryPlugin;
import org.teiid.query.QueryPlugin.Event;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorException;

public class DDLFileMetadataRepository extends MetadataRepository {

@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
if (factory.getRawMetadata() != null) {
VDBResource resource = factory.getVDBResources().get(factory.getRawMetadata());
if (resource == null) {
throw new MetadataException(Event.TEIID31137, QueryPlugin.Util.gs(Event.TEIID31137, factory.getRawMetadata()));
}
InputStream is;
try {
is = resource.openStream();
} catch (IOException e1) {
throw new MetadataException(e1);
}
try {
//TODO: could allow for a property driven encoding
factory.parse(new InputStreamReader(is, Charset.forName("UTF-8"))); //$NON-NLS-1$
} finally {
try {
is.close();
} catch (IOException e) {
}
}
}
}

}

0 comments on commit 19d945d

Please sign in to comment.