use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class VDBService method start.
@Override
public void start(final StartContext context) throws StartException {
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
TranslatorRepository repo = new TranslatorRepository();
this.vdb.addAttchment(TranslatorRepository.class, repo);
// check if this is a VDB with index files, if there are then build the TransformationMetadata
UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
// add required connector managers; if they are not already there
for (Translator t : this.vdb.getOverrideTranslators()) {
VDBTranslatorMetaData data = (VDBTranslatorMetaData) t;
String type = data.getType();
VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
data.setModuleName(parent.getModuleName());
data.addAttchment(ClassLoader.class, parent.getAttachment(ClassLoader.class));
data.setParent(parent);
repo.addTranslatorMetadata(data.getName(), data);
}
createConnectorManagers(cmr, repo, this.vdb);
final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
this.vdbListener = new VDBLifeCycleListener() {
@Override
public void added(String name, CompositeVDB cvdb) {
}
@Override
public void beforeRemove(String name, CompositeVDB cvdb) {
}
@Override
public void removed(String name, CompositeVDB cvdb) {
}
@Override
public void finishedDeployment(String name, CompositeVDB cvdb) {
if (!VDBService.this.vdbKey.equals(cvdb.getVDBKey())) {
return;
}
// clear out the indexmetadatarepository as it holds state that is no longer necessary
// $NON-NLS-1$
repositories.put("index", new IndexMetadataRepository());
VDBMetaData vdbInstance = cvdb.getVDB();
if (vdbInstance.getStatus().equals(Status.ACTIVE)) {
vdbService.install();
}
}
};
getVDBRepository().addListener(this.vdbListener);
MetadataStore store = new MetadataStore();
try {
// check to see if there is an index file. if there is then we assume
// that index is the default metadata repo
MetadataRepository<?, ?> defaultRepo = null;
for (String s : this.vdbResources.getEntriesPlusVisibilities().keySet()) {
if (s.endsWith(VDBResources.INDEX_EXT)) {
// $NON-NLS-1$
defaultRepo = super.getMetadataRepository("index");
break;
}
}
this.assignMetadataRepositories(vdb, defaultRepo);
// add transformation metadata to the repository.
getVDBRepository().addVDB(this.vdb, store, vdbResources.getEntriesPlusVisibilities(), udf, cmr);
} catch (VirtualDatabaseException e) {
cleanup(context);
throw new StartException(e);
}
this.vdb.removeAttachment(UDFMetaData.class);
try {
loadMetadata(this.vdb, cmr, store, this.vdbResources);
} catch (TranslatorException e) {
cleanup(context);
throw new StartException(e);
}
this.runtimeVDB = buildRuntimeVDB(this.vdb, context.getController().getServiceContainer());
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class TestVDBMetaData method testMarshellUnmarshellDirectParsing.
@Test
public void testMarshellUnmarshellDirectParsing() throws Exception {
VDBMetaData vdb = TestVDBUtility.buildVDB();
ByteArrayOutputStream out = new ByteArrayOutputStream();
VDBMetadataParser.marshell(vdb, out);
// System.out.println(new String(out.toByteArray()));
// UnMarshell
vdb = VDBMetadataParser.unmarshell(new ByteArrayInputStream(out.toByteArray()));
TestVDBUtility.validateVDB(vdb);
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class TestVDBMetaData method testAdminMOCreation.
@Test
public void testAdminMOCreation() {
VDBMetaData vdb = new VDBMetaData();
PropertiesUtils.setBeanProperty(vdb, "name", "x");
assertEquals("x", vdb.getName());
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class TestVDBMetaData method testVDBMetaDataMapper.
@Test
public void testVDBMetaDataMapper() {
VDBMetaData vdb = TestVDBUtility.buildVDB();
ModelNode node = VDBMetadataMapper.INSTANCE.wrap(vdb, new ModelNode());
vdb = VDBMetadataMapper.INSTANCE.unwrap(node);
TestVDBUtility.validateVDB(vdb);
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class TestVDBMetaData method testClone.
@Test
public void testClone() {
VDBMetaData vdb = TestVDBUtility.buildVDB();
vdb.setXmlDeployment(true);
VDBMetaData clone = vdb.clone();
assertTrue(clone.isXmlDeployment());
assertEquals(1, vdb.getVDBImports().size());
assertNotSame(clone.getModelMetaDatas(), vdb.getModelMetaDatas());
// assertNotSame(clone.getDataPolicyMap(), vdb.getDataPolicyMap());
}
Aggregations