use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project jOOQ by jOOQ.
the class FirebirdTableValuedFunction method getElements0.
@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<>();
Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
Rdb$fields f = RDB$FIELDS.as("f");
// DatabaseMetaData implementation
for (Record record : create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_NAME.trim(), p.RDB$DESCRIPTION, p.RDB$DEFAULT_VALUE, DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE, // [#3342] FIELD_LENGTH should be ignored for LOBs
CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), f.RDB$FIELD_SUB_TYPE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).and(p.RDB$PARAMETER_TYPE.eq((short) 1)).orderBy(p.RDB$PARAMETER_NUMBER)) {
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHAR_LEN", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
result.add(new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(p.RDB$PARAMETER_NAME.trim()), result.size() + 1, type, false, null));
}
return result;
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project atlasmap by atlasmap.
the class SchemaInspector method doInspect.
private void doInspect(InputStream is) throws Exception {
xmlDocument = AtlasXmlModelFactory.createXmlDocument();
Fields fields = new Fields();
xmlDocument.setFields(fields);
namespaceContext = new AtlasXmlNamespaceContext();
rootNamespace = null;
XSOMParser parser = new XSOMParser(SAXParserFactory.newInstance());
parser.setAnnotationParser(new DomAnnotationParserFactory());
parser.setErrorHandler(new XSOMErrorHandler());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(is);
Element root = doc.getDocumentElement();
if (root == null) {
throw new XmlInspectionException("XML schema document is empty");
} else if ("SchemaSet".equals(root.getLocalName())) {
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(namespaceContext);
NodeList subSchemas = (NodeList) xpath.evaluate(String.format("/%s:SchemaSet/%s:AdditionalSchemas/%s:schema", NS_PREFIX_SCHEMASET, NS_PREFIX_SCHEMASET, NS_PREFIX_XMLSCHEMA), doc, XPathConstants.NODESET);
for (int i = 0; i < subSchemas.getLength(); i++) {
Element e = (Element) subSchemas.item(i);
inheritNamespaces(e, false);
parser.parse(toInputStream(transformer, e));
}
Element rootSchema = (Element) xpath.evaluate(String.format("/%s:SchemaSet/%s:schema", NS_PREFIX_SCHEMASET, NS_PREFIX_XMLSCHEMA), doc, XPathConstants.NODE);
if (rootSchema == null) {
throw new XmlInspectionException("The root schema '/SchemaSet/schema' must be specified once and only once");
}
rootNamespace = getTargetNamespace(rootSchema);
if (rootNamespace != null && !rootNamespace.isEmpty()) {
namespaceContext.add("tns", rootNamespace);
}
inheritNamespaces(rootSchema, true);
parser.parse(toInputStream(transformer, rootSchema));
} else if ("schema".equals(root.getLocalName())) {
parser.parse(toInputStream(transformer, root));
rootNamespace = getTargetNamespace(root);
if (rootNamespace != null && !rootNamespace.isEmpty()) {
namespaceContext.add("tns", rootNamespace);
}
} else {
throw new XmlInspectionException(String.format("Unsupported document element '%s': root element must be 'schema' or 'SchemaSet'", root.getLocalName()));
}
XSSchemaSet schemaSet = parser.getResult();
printSchemaSet(schemaSet);
populateNamespaces();
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project atlasmap by atlasmap.
the class CsvFieldReader method readSchema.
/**
* Reads only the first row of the document.
*
* If firstRecordAsHeader is set to true it uses column names for field names, otherwise it uses an index
* starting from 0.
*
* @return {@link Document} built from CSV
* @throws AtlasException if it fails
*/
public Document readSchema() throws AtlasException {
CSVFormat csvFormat = csvConfig.newCsvFormat();
CSVParser parser;
try {
document.mark(Integer.MAX_VALUE);
parser = csvFormat.parse(new InputStreamReader(document));
} catch (IOException e) {
throw new AtlasException(e);
}
List<CsvField> fields = new ArrayList<>();
if (csvConfig.isFirstRecordAsHeader()) {
for (String headerName : parser.getHeaderNames()) {
CsvField field = new CsvField();
field.setName(headerName);
field.setPath("/<>/" + headerName);
field.setFieldType(FieldType.STRING);
fields.add(field);
}
} else {
CSVRecord record = parser.iterator().next();
for (int i = 0; i < record.size(); i++) {
CsvField field = new CsvField();
if (parser.getHeaderNames() != null && parser.getHeaderNames().size() > i) {
field.setName(parser.getHeaderNames().get(i));
} else {
field.setColumn(i);
field.setName(String.valueOf(i));
}
field.setPath("/<>/" + field.getName());
field.setFieldType(FieldType.STRING);
fields.add(field);
}
}
try {
document.reset();
} catch (IOException e) {
throw new AtlasException(e);
}
CsvFields csvFields = new CsvFields();
csvFields.getCsvField().addAll(fields);
CsvComplexType csvComplexType = new CsvComplexType();
csvComplexType.setFieldType(FieldType.COMPLEX);
csvComplexType.setCollectionType(CollectionType.LIST);
csvComplexType.setPath("/<>");
csvComplexType.setName("");
csvComplexType.setCsvFields(csvFields);
Fields documentFields = new Fields();
documentFields.getField().add(csvComplexType);
Document document = new Document();
document.setFields(documentFields);
return document;
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project atlasmap by atlasmap.
the class XmlInstanceInspector method inspect.
/**
* Inspects the XML instance.
* @param document XML instance
*/
public void inspect(Document document) {
xmlDocument.setFields(new Fields());
parseDocument(document.getDocumentElement());
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project atlasmap by atlasmap.
the class XmlSchemaInspector method doInspect.
private void doInspect(InputStream is) throws Exception {
xmlDocument = AtlasXmlModelFactory.createXmlDocument();
Fields fields = new Fields();
xmlDocument.setFields(fields);
AtlasXmlSchemaSetParser parser = new AtlasXmlSchemaSetParser(this.classLoader);
XSSchemaSet schemaSet = parser.parse(is);
this.namespaceContext = parser.getNamespaceContext();
this.rootNamespace = parser.getRootNamespace();
printSchemaSet(schemaSet);
populateNamespaces();
}
Aggregations