Package open.dolphin.delegater

Source Code of open.dolphin.delegater.AppointmentDelegater

package open.dolphin.delegater;

import java.util.ArrayList;
import javax.naming.NamingException;
import open.dolphin.dto.AppointSpec;
import open.dolphin.ejb.RemoteKarteService;
import open.dolphin.infomodel.AppointmentModel;

/**
* AppointmentDelegater
*
* @author Kazushi Minagawa
*/
public class AppointmentDelegater extends BusinessDelegater {

    public int putAppointments(ArrayList results) {

        int size = results.size();
        ArrayList<AppointmentModel> added = new ArrayList<AppointmentModel>();
        ArrayList<AppointmentModel> updated = new ArrayList<AppointmentModel>();
        ArrayList<AppointmentModel> removed = new ArrayList<AppointmentModel>();

        for (int i = 0; i < size; i++) {

            AppointmentModel model = (AppointmentModel) results.get(i);
            int state = model.getState();
            String appoName = model.getName();

            if (state == AppointmentModel.TT_NEW) {
                // 新規予約
                added.add(model);

            } else if (state == AppointmentModel.TT_REPLACE && appoName != null) {
                // 変更された予約
                updated.add(model);

            } else if (state == AppointmentModel.TT_REPLACE && appoName == null) {
                // 取り消された予約
                removed.add(model);
            }
        }

        int retCode = 0;
        AppointSpec spec = new AppointSpec();
        spec.setAdded(added);
        spec.setUpdared(updated);
        spec.setRemoved(removed);

        try {
            getService().putAppointments(spec);

        } catch (NamingException e) {
            System.out.println("AppointmentDelegater.java: " + e);
            processError(e);
        }

        return retCode;
    }

    private RemoteKarteService getService() throws NamingException {
        return (RemoteKarteService) getService("RemoteKarteService");
    }
}
TOP

Related Classes of open.dolphin.delegater.AppointmentDelegater

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.