use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.
the class EmbeddedServer method deployVDB.
/**
* Deploy the given set of models as vdb name.1
* @param name
* @param models
* @throws ConnectorManagerException
* @throws VirtualDatabaseException
* @throws TranslatorException
*/
public void deployVDB(String name, ModelMetaData... models) throws ConnectorManagerException, VirtualDatabaseException, TranslatorException {
VDBMetaData vdb = new VDBMetaData();
vdb.setXmlDeployment(true);
VDBKey key = new VDBKey(name, null);
vdb.setName(key.getName());
if (key.isAtMost()) {
if (name.endsWith(".")) {
// error
} else {
// $NON-NLS-1$
vdb.setVersion("1");
}
} else {
vdb.setVersion(key.getVersion());
}
vdb.setModels(Arrays.asList(models));
// TODO: the api should be hardened to prevent the creation of invalid metadata
// missing source/translator names will cause issues
deployVDB(vdb, null);
}
use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.
the class VDBRepository method addVDB.
public void addVDB(VDBMetaData vdb, MetadataStore metadataStore, LinkedHashMap<String, VDBResources.Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws VirtualDatabaseException {
// get the system VDB metadata store
if (this.systemStore == null) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40022, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40022));
}
if (dataRolesRequired && vdb.getDataPolicyMap().isEmpty()) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40143, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40143, vdb));
}
boolean pgMetadataEnabled = ADD_PG_METADATA;
String includePgMetadata = vdb.getPropertyValue("include-pg-metadata");
if (includePgMetadata != null) {
pgMetadataEnabled = Boolean.parseBoolean(includePgMetadata);
}
if (pgMetadataEnabled && odbcException != null) {
throw odbcException;
}
MetadataStore[] stores = null;
if (pgMetadataEnabled) {
stores = new MetadataStore[] { this.systemStore, odbcStore };
} else {
stores = new MetadataStore[] { this.systemStore };
}
CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this, stores);
lock.lock();
try {
VDBKey vdbKey = cvdb.getVDBKey();
if (vdbKey.isAtMost()) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40145, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40145, vdbKey));
}
if (vdbRepo.containsKey(vdbKey)) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40035, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion()));
}
// canonicalize the version
vdb.setVersion(vdbKey.getVersion());
// save the key for comparisons
vdb.addAttchment(VDBKey.class, vdbKey);
vdb.setStatus(Status.LOADING);
this.vdbRepo.put(vdbKey, cvdb);
this.pendingDeployments.remove(vdbKey);
vdbAdded.signalAll();
} finally {
lock.unlock();
}
notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.
the class VDBRepository method addPendingDeployment.
public void addPendingDeployment(VDBMetaData deployment) {
deployment.setStatus(Status.LOADING);
VDBKey key = new VDBKey(deployment.getName(), deployment.getVersion());
this.pendingDeployments.put(key, deployment);
}
use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.
the class VDBRepository method getVDB.
public VDBMetaData getVDB(String vdbName, Object vdbVersion) {
VDBKey key = new VDBKey(vdbName, vdbVersion);
CompositeVDB cvdb = this.vdbRepo.get(key);
if (cvdb != null) {
return cvdb.getVDB();
}
return this.pendingDeployments.get(key);
}
use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.
the class VDBRepository method getLiveVDB.
/**
* A live vdb may be loading or active
* @param vdbName
* @return
*/
public VDBMetaData getLiveVDB(String vdbName) {
VDBMetaData result = null;
VDBKey key = new VDBKey(vdbName, null);
if (!key.isAtMost()) {
CompositeVDB v = this.vdbRepo.get(key);
if (v != null) {
return v.getVDB();
}
return null;
}
for (Map.Entry<VDBKey, CompositeVDB> entry : this.vdbRepo.tailMap(key).entrySet()) {
if (!key.acceptsVerion(entry.getKey())) {
break;
}
VDBMetaData vdb = entry.getValue().getVDB();
switch(vdb.getConnectionType()) {
case ANY:
result = vdb;
break;
case BY_VERSION:
case NONE:
if (result == null || result.getConnectionType() == ConnectionType.NONE) {
result = vdb;
}
break;
}
}
return result;
}
Aggregations