MappingElement itemsA = cats.addChildElement(new MappingElement("Items")); //$NON-NLS-1$
MappingElement item = itemsA.addChildElement(new MappingElement("Item")); //$NON-NLS-1$
item.setSource("xmltest.items");//$NON-NLS-1$
item.setMaxOccurrs(-1);
item.addAttribute(new MappingAttribute("ItemID", "xmltest.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
item.addChildElement(new MappingElement("Name", "xmltest.items.itemName")); //$NON-NLS-1$ //$NON-NLS-2$
item.addChildElement(new MappingElement("Quantity", "xmltest.items.itemQuantity")); //$NON-NLS-1$ //$NON-NLS-2$
//NESTED STUFF======================================================================
MappingElement nestedWrapper = item.addChildElement(new MappingElement("Suppliers")); //$NON-NLS-1$
MappingElement supplier = nestedWrapper.addChildElement(new MappingElement("Supplier")); //$NON-NLS-1$
supplier.setSource("xmltest.suppliers");//$NON-NLS-1$
supplier.setMaxOccurrs(-1);
supplier.addAttribute(new MappingAttribute("SupplierID", "xmltest.suppliers.supplierNum")); //$NON-NLS-1$ //$NON-NLS-2$
supplier.addChildElement(new MappingElement("Name","xmltest.suppliers.supplierName")); //$NON-NLS-1$ //$NON-NLS-2$
supplier.addChildElement(new MappingElement("Zip", "xmltest.suppliers.supplierZipCode")); //$NON-NLS-1$ //$NON-NLS-2$
MappingElement ordersWrapper = supplier.addChildElement(new MappingElement("Orders")); //$NON-NLS-1$
MappingElement order = ordersWrapper.addChildElement(new MappingElement("Order")); //$NON-NLS-1$
order.setSource("xmltest.orders"); //$NON-NLS-1$
order.setMaxOccurrs(-1);
order.addAttribute(new MappingAttribute("OrderID", "xmltest.orders.orderNum")); //$NON-NLS-1$ //$NON-NLS-2$
order.addChildElement(new MappingElement("OrderDate", "xmltest.orders.orderDate")); //$NON-NLS-1$ //$NON-NLS-2$
order.addChildElement(new MappingElement("OrderQuantity", "xmltest.orders.orderQty")); //$NON-NLS-1$ //$NON-NLS-2$
order.addChildElement(new MappingElement("OrderStatus", "xmltest.orders.orderStatus")) //$NON-NLS-1$ //$NON-NLS-2$
.setMinOccurrs(0);
//NESTED STUFF======================================================================
MappingElement employeesWrapper = supplier.addChildElement(new MappingElement("Employees")); //$NON-NLS-1$
MappingElement employee = employeesWrapper.addChildElement(new MappingElement("Employee")); //$NON-NLS-1$
employee.setSource("xmltest.employees"); //$NON-NLS-1$
employee.setMaxOccurrs(-1);
employee.addAttribute(new MappingAttribute("EmployeeID", "xmltest.employees.employeeNum")); //$NON-NLS-1$ //$NON-NLS-2$
employee.addChildElement(new MappingElement("FirstName", "xmltest.employees.firstName")); //$NON-NLS-1$ //$NON-NLS-2$
employee.addChildElement(new MappingElement("LastName", "xmltest.employees.lastName")); //$NON-NLS-1$ //$NON-NLS-2$
employee.addAttribute(new MappingAttribute("SupervisorID", "xmltest.employees.supervisorNum")); //$NON-NLS-1$ //$NON-NLS-2$
// END MAPPING DOC ======================================================================
// Create virtual docs and doc elements
FakeMetadataObject itemsDoc = FakeMetadataFactory.createVirtualGroup("xmltest.itemsDoc", xmltest, doc); //$NON-NLS-1$
List docE1 = FakeMetadataFactory.createElements(itemsDoc,
new String[] { "Catalogs", //$NON-NLS-1$
"Catalogs.Catalog", //$NON-NLS-1$
"Catalogs.Catalog.items", //$NON-NLS-1$
"Catalogs.Catalog.items.item", //$NON-NLS-1$
"Catalogs.Catalog.items.item.@ItemID", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Name", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Quantity", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.@SupplierID", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Name", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Zip", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders.Order", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders.Order.@OrderID", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders.Order.OrderDate", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders.Order.OrderQuantity", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Orders.Order.OrderStatus", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees.Employee", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees.Employee.@EmployeeID", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees.Employee.FirstName", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees.Employee.LastName", //$NON-NLS-1$
"Catalogs.Catalog.items.item.Suppliers.Supplier.Employees.Employee.@SupervisorID", //$NON-NLS-1$
},
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING,
});
// Create mapping classes - baseball players employees doc
QueryNode playersNode = new QueryNode("SELECT stock.employees.employeeNum, firstName, lastName, supervisorNum FROM stock.employees WHERE specializesInItemNum is not null"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rsPlayers = FakeMetadataFactory.createVirtualGroup("xmltest.players", xmltest, playersNode); //$NON-NLS-1$
QueryNode managersNode = new QueryNode("SELECT stock.employees.employeeNum, firstName, lastName, supervisorNum FROM stock.employees WHERE stock.employees.employeeNum = ?"); //$NON-NLS-1$ //$NON-NLS-2$
managersNode.addBinding("xmltest.players.supervisorNum"); //$NON-NLS-1$
FakeMetadataObject rsManagers = FakeMetadataFactory.createVirtualGroup("xmltest.managers", xmltest, managersNode); //$NON-NLS-1$
// TODO what if elements in criteria weren't fully qualified? see defect 19541
QueryNode ownersNode = new QueryNode("SELECT stock.employees.employeeNum, firstName, lastName, supervisorNum FROM stock.employees WHERE stock.employees.employeeNum = ?"); //$NON-NLS-1$ //$NON-NLS-2$
ownersNode.addBinding("xmltest.managers.supervisorNum"); //$NON-NLS-1$
FakeMetadataObject rsOwners = FakeMetadataFactory.createVirtualGroup("xmltest.owners", xmltest, ownersNode); //$NON-NLS-1$
// Create mapping classes elements - items doc
List rsPlayersElements = FakeMetadataFactory.createElements(rsPlayers,
new String[] { "employeeNum", "firstName", "lastName", "supervisorNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
List rsManagersElements = FakeMetadataFactory.createElements(rsManagers,
new String[] { "employeeNum", "firstName", "lastName", "supervisorNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
List rsOwnersElements = FakeMetadataFactory.createElements(rsOwners,
new String[] { "employeeNum", "firstName", "lastName", "supervisorNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
// MAPPING DOC - baseball players ======================================================================
MappingDocument doc2 = new MappingDocument(true);
MappingElement root2 = doc2.addChildElement(new MappingElement("BaseballPlayers")); //$NON-NLS-1$
MappingElement player = root2.addChildElement(new MappingElement("Player")); //$NON-NLS-1$
player.setSource("xmltest.players"); //$NON-NLS-1$
player.setMaxOccurrs(-1);
player.addAttribute(new MappingAttribute("PlayerID", "xmltest.players.employeeNum")); //$NON-NLS-1$ //$NON-NLS-2$
player.addChildElement(new MappingElement("FirstName", "xmltest.players.firstName")); //$NON-NLS-1$ //$NON-NLS-2$
player.addChildElement(new MappingElement("LastName", "xmltest.players.lastName")); //$NON-NLS-1$ //$NON-NLS-2$
MappingElement manager = player.addChildElement(new MappingElement("Manager")); //$NON-NLS-1$
manager.setSource("xmltest.managers");//$NON-NLS-1$
manager.setMaxOccurrs(-1);
manager.addAttribute(new MappingAttribute("ManagerID", "xmltest.managers.employeeNum")); //$NON-NLS-1$ //$NON-NLS-2$
manager.addChildElement(new MappingElement("FirstName", "xmltest.managers.firstName")); //$NON-NLS-1$ //$NON-NLS-2$
manager.addChildElement(new MappingElement("LastName", "xmltest.managers.lastName")); //$NON-NLS-1$ //$NON-NLS-2$
MappingElement owner = manager.addChildElement(new MappingElement("Owner")); //$NON-NLS-1$
owner.setSource("xmltest.owners"); //$NON-NLS-1$
owner.setMaxOccurrs(-1);
owner.addAttribute(new MappingAttribute("OwnerID", "xmltest.owners.employeeNum")); //$NON-NLS-1$ //$NON-NLS-2$
owner.addChildElement(new MappingElement("FirstName", "xmltest.owners.firstName")); //$NON-NLS-1$ //$NON-NLS-2$
owner.addChildElement(new MappingElement("LastName", "xmltest.owners.lastName")); //$NON-NLS-1$ //$NON-NLS-2$
// END MAPPING DOC ======================================================================
// Create virtual docs and doc elements