Package com.spreadbible.ctlib

Source Code of com.spreadbible.ctlib.CTTester

/*
* Author: Bo Maryniuk <bo@suse.de>
*
* Copyright (c) 2013 Bo Maryniuk. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*     1. Redistributions of source code must retain the above copyright notice,
*     this list of conditions and the following disclaimer.
*
*     2. Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in the
*     documentation and/or other materials provided with the distribution.
*
*     3. The name of the author may not be used to endorse or promote products
*     derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY BO MARYNIUK "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.spreadbible.ctlib;

import com.spreadbible.ctlib.entities.CDBPerson;
import com.spreadbible.ctlib.entities.CHKDocument;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
*
* @author bo
*/
public class CTTester {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        CTLib ctlib = new CTLib(args[0], args[1], args[2]);
        ctlib.getCheckInService().initDatabase();

        List<CDBPerson> persons = ctlib.getUsersService().getPersons(null);
        for (int i = 0; i < persons.size(); i++) {
            CDBPerson p = persons.get(i);
            System.err.println(String.format("%s %s (%s) - %s",
                    p.getName(), p.getLastName(), p.getNickName(), p.getEmail()));
        }
       
        // do some fun with the checkin
        System.err.println("Current docs:");
        List<CHKDocument> docs = ctlib.getCheckInService().getDocuments();
        for (int i = 0; i < docs.size(); i++) {
            CHKDocument doc = docs.get(i);
            ctlib.getCheckInService().fillDocument(doc);
            System.err.println("\tDoc: " + doc.getTitle());
            for (int j = 0; j < doc.getAssignees().size(); j++) {
                CDBPerson p = doc.getAssignees().get(j);
                System.err.println("\t\t" + p.getName() + " " + p.getLastName());
            }
        }
        System.err.println("------");
       
        // New document
        CHKDocument doc = new CHKDocument();
        doc.setTitle("Doc for " + new Date());
        doc.setDescription("test doc");
        ctlib.getCheckInService().setDocument(doc); // Register new document in the db

        Random rnd = new Random();
        rnd.setSeed(new Date().getTime());
        for (int i = 0; i < rnd.nextInt(persons.size()); i++) {
            doc.pushPerson(persons.get(rnd.nextInt(persons.size())));
            ctlib.getCheckInService().addPerson(doc);
        }
    }   
}
TOP

Related Classes of com.spreadbible.ctlib.CTTester

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.