Package org.jivesoftware.xmpp.workgroup

Examples of org.jivesoftware.xmpp.workgroup.Workgroup


            super();
            this.offer = offer;
        }

        public int compare(AgentSession item1, AgentSession item2) {
            Workgroup workgroup = offer.getRequest().getWorkgroup();
            int int1 = item1.getCurrentChats(workgroup);
            int int2 = item2.getCurrentChats(workgroup);

            if (int1 == int2) {
                // Base the decision on previous offer rejections
View Full Code Here


                        initialAgent = null;
                        Thread.sleep(1000);
                    }
                    else {
                        // Recheck for changed maxchat setting
                        Workgroup workgroup = request.getWorkgroup();
                        if (session.getCurrentChats(workgroup) < session.getMaxChats(workgroup)) {
                            // Set the timeout of the offer based on the remaining time of the
                            // initial request and the default offer timeout
                            timeRemaining = timeoutTime - System.currentTimeMillis();
                            offer.setTimeout(timeRemaining < info.getOfferTimeout() ?
View Full Code Here

        if (initialAgent != null) {
            final AgentSessionList agentSessionList = queue.getAgentSessionList();
            for (AgentSession agentSession : agentSessionList.getAgentSessions()) {
                String sessionAgent = agentSession.getAgent().getAgentJID().toBareJID();
                boolean match = sessionAgent.startsWith(initialAgent.toLowerCase());
                Workgroup workgroup = offer.getRequest().getWorkgroup();
                if (agentSession.isAvailableToChat() &&
                        agentSession.getCurrentChats(workgroup) < agentSession.getMaxChats(workgroup) && match) {
                    bestSession = agentSession;
                    // Log debug trace
                    Log.debug("RR - Initial agent: " + bestSession.getJID() +
View Full Code Here

                // Keep track when the invitation was sent to the user
                offerAccpeted = System.currentTimeMillis();
            }
            else {
                // Invite the agent to the room by sending an offer
                Workgroup workgroup = agentSession.getWorkgroups().iterator().next();
                RequestQueue requestQueue = workgroup.getRequestQueues().iterator().next();
                // Add the requested agent as the initial target agent to get the offer
                getMetaData().put("agent", Arrays.asList(invitee.toString()));
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Dispatch the request
                requestQueue.getDispatcher().injectRequest(this);
            }
        }
        else if (Type.queue == type) {
            // Send offer to the best again available in the requested queue
            Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
            if (targetWorkgroup == null) {
                // No workgroup was found for the specified invitee. Send a Message with the error
                sendErrorMessage("Specified workgroup was not found.");
                return;
            }
            try {
                RequestQueue requestQueue = targetWorkgroup.getRequestQueue(invitee.getResource());
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Dispatch the request
                requestQueue.getDispatcher().injectRequest(this);
            }
            catch (NotFoundException e) {
                // No queue was found for the specified invitee. Send a Message with the error
                sendErrorMessage("Specified queue was not found.");
            }
        }
        else if (Type.workgroup == type) {
            // Select the best queue based on the original request
            Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
            if (targetWorkgroup != null) {
                RequestQueue requestQueue = RoutingManager.getInstance().getBestQueue(targetWorkgroup, userRequest);
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Send offer to the best again available in the requested queue
                requestQueue.getDispatcher().injectRequest(this);
View Full Code Here

        JiveGlobals.deleteProperty("interceptor.global." + getPropertySuffix());

        // Delete all the workgroup interceptors stored as properties.
        for (String jid : localInterceptors.keySet()) {
            try {
                Workgroup workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(jid));

                Collection<String> propertyNames = workgroup.getProperties().getPropertyNames();
                for (String propertyName : propertyNames) {
                   if (propertyName.startsWith("jive.interceptor." + getPropertySuffix())) {
                       workgroup.getProperties().deleteProperty(propertyName);
                   }
                }
            }
            catch (Exception e) {
               Log.error(e.getMessage(), e);
           }
        }

        // Save the global interceptors as system properties
        JiveGlobals.setProperties(getPropertiesMap(globalInterceptors,
                "interceptor.global." + getPropertySuffix() + "."));

        // Save all the workgroup interceptors as properties of the workgroups.
        for (String jid : localInterceptors.keySet()) {
            try {
                Workgroup workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(jid));
                Map propertyMap = getPropertiesMap(localInterceptors.get(jid),
                        "jive.interceptor." + getPropertySuffix() + ".");
                for (Iterator i=propertyMap.keySet().iterator(); i.hasNext(); ) {
                    String name = (String)i.next();
                    String value = (String)propertyMap.get(name);
                    workgroup.getProperties().setProperty(name, value);
                }
            }
            catch (Exception e) {
               Log.error(e.getMessage(), e);
           }
View Full Code Here

        }
        globalInterceptors.addAll(interceptorList);
    }

    private void loadLocalInterceptors(String workgroupJID) throws UserNotFoundException {
        Workgroup workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupJID));

        int interceptorCount = 0;
        String iCount = workgroup.getProperties().getProperty("jive.interceptor." +
                getPropertySuffix() + ".interceptorCount");
        if (iCount != null) {
            try {
                interceptorCount = Integer.parseInt(iCount);
            }
            catch (NumberFormatException nfe) { /* ignore */ }
        }

        // Load up all intercpetors.
        List<PacketInterceptor> interceptorList = new ArrayList<PacketInterceptor>(interceptorCount);
        for (int i=0; i<interceptorCount; i++) {
            try {
                String interceptorContext = "jive.interceptor." + getPropertySuffix() + ".interceptor" + i + ".";
                String className = workgroup.getProperties().getProperty(interceptorContext +
                        "className");
                Class interceptorClass = loadClass(className);
                interceptorList.add((PacketInterceptor) interceptorClass.newInstance());

                // Load properties.
                Map<String, String> interceptorProps = new HashMap<String, String>();
                for (String key : getChildrenPropertyNames(interceptorContext + "properties",
                        workgroup.getProperties().getPropertyNames()))
                {
                    String value = workgroup.getProperties().getProperty(key);
                    // Get the bean property name, which is everything after the last '.' in the
                    // xml property name.
                    interceptorProps.put(key.substring(key.lastIndexOf(".")+1), value);
                }

View Full Code Here

                // Keep track when the invitation was sent to the user
                offerAccepted = System.currentTimeMillis();
            }
            else {
                // Invite the agent to the room by sending an offer
                Workgroup workgroup = agentSession.getWorkgroups().iterator().next();
                RequestQueue requestQueue = workgroup.getRequestQueues().iterator().next();
                // Add the requested agent as the initial target agent to get the offer
                getMetaData().put("agent", Arrays.asList(invitee.toString()));
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Dispatch the request
                requestQueue.getDispatcher().injectRequest(this);
            }
        }
        else if (Type.queue == type) {
            // Send offer to the best again available in the requested queue
            Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
            if (targetWorkgroup == null) {
                // No workgroup was found for the specified invitee. Send a Message with the error
                sendErrorMessage("Specified workgroup was not found.");
                return;
            }
            try {
                RequestQueue requestQueue = targetWorkgroup.getRequestQueue(invitee.getResource());
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Dispatch the request
                requestQueue.getDispatcher().injectRequest(this);
            }
            catch (NotFoundException e) {
                // No queue was found for the specified invitee. Send a Message with the error
                sendErrorMessage("Specified queue was not found.");
            }
        }
        else if (Type.workgroup == type) {
            // Select the best queue based on the original request
            Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
            if (targetWorkgroup != null) {
                RequestQueue requestQueue = RoutingManager.getInstance().getBestQueue(targetWorkgroup, userRequest);
                getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
                // Send offer to the best again available in the requested queue
                requestQueue.getDispatcher().injectRequest(this);
View Full Code Here

     * @param startDate the start date.
     * @param endDate the end date.
     * @return the number of chats requests accepted by the workgroup.
     */
    public static int getNumberOfChatsAccepted(String workgroupName, Date startDate, Date endDate) {
        Workgroup workgroup = null;
        try {
            workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
        }
        catch (Exception ex) {
            Log.error(ex.getMessage(), ex);
        }
        if (workgroup == null) {
            return 0;
        }

        int count = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(ACCEPTED_CHATS_COUNT);
            pstmt.setLong(1, workgroup.getID());
            pstmt.setString(2, StringUtils.dateToMillis(startDate));
            pstmt.setString(3, StringUtils.dateToMillis(endDate));

            rs = pstmt.executeQuery();
            if (rs.next()) {
View Full Code Here

     *
     * @param workgroupName the name of the workgroup.
     * @return the total length of all chats in the specified workgroup.
     */
    public static long getTotalChatTimeForWorkgroup(String workgroupName) {
        Workgroup workgroup = null;

        try {
            workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
        }
        catch (Exception ex) {
            Log.error(ex.getMessage(), ex);
        }

        int totalWorkgroupChatTime = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(CHAT_TIMES_FOR_WORKGROUPS);
            pstmt.setLong(1, workgroup.getID());
            rs = pstmt.executeQuery();

            while (rs.next()) {
                String startTimeString = rs.getString(1);
                String endTimeString = rs.getString(2);
View Full Code Here

     * @param startDate the time to begin the search from.
     * @param endDate the time to end the search.
     * @return the total number of requests
     */
    public static int getNumberOfRequestsForWorkgroup(String workgroupName, Date startDate, Date endDate) {
        Workgroup workgroup = getWorkgroup(workgroupName);
        if (workgroup == null) {
            return 0;
        }

        int count = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(WORKGROUP_REQUEST_COUNT);
            pstmt.setLong(1, workgroup.getID());
            pstmt.setString(2, StringUtils.dateToMillis(startDate));
            pstmt.setString(3, StringUtils.dateToMillis(endDate));

            rs = pstmt.executeQuery();
            if (rs.next()) {
View Full Code Here

TOP

Related Classes of org.jivesoftware.xmpp.workgroup.Workgroup

Copyright © 2018 www.massapicom. 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.