Package org.apache.tapestry.vlib

Examples of org.apache.tapestry.vlib.VirtualLibraryEngine


        }

        Integer[] keys = (Integer[]) selectedBooks.toArray(new Integer[count]);
        Person toUser = getToUser();

        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();

        int i = 0;
        while (true)
        {
            try
            {
                IOperations operations = vengine.getOperations();

                operations.transferBooks(toUser.getId(), keys);

                break;
            }
            catch (FinderException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure("Unable to transfer ownership of books.", ex, i++);
            }
        }

        Person fromUser = getFromUser();
        IMessageProperty selectPage = (TransferBooksSelect) cycle.getPage("TransferBooksSelect");
View Full Code Here


        cycle.activate(selectPage);
    }

    private IPropertySelectionModel buildUserBookModel(Person user)
    {
        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
        Book[] books = null;

        int i = 0;
        while (true)
        {
            books = null;

            try
            {
                IBookQuery query = vengine.createNewQuery();

                int count = query.ownerQuery(user.getId(), null);

                if (count > 0)
                    books = query.get(0, count);

                break;
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure(
                    "Unable to retrieve books owned by " + user.getNaturalName() + ".",
                    ex,
                    i++);
            }
        }
View Full Code Here

        return model;
    }

    private Person readPerson(Integer personId)
    {
        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();

        return vengine.readPerson(personId);
    }
View Full Code Here

        if (isInError())
            return;

        Visit visit = (Visit) getVisit();
        Integer userId = visit.getUserId();
        VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();

        attributes.put("ownerId", userId);
        attributes.put("holderId", userId);

        int i = 0;
        while (true)
        {
            try
            {

                IOperations operations = vengine.getOperations();

                if (publisherId != null)
                    operations.addBook(attributes);
                else
                {
                    operations.addBook(attributes, publisherName);

                    // Clear the app's cache of info; in this case, known publishers.

                    vengine.clearCache();
                }

                break;
            }
            catch (CreateException ex)
            {
                setError("Error adding book: " + ex.getMessage());
                return;
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure("Remote exception adding new book.", ex, i++);
            }
        }

        // Success.  First, update the message property of the return page.
View Full Code Here

     *
     **/

    private void readPublishers()
    {
        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
        Publisher[] publishers = null;

        int i = 0;
        while (true)
        {
            try
            {
                IOperations operations = vengine.getOperations();

                publishers = operations.getPublishers();

                break;
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure(getMessage("read-failure"), ex, i++);
            }
        }

        ListEditMap map = new ListEditMap();

View Full Code Here

                ? null
                : (Integer[]) deletedIds.toArray(new Integer[deletedIds.size()]);

        // Now, push the updates through to the database

        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();

        int i = 0;
        while (true)
        {
            try
            {
                IOperations operations = vengine.getOperations();

                operations.updatePublishers(updated, deleted);

                break;
            }
            catch (FinderException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoveException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure(getMessage("update-failure"), ex, i++);
            }
        }

        // Clear any cached info about publishers.

        vengine.clearCache();
    }
View Full Code Here

        {
            setErrorField("inputPassword1", getMessage("password-must-match"));
            return;
        }

        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
        Login login = (Login) cycle.getPage("Login");

        int i = 0;
        while (true)
        {
            try
            {
                IOperations bean = vengine.getOperations();
                Person user =
                    bean.registerNewUser(getFirstName(), getLastName(), getEmail(), password1);

                // Ask the login page to return us to the proper place, as well
                // as set a cookie identifying the user for next time.

                login.loginUser(user, cycle);

                break;
            }
            catch (RegistrationException ex)
            {
                setError(ex.getMessage());
                return;
            }
            catch (CreateException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure("Remote exception registering new user.", ex, i++);
            }
        }
    }
View Full Code Here

        Object[] parameters = cycle.getServiceParameters();
        Integer bookPK = (Integer) parameters[0];

        Visit visit = (Visit) getPage().getVisit();
        Home home = (Home) cycle.getPage("Home");
        VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();

        int i = 0;
        while (true)
        {
            try
            {
                IOperations bean = vengine.getOperations();
                Book book = bean.borrowBook(bookPK, visit.getUserId());

                home.setMessage("Borrowed: " + book.getTitle());

                break;
            }
            catch (BorrowException ex)
            {
                vengine.presentError(ex.getMessage(), cycle);
                return;
            }
            catch (FinderException ex)
            {
                throw new ApplicationRuntimeException("Unable to find book or user. ", ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure("Remote exception borrowing book.", ex, i++);
            }
        }

        cycle.activate(home);
    }
View Full Code Here

    public void beginEdit(IRequestCycle cycle, Integer bookId)
    {
        setBookId(bookId);

        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();

        int i = 0;
        while (true)
        {
            try
            {
                // Get the attributes as a source for our input fields.

                IOperations operations = vengine.getOperations();

                setAttributes(operations.getBookAttributes(bookId));

                break;
            }
            catch (FinderException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure(
                    "Remote exception setting up page for book #" + bookId + ".",
                    ex,
                    i++);
            }
        }
View Full Code Here

        if (isInError())
            return;

        // OK, do the update.

        VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();
        Integer bookId = getBookId();

        int i = 0;
        while (true)
        {
            IOperations bean = vengine.getOperations();

            try
            {
                if (publisherId != null)
                    bean.updateBook(bookId, attributes);
                else
                {
                    bean.updateBook(bookId, attributes, publisherName);
          vengine.clearCache();
                }

                break;
            }
            catch (FinderException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (CreateException ex)
            {
                throw new ApplicationRuntimeException(ex);
            }
            catch (RemoteException ex)
            {
                vengine.rmiFailure("Remote exception updating book #" + bookId + ".", ex, i++);

                continue;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.vlib.VirtualLibraryEngine

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.