private UDFMetaData getUDF() { UDFMetaData mergedUDF = new UDFMetaData(); if (this.udf != null) { mergedUDF.addFunctions(this.udf); } for (Schema schema : store.getSchemas().values()) { Collection<FunctionMethod> funcs = schema.getFunctions().values(); mergedUDF.addFunctions(schema.getName(), funcs); } if (this.cmr != null) { // system scoped common source functions for (ConnectorManager cm : this.cmr.getConnectorManagers().values()) { List<FunctionMethod> funcs = cm.getPushDownFunctions(); mergedUDF.addFunctions(CoreConstants.SYSTEM_MODEL, funcs); } } if (this.children != null) { // udf model functions - also scoped to the model for (CompositeVDB child : this.children.values()) { UDFMetaData funcs = child.getUDF(); if (funcs != null) { mergedUDF.addFunctions(funcs); } } } return mergedUDF; }
@Override public void execute( VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) { for (Schema schema : store.getSchemaList()) { if (vdb.getImportedModels().contains(schema.getName())) { continue; } ModelMetaData model = vdb.getModel(schema.getName()); if (schema.getTables().isEmpty() && schema.getProcedures().isEmpty() && schema.getFunctions().isEmpty()) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31070, model.getName())); } for (Table t : schema.getTables().values()) { if (t.getColumns() == null || t.getColumns().size() == 0) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31071, t.getFullName())); } Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); validateConstraintNames(metadataValidator, report, model, t.getAllKeys(), names); validateConstraintNames( metadataValidator, report, model, t.getFunctionBasedIndexes(), names); } // procedure validation is handled in parsing routines. if (!schema.getFunctions().isEmpty()) { ActivityReport<ReportItem> funcReport = new ActivityReport<ReportItem>( "Translator metadata load " + model.getName()); // $NON-NLS-1$ FunctionMetadataValidator.validateFunctionMethods( teiidVersion, schema.getFunctions().values(), report); if (report.hasItems()) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31073, funcReport)); } } } }
private static TransformationMetadata buildTransformationMetaData( VDBMetaData vdb, LinkedHashMap<String, VDBResources.Resource> visibilityMap, MetadataStore store, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) { Collection<FunctionTree> udfs = new ArrayList<FunctionTree>(); if (udf != null) { for (Map.Entry<String, UDFSource> entry : udf.getFunctions().entrySet()) { udfs.add(new FunctionTree(entry.getKey(), entry.getValue(), true)); } } CompositeMetadataStore compositeStore = new CompositeMetadataStore(store); for (MetadataStore s : additionalStores) { compositeStore.merge(s); for (Schema schema : s.getSchemas().values()) { if (!schema.getFunctions().isEmpty()) { UDFSource source = new UDFSource(schema.getFunctions().values()); if (udf != null) { source.setClassLoader(udf.getClassLoader()); } udfs.add(new FunctionTree(schema.getName(), source, true)); } if (!schema.getProcedures().isEmpty()) { FunctionTree ft = FunctionTree.getFunctionProcedures(schema); if (ft != null) { udfs.add(ft); } } } } TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs); metadata.setUseOutputNames(false); metadata.setWidenComparisonToString(WIDEN_COMPARISON_TO_STRING); return metadata; }
private void visit(Schema schema) { boolean first = true; if (this.includeTables) { for (Table t : schema.getTables().values()) { if (first) { first = false; } else { append(NEWLINE); append(NEWLINE); } visit(t); } } if (this.includeProcedures) { for (Procedure p : schema.getProcedures().values()) { if (first) { first = false; } else { append(NEWLINE); append(NEWLINE); } visit(p); } } if (this.includeFunctions) { for (FunctionMethod f : schema.getFunctions().values()) { if (first) { first = false; } else { append(NEWLINE); append(NEWLINE); } visit(f); } } }
@Override public void execute( VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) { for (Schema schema : store.getSchemaList()) { if (vdb.getImportedModels().contains(schema.getName())) { continue; } ModelMetaData model = vdb.getModel(schema.getName()); for (Table t : schema.getTables().values()) { if (t.isPhysical() && !model.isSource()) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31075, t.getFullName(), model.getName())); } } Set<String> names = new HashSet<String>(); for (Procedure p : schema.getProcedures().values()) { boolean hasReturn = false; names.clear(); for (int i = 0; i < p.getParameters().size(); i++) { ProcedureParameter param = p.getParameters().get(i); if (param.isVarArg() && param != p.getParameters().get(p.getParameters().size() - 1)) { // check that the rest of the parameters are optional // this accommodates variadic multi-source procedures // effective this and the resolving logic ensure that you can used named parameters // for everything, // or call the vararg procedure as normal if (isTeiidOrGreater(Version.TEIID_8_10)) { for (int j = i + 1; j < p.getParameters().size(); j++) { ProcedureParameter param1 = p.getParameters().get(j); if ((param1.getType() == Type.In || param1.getType() == Type.InOut) && (param1.isVarArg() || (param1.getNullType() != NullType.Nullable && param1.getDefaultValue() == null))) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31112, p.getFullName())); } } } else { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31112, p.getFullName())); } } if (param.getType() == ProcedureParameter.Type.ReturnValue) { if (hasReturn) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31107, p.getFullName())); } hasReturn = true; } else if (p.isFunction() && param.getType() != ProcedureParameter.Type.In && teiidVersion.isGreaterThanOrEqualTo(Version.TEIID_8_11)) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31165, p.getFullName(), param.getFullName())); } if (!names.add(param.getName())) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31106, p.getFullName(), param.getFullName())); } } if (!p.isVirtual() && !model.isSource()) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31077, p.getFullName(), model.getName())); } if (p.isFunction() && teiidVersion.isGreaterThanOrEqualTo(Version.TEIID_8_11)) { if (!hasReturn) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31166, p.getFullName())); } if (p.isVirtual() && p.getQueryPlan() == null) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31167, p.getFullName())); } } } for (FunctionMethod func : schema.getFunctions().values()) { for (FunctionParameter param : func.getInputParameters()) { if (param.isVarArg() && param != func.getInputParameters().get(func.getInputParameterCount() - 1)) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31112, func.getFullName())); } } if (func.getPushdown().equals(FunctionMethod.PushDown.MUST_PUSHDOWN) && !model.isSource()) { metadataValidator.log( report, model, Messages.gs(Messages.TEIID.TEIID31078, func.getFullName(), model.getName())); } } } }