Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

In this page you can find the example usage for java.lang String compareToIgnoreCase.

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector getPropertyValues(Entity concept, String property_type, String property_name) {
    Vector v = new Vector();
    org.LexGrid.commonTypes.Property[] properties = null;
    if (property_type.compareToIgnoreCase("GENERIC") == 0) {
        properties = concept.getProperty();
    } else if (property_type.compareToIgnoreCase("PRESENTATION") == 0) {
        properties = concept.getPresentation();
    }// w w  w.  j a  va 2  s . com
    /*
     * else if (property_type.compareToIgnoreCase("INSTRUCTION")== 0) {
     * properties = concept.getInstruction(); }
     */
    else if (property_type.compareToIgnoreCase("COMMENT") == 0) {
        properties = concept.getComment();
    } else if (property_type.compareToIgnoreCase("DEFINITION") == 0) {
        properties = concept.getDefinition();
    } else {

        _logger.warn("WARNING: property_type not found -- " + property_type);

    }

    if (properties == null || properties.length == 0)
        return v;
    for (int i = 0; i < properties.length; i++) {
        Property p = (Property) properties[i];
        if (property_name.compareTo(p.getPropertyName()) == 0) {
            //String t = p.getValue().getContent();
            StringBuffer buf = new StringBuffer();
            buf.append(p.getValue().getContent());

            Source[] sources = p.getSource();
            if (sources != null && sources.length > 0) {
                Source src = sources[0];
                //t = t + "|" + src.getContent();
                buf.append("|" + src.getContent());

            } else {
                if (property_name.compareToIgnoreCase("definition") == 0) {
                    _logger.warn("*** WARNING: " + property_name + " with no source data: "
                            + p.getValue().getContent());
                    PropertyQualifier[] qualifiers = p.getPropertyQualifier();
                    if (qualifiers != null && qualifiers.length > 0) {
                        for (int j = 0; j < qualifiers.length; j++) {
                            PropertyQualifier q = qualifiers[j];
                            String qualifier_name = q.getPropertyQualifierName();
                            String qualifier_value = q.getValue().getContent();
                            // _logger.debug("\t*** qualifier_name: " +
                            // qualifier_name);
                            // _logger.debug("\t*** qualifier_value: "
                            // + qualifier_value);
                            if (qualifier_name.compareTo("source") == 0) {
                                //t = t + "|" + qualifier_value;
                                // _logger.debug("*** SOURCE: " +
                                // qualifier_value);
                                buf.append("|" + qualifier_value);
                                break;
                            }
                        }
                    } else {
                        _logger.warn("*** SOURCE NOT FOUND IN qualifiers neither. ");
                    }
                }
            }
            String t = buf.toString();
            v.add(t);
        }
    }
    return v;
}

From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java

/**
 * It runs on the workserver only//from   ww  w.  ja v a2  s.c om
 */
@Override
protected void handleUpdateDeployStatus(List editions) throws Exception {
    if (editions != null && editions.size() > 0) {
        //group editions by liveserver
        Map<LiveServerCredentials, List<EditionHbm>> editionsByLiveServers = new HashMap<LiveServerCredentials, List<EditionHbm>>();
        for (EditionHbm edition : (List<EditionHbm>) editions) {
            // edition is deployed - no new status expected
            if (edition.getEndActionTimestamp() != null) {
                continue;
            }
            SiteHbm site = getSiteHbmDao().load(edition.getSiteId());
            LiveServerCredentials credentials = new LiveServerCredentials();
            org.w3c.dom.Document doc = null;
            try {
                doc = XercesHelper.string2Dom(site.getConfigXML());
                credentials.liveServerIP = XercesHelper.getNodeValue(doc, "/config/default/liveServer/url");
                credentials.liveServerUserName = XercesHelper.getNodeValue(doc,
                        "/config/default/liveServer/username");
                credentials.liveServerPass = XercesHelper.getNodeValue(doc,
                        "/config/default/liveServer/password");
            } catch (Exception exe) {
                log.error("Error occured reading siteConfig: ", exe);
            } finally {
                doc = null;
            }
            if (!editionsByLiveServers.containsKey(credentials)) {
                List<EditionHbm> editionsOnLiveServer = new ArrayList<EditionHbm>();
                editionsOnLiveServer.add(edition);
                editionsByLiveServers.put(credentials, editionsOnLiveServer);
            } else {
                editionsByLiveServers.get(credentials).add(edition);
            }

        }

        for (Entry<LiveServerCredentials, List<EditionHbm>> editionsByLiveServer : editionsByLiveServers
                .entrySet()) {
            List<EditionHbm> editionStatusesRequest = editionsByLiveServer.getValue();
            List<EditionValue> editionStatusesResponse = getDeployStatusFromLiveServer(
                    editionsByLiveServer.getValue(), editionsByLiveServer.getKey());
            for (EditionHbm editionRequest : editionStatusesRequest) {
                boolean foundEditionInResponse = false;
                EditionValue editionValueRequest = editionRequest.getDao();
                for (EditionValue editionResponse : editionStatusesResponse) {
                    if (editionResponse.getWorkServerEditionId().equals(editionValueRequest.getEditionId())) {
                        //update deploy status
                        if (editionResponse.getDeployStatus() == null) {
                            editionRequest.setDeployStatus(new byte[0]);
                        } else {
                            editionRequest.setDeployStatus(editionResponse.getDeployStatus().getBytes());
                            String message = new String(editionResponse.getDeployStatus().getBytes());
                            if (message.compareToIgnoreCase("ImportSuccessful") == 0
                                    && editionRequest.getEndActionTimestamp() == null) {
                                createDeployFinishedTask(message, editionRequest);
                                setViewComponentsOnline(editionRequest);
                            }
                            if (message.contains("Exception")
                                    && editionRequest.getEndActionTimestamp() == null) {
                                createDeployFinishedTask(message, editionRequest);
                            }
                        }
                        editionRequest.setStartActionTimestamp(
                                editionResponse.getStartActionTimestamp() == null ? null
                                        : editionResponse.getStartActionTimestamp().getTime());
                        editionRequest
                                .setEndActionTimestamp(editionResponse.getEndActionTimestamp() == null ? null
                                        : editionResponse.getEndActionTimestamp().getTime());
                        getEditionHbmDao().update(editionRequest);
                        foundEditionInResponse = true;
                        break;
                    }
                }

                if (!foundEditionInResponse) {
                    //deploy finished
                    //getEditionHbmDao().remove(editionRequest.getEditionId());
                }
            }
        }

    }
}

From source file:org.muse.mneme.impl.SubmissionServiceImpl.java

/**
 * Get the submissions to the assignment made by all users.
 * /* ww  w . j  av  a  2s. c o m*/
 * @param assessment
 *        The assessment.
 * @param sort
 *        The sort.
 * @param question
 *        An optional question, to use for sort-by-score (the score would be for this question in the submission, not the overall).
 * @return A List<Submission> of the submissions for the assessment.
 */
protected List<SubmissionImpl> getAssessmentSubmissions(Assessment assessment,
        final FindAssessmentSubmissionsSort sort, final Question question) {
    // collect the submissions to this assessment
    List<SubmissionImpl> rv = this.storage.getAssessmentSubmissions(assessment);

    // get all possible users who can submit
    Set<String> userIds = this.securityService.getUsersIsAllowed(MnemeService.SUBMIT_PERMISSION,
            assessment.getContext());

    // filter out any userIds that are not currently defined
    List<User> users = this.userDirectoryService.getUsers(userIds);
    userIds.clear();
    for (User user : users) {
        userIds.add(user.getId());
    }

    // if any user is not represented in the submissions we found, add an empty submission
    for (String userId : userIds) {
        boolean found = false;
        for (Submission s : rv) {
            if (s.getUserId().equals(userId)) {
                found = true;
                break;
            }
        }

        if (!found) {
            SubmissionImpl s = this.getPhantomSubmission(userId, assessment);
            rv.add(s);
        }
    }

    // filter out any submissions found that are not for one of the users in the userIds list (they may have lost permission)
    for (Iterator i = rv.iterator(); i.hasNext();) {
        SubmissionImpl submission = (SubmissionImpl) i.next();

        if (!userIds.contains(submission.getUserId())) {
            i.remove();
        }
    }

    // sort - secondary sort of user name, or if primary is title, on submit date
    Collections.sort(rv, new Comparator() {
        public int compare(Object arg0, Object arg1) {
            int rv = 0;
            FindAssessmentSubmissionsSort secondary = null;
            switch (sort) {
            case userName_a:
            case userName_d:
            case status_a:
            case status_d: {
                String id0 = ((Submission) arg0).getUserId();
                try {
                    User u = userDirectoryService.getUser(id0);
                    id0 = u.getSortName();
                } catch (UserNotDefinedException e) {
                }

                String id1 = ((Submission) arg1).getUserId();
                try {
                    User u = userDirectoryService.getUser(id1);
                    id1 = u.getSortName();
                } catch (UserNotDefinedException e) {
                }

                rv = id0.compareToIgnoreCase(id1);
                secondary = FindAssessmentSubmissionsSort.sdate_a;
                break;
            }
            case final_a:
            case final_d: {
                Float final0 = null;
                Float final1 = null;
                if (question != null) {
                    Answer a0 = ((Submission) arg0).getAnswer(question);
                    Answer a1 = ((Submission) arg1).getAnswer(question);
                    final0 = ((a0 == null) ? Float.valueOf(0f) : a0.getTotalScore());
                    final1 = ((a1 == null) ? Float.valueOf(0f) : a1.getTotalScore());
                } else {
                    final0 = ((Submission) arg0).getTotalScore();
                    final1 = ((Submission) arg1).getTotalScore();
                }

                // null sorts small
                if ((final0 == null) && (final1 == null)) {
                    rv = 0;
                } else if (final0 == null) {
                    rv = -1;
                } else if (final1 == null) {
                    rv = 1;
                } else {
                    rv = final0.compareTo(final1);
                }
                secondary = FindAssessmentSubmissionsSort.userName_a;
                break;
            }
            case sdate_a:
            case sdate_d: {
                Date date0 = ((Submission) arg0).getSubmittedDate();
                Date date1 = ((Submission) arg1).getSubmittedDate();
                if ((date0 == null) && (date1 == null)) {
                    rv = 0;
                } else if (date0 == null) {
                    rv = -1;
                } else if (date1 == null) {
                    rv = 1;
                } else {
                    rv = ((Submission) arg0).getSubmittedDate()
                            .compareTo(((Submission) arg1).getSubmittedDate());
                }

                secondary = null;
                break;
            }
            }

            // secondary sort
            FindAssessmentSubmissionsSort third = null;
            if ((rv == 0) && (secondary != null)) {
                switch (secondary) {
                case userName_a:
                case userName_d: {
                    String id0 = ((Submission) arg0).getUserId();
                    try {
                        User u = userDirectoryService.getUser(id0);
                        id0 = u.getSortName();
                    } catch (UserNotDefinedException e) {
                    }

                    String id1 = ((Submission) arg1).getUserId();
                    try {
                        User u = userDirectoryService.getUser(id1);
                        id1 = u.getSortName();
                    } catch (UserNotDefinedException e) {
                    }

                    rv = id0.compareToIgnoreCase(id1);
                    third = FindAssessmentSubmissionsSort.sdate_a;
                    break;
                }

                case sdate_a:
                case sdate_d: {
                    Date date0 = ((Submission) arg0).getSubmittedDate();
                    Date date1 = ((Submission) arg1).getSubmittedDate();
                    if ((date0 == null) && (date1 == null)) {
                        rv = 0;
                    } else if (date0 == null) {
                        rv = -1;
                    } else if (date1 == null) {
                        rv = 1;
                    } else {
                        rv = ((Submission) arg0).getSubmittedDate()
                                .compareTo(((Submission) arg1).getSubmittedDate());
                    }
                    break;
                }
                }
            }

            // third sort
            if ((rv == 0) && (third != null)) {
                switch (third) {
                case sdate_a:
                case sdate_d: {
                    Date date0 = ((Submission) arg0).getSubmittedDate();
                    Date date1 = ((Submission) arg1).getSubmittedDate();
                    if ((date0 == null) && (date1 == null)) {
                        rv = 0;
                    } else if (date0 == null) {
                        rv = -1;
                    } else if (date1 == null) {
                        rv = 1;
                    } else {
                        rv = ((Submission) arg0).getSubmittedDate()
                                .compareTo(((Submission) arg1).getSubmittedDate());
                    }
                    break;
                }
                }
            }

            return rv;
        }
    });

    // reverse for descending (except for status)
    switch (sort) {
    case final_d:
    case userName_d:
    case sdate_d: {
        Collections.reverse(rv);
    }
    }

    return rv;
}

From source file:gov.nih.nci.evs.browser.utils.SearchUtils.java

private static CodedNodeSet matchConceptCode_CNS(String scheme, String version, String matchText, String source,
        String matchAlgorithm) throws Exception {

    ResolvedConceptReferencesIterator iterator = null;

    LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService();
    CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
    versionOrTag.setVersion(version);/*  www .  ja  v  a 2  s. c  o m*/

    if (lbSvc == null) {
        _logger.warn("lbSvc = null");
        return null;
    }

    LocalNameList contextList = null;
    NameAndValueList qualifierList = null;

    Vector<String> v = null;
    String code = matchText;
    String sourceAbbr = source;
    CodedNodeSet cns = null;

    if (code != null && code.compareTo("") != 0) {
        qualifierList = new NameAndValueList();
        NameAndValue nv = new NameAndValue();
        nv.setName("source-code");
        nv.setContent(code);
        qualifierList.addNameAndValue(nv);
    }

    LocalNameList propertyLnL = null;
    // sourceLnL
    Vector<String> w2 = new Vector<String>();
    w2.add(sourceAbbr);
    LocalNameList sourceLnL = vector2LocalNameList(w2);
    if (sourceAbbr != null && (sourceAbbr.compareTo("*") == 0 || sourceAbbr.compareToIgnoreCase("ALL") == 0)) {
        sourceLnL = null;
    }

    SortOptionList sortCriteria = null;// Constructors.createSortOptionList(new
                                       // String[]{"matchToQuery", "code"});
    try {
        //CodedNodeSet cns = lbSvc.getCodingSchemeConcepts(scheme, version);

        cns = getNodeSet(lbSvc, scheme, versionOrTag);

        if (cns == null) {
            _logger.warn("getNodeSet returns null");
            return null;
        }
        CodedNodeSet.PropertyType[] types = new PropertyType[] { PropertyType.PRESENTATION };
        cns = cns.restrictToProperties(propertyLnL, types, sourceLnL, contextList, qualifierList);

        if (cns != null) {
            //boolean activeOnly = false;
            //cns = restrictToActiveStatus(cns, activeOnly);

            try {
                iterator = cns.resolve(sortCriteria, null, null);// ConvenienceMethods.createLocalNameList(getPropertyForCodingScheme(cs)),null);
            } catch (Exception ex) {

            }
        }

    } catch (Exception e) {
        //return null;
        //e.printStackTrace();
    }

    if (iterator == null || iterator.numberRemaining() <= 0) {
        /*
                             _logger
                                .warn("matchConceptCode_CNS scheme: " + scheme + "   version: " + version + "   algorithm: " + matchAlgorithm + " -- no source code match " + matchText);
                
                            _logger
                                .warn("matchConceptCode_CNS calling concept code match scheme: " + scheme + "   version: " + version + " " + matchText);
                
                
        */

        return matchConceptCode_CNS(scheme, version, matchText);
    }
    return cns;
}

From source file:de.escidoc.core.test.EscidocRestSoapTestBase.java

/**
 * Asserts if the elements requested by the xPath are sorted correctly.
 *
 * @param xml               xml.//from www .j a v  a2s. co  m
 * @param xpath             xpath-expression
 * @param prerequisiteXpath prerequisite xpath-expression
 * @param isAscending       if sort-order is ascending
 * @param getIdAttribute    if true: get the id-attribute of the element dependent of the transport
 * @throws Exception e
 */
public void assertSorted(final String xml, final String xpath, final String prerequisiteXpath,
        final boolean isAscending, final boolean getIdAttribute) throws Exception {

    String replacedXpath = xpath;
    if (getIdAttribute) {
        if (getTransport() == Constants.TRANSPORT_REST) {
            replacedXpath += PART_XLINK_HREF;
        } else {
            replacedXpath += PART_OBJID;
        }
    }
    NodeList nodes = selectNodeList(EscidocRestSoapTestBase.getDocument(xml), replacedXpath);
    String lastValue = "";
    if (!isAscending) {
        lastValue = "ZZZZZZZZZZZZZZZZZZZZZ";
    }
    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (prerequisiteXpath != null) {
            NodeList prerequisite = XPathAPI.selectNodeList(node, prerequisiteXpath);
            if (prerequisite == null || prerequisite.getLength() == 0) {
                continue;
            }
        }
        String nodeValue = node.getNodeValue();
        if (nodeValue == null) {
            fail("nodeValue for xpath " + replacedXpath + " is null");
        }
        if (getIdAttribute && getTransport() == Constants.TRANSPORT_REST) {
            nodeValue = getObjidFromHref(nodeValue);
        }
        if (isAscending) {
            if (nodeValue.compareToIgnoreCase(lastValue) < 0) {
                fail(nodeValue + " is not sorted correctly, should be >= " + lastValue);
            } else if (nodeValue.compareTo(lastValue) > 0) {
                lastValue = nodeValue;
            }
        } else {
            if (nodeValue.compareToIgnoreCase(lastValue) > 0) {
                fail(nodeValue + " is not sorted correctly, should be <= " + lastValue);
            } else if (nodeValue.compareTo(lastValue) < 0) {
                lastValue = nodeValue;
            }
        }
    }
}

From source file:org.silverpeas.components.kmelia.control.KmeliaSessionController.java

private List<KmeliaPublication> sortByDescription(List<KmeliaPublication> publications) {
    KmeliaPublication[] pubs = publications.toArray(new KmeliaPublication[publications.size()]);
    for (int i = pubs.length; --i >= 0;) {
        boolean swapped = false;
        for (int j = 0; j < i; j++) {
            String p1 = pubs[j].getDetail().getDescription(getCurrentLanguage());
            if (p1 == null) {
                p1 = "";
            }/*  ww  w . j  a v a  2 s.co m*/
            String p2 = pubs[j + 1].getDetail().getDescription(getCurrentLanguage());
            if (p2 == null) {
                p2 = "";
            }
            if (p1.compareToIgnoreCase(p2) > 0) {
                KmeliaPublication pub = pubs[j];
                pubs[j] = pubs[j + 1];
                pubs[j + 1] = pub;
                swapped = true;
            }
        }
        if (!swapped) {
            break;
        }
    }
    return Arrays.asList(pubs);
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static HashMap getAssociatedConceptsHashMap(String codingSchemeName, String vers, String code,
        String source, int resolveCodedEntryDepth) {
    HashMap hmap = new HashMap();
    try {/*  w  w w.j a  v a  2s. c  om*/
        LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService();
        if (lbSvc == null)
            return null;
        LexBIGServiceConvenienceMethods lbscm = (LexBIGServiceConvenienceMethods) lbSvc
                .getGenericExtension("LexBIGServiceConvenienceMethods");
        lbscm.setLexBIGService(lbSvc);
        /*
                    if (lbSvc == null) {
        _logger.warn("lbSvc == null???");
        return hmap;
                    }
        */
        CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
        if (vers != null)
            versionOrTag.setVersion(vers);
        CodedNodeGraph cng = lbSvc.getNodeGraph(codingSchemeName, null, null);

        if (source != null) {
            cng = cng.restrictToAssociations(Constructors.createNameAndValueList(META_ASSOCIATIONS),
                    Constructors.createNameAndValueList("source", source));
        }

        CodedNodeSet.PropertyType[] propertyTypes = new CodedNodeSet.PropertyType[1];
        propertyTypes[0] = PropertyType.PRESENTATION;

        ResolvedConceptReferenceList matches = cng.resolveAsList(
                Constructors.createConceptReference(code, codingSchemeName), true, false,
                resolveCodedEntryDepth, 1, null, propertyTypes, null, -1);

        if (matches.getResolvedConceptReferenceCount() > 0) {
            Enumeration<ResolvedConceptReference> refEnum = (Enumeration<ResolvedConceptReference>) matches
                    .enumerateResolvedConceptReference();

            while (refEnum.hasMoreElements()) {
                ResolvedConceptReference ref = refEnum.nextElement();
                AssociationList sourceof = ref.getSourceOf();
                if (sourceof != null) {
                    Association[] associations = sourceof.getAssociation();
                    if (associations != null) {
                        for (int i = 0; i < associations.length; i++) {
                            Association assoc = associations[i];
                            String associationName = lbscm.getAssociationNameFromAssociationCode(
                                    codingSchemeName, versionOrTag, assoc.getAssociationName());

                            Vector v = new Vector();
                            AssociatedConcept[] acl = assoc.getAssociatedConcepts().getAssociatedConcept();
                            for (int j = 0; j < acl.length; j++) {
                                AssociatedConcept ac = acl[j];
                                if (associationName.compareToIgnoreCase("equivalentClass") != 0) {
                                    v.add(ac);
                                }
                            }

                            hmap.put(associationName, v);
                        }
                    }
                }
            }
        }

        cng = lbSvc.getNodeGraph(codingSchemeName, null, null);

        if (source != null) {
            cng = cng.restrictToAssociations(
                    Constructors
                            .createNameAndValueList(new MetaTreeUtils(lbSvc).getHierAssociationToChildNodes()),
                    Constructors.createNameAndValueList("source", source));
        } else {
            cng = cng.restrictToAssociations(Constructors
                    .createNameAndValueList(new MetaTreeUtils(lbSvc).getHierAssociationToChildNodes()), null);
        }

        matches = cng.resolveAsList(Constructors.createConceptReference(code, codingSchemeName), false, true,
                resolveCodedEntryDepth, 1, null, propertyTypes, null, -1);

        if (matches.getResolvedConceptReferenceCount() > 0) {
            Enumeration<ResolvedConceptReference> refEnum = (Enumeration<ResolvedConceptReference>) matches
                    .enumerateResolvedConceptReference();

            while (refEnum.hasMoreElements()) {
                ResolvedConceptReference ref = refEnum.nextElement();
                AssociationList sourceof = ref.getTargetOf();
                if (sourceof != null) {
                    Association[] associations = sourceof.getAssociation();
                    if (associations != null) {
                        for (int i = 0; i < associations.length; i++) {
                            Association assoc = associations[i];
                            String associationName = lbscm.getAssociationNameFromAssociationCode(
                                    codingSchemeName, versionOrTag, assoc.getAssociationName());
                            Vector v = new Vector();
                            AssociatedConcept[] acl = assoc.getAssociatedConcepts().getAssociatedConcept();
                            for (int j = 0; j < acl.length; j++) {
                                AssociatedConcept ac = acl[j];
                                if (associationName.compareToIgnoreCase("equivalentClass") != 0) {
                                    v.add(ac);
                                }
                            }
                            if (associationName.compareTo("CHD") == 0) {
                                associationName = "PAR";
                            }
                            hmap.put(associationName, v);
                        }
                    }
                }
            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return hmap;
}

From source file:com.dell.asm.asmcore.asmmanager.app.rest.DeploymentService.java

/**
 * Used to transfer pool name in exception message.
 * @param sPoolID//from w w  w  .  ja v  a2 s  .co m
 * @param deviceGroups
 * @return
 */
private String getPoolName(String sPoolID, List<DeviceGroupEntity> deviceGroups) {
    if (sPoolID == null) {
        return "No pool specified";
    } else if (sPoolID
            .compareToIgnoreCase(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_POOL_GLOBAL_ID) == 0) {
        return ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_POOL_GLOBAL_NAME;
    } else {
        if (deviceGroups != null) {
            for (int i = 0; i < deviceGroups.size(); i++) {
                String sID = "" + deviceGroups.get(i).getSeqId();
                if (sID.compareToIgnoreCase(sPoolID) == 0) {
                    return deviceGroups.get(i).getName();
                }
            }
        }
    }

    logger.error("getPoolName: no pool found with ID" + sPoolID);
    return "";

}

From source file:com.stratelia.webactiv.kmelia.control.KmeliaSessionController.java

private List<KmeliaPublication> sortByDescription(List<KmeliaPublication> publications) {
    KmeliaPublication[] pubs = publications.toArray(new KmeliaPublication[publications.size()]);
    for (int i = pubs.length; --i >= 0;) {
        boolean swapped = false;
        for (int j = 0; j < i; j++) {
            String p1 = pubs[j].getDetail().getDescription(getCurrentLanguage());
            if (p1 == null) {
                p1 = "";
            }/*  www  .  j  a v  a2s  .c  o m*/
            String p2 = pubs[j + 1].getDetail().getDescription(getCurrentLanguage());
            if (p2 == null) {
                p2 = "";
            }
            if (p1.compareToIgnoreCase(p2) > 0) {
                KmeliaPublication T = pubs[j];
                pubs[j] = pubs[j + 1];
                pubs[j + 1] = T;
                swapped = true;
            }
        }
        if (!swapped) {
            break;
        }
    }
    return Arrays.asList(pubs);
}

From source file:org.etudes.mneme.impl.SubmissionServiceImpl.java

/**
 * {@inheritDoc}//from   w ww.  j a va  2  s . c o  m
 */
public List<Question> findPartQuestions(Part part) {
    if (M_log.isDebugEnabled())
        M_log.debug("findPartQuestions: " + part.getId());

    List<String> qids = this.storage.findPartQuestions(part);
    List<Question> rv = new ArrayList<Question>();

    boolean fromDraw = false;
    for (String qid : qids) {
        // get the question from the part so the contexts are all set
        QuestionImpl q = (QuestionImpl) part.getQuestion(qid);
        if (q != null) {
            rv.add(q);
            if ((q.getPartDetail() != null) && (q.getPartDetail() instanceof PoolDraw)) {
                fromDraw = true;
            }
        }
    }

    // for random order parts or parts that have some draws, sort the question alpha by description
    if (part.getRandomize() || fromDraw) {
        Collections.sort(rv, new Comparator<Question>() {
            public int compare(Question arg0, Question arg1) {
                String s0 = StringUtil.trimToZero(arg0.getDescription());
                String s1 = StringUtil.trimToZero(arg1.getDescription());
                int rv = s0.compareToIgnoreCase(s1);
                return rv;
            }
        });
    }

    // otherwise sort by presentation order
    else {
        Collections.sort(rv, new Comparator<Question>() {
            public int compare(Question arg0, Question arg1) {
                return arg0.getAssessmentOrdering().getPosition()
                        .compareTo(arg1.getAssessmentOrdering().getPosition());
            }
        });
    }

    return rv;
}