/** * Create a ModelRecord instance from the specified index record */ public Schema createModelRecord(final char[] record) { final List<String> tokens = getStrings(record, IndexConstants.RECORD_STRING.RECORD_DELIMITER); final Schema model = new Schema(); // The tokens are the standard header values int tokenIndex = 0; setRecordHeaderValues(model, tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++)); // The next token is the max set size tokenIndex++; // The next token is the model type model.setPhysical(Integer.parseInt(tokens.get(tokenIndex++)) == 0); // The next token is the primary metamodel Uri model.setPrimaryMetamodelUri(getObjectValue(tokens.get(tokenIndex++))); // The next token are the supports flags tokens.get(tokenIndex++); // The next tokens are footer values - the footer will contain the version number for the index record setRecordFooterValues(model, tokens, tokenIndex); return model; }
/** * Create a ModelRecord instance from the specified index record */ public Schema createModelRecord(final char[] record) { final List<String> tokens = getStrings(record, IndexConstants.RECORD_STRING.RECORD_DELIMITER); final Schema model = new Schema(); // The tokens are the standard header values int tokenIndex = 0; setRecordHeaderValues(model, tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++)); // The next token is the max set size tokenIndex++; // The next token is the model type model.setPhysical(Integer.parseInt(tokens.get(tokenIndex++)) == 0); // The next token is the primary metamodel Uri model.setPrimaryMetamodelUri(getObjectValue(tokens.get(tokenIndex++))); // The next token are the supports flags tokens.get(tokenIndex++); // The next tokens are footer values - the footer will contain the version number for the index record setRecordFooterValues(model, tokens, tokenIndex); return model; }
/** * Create a virtual model with default settings. */ public static Schema createVirtualModel(String name, MetadataStore metadataStore) { Schema schema = new Schema(); schema.setName(name); schema.setPhysical(false); metadataStore.addSchema(schema); return schema; }
protected MetadataFactory createMetadataFactory(VDBMetaData vdb, MetadataStore store, ModelMetaData model, Map<String, ? extends VDBResource> vdbResources) { Map<String, Datatype> datatypes = store.getDatatypes(); MetadataFactory factory = new MetadataFactory(vdb.getName(), vdb.getVersion(), datatypes, model); factory.getSchema().setPhysical(model.isSource()); factory.setParser(new QueryParser()); //for thread safety each factory gets it's own instance. factory.setVdbResources(vdbResources); factory.setVDBClassLoader(vdb.getAttachment(ClassLoader.class)); return factory; }
schema = new Schema(); schema.setName(name); schema.setPhysical(physical); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SERVER:
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; }
schema.setAnnotation(m.getDescription()); schema.setVisible(m.isVisible()); schema.setPhysical(m.isSource()); schema.setProperties(m.getPropertiesMap()); metadataStore.addSchema(schema);
schema = new Schema(); schema.setName(name); schema.setPhysical(physical); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SERVER:
schema = new Schema(); schema.setName(name); schema.setPhysical(physical); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SERVER:
@Test public void testDDLMetadata() throws Exception { String ddl = "CREATE VIRTUAL FUNCTION SourceFunc(msg varchar) RETURNS varchar " + "OPTIONS(CATEGORY 'misc', DETERMINISM 'DETERMINISTIC', " + "\"NULL-ON-NULL\" 'true', JAVA_CLASS '"+TestFunctionPushdown.class.getName()+"', JAVA_METHOD 'sourceFunc');" + "CREATE VIEW X (Y varchar) as SELECT e1 from pm1.g1;"; MetadataFactory mf = TestDDLParser.helpParse(ddl, "model"); mf.getSchema().setPhysical(false); MetadataStore ms = mf.asMetadataStore(); ms.merge(RealMetadataFactory.example1Cached().getMetadataStore()); QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(ms, "example1"); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setFunctionSupport("model.SourceFunc", true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpPlan("select sourceFunc(y) from x", metadata, null, capFinder, new String[] {"SELECT sourceFunc(g_0.e1) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ caps.setFunctionSupport("model.SourceFunc", false); helpPlan("select sourceFunc(y) from x", metadata, null, capFinder, new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ }
@Test public void testSkipDocumentModel() throws Exception { ModelMetaData model = new ModelMetaData(); model.setName("xmlstuff"); model.setModelType(Model.Type.VIRTUAL); vdb.addModel(model); MetadataFactory mf = new MetadataFactory("myVDB",1, "xmlstuff", TestDDLParser.getDataTypes(), new Properties(), null); mf.getSchema().setPhysical(false); Table t = mf.addTable("xmldoctable"); t.setTableType(Table.Type.Document); mf.addColumn("c1", "string", t); t.setSelectTransformation("some dummy stuff, should not be validated"); t.setVirtual(true); Table t2 = mf.addTable("xmldoctable2"); t2.setTableType(Table.Type.XmlMappingClass); mf.addColumn("c1", "string", t2); t2.setSelectTransformation("some dummy stuff, should not be validated"); t2.setVirtual(true); mf.mergeInto(store); buildTransformationMetadata(); ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store); assertFalse(printError(report), report.hasItems()); }