private void checkStatus(List<Runnable> runnables, VDBMetaData vdb, ModelMetaData model, ConnectorManager cm) { //get the pending metadata load model.removeAttachment(VDBStatusChecker.class); Runnable r = model.removeAttachment(Runnable.class); if (r != null) { runnables.add(r); } else { String status = cm.getStausMessage(); if (status != null && status.length() > 0) { Severity severity = vdb.getStatus() == Status.LOADING?Severity.WARNING:Severity.ERROR; model.addRuntimeMessage(severity, status); LogManager.logInfo(LogConstants.CTX_RUNTIME, status); } else if (vdb.getStatus() != Status.LOADING){ model.clearRuntimeMessages(); } else { //mark the model to indicate that it should be reloaded if it //is currently failing a load model.addAttchment(VDBStatusChecker.class, this); } } }
protected void assignMetadataRepositories(VDBMetaData deployment, MetadataRepository<?, ?> defaultRepo) throws VirtualDatabaseException { for (ModelMetaData model:deployment.getModelMetaDatas().values()) { if (model.getModelType() != Type.OTHER && (model.getName() == null || model.getName().indexOf('.') >= 0) || model.getName().equalsIgnoreCase(CoreConstants.SYSTEM_MODEL) || model.getName().equalsIgnoreCase(CoreConstants.SYSTEM_ADMIN_MODEL) || model.getName().equalsIgnoreCase(CoreConstants.ODBC_MODEL)) { throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40121, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40121, model.getName(), deployment.getName(), deployment.getVersion())); } if (model.isSource() && model.getSourceNames().isEmpty()) { throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40093, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40093, model.getName(), deployment.getName(), deployment.getVersion())); } if (model.getModelType() == Type.FUNCTION || model.getModelType() == Type.OTHER) { continue; } MetadataRepository<?, ?> repo = getMetadataRepository(deployment, model, defaultRepo); //handle multi-source column creation if (model.isSupportsMultiSourceBindings() && Boolean.valueOf(model.getPropertyValue("multisource.addColumn"))) { //$NON-NLS-1$ List<MetadataRepository<?, ?>> repos = new ArrayList<MetadataRepository<?, ?>>(2); repos.add(repo); String columnName = model.getPropertyValue(MultiSourceMetadataWrapper.MULTISOURCE_COLUMN_NAME); repos.add(new MultiSourceMetadataRepository(columnName==null?MultiSourceElement.DEFAULT_MULTI_SOURCE_ELEMENT_NAME:columnName)); repo = new ChainingMetadataRepository(repos); } model.addAttchment(MetadataRepository.class, repo); } }
public static ModelMetaData buildModel(String modelName, boolean physical, VDBMetaData vdb, MetadataStore store, String ddl) throws Exception { ModelMetaData model = new ModelMetaData(); model.setName(modelName); model.setModelType(physical?Model.Type.PHYSICAL:Model.Type.VIRTUAL); vdb.addModel(model); DDLMetadataRepository repo = new DDLMetadataRepository(); MetadataFactory mf = new MetadataFactory("myVDB",1, modelName, TestDDLParser.getDataTypes(), new Properties(), ddl); mf.setParser(QueryParser.getQueryParser()); mf.getSchema().setPhysical(physical); repo.loadMetadata(mf, null, null, ddl); mf.mergeInto(store); model.addAttchment(MetadataFactory.class, mf); return model; }
private ModelMetaData buildSourceTableWithPK() { ModelMetaData model = new ModelMetaData(); model.setName("source"); model.setModelType(Model.Type.PHYSICAL); MetadataFactory target = new MetadataFactory(VDBNAME, VDBVERSION, SystemMetadata.getInstance().getRuntimeTypeMap(), model); Table t = target.addTable("Person"); target.addColumn("id", "integer", t); target.addColumn("name", "string", t); target.addColumn("dob", "date", t); target.addPrimaryKey("PK", Arrays.asList("id"), t); Table addr = target.addTable("address"); target.addColumn("id", "integer", addr); target.addColumn("street", "string", addr); target.addColumn("pid", "integer", addr); target.addPrimaryKey("PK", Arrays.asList("id"), addr); target.addForeignKey("FK", Arrays.asList("pid"), Arrays.asList("id"), "Person", addr); String ddl = DDLStringVisitor.getDDLString(target.getSchema(), null, null); model.addSourceMetadata("ddl", ddl); model.addAttchment(MetadataFactory.class, target); return model; }
private ModelMetaData buildSourceTableWithCompositePK() { ModelMetaData model = new ModelMetaData(); model.setName("source"); model.setModelType(Model.Type.PHYSICAL); MetadataFactory target = new MetadataFactory(VDBNAME, VDBVERSION, SystemMetadata.getInstance().getRuntimeTypeMap(), model); Table t = target.addTable("Person"); target.addColumn("id", "integer", t); target.addColumn("name", "string", t); target.addColumn("dob", "date", t); target.addPrimaryKey("PK", Arrays.asList("id", "name"), t); String ddl = DDLStringVisitor.getDDLString(target.getSchema(), null, null); model.addSourceMetadata("ddl", ddl); model.addAttchment(MetadataFactory.class, target); return model; }
private ModelMetaData buildSourceTable() { ModelMetaData model = new ModelMetaData(); model.setName("source"); model.setModelType(Model.Type.PHYSICAL); MetadataFactory target = new MetadataFactory(VDBNAME, VDBVERSION, SystemMetadata.getInstance().getRuntimeTypeMap(), model); Table t = target.addTable("Person"); target.addColumn("id", "integer", t); target.addColumn("name", "string", t); target.addColumn("dob", "date", t); model.addAttchment(MetadataFactory.class, target); String ddl = DDLStringVisitor.getDDLString(target.getSchema(), null, null); model.addSourceMetadata("ddl", ddl); return model; }