use of org.teiid.metadata.Procedure in project teiid by teiid.
the class RestASMBasedWebArchiveBuilder method findContentType.
private String findContentType(Procedure procedure) {
String contentType = "plain";
ColumnSet<Procedure> rs = procedure.getResultSet();
if (rs != null) {
Column returnColumn = rs.getColumns().get(0);
if (returnColumn.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.XML)) {
// $NON-NLS-1$
contentType = "xml";
} else if (returnColumn.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.CLOB)) {
contentType = "json";
}
} else {
for (ProcedureParameter pp : procedure.getParameters()) {
if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
if (pp.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.XML)) {
// $NON-NLS-1$
contentType = "xml";
} else if (pp.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.CLOB)) {
// $NON-NLS-1$
contentType = "json";
}
}
}
}
return contentType;
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class RestASMBasedWebArchiveBuilder method hasRestMetadata.
@Override
public boolean hasRestMetadata(VDBMetaData vdb) {
// $NON-NLS-1$
String generate = vdb.getPropertyValue(REST_NAMESPACE + "auto-generate");
if (generate == null || !Boolean.parseBoolean(generate)) {
return false;
}
// $NON-NLS-1$
String securityType = vdb.getPropertyValue(REST_NAMESPACE + "security-type");
if (securityType != null && !securityType.equalsIgnoreCase("none") && !securityType.equalsIgnoreCase("httpbasic")) {
// $NON-NLS-1$ //$NON-NLS-2$
return false;
}
MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
Schema schema = metadataStore.getSchema(model.getName());
if (schema == null) {
// OTHER type, which does not have a corresponding Teiid schema
continue;
}
Collection<Procedure> procedures = schema.getProcedures().values();
for (Procedure procedure : procedures) {
// $NON-NLS-1$
String uri = procedure.getProperty(REST_NAMESPACE + "URI", false);
// $NON-NLS-1$
String method = procedure.getProperty(REST_NAMESPACE + "METHOD", false);
if (uri != null && method != null) {
return true;
}
}
}
return false;
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class EventDistributorImpl method setProcedureDefinition.
@Override
public void setProcedureDefinition(String vdbName, String vdbVersion, String schema, String procName, String definition) {
Schema s = getSchema(vdbName, vdbVersion, schema);
if (s == null) {
return;
}
Procedure p = s.getProcedures().get(procName);
if (p == null) {
return;
}
DdlPlan.alterProcedureDefinition(getVdbRepository().getLiveVDB(vdbName, vdbVersion), p, definition, true);
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class MultiSourceMetadataRepository method loadMetadata.
@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory<Object, Object> executionFactory, Object connectionFactory) throws TranslatorException {
Schema s = factory.getSchema();
for (Table t : s.getTables().values()) {
if (!t.isPhysical()) {
continue;
}
Column c = t.getColumnByName(multiSourceColumnName);
if (c == null) {
c = factory.addColumn(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, t);
MultiSourceMetadataWrapper.setMultiSourceElementMetadata(c);
}
}
outer: for (Procedure p : s.getProcedures().values()) {
if (p.isVirtual()) {
continue;
}
for (ProcedureParameter pp : p.getParameters()) {
if (multiSourceColumnName.equalsIgnoreCase(pp.getName())) {
continue outer;
}
}
ProcedureParameter pp = factory.addProcedureParameter(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, Type.In, p);
pp.setNullType(NullType.Nullable);
}
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestMetadataObject method helpTestProcedureID.
public void helpTestProcedureID(String procName, String shortName, int inputParamCount, String[] paramNames, String rsParamName, TranslationUtility transUtil) throws Exception {
Procedure procID = getProcedureID(procName, inputParamCount, transUtil);
assertEquals(procName, procID.getFullName());
assertEquals(shortName, procID.getName());
// Check children
List<ProcedureParameter> children = procID.getParameters();
int i = 0;
for (ProcedureParameter childID : children) {
assertEquals(procID, childID.getParent());
// $NON-NLS-1$
assertTrue(childID.getFullName() + " " + procID.getFullName(), childID.getFullName().startsWith(procID.getFullName()));
assertEquals(paramNames[i++], childID.getName());
}
if (rsParamName != null) {
assertEquals(rsParamName, procID.getResultSet().getName());
} else {
assertNull(procID.getResultSet());
}
}
Aggregations