use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project atlasmap by atlasmap.
the class AtlasKafkaConnectModelFactory method createKafkaConnectDocument.
/**
* Creates the Kafka Connect Document.
* @return Document
*/
public static KafkaConnectDocument createKafkaConnectDocument() {
KafkaConnectDocument kafkaConnectDocument = new KafkaConnectDocument();
kafkaConnectDocument.setFields(new Fields());
return kafkaConnectDocument;
}
use of org.jooq.meta.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.meta.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.meta.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.meta.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