Example usage for java.util HashSet isEmpty

List of usage examples for java.util HashSet isEmpty

Introduction

In this page you can find the example usage for java.util HashSet isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:net.sourceforge.mipa.predicatedetection.lattice.sequence.SequenceWindowedLatticeChecker.java

private boolean computePredicateOri(SequenceLatticeIDNode node) {
    // TODO Auto-generated method stub
    if (node == null) {
        return false;
    }/*from  ww  w .  j  av  a2 s .c  om*/
    boolean flagIntersection = false;
    boolean flagInclusion = true;
    HashSet<State> reachedStates = node.getReachedStates();
    HashSet<State> acceptStates = automaton.getAcceptStates();
    Iterator<State> it = reachedStates.iterator();
    while (it.hasNext()) {
        boolean flag = false;
        State state = it.next();
        Iterator<State> iterator = acceptStates.iterator();
        while (iterator.hasNext()) {
            State acceptState = iterator.next();
            if (state.getName().equals(acceptState.getName())) {
                flag = true;
                break;
            }
        }
        if (flag == false) {
            flagInclusion = false;
        } else {
            flagIntersection = true;
        }
        if (flagInclusion == false && flagIntersection == true) {
            break;
        }
    }
    if (reachedStates.isEmpty()) {
        node.setFlagInclusion(false);
        node.setFlagIntersection(false);
    } else {
        node.setFlagInclusion(flagInclusion);
        node.setFlagIntersection(flagIntersection);
    }
    long time_t = (new Date()).getTime();
    if (type == NodeType.DEF) {
        boolean result = flagInclusion;
        if (result == true) {
            if (count == 0) {
                // to do
            }
            count++;
            return true;
        }
    } else if (type == NodeType.POS) {
        boolean result = flagIntersection;
        if (result == true) {
            if (count == 0) {
                // to do
            }
            count++;
            return true;
        }
    }
    wastedOriTime += (new Date()).getTime() - time_t;
    return false;
}

From source file:net.sourceforge.mipa.predicatedetection.lattice.sequence.SequenceWindowedLatticeChecker.java

private boolean computePredicate(SequenceLatticeIDNode node) {
    if (node == null) {
        return false;
    }//from w  w  w.j ava2 s . c  o  m
    boolean flagIntersection = false;
    boolean flagInclusion = true;
    HashSet<State> reachedStates = node.getReachedStates();
    HashSet<State> acceptStates = automaton.getAcceptStates();
    Iterator<State> it = reachedStates.iterator();
    while (it.hasNext()) {
        boolean flag = false;
        State state = it.next();
        Iterator<State> iterator = acceptStates.iterator();
        while (iterator.hasNext()) {
            State acceptState = iterator.next();
            if (state.getName().equals(acceptState.getName())) {
                flag = true;
                break;
            }
        }
        if (flag == false) {
            flagInclusion = false;
        } else {
            flagIntersection = true;
        }
        if (flagInclusion == false && flagIntersection == true) {
            break;
        }
    }
    if (reachedStates.isEmpty()) {
        node.setFlagInclusion(false);
        node.setFlagIntersection(false);
    } else {
        node.setFlagInclusion(flagInclusion);
        node.setFlagIntersection(flagIntersection);
    }
    // long time_t = (new Date()).getTime();
    if (type == NodeType.DEF) {
        boolean result = flagInclusion;
        if (result == true) {
            /*
             * if (count == 0) { try { application.callback(predicateID,
             * String.valueOf(true)); } catch (Exception e) {
             * e.printStackTrace(); } } count++;
             */
            return true;
        }
    } else if (type == NodeType.POS) {
        boolean result = flagIntersection;
        if (result == true) {
            /*
             * if (count == 0) { try { application.callback(predicateID,
             * String.valueOf(true)); } catch (Exception e) {
             * e.printStackTrace(); } } count++;
             */
            return true;
        }
    }
    // wastedTime += (new Date()).getTime() - time_t;
    return false;
}

From source file:amie.keys.CombinationsExplorationNew.java

private static GraphNew mergeGraphNews(GraphNew currentGraphNew, GraphNew graph2,
        HashSet<Node> currentGraphNewTopNodes, HashSet<Integer> conditionProperties) {
    HashSet<Node> childrenNodes = new HashSet<>();
    for (Node currentGraphNewtopNode : currentGraphNewTopNodes) {
        if (currentGraphNewtopNode.toExplore) {
            //   System.out.println("currentGraphNewtopNode:"+currentGraphNewtopNode);
            if (graph2.graph.containsKey(currentGraphNewtopNode)) {
                // System.out.println("yes");
                Node nodeInGraphNew2 = graph2.getNode(currentGraphNewtopNode);
                if (!nodeInGraphNew2.toExplore) {
                    //   System.out.println("no2");
                    currentGraphNewtopNode.toExplore = false;
                    currentGraphNew.getAndCreateNode(currentGraphNewtopNode);
                } else {
                    // System.out.println("yes2");
                    HashSet<Integer> allProperties = new HashSet<>();
                    allProperties.addAll(conditionProperties);
                    allProperties.addAll(currentGraphNewtopNode.set);
                    //  System.out.println("allProperties:"+allProperties);
                    if (!containsSubSet(allProperties)) {
                        //  System.out.println("no3");
                        currentGraphNewtopNode.toExplore = false;
                        currentGraphNew.getAndCreateNode(currentGraphNewtopNode);
                    }// ww  w  . ja  v a2s  .c  o  m
                }
            } else {
                //   System.out.println("no");
                currentGraphNewtopNode.toExplore = false;
                currentGraphNew.getAndCreateNode(currentGraphNewtopNode);
            }
        }

        if (currentGraphNew.graph.get(currentGraphNewtopNode) != null) {
            childrenNodes.addAll(currentGraphNew.graph.get(currentGraphNewtopNode));
        }
    }
    if (!childrenNodes.isEmpty()) {
        mergeGraphNews(currentGraphNew, graph2, childrenNodes, conditionProperties);
    }
    return currentGraphNew;
}

From source file:com.healthcit.cacure.businessdelegates.QuestionAnswerManager.java

public DuplicateResultBean hasShortNameDuplicates(List<String> collectedShortNames) {
    HashSet<String> uniqShortnamesSet = new HashSet<String>(collectedShortNames);
    HashSet<String> duplShortnamesSet = new HashSet<String>();
    if (uniqShortnamesSet.size() != collectedShortNames.size()) {
        for (String uniqSn : uniqShortnamesSet) {
            collectedShortNames.remove(uniqSn);
        }/*from w ww .j ava  2s  .  c  o m*/
        duplShortnamesSet.addAll(collectedShortNames);
    }
    Set<String> exactQuestionsShortNames = qstDao.getQuestionsShortNamesLike(uniqShortnamesSet, true);
    duplShortnamesSet.addAll(exactQuestionsShortNames);
    Set<String> exactTableShortNames = teDao.getTableShortNamesLike(uniqShortnamesSet, true);
    duplShortnamesSet.addAll(exactTableShortNames);
    if (duplShortnamesSet.isEmpty()) {
        return new DuplicateResultBean(DuplicateResultType.OK, null);
    } else {
        return new DuplicateResultBean(DuplicateResultType.NOT_UNIQUE,
                duplShortnamesSet.toArray(new String[0]));
    }
}

From source file:org.unitime.timetable.solver.TimetableDatabaseSaver.java

private Long[] save(org.hibernate.Session hibSession) throws Exception {

    if (iStudentSectioning)
        getModel().switchStudents(getAssignment());

    iProgress.setStatus("Saving solution ...");

    if (iSolverGroupId == null || iSolverGroupId.length == 0) {
        iProgress.fatal("No solver group loaded.");
        return null;
    }//from   w w  w.  j  a  v  a 2  s . c  om

    Hashtable solverGroups = new Hashtable();
    for (int i = 0; i < iSolverGroupId.length; i++) {
        SolverGroup solverGroup = SolverGroupDAO.getInstance().get(iSolverGroupId[i], hibSession);
        if (solverGroup == null) {
            iProgress.fatal("Unable to load solver group " + iSolverGroupId[i] + ".");
            return null;
        }
        solverGroups.put(solverGroup.getUniqueId(), solverGroup);
        iProgress.debug("solver group [" + (i + 1) + "]: " + solverGroup.getName());
    }

    iSolutions = new Hashtable();
    if (!iCreateNew && iSolutionId != null && iSolutionId.length >= 0) {
        for (int i = 0; i < iSolverGroupId.length; i++) {
            if (i < iSolutionId.length && iSolutionId[i] != null) {
                Solution solution = (new SolutionDAO()).get(iSolutionId[i], hibSession);
                if (solution == null) {
                    iProgress.warn("Unable to load solution " + iSolutionId[i]);
                    continue;
                }
                if (!solverGroups.containsKey(solution.getOwner().getUniqueId())) {
                    iProgress.warn("Solution " + iSolutionId[i]
                            + " ignored -- it does not match with the owner(s) of the problem");
                    continue;
                }
                if (solution.isCommited().booleanValue()) {
                    solution.uncommitSolution(hibSession,
                            getModel().getProperties().getProperty("General.OwnerPuid"));
                    if (!iCommitSolution) {
                        String className = ApplicationProperty.ExternalActionSolutionCommit.value();
                        if (className != null && className.trim().length() > 0) {
                            HashSet<Solution> touchedSolutions = new HashSet<Solution>();
                            touchedSolutions.add(solution);
                            ExternalSolutionCommitAction commitAction = (ExternalSolutionCommitAction) (Class
                                    .forName(className).newInstance());
                            commitAction.performExternalSolutionCommitAction(touchedSolutions, hibSession);
                        }

                    }
                }
                solution.empty(hibSession, getFileProxy());
                iSolutions.put(solution.getOwner().getUniqueId(), solution);
            }
        }
    }

    Session session = SessionDAO.getInstance().get(iSessionId, hibSession);
    if (session == null) {
        iProgress.fatal("No session loaded.");
        return null;
    }
    iProgress.debug("session: " + session.getLabel());

    for (Enumeration e = solverGroups.elements(); e.hasMoreElements();) {
        SolverGroup solverGroup = (SolverGroup) e.nextElement();
        Solution solution = (Solution) iSolutions.get(solverGroup.getUniqueId());
        if (solution == null) {
            solution = new Solution();
            iSolutions.put(solverGroup.getUniqueId(), solution);
        }
        solution.setCommitDate(null);
        solution.setCreated(new Timestamp((new Date()).getTime()));
        solution.setCreator(Test.getVersionString());
        solution.setNote(getModel().getProperties().getProperty("General.Note"));
        solution.setOwner(solverGroup);
        solverGroup.getSolutions().add(solution);
        solution.setValid(Boolean.TRUE);
        solution.setCommited(Boolean.FALSE);

        iProgress.setPhase("Saving solver parameters ...", getModel().getProperties().size());
        HashSet params = new HashSet();
        for (Iterator i1 = getModel().getProperties().entrySet().iterator(); i1.hasNext();) {
            Map.Entry entry = (Map.Entry) i1.next();
            String name = (String) entry.getKey();
            String value = (String) entry.getValue();
            SolverParameterDef def = SolverParameterDef.findByNameType(hibSession, name,
                    SolverParameterGroup.sTypeCourse);
            if (def != null) {
                iProgress.trace("save " + name + "=" + value);
                SolverParameter param = new SolverParameter();
                param.setDefinition(def);
                param.setValue(value);
                hibSession.save(param);
                params.add(param);
            }
            iProgress.incProgress();
        }
        solution.setParameters(params);

        hibSession.saveOrUpdate(solution);
    }

    hibSession.flush();
    hibSession.clear();
    int batchIdx = 0;

    iProgress.setPhase("Saving assignments ...", getModel().variables().size());
    for (Lecture lecture : getModel().variables()) {
        Placement placement = getAssignment().getValue(lecture);
        if (placement != null) {
            iProgress.trace("save " + lecture.getName() + " " + placement.getName());
            Class_ clazz = (new Class_DAO()).get(lecture.getClassId(), hibSession);
            if (clazz == null) {
                iProgress.warn("Unable to save assignment for class " + lecture + " ("
                        + placement.getLongName(iUseAmPm) + ") -- class (id:" + lecture.getClassId()
                        + ") does not exist.");
                continue;
            }
            HashSet rooms = new HashSet();
            if (placement.isMultiRoom()) {
                for (RoomLocation r : placement.getRoomLocations()) {
                    Location room = (new LocationDAO()).get(r.getId(), hibSession);
                    if (room == null) {
                        iProgress.warn("Unable to save assignment for class " + lecture + " ("
                                + placement.getLongName(iUseAmPm) + ") -- room (id:" + r.getId()
                                + ") does not exist.");
                        continue;
                    }
                    rooms.add(room);
                }
                if (rooms.size() != placement.getRoomLocations().size())
                    continue;
            } else {
                Location room = (new LocationDAO()).get(placement.getRoomLocation().getId(), hibSession);
                if (room == null) {
                    iProgress.warn("Unable to save assignment for class " + lecture + " ("
                            + placement.getLongName(iUseAmPm) + ") -- room (id:"
                            + placement.getRoomLocation().getId() + ") does not exist.");
                    continue;
                }
                rooms.add(room);
            }

            HashSet instructors = new HashSet();
            for (InstructorConstraint ic : lecture.getInstructorConstraints()) {
                DepartmentalInstructor instructor = null;
                if (ic.getPuid() != null && ic.getPuid().length() > 0) {
                    instructor = DepartmentalInstructor.findByPuidDepartmentId(ic.getPuid(),
                            clazz.getControllingDept().getUniqueId());
                } else if (ic.getResourceId() != null) {
                    instructor = (new DepartmentalInstructorDAO()).get(ic.getResourceId(), hibSession);
                }
                if (instructor != null)
                    instructors.add(instructor);
            }

            TimePattern pattern = (new TimePatternDAO()).get(placement.getTimeLocation().getTimePatternId(),
                    hibSession);
            if (pattern == null) {
                iProgress.warn("Unable to save assignment for class " + lecture + " ("
                        + placement.getLongName(iUseAmPm) + ") -- time pattern (id:"
                        + placement.getTimeLocation().getTimePatternId() + ") does not exist.");
                continue;
            }
            Solution solution = getSolution(lecture, hibSession);
            if (solution == null) {
                iProgress.warn("Unable to save assignment for class " + lecture + " ("
                        + placement.getLongName(iUseAmPm)
                        + ") -- none or wrong solution group assigned to the class");
                continue;
            }
            Assignment assignment = new Assignment();
            assignment.setClazz(clazz);
            assignment.setClassId(clazz.getUniqueId());
            assignment.setClassName(lecture.getName());
            assignment.setDays(new Integer(placement.getTimeLocation().getDayCode()));
            assignment.setStartSlot(new Integer(placement.getTimeLocation().getStartSlot()));
            assignment.setTimePattern(pattern);
            if (placement.getTimeLocation().getDatePatternId() != null)
                assignment.setDatePattern(DatePatternDAO.getInstance()
                        .get(placement.getTimeLocation().getDatePatternId(), hibSession));
            assignment.setRooms(rooms);
            assignment.setInstructors(instructors);
            assignment.setSolution(solution);
            hibSession.save(assignment);
            iAssignments.put(lecture.getClassId(), assignment);
            if (++batchIdx % BATCH_SIZE == 0) {
                hibSession.flush();
                hibSession.clear();
            }
        }
        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    if (getModel().getProperties().getPropertyBoolean("General.SaveStudentEnrollments", true)) {
        iProgress.setPhase("Saving student enrollments ...", getModel().variables().size());
        for (Lecture lecture : getModel().variables()) {
            Class_ clazz = (new Class_DAO()).get(lecture.getClassId(), hibSession);
            if (clazz == null)
                continue;
            iProgress.trace("save " + lecture.getName());
            Solution solution = getSolution(lecture, hibSession);
            if (solution == null) {
                iProgress.warn("Unable to save student enrollments for class " + lecture
                        + "  -- none or wrong solution group assigned to the class");
                continue;
            }

            for (Iterator i2 = lecture.students().iterator(); i2.hasNext();) {
                Student student = (Student) i2.next();
                StudentEnrollment enrl = new StudentEnrollment();
                enrl.setStudentId(student.getId());
                enrl.setClazz(clazz);
                enrl.setSolution(solution);
                hibSession.save(enrl);
                if (++batchIdx % BATCH_SIZE == 0) {
                    hibSession.flush();
                    hibSession.clear();
                }
            }

            iProgress.incProgress();
        }

        hibSession.flush();
        hibSession.clear();
        batchIdx = 0;
    }

    /**  // is this needed?
    iProgress.setPhase("Saving joint enrollments ...", getModel().getJenrlConstraints().size());
    for (Enumeration e1=getModel().getJenrlConstraints().elements();e1.hasMoreElements();) {
     JenrlConstraint jenrlConstraint = (JenrlConstraint)e1.nextElement();
             
     Class_ clazz1 = (new Class_DAO()).get(((Lecture)jenrlConstraint.first()).getClassId());
     Class_ clazz2 = (new Class_DAO()).get(((Lecture)jenrlConstraint.second()).getClassId());
             
     JointEnrollment jenrl = new JointEnrollment();
     jenrl.setJenrl(new Double(jenrlConstraint.getJenrl()));
     jenrl.setClass1(clazz1);
     jenrl.setClass2(clazz2);
     jenrl.setSolution(solution);
     hibSession.save(jenrl);
             
     iProgress.incProgress();
    }
    */

    SolverInfoDef defGlobalInfo = SolverInfoDef.findByName(hibSession, "GlobalInfo");
    if (defGlobalInfo == null)
        iProgress.warn("Global info is not registered.");
    SolverInfoDef defCbsInfo = SolverInfoDef.findByName(hibSession, "CBSInfo");
    if (defCbsInfo == null)
        iProgress.warn("Constraint-based statistics info is not registered.");
    SolverInfoDef defAssignmentInfo = SolverInfoDef.findByName(hibSession, "AssignmentInfo");
    if (defAssignmentInfo == null)
        iProgress.warn("Assignment info is not registered.");
    SolverInfoDef defDistributionInfo = SolverInfoDef.findByName(hibSession, "DistributionInfo");
    if (defDistributionInfo == null)
        iProgress.warn("Distribution constraint info is not registered.");
    SolverInfoDef defJenrlInfo = SolverInfoDef.findByName(hibSession, "JenrlInfo");
    if (defJenrlInfo == null)
        iProgress.warn("Joint enrollments info is not registered.");
    SolverInfoDef defLogInfo = SolverInfoDef.findByName(hibSession, "LogInfo");
    if (defLogInfo == null)
        iProgress.warn("Solver log info is not registered.");
    SolverInfoDef defBtbInstrInfo = SolverInfoDef.findByName(hibSession, "BtbInstructorInfo");
    if (defBtbInstrInfo == null)
        iProgress.warn("Back-to-back instructor info is not registered.");

    Hashtable<Solution, List<Lecture>> lectures4solution = new Hashtable<Solution, List<Lecture>>();
    for (Lecture lecture : getModel().variables()) {
        Solution s = getSolution(lecture, hibSession);
        if (s == null)
            continue;
        List<Lecture> lectures = lectures4solution.get(s);
        if (lectures == null) {
            lectures = new ArrayList<Lecture>();
            lectures4solution.put(s, lectures);
        }
        lectures.add(lecture);
    }

    iProgress.setPhase("Saving global info ...", solverGroups.size());
    for (Enumeration e = solverGroups.elements(); e.hasMoreElements();) {
        SolverGroup solverGroup = (SolverGroup) e.nextElement();
        Solution solution = (Solution) iSolutions.get(solverGroup.getUniqueId());
        List<Lecture> lectures = lectures4solution.get(solution);
        if (lectures == null)
            lectures = new ArrayList<Lecture>(0);
        SolutionInfo solutionInfo = new SolutionInfo();
        solutionInfo.setDefinition(defGlobalInfo);
        solutionInfo.setOpt(null);
        solutionInfo.setSolution(solution);
        solutionInfo.setInfo(new PropertiesInfo(getSolution().getInfo(lectures)), getFileProxy());
        hibSession.save(solutionInfo);
        solution.setGlobalInfo(solutionInfo);
        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    ConflictStatistics cbs = null;
    for (Extension ext : getSolver().getExtensions()) {
        if (ext instanceof ConflictStatistics) {
            cbs = (ConflictStatistics) ext;
            break;
        }
    }
    if (cbs != null && cbs.getNoGoods() != null) {
        ConflictStatisticsInfo cbsInfo = new ConflictStatisticsInfo();
        cbsInfo.load(getSolver(), cbs);
        iProgress.setPhase("Saving conflict-based statistics ...", 1);
        for (Enumeration e = iSolutions.elements(); e.hasMoreElements();) {
            Solution solution = (Solution) e.nextElement();
            List<Lecture> lectures = lectures4solution.get(solution);
            if (lectures == null)
                lectures = new ArrayList<Lecture>(0);
            SolutionInfo cbsSolutionInfo = new SolutionInfo();
            cbsSolutionInfo.setDefinition(defCbsInfo);
            cbsSolutionInfo.setOpt(null);
            cbsSolutionInfo.setSolution(solution);
            cbsSolutionInfo.setInfo(cbsInfo.getConflictStatisticsSubInfo(lectures), getFileProxy());
            hibSession.save(cbsSolutionInfo);
            if (++batchIdx % BATCH_SIZE == 0) {
                hibSession.flush();
                hibSession.clear();
            }
        }
        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Saving variable infos ...", getModel().variables().size());
    for (Lecture lecture : getModel().variables()) {
        Placement placement = getAssignment().getValue(lecture);
        if (placement != null) {
            Assignment assignment = (Assignment) iAssignments.get(lecture.getClassId());
            AssignmentInfo assignmentInfo = new AssignmentInfo();
            assignmentInfo.setAssignment(assignment);
            assignmentInfo.setDefinition(defAssignmentInfo);
            assignmentInfo.setOpt(null);
            assignmentInfo.setInfo(new AssignmentPreferenceInfo(getSolver(), placement, true, true),
                    getFileProxy());
            hibSession.save(assignmentInfo);
            if (++batchIdx % BATCH_SIZE == 0) {
                hibSession.flush();
                hibSession.clear();
            }
        }
        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Saving btb instructor infos ...", getModel().variables().size());
    for (Lecture lecture1 : getModel().variables()) {
        Placement placement1 = (Placement) getAssignment().getValue(lecture1);
        iProgress.incProgress();
        if (placement1 == null)
            continue;
        for (InstructorConstraint ic : lecture1.getInstructorConstraints()) {
            for (Lecture lecture2 : ic.variables()) {
                Placement placement2 = (Placement) getAssignment().getValue(lecture2);
                if (placement2 == null || lecture2.getClassId().compareTo(lecture1.getClassId()) <= 0)
                    continue;
                int pref = ic.getDistancePreference(placement1, placement2);
                if (pref == PreferenceLevel.sIntLevelNeutral)
                    continue;
                iProgress.trace("Back-to-back instructor constraint (" + pref + ") between " + placement1
                        + " and " + placement2);
                BtbInstructorConstraintInfo biInfo = new BtbInstructorConstraintInfo();
                biInfo.setPreference(pref);
                biInfo.setInstructorId(ic.getResourceId());
                ConstraintInfo constraintInfo = new ConstraintInfo();
                constraintInfo.setDefinition(defBtbInstrInfo);
                constraintInfo.setOpt(String.valueOf(ic.getResourceId()));
                HashSet biAssignments = new HashSet();
                Assignment assignment = (Assignment) iAssignments.get(lecture1.getClassId());
                if (assignment != null)
                    biAssignments.add(assignment);
                assignment = (Assignment) iAssignments.get(lecture2.getClassId());
                if (assignment != null)
                    biAssignments.add(assignment);
                if (!biAssignments.isEmpty()) {
                    constraintInfo.setAssignments(biAssignments);
                    constraintInfo.setInfo(biInfo, getFileProxy());
                    hibSession.save(constraintInfo);
                    if (++batchIdx % BATCH_SIZE == 0) {
                        hibSession.flush();
                        hibSession.clear();
                    }
                } else {
                    iProgress.trace("   NO ASSIGNMENTS !!!");
                }
            }
        }
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Saving group constraint infos ...", getModel().getGroupConstraints().size());
    for (GroupConstraint gc : getModel().getGroupConstraints()) {
        GroupConstraintInfo gcInfo = new GroupConstraintInfo(getAssignment(), gc);
        ConstraintInfo constraintInfo = new ConstraintInfo();
        constraintInfo.setDefinition(defDistributionInfo);
        constraintInfo.setOpt(gcInfo.isSatisfied() ? "1" : "0");
        iProgress.trace("Distribution constraint " + gcInfo.getName() + " (p:" + gcInfo.getPreference() + ", s:"
                + gcInfo.isSatisfied() + ") between");
        HashSet gcAssignments = new HashSet();
        for (Lecture lecture : gc.variables()) {
            Assignment assignment = (Assignment) iAssignments.get(lecture.getClassId());
            iProgress.trace("  " + getAssignment().getValue(lecture));
            if (assignment != null)
                gcAssignments.add(assignment);
        }

        if (!gcAssignments.isEmpty()) {
            constraintInfo.setAssignments(gcAssignments);
            constraintInfo.setInfo(gcInfo, getFileProxy());
            hibSession.save(constraintInfo);
            if (++batchIdx % BATCH_SIZE == 0) {
                hibSession.flush();
                hibSession.clear();
            }
        } else {
            iProgress.trace("   NO ASSIGNMENTS !!!");
        }

        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Saving student enrollment infos ...", getModel().getJenrlConstraints().size());
    for (JenrlConstraint jc : getModel().getJenrlConstraints()) {
        if (!jc.isInConflict(getAssignment()) || !jc.isOfTheSameProblem()) {
            iProgress.incProgress();
            continue;
        }
        JenrlInfo jInfo = new JenrlInfo(getSolver(), jc);
        ConstraintInfo constraintInfo = new ConstraintInfo();
        constraintInfo.setDefinition(defJenrlInfo);
        constraintInfo.setOpt((jInfo.isSatisfied() ? "S" : "") + (jInfo.isHard() ? "H" : "")
                + (jInfo.isDistance() ? "D" : "") + (jInfo.isFixed() ? "F" : "")
                + (jInfo.isImportant() ? "I" : "") + (jInfo.isInstructor() ? "X" : ""));
        Assignment firstAssignment = (Assignment) iAssignments.get(((Lecture) jc.first()).getClassId());
        Assignment secondAssignment = (Assignment) iAssignments.get(((Lecture) jc.second()).getClassId());
        if (firstAssignment == null || secondAssignment == null)
            continue;
        HashSet jAssignments = new HashSet();
        jAssignments.add(firstAssignment);
        jAssignments.add(secondAssignment);
        constraintInfo.setAssignments(jAssignments);
        constraintInfo.setInfo(jInfo, getFileProxy());
        hibSession.save(constraintInfo);
        if (++batchIdx % BATCH_SIZE == 0) {
            hibSession.flush();
            hibSession.clear();
        }

        iProgress.incProgress();
    }

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Saving committed student enrollment infos ...", iSolutions.size());
    for (Enumeration e = iSolutions.elements(); e.hasMoreElements();) {
        Solution solution = (Solution) e.nextElement();
        solution.updateCommittedStudentEnrollmentInfos(hibSession);
        iProgress.incProgress();
    }
    iProgress.incProgress();

    /*
    iProgress.setPhase("Saving committed student enrollment infos ...", getModel().assignedVariables().size());
    for (Enumeration e1=getModel().assignedVariables().elements();e1.hasMoreElements();) {
     Lecture lecture = (Lecture)e1.nextElement();
     Assignment assignment = (Assignment)iAssignments.get(lecture.getClassId());
    if (assignment==null) continue;
    Hashtable infos = JenrlInfo.getCommitedJenrlInfos(lecture);
     for (Iterator i2=infos.entrySet().iterator();i2.hasNext();) {
        Map.Entry entry = (Map.Entry)i2.next();
        Integer assignmentId = (Integer)entry.getKey();
        JenrlInfo jInfo = (JenrlInfo)entry.getValue();
        Assignment other = (new AssignmentDAO()).get(assignmentId,hibSession);
        if (other==null) continue;
         ConstraintInfo constraintInfo = new ConstraintInfo();
         constraintInfo.setDefinition(defJenrlInfo);
         constraintInfo.setOpt("C"+(jInfo.isSatisfied()?"S":"")+(jInfo.isHard()?"H":"")+(jInfo.isDistance()?"D":"")+(jInfo.isFixed()?"F":""));
         HashSet jAssignments = new HashSet();
         jAssignments.add(assignment);
         jAssignments.add(other);
         constraintInfo.setAssignments(jAssignments);
         constraintInfo.setInfo(jInfo,getFileProxy());
         hibSession.save(constraintInfo);
        if (++batchIdx % BATCH_SIZE == 0) {
           hibSession.flush(); hibSession.clear();
        }
     }
     iProgress.incProgress();
    }
    */

    hibSession.flush();
    hibSession.clear();
    batchIdx = 0;

    iProgress.setPhase("Done", 1);
    iProgress.incProgress();

    Long ret[] = new Long[iSolutions.size()];
    int idx = 0;
    for (Enumeration e = iSolutions.elements(); e.hasMoreElements();)
        ret[idx++] = ((Solution) e.nextElement()).getUniqueId();

    return ret;
}

From source file:amie.keys.CombinationsExplorationNew.java

public static void discoverConditionalKeysForComplexConditions(GraphNew graph, HashSet<Node> candidateKeys,
        Rule conditionRule) {//from   w  w  w  .j av  a2s. c o  m
    HashSet<Node> childrenCandidateKeys = new HashSet<>();
    //   System.out.println("candidates:" + candidateKeys);

    for (Node candidateKey : candidateKeys) {
        //   System.out.println("candidate:" + candidateKey);
        if (candidateKey.toExplore) {
            //       System.out.println("candidate:" + candidateKey);
            if (candidateKey.toExplore) {
                List<String> properties = candidateKey.mapToString(id2Property);
                //      System.out.println("properties:"+properties);
                Rule amieRule = buildAMIERule(properties, conditionRule);

                boolean isConditionalKey = isConditionaKey(amieRule);
                if (amieRule.getSupport() < support || isConditionalKey) {
                    candidateKey.toExplore = false;
                    //      System.out.println("key");
                    flagChildren(graph, candidateKey);
                }

                // If the rule is a conditional above the support
                // and there is no a simpler key already discovered
                // then output it
                if (isConditionalKey && amieRule.getSupport() >= support
                        && !isSubsumedByKey(amieRule, conditionRule, conditions2Keys)) {
                    System.out.println(Utilities.formatKey(amieRule));
                    conditions2Keys.put(conditionRule, amieRule);
                }

                if (candidateKey.toExplore) {
                    if (graph.graph.containsKey(candidateKey)) {
                        childrenCandidateKeys.addAll(graph.graph.get(candidateKey));
                    }
                }
            }
        } else {
            flagChildren(graph, candidateKey);
        }
    }
    if (!childrenCandidateKeys.isEmpty()) {
        discoverConditionalKeysForComplexConditions(graph, childrenCandidateKeys, conditionRule);
    }
}

From source file:com.milaboratory.core.tree.SequenceTreeMapTest.java

@Test
public void testNIterator() throws Exception {
    SequenceTreeMap<NucleotideSequence, Integer> map = new SequenceTreeMap<>(NucleotideSequence.ALPHABET);

    assertNull(map.put(new NucleotideSequence("attagaca"), 1)); // 1 mm
    assertNull(map.put(new NucleotideSequence("attacaca"), 2)); // match
    assertNull(map.put(new NucleotideSequence("ataacaca"), 3)); // 1 mm
    assertNull(map.put(new NucleotideSequence("attcgtca"), 4)); // many mm
    assertNull(map.put(new NucleotideSequence("atttacaca"), 5)); // 1 insertion in stretch
    assertNull(map.put(new NucleotideSequence("atacaca"), 6)); // 1 deletion in the "t" stretch
    assertNull(map.put(new NucleotideSequence("attacacta"), 7)); // 1 insertion
    assertNull(map.put(new NucleotideSequence("attcaca"), 8)); // 1 deletion
    assertNull(map.put(new NucleotideSequence("attacac"), 9)); // 1 deletion in the end
    assertNull(map.put(new NucleotideSequence("ttacaca"), 10)); // 1 deletion in the beginning
    assertNull(map.put(new NucleotideSequence("tattacaca"), 11)); // 1 insertion in the beginning
    assertNull(map.put(new NucleotideSequence("attacacat"), 12)); // 1 insertion in the ent
    assertNull(map.put(new NucleotideSequence("attacact"), 13)); // 1 mm end
    assertNull(map.put(new NucleotideSequence("tttacaca"), 14)); // 1 mm begin

    NucleotideSequence reference = new NucleotideSequence("attacaca");

    SequenceTreeMap.Node<Integer> node;

    HashSet<Integer>[] allAsserts = new HashSet[3];
    allAsserts[0] = new HashSet<>(Arrays.asList(1, 3, 13, 14));
    allAsserts[1] = new HashSet<>(Arrays.asList(6, 8, 9, 10));
    allAsserts[2] = new HashSet<>(Arrays.asList(5, 7, 11, 12));

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

        double lastPenalty = -1.0;
        HashSet<Integer> asserts = new HashSet<>();
        asserts.add(2);/*from   w  w  w.  ja v  a2  s .  com*/
        int[] maxMut = new int[3];
        for (int j = 0; j < 3; ++j) {
            if (((0x1 << j) & i) != 0) {
                maxMut[j] = 1;
                asserts.addAll(allAsserts[j]);
            }
        }

        HashSet<Integer> asserts1 = new HashSet<>(asserts);

        NeighborhoodIterator ni = map.getNeighborhoodIterator(reference, 0.5,
                new double[] { 0.31, 0.301, 0.3001 }, maxMut, null);

        while ((node = ni.nextNode()) != null) {
            assertTrue(lastPenalty <= ni.getPenalty());
            lastPenalty = ni.getPenalty();
            asserts.remove(node.object);
            assertTrue(asserts1.contains(node.object));
        }
        assertTrue(asserts.isEmpty());
    }
}

From source file:crossspectrumapp.CrossSpectrumApp.java

private HashSet<Integer> getSelections() throws SQLException, LdvTableException, ViewConfigException {
    HashSet<Integer> ret = new HashSet<>();
    long strt = System.currentTimeMillis();
    getDbTables();//from   ww w . ja v a  2  s  . c o m

    {
        int n;
        String[] channelNames = cscl.getChannelNames();
        if (channelNames == null || channelNames.length == 0) {
            throw new IllegalArgumentException("No Channel specified");
        }
        if (channelNames.length != 2) {
            throw new IllegalArgumentException("2 and only 2 channels need to be specified.");
        }
        String server = cscl.getServer();
        String cType = cscl.getcType();

        if ((server == null || server.isEmpty()) && (cType == null || cType.isEmpty())) {
            for (String channelName : channelNames) {
                n = chanTbl.getBestMatch(channelName);
                ret.add(n);
            }
        } else {
            if (cType == null || cType.isEmpty()) {
                cType = "raw";
            }
            for (String channelName : channelNames) {
                TreeSet<ChanInfo> chSet = chanTbl.getAsSet(server, channelName, cType, 10);
                if (chSet.size() > 1) {
                    System.err.println("Warning: more than one channel matches: " + channelName);
                }

                for (ChanInfo ci : chSet) {
                    Integer id = ci.getId();
                    ret.add(id);
                }
            }
        }
        if (ret.isEmpty()) {
            for (String channelName : channelNames) {
                System.err.println("Channel requested was not found: " + channelName);
            }
        }
    }
    return ret;

}

From source file:org.fao.geonet.kernel.search.LuceneSearcher.java

/**
 * Retrieves metadata from the index.//  w  ww.j av  a2s .  co m
 * 
 * @param doc
 * @param id
 * @param dumpAllField   If dumpFields is null and dumpAllField set to true, dump all index content.
 * @param dumpFields   If not null, dump only the fields define in {@link LuceneConfig#getDumpFields()}.
 * @return
 */
private static Element getMetadataFromIndex(Document doc, String id, boolean dumpAllField, String searchLang,
        Set<String> multiLangSearchTerm, Map<String, String> dumpFields) {
    // Retrieve the info element
    String root = doc.get("_root");
    String schema = doc.get("_schema");
    String source = doc.get("_source");
    String uuid = doc.get("_uuid");
    String title = doc.get("_title");

    String createDate = doc.get("_createDate");
    if (createDate != null)
        createDate = createDate.toUpperCase();
    String changeDate = doc.get("_changeDate");
    if (changeDate != null)
        changeDate = changeDate.toUpperCase();

    // Root element is using root element name if not using only the index content (ie. dumpAllField)
    // probably because the XSL need that info later ?
    Element md = new Element("metadata");

    Element info = new Element(Edit.RootChild.INFO, Edit.NAMESPACE);

    addElement(info, Edit.Info.Elem.ID, id);
    addElement(info, Edit.Info.Elem.UUID, uuid);
    addElement(info, Edit.Info.Elem.SCHEMA, schema);
    addElement(info, Edit.Info.Elem.CREATE_DATE, createDate);
    addElement(info, Edit.Info.Elem.CHANGE_DATE, changeDate);
    addElement(info, Edit.Info.Elem.SOURCE, source);
    addElement(info, Edit.Info.Elem.TITLE, title);

    HashSet<String> addedTranslation = new HashSet<String>();
    if ((dumpAllField || dumpFields != null) && searchLang != null && multiLangSearchTerm != null) {
        // get the translated fields and dump those instead of the non-translated
        for (String fieldName : multiLangSearchTerm) {
            IndexableField[] values = doc
                    .getFields(LuceneConfig.multilingualSortFieldName(fieldName, searchLang));
            for (IndexableField f : values) {
                if (f != null) {
                    String stringValue = f.stringValue();
                    if (!stringValue.trim().isEmpty()) {
                        addedTranslation.add(fieldName);
                        md.addContent(new Element(dumpFields.get(fieldName)).setText(stringValue));
                    }
                }
            }
        }
    }
    if (addedTranslation.isEmpty()) {
        addedTranslation = null;
    }
    if (dumpFields != null) {
        for (String fieldName : dumpFields.keySet()) {
            IndexableField[] values = doc.getFields(fieldName);
            for (IndexableField f : values) {
                if (f != null) {
                    if (addedTranslation == null || !addedTranslation.contains(fieldName)) {
                        md.addContent(new Element(dumpFields.get(fieldName)).setText(f.stringValue()));
                    }
                }
            }
        }
    } else {
        List<IndexableField> fields = doc.getFields();
        for (IndexableField field : fields) {
            String fieldName = field.name();
            String fieldValue = field.stringValue();

            // Dump the categories to the info element
            if (fieldName.equals("_cat")) {
                addElement(info, Edit.Info.Elem.CATEGORY, fieldValue);
            } else if (dumpAllField && (addedTranslation == null || !addedTranslation.contains(fieldName))) {
                // And all other field to the root element in dump all mode
                md.addContent(new Element(fieldName).setText(fieldValue));
            }
        }
    }
    md.addContent(info);
    return md;
}

From source file:me.mneri.rice.Connection.java

private void initCallbacks() {
    // Cambi di stato
    on(REGISTER, event -> {//  w ww . ja  v a2 s  . c o  m
        if (mAutoJoin.size() > 0) {
            for (String channel : mAutoJoin)
                join(channel);

            mAutoJoin.clear();
        } else {
            for (Conversation conversation : mConversations.values()) {
                if (conversation.getType() == Conversation.Type.CHANNEL)
                    join(conversation.getName());
            }
        }
    });
    on(CLOSE, event -> {
        OutputInterfaceFactory f = OutputInterfaceFactory.instance();
        //@formatter:off
        try {
            mSocket.close();
        } catch (Exception ignored) {
        } finally {
            mSocket = null;
        }
        try {
            mInputThread.quit();
        } catch (Exception ignored) {
        } finally {
            mInputThread = null;
        }
        try {
            f.release(mOutputInterface);
        } catch (Exception ignored) {
        } finally {
            mOutputInterface = null;
        }
        //@formatter:on

        mCapabilities.clear();
        mCurrentHost = null;
        mHostCapabilities.clear();
        mHostIrcdVersion = null;
    });

    // Ricezione messaggi
    on(AUTHENTICATE, event -> {
        String body = mWantedNick + "\0" + mUser + "\0" + mPass;
        sendRawString("AUTHENTICATE " + new String(Base64.encodeBase64(body.getBytes())) + "\r\n");
    });
    on(AWAY, (Event event) -> {
        Message message = (Message) event.data;

        if (message.params.size() > 0) {
            // TODO: User is away
        } else {
            // TODO: User is returned
        }
    });
    on(CAP, event -> {
        Message message = (Message) event.data;
        String sub = message.params.get(1);

        if (sub.equals("ACK")) {
            ArrayList<String> caps = new ArrayList<>(Arrays.asList(message.params.get(2).split("\\s+")));

            for (String cap : caps) {
                if (cap.startsWith("-"))
                    mCapabilities.remove(cap.substring(1));
                else
                    mCapabilities.add(cap.replaceAll("[-~=]", ""));
            }
        }
    });
    on(CAP, event -> {
        Message message = (Message) event.data;
        String sub = message.params.get(1);

        if (mState == State.CONNECTED) {
            ArrayList<String> caps = new ArrayList<>(Arrays.asList(message.params.get(2).split("\\s+")));

            switch (sub) {
            case "ACK":
                if (caps.contains("sasl"))
                    sendRawString("AUTHENTICATE PLAIN\r\n");
                else
                    cap("END");
                break;
            case "LS":
                mHostCapabilities.addAll(caps);
                HashSet<String> wanted = new HashSet<>(mWantedCapabilities);
                wanted.retainAll(caps);

                if (TextUtils.isEmpty(mPass))
                    wanted.remove("sasl");

                if (wanted.isEmpty()) {
                    cap("END");
                } else {
                    StringBundler requesting = new StringBundler();

                    for (String s : wanted)
                        requesting.append(s).append(" ");

                    cap("REQ", requesting.toString());
                }
            }
        }
    });
    on(ERR_NICKNAMEINUSE, new Callback() {
        private int mTries;

        @Override
        public void performAction(Event event) {
            if (mState == State.CONNECTED && mAutoNickChange)
                nick(mWantedNick + (++mTries));
        }
    });
    on(JOIN, event -> {
        Message message = (Message) event.data;
        User user = mUsers.get(message.nick);

        if (mUser == null)
            user = new User(message.nick, message.user, message.host);

        if (mCapabilities.contains("extended-join")) {
            user.setAccount(message.params.get(1));
            user.setReal(message.params.get(2));
        }

        String channel = message.params.get(0);
    });
    on(MODE, event -> {
        Message message = (Message) event.data;
        String target = message.params.get(0);
        String specs = message.params.get(1);

        // Ci interessa solo la nostra user mode
        if (target.equals(mNick)) {
            char mode;
            boolean value = false;

            for (int i = 0; i < specs.length(); i++) {
                mode = specs.charAt(i);

                //@formatter:off
                if (mode == '+')
                    value = true;
                else if (mode == '-')
                    value = false;
                else if (mode != ' ')
                    mUserMode.put(mode, value);
                //@formatter:on
            }
        }
    });
    on(NICK, event -> {
        Message message = (Message) event.data;

        if (TextUtils.compareIgnoreCase(mNick, message.nick, mCaseMapping) == 0)
            mNick = message.params.get(0);
    });
    on(PING, event -> {
        Message message = (Message) event.data;
        pong(message.params.get(0));
    });
    on(RPL_ISUPPORT, event -> {
        Message message = (Message) event.data;
        Pattern pattern = Pattern.compile("Try server (.+), port (\\d+)");
        Matcher matcher = pattern.matcher(message.params.get(1));
        boolean isRplBounce = matcher.find();

        if (isRplBounce) {
            mIsupportCompilant = false;

            try {
                if (mAutoBounce) {
                    mHost = matcher.group(1);
                    mPort = Integer.parseInt(matcher.group(2));
                    emit(new Event(BOUNCE, this));
                    stop();
                    start();
                }
            } catch (Exception ignored) {
            }
        } else {
            mIsupportCompilant = true;
            pattern = Pattern.compile("([A-Z]+)(=(\\S+))?");

            for (int i = 1; i < message.params.size(); i++) {
                matcher = pattern.matcher(message.params.get(i));

                while (matcher.find()) {
                    String key = matcher.group(1);
                    String value = matcher.group(3);

                    try {
                        switch (key) {
                        case "CASEMAPPING":
                            if (value.equals("ascii"))
                                mCaseMapping = CaseMapping.ASCII;
                            else if (value.equals("strict-rfc1459"))
                                mCaseMapping = CaseMapping.STRICT_RFC1459;

                            break;
                        case "NETWORK":
                            mNetwork = value;
                            break;
                        }
                    } catch (Exception ignored) {
                    }
                }
            }
        }
    });
    on(RPL_MYINFO, event -> {
        Message message = (Message) event.data;
        mCurrentHost = message.params.get(1);
        mHostIrcdVersion = message.params.get(2);
        String userModes = message.params.get(3);
        String channelModes = message.params.get(4);

        for (int i = 0; i < userModes.length(); i++)
            mUserMode.put(userModes.charAt(i), false);

        for (int i = 0; i < channelModes.length(); i++)
            mAvailChannelModes.add(channelModes.charAt(i));

        mState = State.REGISTERED;
        emit(new Event(REGISTER, this));
    });
    on(RPL_SASLSUCCESS, event -> {
        if (mState == State.CONNECTED)
            cap("END");
    });
    on(RPL_WELCOME, (Event event) -> {
        Message message = (Message) event.data;
        mNick = message.params.get(0);
    });

    // Stato delle conversazioni
    on(JOIN, event -> {
        Message message = (Message) event.data;
        String target = message.params.get(0);
        Conversation conversation = mConversations.get(target);

        if (conversation == null) {
            conversation = new Conversation(target, mFactory);
            mConversations.put(target, conversation);
            emit(new Event(NEW_CONVERSATION, conversation));
        }

        conversation.addUser(message.nick);
    });
    on(new String[] { KICK, PART }, event -> {
        Message message = (Message) event.data;
        String conversationName = message.params.get(0);
        String target;

        if (message.command.equals(PART))
            target = message.nick;
        else
            target = message.params.get(1);

        if (TextUtils.compareIgnoreCase(target, mNick, mCaseMapping) == 0) {
            Conversation conversation = mConversations.remove(conversationName);
            emit(new Event(REMOVE_CONVERSATION, conversation));
        } else {
            Conversation conversation = mConversations.get(conversationName);

            if (conversation == null) {
                conversation = new Conversation(conversationName, mFactory);
                mConversations.put(conversationName, conversation);
                emit(new Event(NEW_CONVERSATION, conversation));
            }

            conversation.removeUser(target);
            conversation.putMessage(message);
        }
    });
    on(new String[] { JOIN, NOTICE, PRIVMSG }, event -> {
        Message message = (Message) event.data;
        String target = message.params.get(0);

        if (message.command.equals(PRIVMSG) || message.command.equals(NOTICE)) {
            if (mState == State.REGISTERED) {
                if (TextUtils.compareIgnoreCase(target, mNick, mCaseMapping) == 0)
                    target = message.nick;
            }
        }

        Conversation conversation = mConversations.get(target);

        if (conversation == null) {
            conversation = new Conversation(target, mFactory);
            mConversations.put(target, conversation);
            emit(new Event(NEW_CONVERSATION, conversation));
        }

        conversation.putMessage(message);
    });
    on(NICK, event -> {
        Message message = (Message) event.data;

        for (Conversation conversation : mConversations.values()) {
            if (conversation.contains(message.nick)) {
                conversation.removeUser(message.nick);
                conversation.addUser(message.params.get(0));
                conversation.putMessage(message);
            }
        }
    });
    on(new String[] { RPL_NAMREPLY, RPL_ENDOFNAMES }, new Callback() {
        StringBundler sb;

        @Override
        public void performAction(Event event) {
            Message message = (Message) event.data;

            switch (message.command) {
            case RPL_NAMREPLY:
                if (sb == null)
                    sb = new StringBundler();

                sb.append(" ");
                sb.append(message.params.get(3));
                break;
            case RPL_ENDOFNAMES:
                String target = message.params.get(1);
                Conversation conversation = mConversations.get(target);

                if (conversation == null) {
                    conversation = new Conversation(target, mFactory);
                    mConversations.put(target, conversation);
                    emit(new Event(NEW_CONVERSATION, conversation));
                }

                conversation.clearUsers();
                conversation.addUsers(Arrays.asList(sb.toString().split("\\s+")));
                sb = null;
            }
        }
    });
    on(RPL_WHOREPLY, event -> {
        Message message = (Message) event.data;

        String user = message.params.get(2);
        String host = message.params.get(3);
        String server = message.params.get(4);
        String nick = message.params.get(5);
        boolean away = message.params.get(6).equals("G");
    });
    on(QUIT, event -> {
        Message message = (Message) event.data;

        for (Conversation conversation : mConversations.values()) {
            if (conversation.contains(message.nick)) {
                conversation.removeUser(message.nick);
                conversation.putMessage(message);
            }
        }
    });
}