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:com.krawler.workflow.bizservice.WorkflowServiceImpl.java

private void getNodeInfo(Node node, ObjectInfo obj) {
    int a;//from  w w  w. j av  a 2s. c o  m
    String name = "";
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap attributes = node.getAttributes();
        for (a = 0; a < attributes.getLength(); a++) {
            Node attribute = attributes.item(a);
            name = attribute.getNodeName();
            if (name.compareToIgnoreCase("Id") == 0) {
                obj.objId = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("Name") == 0) {
                obj.name = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("Parent") == 0) {
                obj.parentId = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("ParentPool") == 0) {
                obj.domEl = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("refId") == 0) {
                obj.refId = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("hasStart") == 0) {
                obj.hasStart = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("hasEnd") == 0) {
                obj.hasEnd = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("startRefId") == 0) {
                obj.startRefId = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("endRefId") == 0) {
                obj.endRefId = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("derivationRule") == 0) {
                obj.derivationRule = attribute.getNodeValue();
            } else if (name.compareToIgnoreCase("domEl") == 0) {
                obj.domEl = attribute.getNodeValue();
            }

        }
    }
}

From source file:sim.app.sugarscape.Sugarscape.java

/***************************************************************************
* Set the model parameters per whatever is supplied in a .conf file.
* the last value in each statement is the default value if no parameter is 
* identified./* w  w  w .  j  a v  a  2 s.  c o  m*/
* 
* Although this is a nice way to do it, one still has to 1) specify the
* primitive type and 2) default value for *each* parameter.  An alternative
* is to use java.util.Properties and the approach in MASON web tutorial #2:
* http://cs.gmu.edu/~eclab/projects/mason/extensions/webtutorial2/index.html
* 
* I decided not to use because it would involve a creating a bunch of get
* and set methods, and that would result in approximately the same amount of
* code as far as I can tell. Your mileage may vary.
***************************************************************************/
public void loadParameters() {
    if (paramDB == null)
        return;
    /***********************************************************************
    * Environment parameters
    ***********************************************************************/
    season_rate = paramDB.getIntWithDefault(new Parameter("season_rate"), null, VIRT_INFINITY);
    //System.out.println(season_rate + " =season_rate");
    summer_grow = paramDB.getIntWithDefault(new Parameter("summer_rate"), null, 1);
    winter_grow = paramDB.getIntWithDefault(new Parameter("winter_rate"), null, 1);

    pollution_harvest = paramDB.getIntWithDefault(new Parameter("pollution_harvest"), null, 0);
    pollution_start = paramDB.getIntWithDefault(new Parameter("pollution_start"), null, 0);
    pollution_diffuse_start = paramDB.getIntWithDefault(new Parameter("pollution_diffuse_start"), null, 0);
    pollution_enabled = paramDB.getBoolean(new Parameter("pollution_enabled"), null, false);
    pollution_harvest = paramDB.getIntWithDefault(new Parameter("pollution_harvest"), null, 0);

    rules_seq_environment = paramDB.getStringWithDefault(new Parameter("rules_sequence_environment"), null,
            null);

    String terrain_type = paramDB.getStringWithDefault(new Parameter("terrain_type"), null, "toroidal");
    if (terrain_type.compareToIgnoreCase("toroid") == 0) {
        toroidal = true;
    }

    terrain_files[0] = paramDB.getStringWithDefault(new Parameter("sugar_terrain"), null, "conf/sugar.txt");
    terrain_files[1] = paramDB.getStringWithDefault(new Parameter("spice_terrain"), null, "conf/spice.txt");

    gridWidth = paramDB.getIntWithDefault(new Parameter("grid_width"), null, 50);
    gridHeight = paramDB.getIntWithDefault(new Parameter("grid_height"), null, 50);

    resources = paramDB.getIntWithDefault(new Parameter("resources"), null, 1);

    /********************************************************************************************
    * Agent parameters
    *********************************************************************************************/
    numAgents = paramDB.getIntWithDefault(new Parameter("num_agents"), null, 50);
    agent_replacement = paramDB.getBoolean(new Parameter("replacement"), null, false);
    agents_file = paramDB.getStringWithDefault(new Parameter("agents_file"), null, null);

    vision_min = paramDB.getIntWithDefault(new Parameter("vision_min"), null, 2);
    vision_max = paramDB.getIntWithDefault(new Parameter("vision_max"), null, 1);

    repl_min = paramDB.getIntWithDefault(new Parameter("min_age"), null, 60);
    repl_max = paramDB.getIntWithDefault(new Parameter("max_age"), null, 100);

    metabolic_sugar = paramDB.getIntWithDefault(new Parameter("metabolism_sugar"), null, 1);
    metabolic_spice = paramDB.getIntWithDefault(new Parameter("metabolism_spice"), null, 1);

    reproduction = paramDB.getBoolean(new Parameter("reproduction"), null, false);
    reproduction_min = paramDB.getIntWithDefault(new Parameter("reproduction_min"), null, -1);
    female_fertility_start_min = paramDB.getIntWithDefault(new Parameter("female_fertility_start_min"), null,
            12);
    female_fertility_start_max = paramDB.getIntWithDefault(new Parameter("female_fertility_start_max"), null,
            15);
    female_fertility_end_min = paramDB.getIntWithDefault(new Parameter("female_fertility_end_min"), null, 40);
    female_fertility_end_max = paramDB.getIntWithDefault(new Parameter("female_fertility_end_max"), null, 50);

    male_fertility_start_min = paramDB.getIntWithDefault(new Parameter("male_fertility_start_min"), null, 12);
    male_fertility_start_max = paramDB.getIntWithDefault(new Parameter("male_fertility_start_max"), null, 15);
    male_fertility_end_min = paramDB.getIntWithDefault(new Parameter("male_fertility_end_min"), null, 50);
    male_fertility_end_max = paramDB.getIntWithDefault(new Parameter("male_fertility_end_max"), null, 60);

    culture_tags = paramDB.getIntWithDefault(new Parameter("culture_tags"), null, 3);

    initial_endowment_min_sugar = paramDB.getIntWithDefault(new Parameter("initial_endowment_min_sugar"), null,
            50);
    initial_endowment_min_spice = paramDB.getIntWithDefault(new Parameter("initial_endowment_min_spice"), null,
            50);
    initial_endowment_max_sugar = paramDB.getIntWithDefault(new Parameter("initial_endowment_max_sugar"), null,
            100);
    initial_endowment_max_spice = paramDB.getIntWithDefault(new Parameter("initial_endowment_max_spice"), null,
            100);

    rules_seq_agent = paramDB.getStringWithDefault(new Parameter("rules_sequence_agents"), null, null);

    /********************************************************************************************
    * Statistics, graphing, and logging params, and other housekeeping
    *********************************************************************************************/
    debug = paramDB.getBoolean(new Parameter("debug"), null, false);
    stats_rate = paramDB.getIntWithDefault(new Parameter("stats_rate"), null, 1);
    stats_start = paramDB.getIntWithDefault(new Parameter("stats_start"), null, 1);
    String statistics_output = paramDB.getStringWithDefault(new Parameter("stats_out"), null, "print");
    stats_out = PRINT;
    if (statistics_output.compareToIgnoreCase("file") == 0) {
        stats_out = FILE;
    }
    chart_start = paramDB.getIntWithDefault(new Parameter("chart_start"), null, 1);
    chart_display = paramDB.getBoolean(new Parameter("chart_display"), null, false);
    chart_rate = paramDB.getIntWithDefault(new Parameter("chart_rate"), null, 1);

    population_chart_on = paramDB.getBoolean(new Parameter("population_chart"), null, false);
    gini_chart_on = paramDB.getBoolean(new Parameter("gini_chart"), null, false);
    wealth_chart_on = paramDB.getBoolean(new Parameter("wealth_chart"), null, false);
    age_chart_on = paramDB.getBoolean(new Parameter("age_chart"), null, false);
    evolution_chart_on = paramDB.getBoolean(new Parameter("evolution_chart"), null, false);
    culture_tag_chart_on = paramDB.getBoolean(new Parameter("culture_tag_chart"), null, false);
    trade_chart_on = paramDB.getBoolean(new Parameter("trade_chart"), null, false);
    print_trades = paramDB.getBoolean(new Parameter("print_trades"), null, false);
    trades_freq = paramDB.getIntWithDefault(new Parameter("print_trades_freq"), null, 500);
    log_frequency = paramDB.getIntWithDefault(new Parameter("log_frequency"), null, 1);

    print_metabolism_bins = paramDB.getBoolean(new Parameter("print_metabolism_bins"), null, false);
    print_culture = paramDB.getBoolean(new Parameter("print_culture"), null, false);
    metabolism_bins_freq = VIRT_INFINITY;

    /* Uncomment the line below to see the actual parameter values. */
    Enumeration e = paramDB.keys();
    while (e.hasMoreElements()) {
        String s = (String) e.nextElement();
        //System.out.println(paramDB.getProperty(s) + "\t" + s);
    }
}

From source file:org.iexhub.connectors.PDQQueryManager.java

/**
 * @param adminGender//from  ww w .  java 2  s.c o m
 * @param gender
 * @return
 */
private PRPAMT201306UV02LivingSubjectAdministrativeGender setLivingSubjectAdministrativeGender(
        PRPAMT201306UV02LivingSubjectAdministrativeGender adminGender, String gender) {
    CE genderValue = new CE();
    genderValue.setCode(
            ((gender.compareToIgnoreCase("f") == 0) || (gender.compareToIgnoreCase("female") == 0)) ? "F"
                    : (((gender.compareToIgnoreCase("m") == 0) || (gender.compareToIgnoreCase("male") == 0))
                            ? "M"
                            : ""));
    adminGender.getValue().add(genderValue);
    ST genderSemanticsText = new ST();
    genderSemanticsText.getContent().add("LivingSubject.administrativeGender");
    adminGender.setSemanticsText(genderSemanticsText);
    return adminGender;
}

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

public ResolvedConceptReferencesIteratorWrapper searchByName(Vector schemes, Vector versions, String matchText,
        String matchAlgorithm, int maxToReturn) {

    if (matchText == null || matchText.trim().length() == 0)
        return null;

    matchText = matchText.trim();//from w  w  w . j a v  a2  s .c  o  m
    _logger.debug("searchByName ... " + matchText);

    if (matchAlgorithm.compareToIgnoreCase("contains") == 0) {
        matchAlgorithm = new SearchUtils().findBestContainsAlgorithm(matchText);
    }

    LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
    MappingExtension mappingExtension = null;
    try {
        mappingExtension = (MappingExtension) lbSvc.getGenericExtension("MappingExtension");
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }

    ResolvedConceptReferencesIterator itr = null;
    int lcv = 0;
    String scheme = null;
    String version = null;
    int numberRemaining = -1;
    while (itr == null && numberRemaining == -1 && lcv < schemes.size()) {
        scheme = (String) schemes.elementAt(lcv);
        version = (String) versions.elementAt(lcv);
        String containerName = getMappingRelationsContainerName(scheme, version);
        if (containerName != null) {
            try {

                CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
                if (version != null) {
                    versionOrTag.setVersion(version);
                }
                Mapping mapping = mappingExtension.getMapping(scheme, versionOrTag, containerName);

                if (mapping != null) {
                    mapping = mapping.restrictToMatchingDesignations(matchText, SearchDesignationOption.ALL,
                            matchAlgorithm, null, SearchContext.SOURCE_OR_TARGET_CODES);

                    //Finally, resolve the Mapping.
                    itr = mapping.resolveMapping();
                    try {
                        numberRemaining = itr.numberRemaining();
                        //System.out.println("Number of matches: " + numberRemaining);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        lcv++;
    }
    if (itr != null) {
        ResolvedConceptReferencesIteratorWrapper wrapper = new ResolvedConceptReferencesIteratorWrapper(itr);
        wrapper.setCodingSchemeName(scheme);
        wrapper.setCodingSchemeVersion(version);
        return wrapper;
    }
    return null;
}

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

public ResolvedConceptReferencesIteratorWrapper searchByProperties(Vector schemes, Vector versions,
        String matchText, String matchAlgorithm, int maxToReturn) {

    if (matchText == null || matchText.trim().length() == 0)
        return null;

    matchText = matchText.trim();//w  w w  .j a  va 2 s  . c om
    _logger.debug("searchByName ... " + matchText);

    if (matchAlgorithm.compareToIgnoreCase("contains") == 0) {
        matchAlgorithm = new SearchUtils().findBestContainsAlgorithm(matchText);
    }

    CodedNodeSet.PropertyType[] propertyTypes = null;
    LocalNameList propertyNames = null;
    LocalNameList sourceList = null;
    propertyTypes = getAllNonPresentationPropertyTypes();

    LocalNameList contextList = null;
    NameAndValueList qualifierList = null;
    String language = null;
    // to be modified
    //SearchContext searchContext = SearchContext.SOURCE_OR_TARGET_CODES
    ;
    LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
    MappingExtension mappingExtension = null;
    try {
        mappingExtension = (MappingExtension) lbSvc.getGenericExtension("MappingExtension");
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }

    ResolvedConceptReferencesIterator itr = null;
    int lcv = 0;
    String scheme = null;
    String version = null;

    int numberRemaining = -1;
    while (itr == null && numberRemaining == -1 && lcv < schemes.size()) {

        scheme = (String) schemes.elementAt(lcv);
        version = (String) versions.elementAt(lcv);

        String containerName = getMappingRelationsContainerName(scheme, version);
        if (containerName != null) {
            try {

                CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
                if (version != null) {
                    versionOrTag.setVersion(version);
                }

                Mapping mapping = mappingExtension.getMapping(scheme, versionOrTag, containerName);

                if (mapping != null) {

                    mapping = mapping.restrictToMatchingProperties(propertyNames, propertyTypes, sourceList,
                            contextList, qualifierList, matchText, matchAlgorithm, null,
                            SearchContext.SOURCE_OR_TARGET_CODES);

                    //Finally, resolve the Mapping.
                    itr = mapping.resolveMapping();
                    try {
                        numberRemaining = itr.numberRemaining();
                        //System.out.println("Number of matches: " + numberRemaining);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
                //return null;
            }
        }
        lcv++;
    }
    if (itr != null) {
        ResolvedConceptReferencesIteratorWrapper wrapper = new ResolvedConceptReferencesIteratorWrapper(itr);
        wrapper.setCodingSchemeName(scheme);
        wrapper.setCodingSchemeVersion(version);
        return wrapper;
    }
    return null;
}

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

public ResolvedConceptReferencesIteratorWrapper searchByRelationships(Vector schemes, Vector versions,
        String matchText, String matchAlgorithm, int maxToReturn) {

    if (matchText == null || matchText.trim().length() == 0)
        return null;

    matchText = matchText.trim();/*from w ww.  ja v a2  s  .  co  m*/
    _logger.debug("searchByName ... " + matchText);

    if (matchAlgorithm.compareToIgnoreCase("contains") == 0) {
        matchAlgorithm = new SearchUtils().findBestContainsAlgorithm(matchText);
    }

    SearchDesignationOption option = SearchDesignationOption.ALL;
    String language = null;

    //CodedNodeSet.PropertyType[] propertyTypes = null;
    LocalNameList propertyNames = null;
    LocalNameList sourceList = null;
    //propertyTypes = getAllNonPresentationPropertyTypes();

    LocalNameList contextList = null;
    NameAndValueList qualifierList = null;

    LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
    MappingExtension mappingExtension = null;
    try {
        mappingExtension = (MappingExtension) lbSvc.getGenericExtension("MappingExtension");
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }

    ResolvedConceptReferencesIterator itr = null;
    int lcv = 0;
    String scheme = null;
    String version = null;

    int numberRemaining = -1;
    while (itr == null && numberRemaining == -1 && lcv < schemes.size()) {

        scheme = (String) schemes.elementAt(lcv);
        version = (String) versions.elementAt(lcv);

        String containerName = getMappingRelationsContainerName(scheme, version);
        if (containerName != null) {

            LocalNameList relationshipList = getSupportedAssociationNames(lbSvc, scheme, version,
                    containerName);

            try {

                CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
                if (version != null) {
                    versionOrTag.setVersion(version);
                }
                Mapping mapping = mappingExtension.getMapping(scheme, versionOrTag, containerName);

                if (mapping != null) {

                    mapping = mapping.restrictToRelationship(matchText, option, matchAlgorithm, language,
                            relationshipList);

                    //Finally, resolve the Mapping.
                    itr = mapping.resolveMapping();
                    try {
                        numberRemaining = itr.numberRemaining();
                        //System.out.println("Number of matches: " + numberRemaining);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
                //return null;
            }
        }
        lcv++;
    }
    if (itr != null) {
        ResolvedConceptReferencesIteratorWrapper wrapper = new ResolvedConceptReferencesIteratorWrapper(itr);
        wrapper.setCodingSchemeName(scheme);
        wrapper.setCodingSchemeVersion(version);
        return wrapper;
    }
    return null;
}

From source file:org.iexhub.services.GetPatientDataService.java

@GET
@Path("/ccd")
@Produces({ MediaType.APPLICATION_JSON })
public Response getCCD(@Context HttpHeaders headers) {
    log.info("Entered getPatientData service");

    boolean tls = false;
    tls = (IExHubConfig.getProperty("XdsBRegistryEndpointURI") == null) ? false
            : ((IExHubConfig.getProperty("XdsBRegistryEndpointURI").toLowerCase().contains("https") ? true
                    : false));//w  w  w. ja  v a2s  .  c o  m
    GetPatientDataService.testMode = IExHubConfig.getProperty("TestMode", GetPatientDataService.testMode);
    GetPatientDataService.testJSONDocumentPathname = IExHubConfig.getProperty("TestJSONDocumentPathname",
            GetPatientDataService.testJSONDocumentPathname);
    GetPatientDataService.cdaToJsonTransformXslt = IExHubConfig.getProperty("CDAToJSONTransformXSLT",
            GetPatientDataService.cdaToJsonTransformXslt);
    GetPatientDataService.iExHubDomainOid = IExHubConfig.getProperty("IExHubDomainOID",
            GetPatientDataService.iExHubDomainOid);
    GetPatientDataService.iExHubAssigningAuthority = IExHubConfig.getProperty("IExHubAssigningAuthority",
            GetPatientDataService.iExHubAssigningAuthority);
    GetPatientDataService.xdsBRepositoryUniqueId = IExHubConfig.getProperty("XdsBRepositoryUniqueId",
            GetPatientDataService.xdsBRepositoryUniqueId);

    String retVal = "";
    GetPatientDataResponse patientDataResponse = new GetPatientDataResponse();
    DocumentsResponseDto documentsResponseDto = new DocumentsResponseDto();
    List<PatientDocument> patientDocuments = new ArrayList<>();

    if (!testMode) {
        try {
            if (xdsB == null) {
                log.info("Instantiating XdsB connector...");
                xdsB = new XdsB(null, null, tls);
                log.info("XdsB connector successfully started");
            }
        } catch (Exception e) {
            log.error("Error encountered instantiating XdsB connector, " + e.getMessage());
            throw new UnexpectedServerException("Error - " + e.getMessage());
        }

        try {
            MultivaluedMap<String, String> headerParams = headers.getRequestHeaders();
            String ssoAuth = headerParams.getFirst("ssoauth");

            log.info("HTTP headers successfully retrieved");
            String[] splitPatientId = ssoAuth.split("&LastName=");
            String patientId = (splitPatientId[0].split("=").length == 2) ? splitPatientId[0].split("=")[1]
                    : null;

            String[] parts = splitPatientId[1].split("&");
            String lastName = (parts[0].length() > 0) ? parts[0] : null;
            String firstName = (parts[1].split("=").length == 2) ? parts[1].split("=")[1] : null;
            String middleName = (parts[2].split("=").length == 2) ? parts[2].split("=")[1] : null;
            String dateOfBirth = (parts[3].split("=").length == 2) ? parts[3].split("=")[1] : null;
            String gender = (parts[4].split("=").length == 2) ? parts[4].split("=")[1] : null;
            String motherMaidenName = (parts[5].split("=").length == 2) ? parts[5].split("=")[1] : null;
            String addressStreet = (parts[6].split("=").length == 2) ? parts[6].split("=")[1] : null;
            String addressCity = (parts[7].split("=").length == 2) ? parts[7].split("=")[1] : null;
            String addressState = (parts[8].split("=").length == 2) ? parts[8].split("=")[1] : null;
            String addressPostalCode = (parts[9].split("=").length == 2) ? parts[9].split("=")[1] : null;
            String otherIDsScopingOrganization = (parts[10].split("=").length == 2) ? parts[10].split("=")[1]
                    : null;
            String startDate = (parts[11].split("=").length == 2) ? parts[11].split("=")[1] : null;
            String endDate = (parts[12].split("=").length == 2) ? parts[12].split("=")[1] : null;

            log.info("HTTP headers successfully parsed, now calling XdsB registry...");

            // Determine if a complete patient ID (including OID and ISO specification) was provided.  If not, then append IExHubDomainOid and IExAssigningAuthority...
            if (!patientId.contains("^^^&")) {
                patientId = "'" + patientId + "^^^&" + GetPatientDataService.iExHubDomainOid + "&"
                        + GetPatientDataService.iExHubAssigningAuthority + "'";
            }

            AdhocQueryResponse registryResponse = xdsB.registryStoredQuery(patientId,
                    (startDate != null) ? DateFormat.getDateInstance().format(startDate) : null,
                    (endDate != null) ? DateFormat.getDateInstance().format(endDate) : null);

            log.info("Call to XdsB registry successful");

            // Determine if registry server returned any errors...
            if ((registryResponse.getRegistryErrorList() != null)
                    && (registryResponse.getRegistryErrorList().getRegistryError().length > 0)) {

                for (RegistryError_type0 error : registryResponse.getRegistryErrorList().getRegistryError()) {
                    StringBuilder errorText = new StringBuilder();
                    if (error.getErrorCode() != null) {
                        errorText.append("Error code=" + error.getErrorCode() + "\n");
                    }
                    if (error.getCodeContext() != null) {
                        errorText.append("Error code context=" + error.getCodeContext() + "\n");
                    }

                    // Error code location (i.e., stack trace) only to be logged to IExHub error file
                    patientDataResponse.getErrorMsgs().add(errorText.toString());

                    if (error.getLocation() != null) {
                        errorText.append("Error location=" + error.getLocation());
                    }
                    log.error(errorText.toString());
                }
            }

            // Try to retrieve documents...
            RegistryObjectListType registryObjectList = registryResponse.getRegistryObjectList();
            IdentifiableType[] documentObjects = registryObjectList.getIdentifiable();
            if ((documentObjects != null) && (documentObjects.length > 0)) {
                log.info("Documents found in the registry, retrieving them from the repository...");

                HashMap<String, String> documents = new HashMap<String, String>();
                for (IdentifiableType identifiable : documentObjects) {
                    if (identifiable.getClass().equals(ExtrinsicObjectType.class)) {
                        // Determine if the "home" attribute (homeCommunityId in XCA parlance) is present...
                        String home = ((((ExtrinsicObjectType) identifiable).getHome() != null)
                                && (((ExtrinsicObjectType) identifiable).getHome().getPath().length() > 0))
                                        ? ((ExtrinsicObjectType) identifiable).getHome().getPath()
                                        : null;

                        ExternalIdentifierType[] externalIdentifiers = ((ExtrinsicObjectType) identifiable)
                                .getExternalIdentifier();

                        // Find the ExternalIdentifier that has the "XDSDocumentEntry.uniqueId" value...
                        String uniqueId = null;
                        for (ExternalIdentifierType externalIdentifier : externalIdentifiers) {
                            String val = externalIdentifier.getName().getInternationalStringTypeSequence()[0]
                                    .getLocalizedString().getValue().getFreeFormText();
                            if ((val != null) && (val.compareToIgnoreCase("XDSDocumentEntry.uniqueId") == 0)) {
                                log.info("Located XDSDocumentEntry.uniqueId ExternalIdentifier, uniqueId="
                                        + uniqueId);
                                uniqueId = externalIdentifier.getValue().getLongName();
                                break;
                            }
                        }

                        if (uniqueId != null) {
                            documents.put(uniqueId, home);
                            log.info("Document ID added: " + uniqueId + ", homeCommunityId: " + home);
                        }
                    } else {
                        String home = ((identifiable.getHome() != null)
                                && (identifiable.getHome().getPath().length() > 0))
                                        ? identifiable.getHome().getPath()
                                        : null;
                        documents.put(identifiable.getId().getPath(), home);
                        log.info("Document ID added: " + identifiable.getId().getPath() + ", homeCommunityId: "
                                + home);
                    }
                }

                log.info("Invoking XdsB repository connector retrieval...");
                RetrieveDocumentSetResponse documentSetResponse = xdsB
                        .retrieveDocumentSet(xdsBRepositoryUniqueId, documents, patientId);
                log.info("XdsB repository connector retrieval succeeded");

                // Invoke appropriate map(s) to process documents in documentSetResponse...
                if (documentSetResponse.getRetrieveDocumentSetResponse()
                        .getRetrieveDocumentSetResponseTypeSequence_type0() != null) {
                    DocumentResponse_type0[] docResponseArray = documentSetResponse
                            .getRetrieveDocumentSetResponse().getRetrieveDocumentSetResponseTypeSequence_type0()
                            .getDocumentResponse();
                    if (docResponseArray != null) {
                        try {
                            for (DocumentResponse_type0 document : docResponseArray) {
                                log.info("Processing document ID="
                                        + document.getDocumentUniqueId().getLongName());

                                String mimeType = docResponseArray[0].getMimeType().getLongName();
                                if (mimeType.compareToIgnoreCase("text/xml") == 0) {
                                    DataHandler dh = document.getDocument();
                                    String documentStr = dh.getContent().toString();
                                    String documentName = document.getDocumentUniqueId().getLongName();
                                    PatientDocument patientDocument = new PatientDocument(documentName,
                                            documentStr);
                                    patientDocuments.add(patientDocument);
                                } else {
                                    patientDataResponse.getErrorMsgs()
                                            .add("Document retrieved is not XML - document ID="
                                                    + document.getDocumentUniqueId().getLongName());
                                }
                            }
                        } catch (Exception e) {
                            log.error("Error encountered, " + e.getMessage());
                            throw e;
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("Error encountered, " + e.getMessage());
            throw new UnexpectedServerException("Error - " + e.getMessage());
        }
    } else {
        // Return test document when testMode is true
        try {
            retVal = FileUtils.readFileToString(new File(GetPatientDataService.testJSONDocumentPathname));
            return Response.status(Response.Status.OK).entity(retVal).type(MediaType.APPLICATION_JSON).build();
        } catch (Exception e) {
            throw new UnexpectedServerException("Error - " + e.getMessage());
        }
    }
    documentsResponseDto.setDocuments(patientDocuments);

    return Response.status(Response.Status.OK).entity(documentsResponseDto).type(MediaType.APPLICATION_JSON)
            .build();
}

From source file:immf.ServerMain.java

public ServerMain(File conffile) {
    System.out.println("StartUp [" + Version + "]");
    log.info("StartUp [" + Version + "]");
    this.setShutdownHook();
    this.verCheck();
    try {/*from w ww .  j av a  2 s.c o m*/
        log.info("Load Config file " + conffile.getAbsolutePath());
        FileInputStream is = new FileInputStream(conffile);
        this.conf = new Config(is);
        this.numForwardSite = conf.countForwardSite();
        if (numForwardSite > 1) {
            log.info("??????:" + numForwardSite);
        }

    } catch (Exception e) {
        log.fatal("Config Error. ??????", e);
        e.printStackTrace();
        System.exit(1);
    }

    // cookie?????ID
    File stFile = new File(conf.getStatusFile());
    log.info("Load Status file " + stFile.getAbsolutePath());
    this.status = new StatusManager(stFile);
    try {
        this.status.load();
    } catch (Exception e) {
        // ???
        log.info("Status File load error. " + e.getMessage());
        log.info("Status?????");
    }
    log.info("Loaded LastMailID=" + this.status.getLastMailId());

    this.client = new ImodeNetClient(this.conf.getDocomoId(), conf.getDocomoPasswd());
    this.client.setConnTimeout(this.conf.getHttpConnectTimeoutSec() * 1000);
    this.client.setSoTimeout(this.conf.getHttpSoTimeoutSec() * 1000);
    this.client.setMailAddrCharset(this.conf.getMailEncode());
    this.client.setCsvAddressBook(this.conf.getCsvAddressFile());
    //GoogleContactsAccesor??
    GoogleContactsAccessor.initialize(this.conf.getGmailId(), this.conf.getGmailPasswd());
    this.client.setVcAddressBook(this.conf.getVcAddressFile());

    CharacterConverter subjectCharConv = new CharacterConverter();
    for (String file : conf.getForwardSubjectCharConvertFile()) {
        try {
            subjectCharConv.load(new File(file));
        } catch (Exception e) {
            log.error("?(" + file + ")????????", e);
        }
    }
    ImodeForwardMail.setSubjectCharConv(subjectCharConv);

    if (conf.isForwardAddGoomojiSubject()) {
        CharacterConverter goomojiSubjectCharConv = new CharacterConverter();
        if (conf.getForwardGoogleCharConvertFile() != null) {
            try {
                goomojiSubjectCharConv.load(new File(conf.getForwardGoogleCharConvertFile()));
            } catch (Exception e) {
                log.error("?(" + conf.getForwardGoogleCharConvertFile()
                        + ")????????", e);
            }
        }
        ImodeForwardMail.setGoomojiSubjectCharConv(goomojiSubjectCharConv);
    }

    StringConverter strConv = new StringConverter();
    if (conf.getForwardStringConvertFile() != null) {
        try {
            strConv.load(new File(conf.getForwardStringConvertFile()));
        } catch (Exception e) {
            log.error("?(" + conf.getForwardStringConvertFile()
                    + ")????????", e);
        }
    }
    ImodeForwardMail.setStrConv(strConv);

    // ???
    this.loadIgnoreDomainList(this.conf, 1);

    try {
        // ??cookie
        if (this.conf.isSaveCookie()) {
            log.info("Load cookie");
            for (Cookie cookie : this.status.getCookies()) {
                this.client.addCookie(cookie);
            }
        }
    } catch (Exception e) {
    }

    // ?
    spicker = new SendMailPicker(conf, this, this.client, this.status);
    new SendMailBridge(conf, this.client, this.spicker, this.status);

    // ?
    Config forwardConf = this.conf;
    ForwardMailPicker fpicker = new ForwardMailPicker(forwardConf, this);
    forwarders.put(forwardConf, fpicker);

    for (int i = 2; i <= numForwardSite; i++) {
        try {
            log.info("Load Config file[" + i + "] " + conffile.getAbsolutePath());
            FileInputStream is = new FileInputStream(conffile);
            is = new FileInputStream(conffile);
            forwardConf = new Config(is, i);
            fpicker = new ForwardMailPicker(forwardConf, this);
            forwarders.put(forwardConf, fpicker);

            // ???
            this.loadIgnoreDomainList(forwardConf, i);

        } catch (Exception e) {
            log.fatal("Config Error. ??????", e);
            e.printStackTrace();
            System.exit(1);
        }
    }

    // skype
    this.skypeForwarder = new SkypeForwarder(conf.getForwardSkypeChat(), conf.getForwardSkypeSms(), conf);

    // im.kayac.com
    this.imKayacNotifier = new ImKayacNotifier(this.conf);

    // appnotifications
    this.appNotifications = new AppNotifications(this.conf, this.status);

    // Growl APIs
    // for Prowl
    this.prowlNotifier = GrowlNotifier.getInstance(ProwlClient.getInstance(), this.conf);

    // for Notify My Android
    this.nmaNotifier = GrowlNotifier.getInstance(NMAClient.getInstance(), this.conf);

    Date lastUpdate = null;
    while (true) {
        if (lastUpdate != null) {
            // ????
            try {
                this.status.load();
            } catch (Exception e) {
            }
            long diff = System.currentTimeMillis() - lastUpdate.getTime();
            if (diff < conf.getForceCheckIntervalSec() * 1000 && !this.status.needConnect()) {
                //????????????
                try {
                    Thread.sleep(conf.getCheckFileIntervalSec() * 1000);
                } catch (Exception e) {
                }
                continue;
            }
        }

        Map<Integer, List<String>> mailIdListMap = null;
        try {
            // ID?(?)
            mailIdListMap = this.client.getMailIdList();
            this.client.checkAddressBook();

        } catch (LoginException e) {
            log.error("", e);
            if (lastUpdate == null) {
                // ?cookie??????????
                log.info("?5?????");
                try {
                    Thread.sleep(1000 * 5);
                } catch (Exception ex) {
                }
                lastUpdate = new Date();
                continue;
            }
            try {
                // ????
                log.info("Wait " + this.conf.getLoginRetryIntervalSec() + " sec.");
                Thread.sleep(this.conf.getLoginRetryIntervalSec() * 1000);
            } catch (Exception ex) {
            }
            continue;
        } catch (Exception e) {
            log.error("Get Mail ID List error.", e);
            try {
                Thread.sleep(this.conf.getLoginRetryIntervalSec() * 1000);
            } catch (Exception ex) {
            }
            continue;
        }

        String newestId = "0"; // ?lastId?
        Iterator<Integer> folderIdIte = mailIdListMap.keySet().iterator();
        while (folderIdIte.hasNext()) {
            // ????
            Integer fid = folderIdIte.next();
            List<String> mailIdList = mailIdListMap.get(fid);

            folderProc(fid, mailIdList);

            if (!mailIdList.isEmpty()) {
                String newestInFolder = mailIdList.get(0);
                if (newestId.compareToIgnoreCase(newestInFolder) < 0) {
                    newestId = newestInFolder;
                }
            }
        }

        // ?
        this.status.resetNeedConnect();

        // status.ini ?
        if (StringUtils.isBlank(this.status.getLastMailId())) {
            this.status.setLastMailId(newestId);
            log.info("LastMailId???????????");
        }
        String lastId = this.status.getLastMailId();
        if (lastId != null && !lastId.equals(newestId)) {
            this.status.setLastMailId(newestId);
            log.info("LastMailId(" + newestId + ")?????");
        }
        try {
            if (this.conf.isSaveCookie()) {
                this.status.setCookies(client.getCookies());
            }
            this.status.save();
            log.info("status?????");
        } catch (Exception e) {
            log.error("Status File save Error.", e);
        }
        lastUpdate = new Date();

        // ?????
        try {
            Thread.sleep(conf.getCheckIntervalSec() * 1000);
        } catch (Exception e) {
        }
    }

}

From source file:com.sfs.whichdoctor.dao.WhichDoctorDAOImpl.java

/**
 * Load siblings.//from  ww  w . jav a 2s  . c om
 *
 * @param guid the GUID of the object
 * @param type the ObjectType of the object
 *
 * @return TreeMap containing sibling details for the identified object
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final TreeMap<String, TreeMap<Integer, Collection<WhichDoctorBean>>> loadSiblings(final int guid,
        final String type) throws WhichDoctorDaoException {

    if (type == null) {
        throw new NullPointerException("The type parameter cannot be null");
    }

    dataLogger.info("History of GUID: " + guid + " requested");

    // Load siblings
    TreeMap<String, TreeMap<Integer, Collection<WhichDoctorBean>>> siblings = new TreeMap<String, TreeMap<Integer, Collection<WhichDoctorBean>>>();

    TreeMap<Integer, Collection<WhichDoctorBean>> memos = loadSiblingBeans(guid, "memo");
    siblings.put("Memos", memos);

    if (type.compareToIgnoreCase("person") == 0 || type.compareToIgnoreCase("organisation") == 0) {
        siblings.put("Addresses", loadSiblingBeans(guid, "address"));
        siblings.put("Phone Numbers", loadSiblingBeans(guid, "phone"));
        siblings.put("Email Addresses", loadSiblingBeans(guid, "email"));
        siblings.put("Specialties", loadSiblingBeans(guid, "specialty"));
    }
    if (type.compareToIgnoreCase("person") == 0) {
        siblings.put("Membership", loadSiblingBeans(guid, "membership"));
        siblings.put("Workshops", loadSiblingBeans(guid, "workshop"));
        siblings.put("Rotations", loadSiblingBeans(guid, "rotation"));
        siblings.put("Projects", loadSiblingBeans(guid, "project"));
        siblings.put("Exams", loadSiblingBeans(guid, "exam"));
        siblings.put("Qualifications", loadSiblingBeans(guid, "qualification"));
    }
    if (type.compareToIgnoreCase("rotation") == 0) {
        siblings.put("Assessments", loadSiblingBeans(guid, "assessment"));
        siblings.put("Reports", loadSiblingBeans(guid, "report"));
        siblings.put("Accreditations", loadSiblingBeans(guid, "accreditation"));
    }
    if (type.compareToIgnoreCase("reimbursement") == 0) {
        siblings.put("Expense Claims", loadSiblingBeans(guid, "expenseclaim"));
    }
    if (type.compareToIgnoreCase("receipt") == 0) {
        siblings.put("Payments", loadSiblingBeans(guid, "payment"));
    }

    return siblings;
}

From source file:org.apache.archiva.common.utils.VersionComparator.java

private int comparePart(String s1, String s2) {
    boolean is1Num = NumberUtils.isNumber(s1);
    boolean is2Num = NumberUtils.isNumber(s2);

    // (Special Case) Test for numbers both first.
    if (is1Num && is2Num) {
        int i1 = NumberUtils.toInt(s1);
        int i2 = NumberUtils.toInt(s2);

        return i1 - i2;
    }//w  ww.j  a  va  2s. co m

    // Test for text both next.
    if (!is1Num && !is2Num) {
        int idx1 = specialWords.indexOf(s1.toLowerCase());
        int idx2 = specialWords.indexOf(s2.toLowerCase());

        // Only operate perform index based operation, if both strings
        // are found in the specialWords index.
        if (idx1 >= 0 && idx2 >= 0) {
            return idx1 - idx2;
        }
    }

    // Comparing text to num
    if (!is1Num && is2Num) {
        return -1;
    }

    // Comparing num to text
    if (is1Num && !is2Num) {
        return 1;
    }

    // Return comparison of strings themselves.
    return s1.compareToIgnoreCase(s2);
}