Package org.teiid.query.mapping.xml

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


        //choice node, non-visual, so it has no name
        boolean exceptionOnDefault = true;
        MappingChoiceNode choice = items.addChoiceNode(new MappingChoiceNode(exceptionOnDefault));
        choice.setSource("xmltest.group.items"); //$NON-NLS-1$
        choice.setMaxOccurrs(-1);
        MappingCriteriaNode crit1 = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'okay'", false)); //$NON-NLS-1$    
        MappingElement item = crit1.addChildElement(new MappingElement("Item")); //$NON-NLS-1$       
        item.addAttribute(new MappingAttribute("ItemID", "xmltest.group.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
        item.addChildElement(new MappingElement("Name", "xmltest.group.items.itemName")) //$NON-NLS-1$ //$NON-NLS-2$
                .setNillable(true);
        item.addChildElement(new MappingElement("Quantity", "xmltest.group.items.itemQuantity")) //$NON-NLS-1$ //$NON-NLS-2$
            .setDefaultValue("0"); //$NON-NLS-1$

        MappingCriteriaNode crit2 = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'discontinued'", false)); //$NON-NLS-1$
        MappingElement discontinued = crit2.addChildElement(new MappingElement("DiscontinuedItem")); //$NON-NLS-1$
        discontinued.addAttribute(new MappingAttribute("ItemID", "xmltest.group.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
        discontinued.addChildElement(new MappingElement("Name", "xmltest.group.items.itemName")) //$NON-NLS-1$ //$NON-NLS-2$
                .setNillable(true);
        discontinued.addChildElement(new MappingElement("Quantity", "xmltest.group.items.itemQuantity")) //$NON-NLS-1$ //$NON-NLS-2$
            .setDefaultValue("0"); //$NON-NLS-1$
                       
        choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'discontinued'", false)).setExclude(true); //$NON-NLS-1$
       
        return doc;
    }
View Full Code Here


        //choice node, non-visual, so it has no name       
        MappingChoiceNode choice = items.addChoiceNode(new MappingChoiceNode());
        choice.setSource("xmltest.group.items"); //$NON-NLS-1$
        choice.setMaxOccurrs(-1);
        MappingCriteriaNode crit = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'okay'", false)); //$NON-NLS-1$
        MappingElement item = crit.addChildElement(new MappingElement("Item")); //$NON-NLS-1$
        item.addAttribute(new MappingAttribute("ItemID", "xmltest.group.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
        item.addChildElement(new MappingElement("Name", "xmltest.group.items.itemName")) //$NON-NLS-1$ //$NON-NLS-2$
            .setNormalizeText(normMode)
            .setNillable(true);
        item.addChildElement(new MappingElement("Quantity", "xmltest.group.items.itemQuantity")) //$NON-NLS-1$ //$NON-NLS-2$
            .setDefaultValue("0"); //$NON-NLS-1$
       
        MappingCriteriaNode crit2 = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'discontinued'", false)); //$NON-NLS-1$
        MappingElement discontinuedItem = crit2.addChildElement(new MappingElement("DiscontinuedItem")); //$NON-NLS-1$
        discontinuedItem.addAttribute(new MappingAttribute("ItemID", "xmltest.group.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
        discontinuedItem.addChildElement(new MappingElement("Name", "xmltest.group.items.itemName")) //$NON-NLS-1$ //$NON-NLS-2$
            .setNormalizeText(normMode)
            .setNillable(true);
        discontinuedItem.addChildElement(new MappingElement("Quantity", "xmltest.group.items.itemQuantity")) //$NON-NLS-1$ //$NON-NLS-2$
            .setDefaultValue("0"); //$NON-NLS-1$
       
        MappingCriteriaNode crit3 = choice.addCriteriaNode(new MappingCriteriaNode());     
        MappingElement unknownItem = crit3.addChildElement(new MappingElement("StatusUnknown")); //$NON-NLS-1$
        unknownItem.addAttribute(new MappingAttribute("ItemID", "xmltest.group.items.itemNum")); //$NON-NLS-1$ //$NON-NLS-2$
        unknownItem.addChildElement(new MappingElement("Name", "xmltest.group.items.itemName")) //$NON-NLS-1$ //$NON-NLS-2$
            .setNormalizeText(normMode)
            .setNillable(true);
        unknownItem.addChildElement(new MappingElement("Quantity", "xmltest.group.items.itemQuantity")) //$NON-NLS-1$ //$NON-NLS-2$
            .setDefaultValue("0"); //$NON-NLS-1$       
       
        MappingCriteriaNode notIncludedSibling = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'something'", false)); //$NON-NLS-1$
        notIncludedSibling.setExclude(true);

        MappingCriteriaNode notIncludedSibling2 = choice.addCriteriaNode(new MappingCriteriaNode("xmltest.group.items.itemStatus = 'something'", false)); //$NON-NLS-1$
        notIncludedSibling2.setExclude(true);
        return doc;       
    }
View Full Code Here

        MappingChoiceNode choice = (MappingChoiceNode)node;
        assertTrue(choice.throwExceptionOnDefault());
       
        node = (MappingNode)choice.getNodeChildren().get(0);
        assertTrue(node instanceof MappingCriteriaNode);
        MappingCriteriaNode criteria = (MappingCriteriaNode)node;
        assertEquals("childNodeCriteria", criteria.getCriteria()); //$NON-NLS-1$
       
        node = (MappingNode)criteria.getNodeChildren().get(0);
        assertTrue(node instanceof MappingElement);
        element = (MappingElement)node;
        assertEquals("childNode", element.getName()); //$NON-NLS-1$
       
    }
View Full Code Here

        MappingChoiceNode choice = (MappingChoiceNode)node;
        assertTrue(choice.throwExceptionOnDefault());
       
        node = (MappingNode)choice.getNodeChildren().get(0);
        assertTrue(node instanceof MappingCriteriaNode);
        MappingCriteriaNode criteria = (MappingCriteriaNode)node;
        assertEquals("childNodeCriteria", criteria.getCriteria()); //$NON-NLS-1$
       
        node = (MappingNode)criteria.getNodeChildren().get(0);
        assertTrue(node instanceof MappingElement);
        element = (MappingElement)node;
        assertEquals("childNode", element.getName()); //$NON-NLS-1$
    }
View Full Code Here

   
   
    public void testAddCriteria() {
        MappingChoiceNode choice = new MappingChoiceNode();
       
        choice.addCriteriaNode(new MappingCriteriaNode("chooseme > ?", false)); //$NON-NLS-1$
       
        // default node
        MappingCriteriaNode c2 = new MappingCriteriaNode();
        choice.addCriteriaNode(c2);
       
       assertTrue(choice.getDefaultNode() == c2);
    }
View Full Code Here

   
    public void testWithoutCriteria() {
        MappingChoiceNode choice = new MappingChoiceNode();
       
        try {
            choice.addCriteriaNode(new MappingCriteriaNode().setAsDefault(false))
            fail("must have failed to add"); //$NON-NLS-1$
        }catch(RuntimeException e) {
        }
       
    }
View Full Code Here

       
       
        MappingDocument doc = new MappingDocument(false);
        MappingElement element = doc.addChildElement(new MappingElement("parentNode")); //$NON-NLS-1$
        MappingChoiceNode choice = element.addChoiceNode(new MappingChoiceNode(true));
        MappingCriteriaNode criteria = choice.addCriteriaNode(new MappingCriteriaNode("childNodeCriteria", false)); //$NON-NLS-1$
        criteria.addChildElement(new MappingElement("childNode")); //$NON-NLS-1$

        String savedXML = saveMappingDocument(doc);
       
        assertEquals(expected, savedXML);       
    }
View Full Code Here

TOP

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

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.