Examples of CommandGroup


Examples of org.apache.tuscany.das.rdb.CommandGroup

    }

    public void testWASDefect330118() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY
                .createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
        commandGroup.setConnection(getConnection());

        // Read all customers and add one
        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        int numCustomers = root.getList("CUSTOMER").size();

        DataObject newCust = root.createDataObject("CUSTOMER");
        newCust.set("ID", new Integer(100));
        newCust.set("ADDRESS", "5528 Wells Fargo Drive");
        newCust.set("LASTNAME", "Gerkin");

        // Now delete this new customer
        newCust.delete();

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

        // Verify
        root = read.executeQuery();
        assertEquals(numCustomers, root.getList("CUSTOMER").size());
View Full Code Here

Examples of org.apache.tuscany.das.rdb.CommandGroup

    }

    public void testUpdateChildThatHasGeneratedKey() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));

        // Read a specific company based on the known ID
        Command readCust = commandGroup.getCommand("all companies and departments");
        DataObject root = readCust.executeQuery();
        DataObject lastCustomer = root.getDataObject("COMPANY[3]");
        Iterator i = lastCustomer.getList("departments").iterator();
        Random generator = new Random();
        int random = generator.nextInt(1000) + 1;
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject) i.next();
            // System.out.println("Modifying department: " +
            // department.getString("NAME"));
            department.setString("NAME", "Dept-" + random);
            random = random + 1;
        }

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

    }
View Full Code Here

Examples of org.apache.tuscany.das.rdb.CommandGroup

    }

    public void testWASDefect330118() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
        commandGroup.setConnection(getConnection());

        // Read all customers and add one
        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        int numCustomers = root.getList("CUSTOMER").size();

        DataObject newCust = root.createDataObject("CUSTOMER");
        newCust.set("ID", new Integer(100));
        newCust.set("ADDRESS", "5528 Wells Fargo Drive");
        newCust.set("LASTNAME", "Gerkin");

        // Now delete this new customer
        newCust.delete();

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

        // Verify
        root = read.executeQuery();
        assertEquals(numCustomers, root.getList("CUSTOMER").size());
View Full Code Here

Examples of org.apache.tuscany.das.rdb.CommandGroup

     * Try a workaround using CommandGroup
     */
    public void testYingChen12162005Workaraound() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomerConfig.xml"));
        commandGroup.setConnection(getConnection());

        Command insert = commandGroup.getCommand("insert customer");
        insert.setParameterValue("ID", new Integer(10));
        insert.setParameterValue("LASTNAME", "Williams");
        insert.setParameterValue("ADDRESS", null);
        insert.execute();

        // Verify
        Command select = commandGroup.getCommand("read customer 10");
        DataObject root = select.executeQuery();
        assertEquals(1, root.getList("CUSTOMER").size());
        assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));

    }
View Full Code Here

Examples of org.apache.tuscany.das.rdb.CommandGroup

    }
   
    public void testUpdateChildThatHasGeneratedKey() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
                       
        //Read a specific company based on the known ID
        Command readCust = commandGroup.getCommand("all companies and departments");
        DataObject root = readCust.executeQuery();      
        DataObject lastCustomer = root.getDataObject("COMPANY[3]");
        Iterator i = lastCustomer.getList("departments").iterator();
        Random generator = new Random();
        int random = generator.nextInt(1000) + 1;
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject)i.next();
            System.out.println("Modifying department: " + department.getString("NAME"));
            department.setString("NAME", "Dept-" + random);
            random = random + 1;
        }
       
        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);
       
   
View Full Code Here

Examples of org.knopflerfish.service.console.CommandGroup

   
    public synchronized void run() {
        bc.addServiceListener(this);
        AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                CommandGroup cg;
                if (commandGroupRef != null) {
                    cg = (CommandGroup) bc.getService(commandGroupRef);
                    if (cg == null) {
                        status = -2;
                        return null;
                    }
                } else {
                    cg = sessionCommandGroup;
                }
                if (out instanceof PrintWriter) {
                    status = cg.execute(args, in, (PrintWriter) out, session);
                } else {
                    status = cg.execute(args, in, new PrintWriter(out), session);
                }
                if (commandGroupRef != null) {
                    try {
                        bc.ungetService(commandGroupRef);
                    } catch (IllegalStateException ignore) {
View Full Code Here

Examples of org.knopflerfish.service.console.CommandGroup

            refs = bc.getServiceReferences(Command.COMMAND_GROUP, null);
        } catch (InvalidSyntaxException ignore) {
        }
        if (refs != null) {
            for (int i = 0; i < refs.length; i++) {
                CommandGroup c = (CommandGroup) bc.getService(refs[i]);
                if (c != null) {
                    String n = c.getGroupName();
                    int j;
                    for (j = 0; j < cg.size(); j++) {
                        if (n.compareTo(((CommandGroup) cg.get(j))
                                .getGroupName()) > 0) {
                            break;
                        }
                    }
                    cg.add(j, c);
                }
            }
        }
        out
                .println("Available command groups (type 'enter' to enter a group):");
        for (Iterator e = cg.iterator(); e.hasNext();) {
            CommandGroup c = (CommandGroup) e.next();
            out.println(c.getGroupName() + " - " + c.getShortHelp());
        }
        if (refs != null) {
            for (int i = 0; i < refs.length; i++) {
                bc.ungetService(refs[i]);
            }
View Full Code Here

Examples of org.knopflerfish.service.console.CommandGroup

     */
    int helpAbout(String group, PrintWriter out, SessionImpl si) {
        try {
            ServiceReference ref = Command.matchCommandGroup(bc, group);
            if (ref != null) {
                CommandGroup c = (CommandGroup) bc.getService(ref);
                if (c != null) {
                    out.print(c.getLongHelp());
                    bc.ungetService(ref);
                    return 0;
                }
            } else {
                // Null means session command group
View Full Code Here

Examples of org.knopflerfish.service.console.CommandGroup

        LogCommands.logConfigTracker = new ServiceTracker(bc, LogConfig.class
                .getName(), null);
        LogCommands.logConfigTracker.open();

        // Register log commands
        CommandGroup logCommandGroup = new LogCommandGroup(bc);
        Hashtable props = new Hashtable();
        props.put("groupName", logCommandGroup.getGroupName());
        bc.registerService(COMMAND_GROUP, logCommandGroup, props);

        // Register log config commands
        CommandGroup logConfigCommandGroup = new LogConfigCommandGroup();
        props = new Hashtable();
        props.put("groupName", logConfigCommandGroup.getGroupName());
        bc.registerService(COMMAND_GROUP, logConfigCommandGroup, props);
    }
View Full Code Here

Examples of org.knopflerfish.service.console.CommandGroup

    ServiceRegistration sr;

    public void start(BundleContext bc) {
        this.bc = bc;
        CommandGroup cg = new CMCommands(bc);
        Hashtable props = new Hashtable();
        props.put("groupName", cg.getGroupName());
        bc.registerService(CommandGroup.class.getName(), cg, props);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.