/** * Creates Lists of Tables with a common Schema name, then adds the Lists to the Schemas. * * @param schemaDescs List of Schemas. * @param tableDescs List of Tables. */ private void addTablesToSchemas(List<SchemaDesc> schemaDescs, List<TableDesc> tableDescs) { for (TableDesc tableDesc : tableDescs) { for (SchemaDesc schemaDesc : schemaDescs) { if (tableDesc.getSchemaName().equals(schemaDesc.getSchemaName())) { schemaDesc.getTableDescs().add(tableDesc); break; } } } }
/** * Adds foreign keys (KeyDesc) to the from table. * * @param schemaDescs */ private void addForeignKeys(List<SchemaDesc> schemaDescs, List<KeyDesc> keyDescs) { for (KeyDesc key : keyDescs) { for (SchemaDesc sd : schemaDescs) { for (TableDesc td : sd.getTableDescs()) { if ( key.getFromTable().equals(td.getTableName())) { td.getKeyDescs().add(key); break; } } } } }
if (schemaDesc.getTableDescs() == null || schemaDesc.getTableDescs().isEmpty()) continue; for (TableDesc tableDesc : schemaDesc.getTableDescs())
/** * @param sd * @return */ private Element toXmlElement(SchemaDesc sd, Namespace ns) { Element eleSchema = new Element("schema", ns); Element ele; ele = new Element("name"); if (sd.getSchemaName() == null) ele.setText(DEFAULT_SCHEMA); else ele.setText(sd.getSchemaName()); eleSchema.addContent(ele); if (sd.getTableDescs() != null) for (TableDesc td : sd.getTableDescs()) { eleSchema.addContent(toXmlElement(td, Namespace.NO_NAMESPACE)); } return eleSchema; }
private TapSchema toTapSchema(Document doc) { TapSchema ret = new TapSchema(); Element root = doc.getRootElement(); Namespace xsi = root.getNamespace("xsi"); if ("tableset".equals(root.getName())) { // content is element-form unqualified List<Element> sels = root.getChildren("schema"); for (Element se : sels) { String sn = se.getChildTextTrim("name"); SchemaDesc sd = new SchemaDesc(sn); List<Element> tabs = se.getChildren("table"); for (Element te : tabs) { TableDesc td = TableReader.toTable(sn, te, xsi); String tn = td.getTableName(); sd.getTableDescs().add(td); } ret.getSchemaDescs().add(sd); } } return ret; } }
|| (sd.getSchemaName().equalsIgnoreCase(table.getSchemaName()))) for (TableDesc td : sd.getTableDescs())
tapUploadSchema.getTableDescs().addAll(tableDescs.values()); tapSchema.getSchemaDescs().add(tapUploadSchema);