Package org.teiid.query.mapping.xml

Examples of org.teiid.query.mapping.xml.MappingElement


        assertTrue(list.get(4) instanceof MappingAllNode);
    }
   
    public void testAddRecursiveElement() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$
       
        MappingElement nodeA = root.addChildElement(new MappingElement("NodeA", "test.nodea")); //$NON-NLS-1$ //$NON-NLS-2$
        nodeA.setSource("recursive.test"); //$NON-NLS-1$

        MappingSequenceNode seq = nodeA.addSequenceNode(new MappingSequenceNode());
        MappingElement nodeB = seq.addChildElement(new MappingElement("NodeB", "test.nodeb")); //$NON-NLS-1$ //$NON-NLS-2$
       
        assertFalse(nodeA.isRootRecursiveNode());
       
        MappingRecursiveElement rElem = (MappingRecursiveElement)nodeB.addChildElement(new MappingRecursiveElement("RecursiveNodeA", "recursive.test")); //$NON-NLS-1$ //$NON-NLS-2$
       
        assertTrue(rElem.isRecursive());
       
        assertTrue(nodeA.isRootRecursiveNode());
    }
View Full Code Here


        assertTrue(nodeA.isRootRecursiveNode());
    }
   
    public void testAddBADRecursiveElement() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$
       
        MappingElement nodeA = root.addChildElement(new MappingElement("NodeA", "test.nodea")); //$NON-NLS-1$ //$NON-NLS-2$
        nodeA.setSource("recursive.test"); //$NON-NLS-1$
       
        MappingSequenceNode seq = nodeA.addSequenceNode(new MappingSequenceNode());
        MappingElement nodeB = seq.addChildElement(new MappingElement("NodeB", "test.nodeb")); //$NON-NLS-1$ //$NON-NLS-2$
       
        assertFalse(nodeA.isRootRecursiveNode());
       
        try {
            nodeB.addChildElement(new MappingRecursiveElement("RecursiveNodeA", "unknown mapping")); //$NON-NLS-1$ //$NON-NLS-2$
            fail("should have failed to add a node with unknown mapping class"); //$NON-NLS-1$
        } catch (RuntimeException e) {
            //e.printStackTrace();
        }       
    } 
View Full Code Here

            //e.printStackTrace();
        }       
    } 
   
    public void testAddNullStagingTable() {       
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        element.addStagingTable(null);
        List stagingTables = element.getStagingTables();
        assertTrue(stagingTables.isEmpty());
    }
View Full Code Here

    return new FakeMetadataFacade(store);
  }

    private static MappingDocument exampleDoc1() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$
        MappingElement node1 = root.addChildElement(new MappingElement("node1")); //$NON-NLS-1$
        MappingElement node2 = node1.addChildElement(new MappingElement("node2")); //$NON-NLS-1$
        node2.addChildElement(new MappingElement("node3")); //$NON-NLS-1$       
        return doc;
    }
View Full Code Here

    }

    private static MappingDocument exampleDoc2() {
       
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$
        MappingElement node1 = root.addChildElement(new MappingElement("node1")); //$NON-NLS-1$
       
        MappingSequenceNode node2 = node1.addSequenceNode(new MappingSequenceNode());   
        node2.addChildElement(new MappingElement("node3")); //$NON-NLS-1$
        root.addChildElement(new MappingElement("node2")); //$NON-NLS-1$
        return doc;
    }
View Full Code Here

    }

    // has ambiguous short and long names
    private static MappingDocument exampleDoc3() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$

        MappingSequenceNode node1 = root.addSequenceNode(new MappingSequenceNode());   
        node1.addChildElement(new MappingElement("node2")); //$NON-NLS-1$
        root.addChildElement(new MappingElement("node2")); //$NON-NLS-1$
        return doc;
    }
View Full Code Here

    // has attributes and elements
    private static MappingDocument exampleDoc4() {
       
        MappingDocument doc = new MappingDocument(false);
       
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$

        root.addAttribute(new MappingAttribute("node6")); //$NON-NLS-1$
        root.addStagingTable("tm1.g1"); //$NON-NLS-1$
       
        MappingElement node1 =root.addChildElement(new MappingElement("node1")); //$NON-NLS-1$
        node1.addAttribute(new MappingAttribute("node2")); //$NON-NLS-1$
       
        MappingElement node3 =root.addChildElement(new MappingElement("node3")); //$NON-NLS-1$
        node3.addAttribute(new MappingAttribute("node4")); //$NON-NLS-1$
       
        MappingElement node5 = node3.addChildElement(new MappingElement("node4")); //$NON-NLS-1$
        MappingElement duplicateRoot = node5.addChildElement(new MappingElement("root")); //$NON-NLS-1$

        duplicateRoot.addChildElement(new MappingElement("node6")); //$NON-NLS-1$       
        return doc;
    }   
View Full Code Here

    }   

    // has a union in the mapping class
    private static MappingDocument exampleDoc5() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$

        MappingElement node1 = root.addChildElement(new MappingElement("node1")); //$NON-NLS-1$
        node1.addChildElement(new MappingElement("node2","xmltest.mc1.e1")); //$NON-NLS-1$ //$NON-NLS-2$
        node1.setSource("xmltest.mc1"); //$NON-NLS-1$
        node1.setMaxOccurrs(-1);
        return doc;
   
View Full Code Here

   
   
    // has two elements with common suffix, but not ambiguous
    private static MappingDocument exampleDoc6() {
        MappingDocument doc = new MappingDocument(false);
        MappingElement root = doc.addChildElement(new MappingElement("root")); //$NON-NLS-1$

        root.addChildElement(new MappingElement("node")); //$NON-NLS-1$
        root.addChildElement(new MappingElement("thenode")); //$NON-NLS-1$
        return doc;
    }   
View Full Code Here

            new String[] { "employeeNum", "firstName", "lastName", "supervisorNum", "specializesInItemNum", "supplierNumFK" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});

        // MAPPING DOC ======================================================================
        MappingDocument doc = new MappingDocument(true);
        MappingElement root = doc.addChildElement(new MappingElement("Catalogs")); //$NON-NLS-1$
       
        MappingElement cats = root.addChildElement(new MappingElement("Catalog")); //$NON-NLS-1$
        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
        FakeMetadataObject playersDoc = FakeMetadataFactory.createVirtualGroup("xmltest.playersDoc", xmltest, doc2); //$NON-NLS-1$
        List playersDocElements = FakeMetadataFactory.createElements(playersDoc,
View Full Code Here

TOP

Related Classes of org.teiid.query.mapping.xml.MappingElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.