public String getFullName() { return procedure.getFullName(); } }
public String buildProcedureSQL() { StringBuilder sql = new StringBuilder(); // fully qualify the procedure name if (getReturn().hasResultSet()) { sql.append("{"); //$NON-NLS-1$ } else { sql.append("{? = "); //$NON-NLS-1$ } sql.append("call ").append(SQLStringVisitor.escapeSinglePart(this.procedure.getFullName())); //$NON-NLS-1$ sql.append("("); //$NON-NLS-1$ boolean first = true; for (SQLParameter parameter:this.sqlParameters) { if (!first) { sql.append(","); //$NON-NLS-1$ } first = false; sql.append(SQLStringVisitor.escapeSinglePart(parameter.getName())).append("=>?"); //$NON-NLS-1$ } sql.append(")"); //$NON-NLS-1$ sql.append("}"); //$NON-NLS-1$ return sql.toString(); }
public ProcedureParameter renameParameter(String oldName, String name, Procedure procedure) { if (this.autoCorrectColumnNames) { name = name.replace(AbstractMetadataRecord.NAME_DELIM_CHAR, '_'); } else if (name.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR) != -1) { throw new MetadataException(DataPlugin.Event.TEIID60008, DataPlugin.Util.gs(DataPlugin.Event.TEIID60008, procedure.getFullName(), name)); } if (procedure.getParameterByName(name) != null) { throw new DuplicateRecordException(DataPlugin.Event.TEIID60016, DataPlugin.Util.gs(DataPlugin.Event.TEIID60016, procedure.getFullName() + AbstractMetadataRecord.NAME_DELIM_CHAR + name)); } ProcedureParameter param = procedure.getParameterByName(oldName); if (param == null) { throw new MetadataException(DataPlugin.Event.TEIID60040, DataPlugin.Util.gs(DataPlugin.Event.TEIID60040, procedure.getFullName(), oldName)); } param.setName(name); return param; }
public static void alterProcedureDefinition(final VDBMetaData vdb, final Procedure p, final String sql, boolean updateStore) { TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); DatabaseStore store = vdb.getAttachment(DatabaseStore.class); try { Command command = QueryParser.getQueryParser().parseProcedure(p.getQueryPlan(), false); QueryResolver.resolveCommand(command, new GroupSymbol(p.getFullName()), Command.TYPE_STORED_PROCEDURE, metadata, false); MetadataValidator.determineDependencies(p, command); } catch (TeiidException e) { //should have been caught in validation, but this logic //is also not mature so since there is no lock on the vdb //it is possible that the plan is no longer valid at this point due //to a concurrent execution } p.setQueryPlan(sql); p.setLastModified(System.currentTimeMillis()); metadata.addToMetadataCache(p, "transformation/"+StoredProcedure.class.getSimpleName().toUpperCase(), null); //$NON-NLS-1$ }
public static void alterProcedureDefinition(final VDBMetaData vdb, final Procedure p, final String sql, boolean updateStore) { TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); DatabaseStore store = vdb.getAttachment(DatabaseStore.class); try { Command command = QueryParser.getQueryParser().parseProcedure(p.getQueryPlan(), false); QueryResolver.resolveCommand(command, new GroupSymbol(p.getFullName()), Command.TYPE_STORED_PROCEDURE, metadata, false); MetadataValidator.determineDependencies(p, command); } catch (TeiidException e) { //should have been caught in validation, but this logic //is also not mature so since there is no lock on the vdb //it is possible that the plan is no longer valid at this point due //to a concurrent execution } p.setQueryPlan(sql); p.setLastModified(System.currentTimeMillis()); metadata.addToMetadataCache(p, "transformation/"+StoredProcedure.class.getSimpleName().toUpperCase(), null); //$NON-NLS-1$ }
public static void alterProcedureDefinition(final VDBMetaData vdb, final Procedure p, final String sql, boolean updateStore) { TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); DatabaseStore store = vdb.getAttachment(DatabaseStore.class); try { Command command = QueryParser.getQueryParser().parseProcedure(p.getQueryPlan(), false); QueryResolver.resolveCommand(command, new GroupSymbol(p.getFullName()), Command.TYPE_STORED_PROCEDURE, metadata, false); MetadataValidator.determineDependencies(p, command); } catch (TeiidException e) { //should have been caught in validation, but this logic //is also not mature so since there is no lock on the vdb //it is possible that the plan is no longer valid at this point due //to a concurrent execution } p.setQueryPlan(sql); p.setLastModified(System.currentTimeMillis()); metadata.addToMetadataCache(p, "transformation/"+StoredProcedure.class.getSimpleName().toUpperCase(), null); //$NON-NLS-1$ }
static void buildProcedures(org.teiid.metadata.Schema schema, CsdlSchema csdlSchema) { // procedures ArrayList<CsdlComplexType> complexTypes = new ArrayList<CsdlComplexType>(); ArrayList<CsdlFunction> functions = new ArrayList<CsdlFunction>(); ArrayList<CsdlFunctionImport> functionImports = new ArrayList<CsdlFunctionImport>(); ArrayList<CsdlAction> actions = new ArrayList<CsdlAction>(); ArrayList<CsdlActionImport> actionImports = new ArrayList<CsdlActionImport>(); for (Procedure proc : schema.getProcedures().values()) { if (!allowedProcedure(proc)){ LogManager.logDetail(LogConstants.CTX_ODATA, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16032, proc.getFullName())); continue; } if (isFuntion(proc)) { buildFunction(schema.getName(), proc, complexTypes, functions, functionImports, csdlSchema); } else { buildAction(schema.getName(), proc, complexTypes, actions, actionImports, csdlSchema); } } csdlSchema.setComplexTypes(complexTypes); csdlSchema.setFunctions(functions); csdlSchema.setActions(actions); csdlSchema.getEntityContainer().setFunctionImports(functionImports); csdlSchema.getEntityContainer().setActionImports(actionImports); }
public void setProcedureDefinition(final String procedureName, final String definition) { if (!assertInEditMode(Mode.SCHEMA)) { return; } Procedure procedure = (Procedure)getSchemaRecord(procedureName, ResourceType.PROCEDURE); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.PROCEDURE, procedure); if (!procedure.isVirtual()) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31238, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31238, procedure.getFullName())); } procedure.setQueryPlan(definition); }
public void setProcedureDefinition(final String procedureName, final String definition) { if (!assertInEditMode(Mode.SCHEMA)) { return; } Procedure procedure = (Procedure)getSchemaRecord(procedureName, ResourceType.PROCEDURE); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.PROCEDURE, procedure); if (!procedure.isVirtual()) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31238, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31238, procedure.getFullName())); } procedure.setQueryPlan(definition); }
public void procedureDropped(String procedureName, Boolean virtual) { if (!assertInEditMode(Mode.SCHEMA)) { return; } Procedure procedure = (Procedure)getSchemaRecord(procedureName, ResourceType.PROCEDURE); if (virtual != null && virtual^procedure.isVirtual()) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31273, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31273, procedure.getFullName())); } assertGrant(Grant.Permission.Privilege.DROP, Database.ResourceType.PROCEDURE, procedure); Schema s = procedure.getParent(); s.removeProcedure(procedureName); }
public void procedureDropped(String procedureName, Boolean virtual) { if (!assertInEditMode(Mode.SCHEMA)) { return; } Procedure procedure = (Procedure)getSchemaRecord(procedureName, ResourceType.PROCEDURE); if (virtual != null && virtual^procedure.isVirtual()) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31273, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31273, procedure.getFullName())); } assertGrant(Grant.Permission.Privilege.DROP, Database.ResourceType.PROCEDURE, procedure); Schema s = procedure.getParent(); s.removeProcedure(procedureName); }
if ((param1.getType() == Type.In || param1.getType() == Type.InOut) && (param1.isVarArg() || (param1.getNullType() != NullType.Nullable && param1.getDefaultValue() == null))) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31112, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31107, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31165, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31106, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31077, p.getFullName(), model.getName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31166, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31167, p.getFullName()));
if ((param1.getType() == Type.In || param1.getType() == Type.InOut) && (param1.isVarArg() || (param1.getNullType() != NullType.Nullable && param1.getDefaultValue() == null))) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31112, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31107, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31165, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31106, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31077, p.getFullName(), model.getName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31166, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31167, p.getFullName()));
if ((param1.getType() == Type.In || param1.getType() == Type.InOut) && (param1.isVarArg() || (param1.getNullType() != NullType.Nullable && param1.getDefaultValue() == null))) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31112, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31107, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31165, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31106, p.getFullName(), param.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31077, p.getFullName(), model.getName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31166, p.getFullName())); metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31167, p.getFullName()));
public static ComplexDocumentNode buildComplexDocumentNode( EdmOperation edmOperation, MetadataStore metadata, OData odata, UniqueNameGenerator nameGenerator, boolean useAlias, UriInfo uriInfo, URLParseService parseService) throws TeiidProcessingException { ComplexDocumentNode resource = new ComplexDocumentNode(); FullQualifiedName fqn = edmOperation.getFullQualifiedName(); String withoutVDB = fqn.getNamespace().substring(fqn.getNamespace().lastIndexOf('.')+1); Schema schema = metadata.getSchema(withoutVDB); Procedure procedure = schema.getProcedure(edmOperation.getName()); StoredProcedure storedQuery = new StoredProcedure(); storedQuery.setProcedureName(procedure.getFullName()); //$NON-NLS-1$ for (int i = 0; i < procedure.getParameters().size(); i++) { storedQuery.setParameter(new SPParameter(i+1, new Reference(i))); } String group = nameGenerator.getNextGroup(); SubqueryFromClause sfc = new SubqueryFromClause(group, storedQuery); //$NON-NLS-1$ resource.setGroupSymbol(new GroupSymbol(group)); resource.setFromClause(sfc); resource.procedure = procedure; return resource; }
String procedureFullName = procRecord.getFullName();
String procedureFullName = procRecord.getFullName();
if (p.isVirtual()) { if (p.getQueryPlan() == null) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31081, p.getFullName(), model.getName()));
if (p.isVirtual()) { if (p.getQueryPlan() == null) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31081, p.getFullName(), model.getName()));
if (p.isVirtual()) { if (p.getQueryPlan() == null) { metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31081, p.getFullName(), model.getName()));