com.waveerp.TableTblOrgRestday.java Source code

Java tutorial

Introduction

Here is the source code for com.waveerp.TableTblOrgRestday.java

Source

/**
 *  Copyright (C) 2012 Wave ERP, Inc. All rights reserved.
 *  This file is part of Wave ERP System.
 * 
 * Wave ERP System is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Wave ERP System is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Wave ERP System.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * The source code used in Wave ERP Framework is available at www.baligyaan.com.
 * 
 * Framework Designed by: Jammi Dee (jammi_dee@yahoo.com)
 * Special thanks to Francis Limbo and Rea Javier for the initial codes
 * 
 * The code still needs to be improved in the future. If you want to HELP, lets
 * us know so that changes can be monitored, controlled and credits can be
 * given to you being kind enough to share your expertise. For the road map and
 * design of the system you can email me.
 * 
 * Some of the codes are based on the codes found in the Internet but we 
 * modified it in order to fit in the Wave ERP framework. If you think that 
 * it is your code and you want to be credited, let us know. If you want 
 * it removed in the system, let us know also. And if you find a defect in 
 * our code, please let me know so that we can fix it immediately! I can be 
 * contacted at jammi_dee@yahoo.com.
 * Create by: Jammi Dee
 * Date: 01/17/2013
 * 
*/

package com.waveerp;

import com.wavemaker.runtime.RuntimeAccess;

//Required for database
import com.dbwaveerp.Dbwaveerp;
import org.hibernate.Session;
import org.hibernate.SQLQuery;

import com.dbwaveerp.data.*;

import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

public class TableTblOrgRestday extends com.wavemaker.runtime.javaservice.JavaServiceSuperClass {

    private Dbwaveerp dbServices = (Dbwaveerp) RuntimeAccess.getInstance().getService(Dbwaveerp.class);

    public TableTblOrgRestday() {
        super(INFO);
    }

    //Added by Jammi Dee 01/17/2013
    public String getTableValue(String pOrgId, String pField) {

        List<Tblorgrestday> myList = null;
        Iterator<Tblorgrestday> iterator = null;
        Tblorgrestday item = null;

        String strResult = "ERROR";

        try {
            dbServices.begin();

            Session session = dbServices.getDataServiceManager().getSession();
            String sQuery = "select * from Tblorgrestday where orgid = '" + pOrgId + "' ;";

            SQLQuery query = session.createSQLQuery(sQuery);
            query.addEntity(Tblorgrestday.class);

            myList = query.list();

            dbServices.commit();

            iterator = myList.iterator();

            /**
             * At this point, only one record should be retrieved
            */
            while (iterator.hasNext()) {

                item = (Tblorgrestday) iterator.next();

                if (pField.compareTo("ENTITYID") == 0) {

                    strResult = (String) item.getEntityid();

                } else if (pField.compareTo("DESCRIPTION") == 0) {

                    strResult = (String) item.getDescription();

                } else if (pField.compareTo("PID") == 0) {

                    strResult = (String) item.getPid();

                } else if (pField.compareTo("DSUN") == 0) {

                    strResult = (String) item.getDsun();

                } else if (pField.compareTo("DMON") == 0) {

                    strResult = (String) item.getDmon();

                } else if (pField.compareTo("DTUES") == 0) {

                    strResult = (String) item.getDtues();

                } else if (pField.compareTo("DWED") == 0) {

                    strResult = (String) item.getDwed();

                } else if (pField.compareTo("DTHU") == 0) {

                    strResult = (String) item.getDthu();

                } else if (pField.compareTo("DFRI") == 0) {

                    strResult = (String) item.getDfri();

                } else if (pField.compareTo("DSAT") == 0) {

                    strResult = (String) item.getDsat();

                } else if (pField.compareTo("JUID") == 0) {

                    strResult = (String) item.getJuid();

                } else if (pField.compareTo("STATUS") == 0) {

                    strResult = (String) item.getSstatus();

                } else {

                    strResult = "NULL";

                }

            }

        } catch (Exception e) {

            dbServices.rollback();
            return "FAIL";

        }

        return strResult;

    }

}