Package com.spreadbible.ctlib

Source Code of com.spreadbible.ctlib.CTLib

/*
* 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 de.suse.lib.sqlmap.SQLMapper;
import java.util.Properties;


/**
*
* @author bo
*/
public class CTLib {
    private UserDBService usersService;
    private CheckInService checkInService;

    private static SQLMapper mapper;


    /**
     * Constructor.
     *
     * @param url jdbc:mysql://host.com/database
     * @param user
     * @param password
     * @throws Exception
     */
    public CTLib(String url, String user, String password) throws Exception {
        Properties config = new Properties();
        config.put("databases", "sdb");
        config.put("sdb.url", url);
        config.put("sdb.user", user);
        config.put("sdb.password", password);

        CTLib.mapper = new SQLMapper(config).setResourceClass(CTLib.class).connect("sdb");
        CTLib.mapper.setResourceRoot("com.spreadbible.ctlib.sql.mariadb");
        //this.mapper.setDebug(true);

        this.usersService = new UserDBService();
        this.checkInService = new CheckInService();
    }

    /**
     * Get SQL Mapper instance.
     *
     * @return
     */
    public static SQLMapper getMapper() {
        return CTLib.mapper;
    }
   

    /**
     * Get CTUsers operations.
     *
     * @return
     */
    public UserDBService getUsersService() {
        return this.usersService;
    }

    /**
     * Get Check-in Service.
     *
     * @return
     */
    public CheckInService getCheckInService() {
        return checkInService;
    }
}
TOP

Related Classes of com.spreadbible.ctlib.CTLib

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.