Search in sources :

Example 16 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class LibraryServerImpl method seekBook.

@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
    System.out.println("***************************************************************");
    System.out.println("*** seekBook request (Request-Response operation) is received *");
    System.out.println("***************************************************************");
    showSeekBookRequest(body);
    List<String> authorsLastNames = body.getAuthorLastName();
    if (authorsLastNames != null && authorsLastNames.size() > 0) {
        String authorsLastName = authorsLastNames.get(0);
        if (authorsLastName != null && authorsLastName.length() > 0 && !"Icebear".equalsIgnoreCase(authorsLastName)) {
            SeekBookError e = prepareException("No book available from author " + authorsLastName);
            System.out.println("No book available from author " + authorsLastName);
            System.out.println("\nSending business fault (SeekBook error) with parameters:");
            throw e;
        }
    }
    ListOfBooks result = new ListOfBooks();
    BookType book = new BookType();
    result.getBook().add(book);
    PersonType author = new PersonType();
    book.getAuthor().add(author);
    author.setFirstName("Jack");
    author.setLastName("Icebear");
    Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
    author.setDateOfBirth(dateOfBirth.getTime());
    book.getTitle().add("Survival in the Arctic");
    book.getPublisher().add("Frosty Edition");
    book.setYearPublished("2010");
    System.out.println("Book(s) is found:");
    showSeekBookResponse(result);
    return result;
}
Also used : BookType(org.talend.types.test.library.common._1.BookType) SeekBookError(org.talend.services.test.library._1_0.SeekBookError) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.test.library.common._1.PersonType) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Example 17 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class Utils method showBooks.

/**
 * Show books.
 *
 * @param booksList the books list
 */
public static void showBooks(final ListOfBooks booksList) {
    if (booksList != null && booksList.getBook() != null && !booksList.getBook().isEmpty()) {
        List<BookType> books = booksList.getBook();
        System.out.println("\nNumber of books: " + books.size());
        int cnt = 0;
        for (BookType book : books) {
            System.out.println("\nBookNum: " + (cnt++ + 1));
            List<PersonType> authors = book.getAuthor();
            if (authors != null && !authors.isEmpty()) {
                for (PersonType author : authors) {
                    System.out.println("Author:  " + author.getFirstName() + " " + author.getLastName());
                }
            }
            System.out.println("Title:   " + book.getTitle());
            System.out.println("Year:    " + book.getYearPublished());
            if (book.getISBN() != null) {
                System.out.println("ISBN:    " + book.getISBN());
            }
        }
    } else {
        System.out.println("List of books is empty");
    }
    System.out.println("");
}
Also used : BookType(org.talend.types.demos.library.common._1.BookType) PersonType(org.talend.types.demos.library.common._1.PersonType)

Example 18 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class LibraryPublisher method publishNewBooksNotifications.

public void publishNewBooksNotifications() throws InterruptedException {
    for (int ndx = 1; ndx < 6; ndx++) {
        Thread.sleep(4000L);
        List<BookType> newBooks = new LinkedList<BookType>();
        BookType book = new BookType();
        newBooks.add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("Jack");
        author.setLastName("Icebear");
        Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("More About Survival in the Arctic - Volume " + ndx);
        book.getPublisher().add("Frosty Edition");
        book.setYearPublished("2011");
        System.out.println("Publishing notification about a new book:");
        System.out.println("Jack Icebear - More About Survival in the Arctic - Volume " + ndx);
        library.newBooks(new Date(), newBooks);
    }
}
Also used : BookType(org.talend.types.demos.library.common._1.BookType) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.demos.library.common._1.PersonType) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 19 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class LibraryServerImpl method seekBook.

@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
    System.out.println("***************************************************************");
    System.out.println("*** seekBook request (Request-Response operation) is received *");
    System.out.println("***************************************************************");
    showSeekBookRequest(body);
    List<String> authorsLastNames = body.getAuthorLastName();
    if (authorsLastNames != null && authorsLastNames.size() > 0) {
        String authorsLastName = authorsLastNames.get(0);
        if (authorsLastName != null && authorsLastName.length() > 0 && (!"Icebear".equalsIgnoreCase(authorsLastName)) && (!"Morillo".equalsIgnoreCase(authorsLastName))) {
            SeekBookError e = prepareException("No book available from author " + authorsLastName);
            System.out.println("No book available from author " + authorsLastName);
            System.out.println("\nSending business fault (SeekBook error) with parameters:");
            Utils.showSeekBookError(e);
            throw e;
        }
    }
    ListOfBooks result = new ListOfBooks();
    if (authorsLastNames.contains("Icebear")) {
        BookType book = new BookType();
        result.getBook().add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("Jack");
        author.setLastName("Icebear");
        Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("Survival in the Arctic");
        book.getPublisher().add("Frosty Edition");
        book.setYearPublished("2010");
    }
    if (authorsLastNames.contains("Morillo")) {
        BookType book = new BookType();
        result.getBook().add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("David A.");
        author.setLastName("Morillo");
        Calendar dateOfBirth = new GregorianCalendar(1970, Calendar.JANUARY, 1);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("The book about software");
        book.getPublisher().add("Frosty Edition");
        book.setYearPublished("2006");
    }
    System.out.println("Book(s) is found:");
    showSeekBookResponse(result);
    return result;
}
Also used : BookType(org.talend.types.demos.library.common._1.BookType) SeekBookError(org.talend.services.demos.library._1_0.SeekBookError) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.demos.library.common._1.PersonType) ListOfBooks(org.talend.types.demos.library.common._1.ListOfBooks)

Aggregations

PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)10 Calendar (java.util.Calendar)8 GregorianCalendar (java.util.GregorianCalendar)8 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)5 SeekBookError (org.talend.services.test.library._1_0.SeekBookError)5 BookType (org.talend.types.test.library.common._1.BookType)5 ListOfBooks (org.talend.types.test.library.common._1.ListOfBooks)5 PersonType (org.talend.types.test.library.common._1.PersonType)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 BookType (org.talend.types.demos.library.common._1.BookType)4 PersonType (org.talend.types.demos.library.common._1.PersonType)4 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SeekBookError (org.talend.services.demos.library._1_0.SeekBookError)2