node.get(VDBNAME).set(vdb.getName()); node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString()); node.get(STATUS).set(vdb.getStatus().toString()); node.get(VERSION).set(vdb.getVersion()); if (vdb.getDescription() != null) { node.get(VDB_DESCRIPTION).set(vdb.getDescription()); node.get(XML_DEPLOYMENT).set(vdb.isXmlDeployment()); List<VDBImportMetadata> imports = vdb.getVDBImports(); if (imports != null && !imports.isEmpty()) { ModelNode importNodes = node.get(IMPORT_VDBS); List<EntryMetaData> entries = vdb.getEntries(); if (entries != null && !entries.isEmpty()) { ModelNode entryNodes = node.get(ENTRIES); Map<String, ModelMetaData> models = vdb.getModelMetaDatas(); if (models != null && !models.isEmpty()) { ModelNode modelNodes = node.get(MODELS); List<Translator> translators = vdb.getOverrideTranslators(); if (translators != null && !translators.isEmpty()) { ModelNode translatorNodes = node.get(OVERRIDE_TRANSLATORS); List<DataPolicy> policies = vdb.getDataPolicies(); if (policies != null && !policies.isEmpty()) { ModelNode dataPoliciesNodes = node.get(DATA_POLICIES);
public static VDBMetaData examplePrivatePhysicalModelVDB() { VDBMetaData vdb = new VDBMetaData(); vdb.setName("example1"); vdb.setVersion(1); ModelMetaData m = RealMetadataFactory.createModel("pm1", true); m.setVisible(false); vdb.addModel(m); vdb.addModel(RealMetadataFactory.createModel("vm1", false)); return vdb; } }
public String getFullName() { return getName() + VERSION_DELIM + getVersion(); }
public void changeConnectionType(ConnectionType type) throws AdminProcessingException { synchronized (this.vdb) { ConnectionType previous = this.vdb.getConnectionType(); this.vdb.setConnectionType(type); try { this.listener.connectionTypeChanged(); } catch(AdminProcessingException e) { this.vdb.setConnectionType(previous); throw e; } } }
public void addPendingDeployment(VDBMetaData deployment) { deployment.setStatus(Status.LOADING); VDBKey key = new VDBKey(deployment.getName(), deployment.getVersion()); this.pendingDeployments.put(key, deployment); }
VDBMetaData vdb = new VDBMetaData(); if (node.has(VDBNAME)) { vdb.setName(node.get(VDBNAME).asString()); vdb.setConnectionType(node.get(CONNECTIONTYPE).asString()); vdb.setStatus(node.get(STATUS).asString()); vdb.setVersion(node.get(VERSION).asString()); vdb.setDescription(node.get(VDB_DESCRIPTION).asString()); vdb.setXmlDeployment(node.get(XML_DEPLOYMENT).asBoolean()); String[] prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode); if (prop != null) { vdb.addProperty(prop[0], prop[1]); VDBImportMetadata vdbImport = VDBImportMapper.INSTANCE.unwrap(modelNode); if (vdbImport != null) { vdb.getVDBImports().add(vdbImport); EntryMetaData entry = EntryMapper.INSTANCE.unwrap(modelNode); if (entry != null) { vdb.getEntries().add(entry); ModelMetaData model = ModelMetadataMapper.INSTANCE.unwrap(modelNode); if (model != null) { vdb.addModel(model);
public static VDBMetaData convert(Database database) { VDBMetaData vdb = new VDBMetaData(); vdb.setName(database.getName()); vdb.setVersion(database.getVersion()); vdb.setDescription(database.getAnnotation()); vdb.setConnectionType(VDB.ConnectionType.valueOf(database.getProperty("connection-type", false))); vdb.getPropertiesMap().putAll(database.getProperties()); vdb.addProperty(VDBMetaData.TEIID_DOMAINS, domainDDLString); translator.setDescription(dw.getAnnotation()); translator.getPropertiesMap().putAll(dw.getProperties()); vdb.addOverideTranslator(translator); mmd.setModelType(Model.Type.VIRTUAL); vdb.addModel(mmd);
public static Database convert(VDBMetaData vdb, MetadataStore metadataStore) { Database db = new Database(vdb.getName(), vdb.getVersion()); db.setProperties(vdb.getPropertiesMap()); if (vdb.getDescription() != null) { db.setAnnotation(vdb.getDescription()); db.setProperty("connection-type", vdb.getConnectionType().name()); List<Translator> translators = vdb.getOverrideTranslators(); for (Translator t: translators) { Collection<ModelMetaData> models = vdb.getModelMetaDatas().values(); for (ModelMetaData m:models) { Schema schema = metadataStore.getSchema(m.getName()); for (String key : vdb.getDataPolicyMap().keySet()) { DataPolicyMetadata dpm = vdb.getDataPolicyMap().get(key); Role role = new Role(dpm.getName()); if (dpm.getMappedRoleNames() != null && !dpm.getMappedRoleNames().isEmpty()) {
private void buildCompositeState(VDBRepository vdbRepository) throws VirtualDatabaseException { if (vdb.getVDBImports().isEmpty()) { this.vdb.addAttchment(ConnectorManagerRepository.class, this.cmr); return; VDBMetaData newMergedVDB = this.vdb.clone(); ConnectorManagerRepository mergedRepo = this.cmr; if (!this.cmr.isShared()) { newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo); ClassLoader[] toSearch = new ClassLoader[vdb.getVDBImports().size()+1]; toSearch[0] = this.vdb.getAttachment(ClassLoader.class); this.children = new LinkedHashMap<VDBKey, CompositeVDB>(); newMergedVDB.setImportedModels(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER)); LinkedHashSet<VDBImport> seen = new LinkedHashSet<>(vdb.getVDBImports()); Stack<VDBImport> toLoad = new Stack<VDBImport>(); toLoad.addAll(seen); throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40083, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40083, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion())); if (!originalChildVDB.getVDBImports().isEmpty() && originalChildVDB.getVisibilityOverrides().isEmpty() && originalChildVDB.getDataPolicies().isEmpty() && originalChildVDB.getModels().isEmpty()) { for (VDBImport childImport : originalChildVDB.getVDBImports()) { if (seen.add(childImport)) { toLoad.push(childImport); newMergedVDB.getVisibilityOverrides().putAll(childVDB.getVisibilityOverrides()); toSearch[i++] = childVDB.getAttachment(ClassLoader.class);
writeAttribute(writer, Element.NAME.getLocalName(), vdb.getName()); writeAttribute(writer, Element.VERSION.getLocalName(), String.valueOf(vdb.getVersion())); if (vdb.getDescription() != null) { writeElement(writer, Element.DESCRIPTION, vdb.getDescription()); writeElement(writer, Element.CONNECTION_TYPE, vdb.getConnectionType().name()); writeProperties(writer, vdb.getPropertiesMap()); for (VDBImport vdbImport : vdb.getVDBImports()) { writer.writeStartElement(Element.IMPORT_VDB.getLocalName()); writeAttribute(writer, Element.NAME.getLocalName(), vdbImport.getName()); Collection<ModelMetaData> models = vdb.getModelMetaDatas().values(); for (ModelMetaData model:models) { if (vdb.getImportedModels().contains(model.getName())) { continue; for(VDBTranslatorMetaData translator:vdb.getOverrideTranslatorsMap().values()) { writeTranslator(writer, translator); for (DataPolicy dp:vdb.getDataPolicies()) { writeDataPolicy(writer, dp); for (EntryMetaData em:vdb.getEntries()) { writer.writeStartElement(Element.ENTRY.getLocalName()); writeAttribute(writer, Element.PATH.getLocalName(), em.getPath());
public static void validateVDB(VDBMetaData vdb) { ModelMetaData modelOne; ModelMetaData modelTwo; assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$ assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$ assertEquals("connection-type", "NONE", vdb.getConnectionType().name()); assertEquals("1", vdb.getVersion()); assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("vdb-value2", vdb.getPropertyValue("vdb-property2")); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$ assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$ assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$ assertEquals(1, vdb.getVDBImports().size()); VDBImport vdbImport = vdb.getVDBImports().get(0); assertEquals("x", vdbImport.getName()); assertEquals("2", vdbImport.getVersion()); modelOne = vdb.getModel("model-one"); //$NON-NLS-1$ assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$ assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$ modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$ assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$ assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$ assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$ List<Translator> translators = vdb.getOverrideTranslators();
public static VDBMetaData buildVDB() { VDBMetaData vdb = new VDBMetaData(); vdb.setName("myVDB"); //$NON-NLS-1$ vdb.setDescription("vdb description"); //$NON-NLS-1$ vdb.setConnectionType("NONE"); vdb.setVersion(1); vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$ vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$ vdb.getVDBImports().add(vdbImport); modelOne.addSourceMetadata("OTHER", "other text"); vdb.addModel(modelOne); vdb.addModel(modelTwo); List<Translator> list = new ArrayList<Translator>(); list.add(t1); vdb.setOverrideTranslators(list); vdb.addDataPolicy(roleOne); em.setDescription("entry one"); em.addProperty("entryone", "1"); vdb.getEntries().add(em); vdb.getEntries().add(em2); return vdb;
@Override public byte[] getContent(VDBMetaData vdb) throws IOException { MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore(); String fullName = vdb.getName() + "_" + vdb.getVersion(); props.setProperty("${vdb-name}", vdb.getName()); props.setProperty("${vdb-version}", String.valueOf(vdb.getVersion())); props.setProperty("${api-page-title}", fullName + " API"); String securityType = vdb.getPropertyValue(REST_NAMESPACE+"security-type"); String securityDomain = vdb.getPropertyValue(REST_NAMESPACE+"security-domain"); String securityRole = vdb.getPropertyValue(REST_NAMESPACE+"security-role"); String version = vdb.getVersion(); VDBKey vdbKey = new VDBKey(vdb.getName(), vdb.getVersion()); for (ModelMetaData model:vdb.getModelMetaDatas().values()) { Schema schema = metadataStore.getSchema(model.getName()); if (schema == null) { byte[] viewContents = getViewClass(vdb.getName(), version, model.getName(), schema, true); if (viewContents != null) { writeEntry("WEB-INF/classes/org/teiid/jboss/rest/"+model.getName()+".class", out, viewContents); writeEntry("META-INF/MANIFEST.MF", out, getFileContents("rest-war/MANIFEST.MF").getBytes()); byte[] bytes = getBootstrapServletClass(vdb.getName(), vdb.getDescription() == null ? vdb.getName() : vdb.getDescription(), vdbKey.getSemanticVersion(), new String[]{"http"}, File.separator + props.getProperty("${context-name}"), "org.teiid.jboss.rest", true); writeEntry("WEB-INF/classes/org/teiid/jboss/rest/Bootstrap.class", out, bytes);
switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break;
public void createConnectorManagers(VDBMetaData deployment, ExecutionFactoryProvider provider) throws ConnectorManagerException { for (ModelMetaData model : deployment.getModelMetaDatas().values()) { List<String> sourceNames = model.getSourceNames(); if (sourceNames.size() != new HashSet<String>(sourceNames).size()) { throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31101, model.getName(), deployment.getName(), deployment.getVersion())); } if (sourceNames.size() > 1 && !model.isSupportsMultiSourceBindings()) { throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31102, model.getName(), deployment.getName(), deployment.getVersion())); } for (SourceMappingMetadata source : model.getSourceMappings()) { createConnectorManager(deployment, provider, source, false); } } }
public void setNewVDBState(DQPWorkContext newWorkContext) { this.vdbState = new VDBState(); VDBMetaData vdb = newWorkContext.getVDB(); GlobalTableStore actualGlobalStore = vdb.getAttachment(GlobalTableStore.class); this.vdbState.globalTables = actualGlobalStore; this.vdbState.session = newWorkContext.getSession(); this.vdbState.classLoader = vdb.getAttachment(ClassLoader.class); this.vdbState.vdbName = vdb.getName(); this.vdbState.vdbVersion = vdb.getVersion(); this.vdbState.dqpWorkContext = newWorkContext; TempMetadataAdapter metadata = new TempMetadataAdapter(vdb.getAttachment(QueryMetadataInterface.class), globalState.sessionTempTableStore.getMetadataStore()); metadata.setSession(true); this.vdbState.metadata = metadata; }
private MetadataFactory loadSchema(VDBMetaData vdb, Properties p, String name, QueryParser parser) { ModelMetaData mmd = new ModelMetaData(); mmd.setName(name); vdb.addModel(mmd); InputStream is = SystemMetadata.class.getClassLoader().getResourceAsStream("org/teiid/metadata/"+name+".sql"); //$NON-NLS-1$ //$NON-NLS-2$ try { MetadataFactory factory = new MetadataFactory(vdb.getName(), vdb.getVersion(), name, typeMap, p, null); parser.parseDDL(factory, new InputStreamReader(is, Charset.forName("UTF-8"))); //$NON-NLS-1$ for (Table t : factory.getSchema().getTables().values()) { t.setSystem(true); } return factory; } finally { try { is.close(); } catch (IOException e) { throw new TeiidRuntimeException(e); } } }
VDBMetaData vdb = new VDBMetaData(); vdb.setName("System"); //$NON-NLS-1$ vdb.setVersion(1); Properties p = new Properties(); this.systemFunctionManager = new SystemFunctionManager(typeMap); loadSchema(vdb, p, "SYSADMIN", parser).mergeInto(systemStore); //$NON-NLS-1$ TransformationMetadata tm = new TransformationMetadata(vdb, new CompositeMetadataStore(systemStore), null, systemFunctionManager.getSystemFunctions(), null); vdb.addAttchment(QueryMetadataInterface.class, tm); MetadataValidator validator = new MetadataValidator(this.typeMap, parser); ValidatorReport report = validator.validate(vdb, systemStore);
if (dataRolesRequired && vdb.getDataPolicyMap().isEmpty()) { throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40143, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40143, vdb)); String includePgMetadata = vdb.getPropertyValue("include-pg-metadata"); if (includePgMetadata != null) { pgMetadataEnabled = Boolean.parseBoolean(includePgMetadata); RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion())); vdb.setVersion(vdbKey.getVersion()); //canonicalize the version vdb.setStatus(Status.LOADING); this.vdbRepo.put(vdbKey, cvdb); this.pendingDeployments.remove(vdbKey); lock.unlock(); notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
if (vdb.getStatus() == Status.FAILED) { return; ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class); for (ModelMetaData model:vdb.getModelMetaDatas().values()) { String sourceName = getSourceName(dataSourceName, model); if (sourceName == null) { if (cm.getExecutionFactory().isSourceRequired() && vdb.getStatus() == Status.ACTIVE) { severity = Severity.ERROR; String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(), vdb.getVersion(), dataSourceName); model.addRuntimeMessage(severity, msg); LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);