Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

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

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

From source file:fr.free.movierenamer.scrapper.impl.movie.TMDbScrapper.java

@Override
protected MovieInfo fetchMediaInfo(Movie movie, Locale language) throws Exception {
    URL searchUrl = new URL("http", apiHost, "/" + version + "/movie/" + movie.getId() + "?api_key=" + apikey
            + "&language=" + language.getLanguage() + "&append_to_response=releases,keywords");
    JSONObject json = URIRequest.getJsonDocument(searchUrl.toURI());

    Map<MovieProperty, String> fields = new EnumMap<MovieProperty, String>(MovieProperty.class);
    Map<MovieInfo.MovieMultipleProperty, List<?>> multipleFields = new EnumMap<MovieInfo.MovieMultipleProperty, List<?>>(
            MovieInfo.MovieMultipleProperty.class);
    fields.put(MovieProperty.title, JSONUtils.selectString("title", json));
    fields.put(MovieProperty.rating, JSONUtils.selectString("vote_average", json));
    fields.put(MovieProperty.votes, JSONUtils.selectString("vote_count", json));
    fields.put(MovieProperty.originalTitle, JSONUtils.selectString("original_title", json));
    fields.put(MovieProperty.releasedDate, JSONUtils.selectString("release_date", json));
    fields.put(MovieProperty.overview, JSONUtils.selectString("overview", json));
    fields.put(MovieProperty.runtime, JSONUtils.selectString("runtime", json));
    fields.put(MovieProperty.budget, JSONUtils.selectString("budget", json));
    fields.put(MovieProperty.tagline, JSONUtils.selectString("tagline", json));
    JSONObject collection = JSONUtils.selectObject("belongs_to_collection", json);
    fields.put(MovieProperty.collection, collection != null ? JSONUtils.selectString("name", collection) : "");

    List<IdInfo> ids = new ArrayList<IdInfo>();
    ids.add(new IdInfo(JSONUtils.selectInteger("id", json), ScrapperUtils.AvailableApiIds.TMDB));
    String imdbId = JSONUtils.selectString("imdb_id", json);
    if (imdbId != null) {
        ids.add(new IdInfo(Integer.parseInt(imdbId.substring(2)), ScrapperUtils.AvailableApiIds.IMDB));
    }/*from   w  ww.  j  a  v  a 2 s  . c o m*/

    for (JSONObject jsonObj : JSONUtils.selectList("countries", json)) {
        if (JSONUtils.selectString("iso_3166_1", jsonObj).equals("US")) {
            fields.put(MovieProperty.certificationCode, JSONUtils.selectString("certification", jsonObj));
            break;
        }
    }

    List<String> genres = new ArrayList<String>();
    for (JSONObject jsonObj : JSONUtils.selectList("genres", json)) {
        genres.add(JSONUtils.selectString("name", jsonObj));
    }

    List<Locale> countries = new ArrayList<Locale>();
    for (JSONObject jsonObj : JSONUtils.selectList("production_countries", json)) {
        countries.add(new Locale("", JSONUtils.selectString("iso_3166_1", jsonObj)));
    }

    List<String> studios = new ArrayList<String>();
    for (JSONObject jsonObj : JSONUtils.selectList("production_companies", json)) {
        studios.add(JSONUtils.selectString("name", jsonObj));
    }

    List<String> tags = new ArrayList<String>();
    JSONObject keywords = JSONUtils.selectObject("keywords", json);
    if (keywords != null) {
        for (JSONObject jsonObj : JSONUtils.selectList("keywords", keywords)) {
            tags.add(JSONUtils.selectString("name", jsonObj));
        }
    }

    multipleFields.put(MovieInfo.MovieMultipleProperty.ids, ids);
    multipleFields.put(MovieInfo.MovieMultipleProperty.studios, studios);
    multipleFields.put(MovieInfo.MovieMultipleProperty.tags, tags);
    multipleFields.put(MovieInfo.MovieMultipleProperty.countries, countries);
    multipleFields.put(MovieInfo.MovieMultipleProperty.genres, genres);

    MovieInfo movieInfo = new MovieInfo(fields, multipleFields);
    return movieInfo;
}

From source file:edu.cornell.mannlib.vitro.webapp.modelaccess.impl.ContextModelAccessImpl.java

private Map<WhichService, ModelMaker> populateModelMakerMap() {
    Map<WhichService, ModelMaker> map = new EnumMap<>(WhichService.class);
    map.put(CONTENT, factory.getModelMaker(CONTENT));
    map.put(CONFIGURATION, factory.getModelMaker(CONFIGURATION));
    log.debug("ModelMakerMap: " + map);
    return Collections.unmodifiableMap(map);
}

From source file:org.forgerock.openidm.repo.jdbc.impl.GenericTableHandler.java

protected Map<QueryDefinition, String> initializeQueryMap() {
    Map<QueryDefinition, String> result = new EnumMap<QueryDefinition, String>(QueryDefinition.class);

    String typeTable = dbSchemaName == null ? "objecttypes" : dbSchemaName + ".objecttypes";
    String mainTable = dbSchemaName == null ? mainTableName : dbSchemaName + "." + mainTableName;
    String propertyTable = dbSchemaName == null ? propTableName : dbSchemaName + "." + propTableName;

    // objecttypes table
    result.put(QueryDefinition.CREATETYPEQUERYSTR, "INSERT INTO " + typeTable + " (objecttype) VALUES (?)");
    result.put(QueryDefinition.READTYPEQUERYSTR,
            "SELECT id FROM " + typeTable + " objtype WHERE objtype.objecttype = ?");

    // Main object table
    result.put(QueryDefinition.READFORUPDATEQUERYSTR, "SELECT obj.* FROM " + mainTable + " obj INNER JOIN "
            + typeTable/*from ww  w.j a  v a  2 s  . c  o  m*/
            + " objtype ON obj.objecttypes_id = objtype.id AND objtype.objecttype = ? WHERE obj.objectid  = ? FOR UPDATE");
    result.put(QueryDefinition.READQUERYSTR, "SELECT obj.rev, obj.fullobject FROM " + typeTable + " objtype, "
            + mainTable
            + " obj WHERE obj.objecttypes_id = objtype.id AND objtype.objecttype = ? AND obj.objectid  = ?");
    result.put(QueryDefinition.CREATEQUERYSTR,
            "INSERT INTO " + mainTable + " (objecttypes_id, objectid, rev, fullobject) VALUES (?,?,?,?)");
    result.put(QueryDefinition.UPDATEQUERYSTR, "UPDATE " + mainTable
            + " obj SET obj.objectid = ?, obj.rev = ?, obj.fullobject = ? WHERE obj.id = ?");
    result.put(QueryDefinition.DELETEQUERYSTR, "DELETE obj FROM " + mainTable + " obj INNER JOIN " + typeTable
            + " objtype ON obj.objecttypes_id = objtype.id AND objtype.objecttype = ? WHERE obj.objectid = ? AND obj.rev = ?");

    /* DB2 Script
    deleteQueryStr = "DELETE FROM " + dbSchemaName + "." + mainTableName + " obj WHERE EXISTS (SELECT 1 FROM " + dbSchemaName + ".objecttypes objtype WHERE obj.objecttypes_id = objtype.id AND objtype.objecttype = ?) AND obj.objectid = ? AND obj.rev = ?";
    */

    // Object properties table
    result.put(QueryDefinition.PROPCREATEQUERYSTR, "INSERT INTO " + propertyTable + " ( " + mainTableName
            + "_id, propkey, proptype, propvalue) VALUES (?,?,?,?)");
    result.put(QueryDefinition.PROPDELETEQUERYSTR, "DELETE prop FROM " + propertyTable + " prop INNER JOIN "
            + mainTable + " obj ON prop." + mainTableName + "_id = obj.id INNER JOIN " + typeTable
            + " objtype ON obj.objecttypes_id = objtype.id WHERE objtype.objecttype = ? AND obj.objectid = ?");
    // Default object queries
    String tableVariable = dbSchemaName == null ? "${_mainTable}" : "${_dbSchema}.${_mainTable}";
    result.put(QueryDefinition.QUERYALLIDS,
            "SELECT obj.objectid FROM " + tableVariable + " obj INNER JOIN " + typeTable
                    + " objtype ON obj.objecttypes_id = objtype.id WHERE objtype.objecttype = ${_resource}");

    return result;
}

From source file:canreg.client.analysis.TopNChartTableBuilder.java

@Override
public LinkedList<String> buildTable(String tableHeader, String reportFileName, int startYear, int endYear,
        Object[][] incidenceData, PopulationDataset[] populations, // can be null
        PopulationDataset[] standardPopulations, LinkedList<ConfigFields> configList, String[] engineParameters,
        FileTypes fileType) throws NotCompatibleDataException {
    String footerString = java.util.ResourceBundle
            .getBundle("canreg/client/analysis/resources/AgeSpecificCasesPerHundredThousandTableBuilder")
            .getString("TABLE BUILT ")
            + new Date()
            + java.util.ResourceBundle
                    .getBundle(/* ww  w  .  j  a  va  2s . com*/
                            "canreg/client/analysis/resources/AgeSpecificCasesPerHundredThousandTableBuilder")
                    .getString(" BY CANREG5.");

    LinkedList<String> generatedFiles = new LinkedList<String>();

    if (Arrays.asList(engineParameters).contains("barchart")) {
        chartType = ChartType.BAR;
    } else {
        chartType = ChartType.PIE;
        includeOther = true;
    }

    if (Arrays.asList(engineParameters).contains("legend")) {
        legendOn = true;
    }

    if (Arrays.asList(engineParameters).contains("r")) {
        useR = true;
    }

    if (Arrays.asList(engineParameters).contains("asr")) {
        countType = CountType.ASR;
    } else if (Arrays.asList(engineParameters).contains("cum64")) {
        countType = CountType.CUM64;
    } else if (Arrays.asList(engineParameters).contains("cum74")) {
        countType = CountType.CUM74;
    } else if (Arrays.asList(engineParameters).contains("per100000")) {
        countType = CountType.PER_HUNDRED_THOUSAND;
    } else {
        // default to cases
        countType = CountType.CASES;
    }

    localSettings = CanRegClientApp.getApplication().getLocalSettings();
    rpath = localSettings.getProperty(LocalSettings.R_PATH);
    // does R exist?
    if (rpath == null || rpath.isEmpty() || !new File(rpath).exists()) {
        useR = false; // force false if R is not installed
    }

    icdLabel = ConfigFieldsReader.findConfig("ICD_groups_labels", configList);

    icd10GroupDescriptions = ConfigFieldsReader.findConfig("ICD10_groups", configList);

    cancerGroupsLocal = EditorialTableTools.generateICD10Groups(icd10GroupDescriptions);

    // indexes
    keyGroupsMap = new EnumMap<KeyCancerGroupsEnum, Integer>(KeyCancerGroupsEnum.class);

    keyGroupsMap.put(KeyCancerGroupsEnum.allCancerGroupsIndex,
            EditorialTableTools.getICD10index("ALL", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.leukemiaNOSCancerGroupIndex,
            EditorialTableTools.getICD10index(950, cancerGroupsLocal));
    keyGroupsMap.put(KeyCancerGroupsEnum.skinCancerGroupIndex,
            EditorialTableTools.getICD10index("C44", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.bladderCancerGroupIndex,
            EditorialTableTools.getICD10index("C67", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.mesotheliomaCancerGroupIndex,
            EditorialTableTools.getICD10index("C45", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.kaposiSarkomaCancerGroupIndex,
            EditorialTableTools.getICD10index("C46", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.myeloproliferativeDisordersCancerGroupIndex,
            EditorialTableTools.getICD10index("MPD", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.myelodysplasticSyndromesCancerGroupIndex,
            EditorialTableTools.getICD10index("MDS", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.allCancerGroupsButSkinIndex,
            EditorialTableTools.getICD10index("ALLbC44", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.brainAndCentralNervousSystemCancerGroupIndex,
            EditorialTableTools.getICD10index("C70-72", icd10GroupDescriptions));
    keyGroupsMap.put(KeyCancerGroupsEnum.ovaryCancerGroupIndex,
            EditorialTableTools.getICD10index(569, cancerGroupsLocal));
    keyGroupsMap.put(KeyCancerGroupsEnum.otherCancerGroupsIndex,
            EditorialTableTools.getICD10index("O&U", icd10GroupDescriptions));

    otherCancerGroupsIndex = keyGroupsMap.get(KeyCancerGroupsEnum.otherCancerGroupsIndex);
    skinCancerGroupIndex = keyGroupsMap.get(KeyCancerGroupsEnum.skinCancerGroupIndex);
    allCancerGroupsIndex = keyGroupsMap.get(KeyCancerGroupsEnum.allCancerGroupsIndex);
    allCancerGroupsButSkinIndex = keyGroupsMap.get(KeyCancerGroupsEnum.allCancerGroupsButSkinIndex);

    numberOfCancerGroups = cancerGroupsLocal.length;

    double[] countsRow;

    if (populations != null && populations.length > 0) {
        if (populations[0].getPopulationDatasetID() < 0) {
            countType = CountType.CASES;
        } else {
            // calculate period pop
            periodPop = new PopulationDataset();
            periodPop.setAgeGroupStructure(populations[0].getAgeGroupStructure());
            periodPop.setReferencePopulation(populations[0].getReferencePopulation());
            for (PopulationDatasetsEntry pde : populations[0].getAgeGroups()) {
                int count = 0;
                for (PopulationDataset pds : populations) {
                    count += pds.getAgeGroupCount(pde.getSex(), pde.getAgeGroup());
                }
                periodPop.addAgeGroup(new PopulationDatasetsEntry(pde.getAgeGroup(), pde.getSex(), count));
            }
        }
    }

    if (incidenceData != null) {
        String sexString, icdString, morphologyString;
        double countArray[][] = new double[numberOfCancerGroups][numberOfSexes];

        int sex, icdIndex, numberOfCases, age;
        double adjustedCases;
        List<Integer> dontCount = new LinkedList<Integer>();
        // all sites but skin?
        if (Arrays.asList(engineParameters).contains("noC44")) {
            dontCount.add(skinCancerGroupIndex);
            tableHeader += ", excluding C44";
        }

        for (Object[] dataLine : incidenceData) {

            // Set default
            adjustedCases = 0.0;

            // Extract data
            sexString = (String) dataLine[SEX_COLUMN];
            sex = Integer.parseInt(sexString.trim());

            // sex = 3 is unknown sex
            if (sex > 2) {
                sex = 3;
            }

            morphologyString = (String) dataLine[MORPHOLOGY_COLUMN];
            icdString = (String) dataLine[ICD10_COLUMN];

            icdIndex = Tools.assignICDGroupIndex(keyGroupsMap, icdString, morphologyString, cancerGroupsLocal);

            age = (Integer) dataLine[AGE_COLUMN];

            if (!dontCount.contains(icdIndex) && icdIndex != DONT_COUNT) {
                // Extract cases
                numberOfCases = (Integer) dataLine[CASES_COLUMN];
                if (countType == CountType.PER_HUNDRED_THOUSAND) {
                    adjustedCases = (100000.0 * numberOfCases)
                            / periodPop.getAgeGroupCount(sex, periodPop.getAgeGroupIndex(age));
                } else if (countType == CountType.ASR) {
                    try {
                        adjustedCases = 100.0
                                * (periodPop.getReferencePopulationForAgeGroupIndex(sex,
                                        periodPop.getAgeGroupIndex(age)) * numberOfCases)
                                / periodPop.getAgeGroupCount(sex, periodPop.getAgeGroupIndex(age));
                    } catch (IncompatiblePopulationDataSetException ex) {
                        Logger.getLogger(TopNChartTableBuilder.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else if (countType == CountType.CUM64) {
                    if (age < 65) {
                        adjustedCases = (100000.0 * numberOfCases)
                                / periodPop.getAgeGroupCount(sex, periodPop.getAgeGroupIndex(age)) * 5.0
                                / 1000.0;
                    }
                } else if (countType == CountType.CUM74) {
                    if (age < 75) {
                        adjustedCases = (100000.0 * numberOfCases)
                                / periodPop.getAgeGroupCount(sex, periodPop.getAgeGroupIndex(age)) * 5.0
                                / 1000.0;
                    }
                } else {
                    adjustedCases = numberOfCases;
                }

                if (sex <= numberOfSexes && icdIndex >= 0 && icdIndex <= cancerGroupsLocal.length) {
                    countArray[icdIndex][sex - 1] += adjustedCases;
                } else {
                    if (otherCancerGroupsIndex >= 0) {
                        countArray[otherCancerGroupsIndex][sex - 1] += adjustedCases;
                    }
                }
                if (allCancerGroupsIndex >= 0) {
                    countArray[allCancerGroupsIndex][sex - 1] += adjustedCases;
                }
                if (allCancerGroupsButSkinIndex >= 0 && skinCancerGroupIndex >= 0
                        && icdIndex != skinCancerGroupIndex) {
                    countArray[allCancerGroupsButSkinIndex][sex - 1] += adjustedCases;
                }
            }
        }

        // separate top 10 and the rest
        TreeSet<CancerCasesCount> topNMale = new TreeSet<CancerCasesCount>(new Comparator<CancerCasesCount>() {

            @Override
            public int compare(CancerCasesCount o1, CancerCasesCount o2) {
                if (o1.getCount().equals(o2.getCount())) {
                    return -o1.toString().compareTo(o2.toString());
                } else {
                    return -(o1.getCount().compareTo(o2.getCount()));
                }
            }
        });
        LinkedList<CancerCasesCount> theRestMale = new LinkedList<CancerCasesCount>();

        TreeSet<CancerCasesCount> topNFemale = new TreeSet<CancerCasesCount>(
                new Comparator<CancerCasesCount>() {

                    @Override
                    public int compare(CancerCasesCount o1, CancerCasesCount o2) {
                        if (o1.getCount().equals(o2.getCount())) {
                            return -o1.toString().compareTo(o2.toString());
                        } else {
                            return -(o1.getCount().compareTo(o2.getCount()));
                        }
                    }
                });
        LinkedList<CancerCasesCount> theRestFemale = new LinkedList<CancerCasesCount>();

        CancerCasesCount otherElement;
        CancerCasesCount thisElement;

        TreeSet<CancerCasesCount> topN;
        LinkedList<CancerCasesCount> theRest;

        for (int icdGroupNumber = 0; icdGroupNumber < countArray.length; icdGroupNumber++) {
            countsRow = countArray[icdGroupNumber];
            for (int sexNumber = 0; sexNumber < 2; sexNumber++) {

                if (sexNumber == 0) {
                    topN = topNMale;
                    theRest = theRestMale;
                } else {
                    topN = topNFemale;
                    theRest = theRestFemale;
                }

                if (countsRow[sexNumber] > 0) {
                    thisElement = new CancerCasesCount(icd10GroupDescriptions[icdGroupNumber],
                            icdLabel[icdGroupNumber].substring(3), countsRow[sexNumber], icdGroupNumber);

                    // if this is the "other" group - add it immediately to "the rest"
                    if (icdGroupNumber == otherCancerGroupsIndex) {
                        theRest.add(thisElement);
                        // if not we check if this is one of the collection groups
                    } else if (icdGroupNumber != allCancerGroupsButSkinIndex
                            && icdGroupNumber != allCancerGroupsIndex) {
                        // if it is less than N cancers in top N - add it
                        if (topN.size() < topNLimit) {
                            topN.add(thisElement);
                        } else {
                            // otherwise we need to compare it to the last element in the top 10
                            otherElement = topN.last();
                            if (thisElement.compareTo(otherElement) < 0) {
                                topN.remove(otherElement);
                                theRest.add(otherElement);
                                topN.add(thisElement);
                            } else {
                                theRest.add(thisElement);
                            }
                        }
                    }
                }
            }
        }

        for (int sexNumber : new int[] { 0, 1 }) {
            String fileName = reportFileName + "-" + sexLabel[sexNumber] + "." + fileType.toString();
            File file = new File(fileName);

            TreeSet<CancerCasesCount> casesCounts;
            Double restCount = Tools.sumUpTheRest(theRestMale, dontCount);

            if (sexNumber == 0) {
                casesCounts = topNMale;
            } else {
                casesCounts = topNFemale;
            }

            if (useR && !fileType.equals(FileTypes.jchart) && !fileType.equals(FileTypes.csv)) {
                String header = "Top 10 by " + countType + ", \n" + tableHeader + ", "
                        + TableBuilderInterface.sexLabel[sexNumber];
                generatedFiles.addAll(Tools.generateRChart(casesCounts, fileName, header, fileType, chartType,
                        includeOther, restCount, rpath, true, "Site"));
            } else {
                double allCount = countArray[allCancerGroupsIndex][sexNumber];
                Color color;
                if (sexNumber == 0) {
                    color = Color.BLUE;
                } else {
                    color = Color.RED;
                }
                String header = "Top 10 by " + countType + ", " + tableHeader + ", "
                        + TableBuilderInterface.sexLabel[sexNumber];
                charts[sexNumber] = Tools.generateJChart(casesCounts, fileName, header, fileType, chartType,
                        includeOther, legendOn, restCount, allCount, color, "Site");
                try {
                    generatedFiles.add(Tools.writeJChartToFile(charts[sexNumber], file, fileType));
                } catch (IOException ex) {
                    Logger.getLogger(TopNChartTableBuilder.class.getName()).log(Level.SEVERE, null, ex);
                } catch (DocumentException ex) {
                    Logger.getLogger(TopNChartTableBuilder.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
    return generatedFiles;
}

From source file:org.ligoj.app.plugin.prov.aws.ProvAwsTerraformService.java

private void writeRegion(final Context context) throws IOException {
    final List<ProvQuoteInstance> instances = new ArrayList<>();
    context.getQuote().getInstances().stream()
            .filter(i -> getLocation(i).getName().equals(context.getLocation())).forEach(instances::add);
    final Map<InstanceMode, List<ProvQuoteInstance>> modes = new EnumMap<>(InstanceMode.class);
    Arrays.stream(InstanceMode.values()).forEach(m -> modes.put(m, new ArrayList<>()));
    instances.stream().forEach(i -> modes.get(toMode(i)).add(i));
    context.setModes(modes);//from  w  w w.j  a  va 2 s .  c  om

    writeRegionStatics(context);
    writeRegionOs(context, instances);
    writeRegionDashboard(context);
    writeRegionInstances(context);
}

From source file:de.doncarnage.minecraft.common.commandhandler.tree.impl.CommandTree.java

private void addChildVerificators() {
    childVerificators = new EnumMap<>(NodeType.class);
    childVerificators.put(NodeType.KEYWORD, new FixedParamVerificator<T>());
    childVerificators.put(NodeType.NEEDED, new VariableParamVerificator<T>());
    childVerificators.put(NodeType.OPTIONAL, new OptionalParamVerificator<T>());
    ChildHandler<T> repeatableChildHandler = new RepeatableParamVerificator<>();
    childVerificators.put(NodeType.NEEDED_REPEATABLE, repeatableChildHandler);
    childVerificators.put(NodeType.OPTIONAL_REPEATABLE, repeatableChildHandler);
}

From source file:dk.netarkivet.harvester.indexserver.distribute.TestIndexRequestServer.java

/**
 * Initialise index request server with no handlers, listening to the index JMS channel.
 *//*ww  w  .  j  a  v  a2  s.  c o m*/
private TestIndexRequestServer() {
    maxConcurrentJobs = Settings.getLong(HarvesterSettings.INDEXSERVER_INDEXING_MAXCLIENTS);
    requestDir = Settings.getFile(HarvesterSettings.INDEXSERVER_INDEXING_REQUESTDIR);
    listeningInterval = Settings.getLong(HarvesterSettings.INDEXSERVER_INDEXING_LISTENING_INTERVAL);

    alwaysReturnFalseMode = Settings.getBoolean(ALWAYS_SET_ISINDEX_READY_TO_FALSE);
    if (alwaysReturnFalseMode) {
        log.info("alwaysSetIsIndexReadyToFalse is true");
    } else {
        log.info("alwaysSetIsIndexReadyToFalse is false");
    }

    jobsForDefaultIndex = Settings.getFile(JOBS_FOR_TESTINDEX);

    if (!jobsForDefaultIndex.exists()) {
        final String msg = "The file '" + jobsForDefaultIndex.getAbsolutePath() + "' does not exist";
        log.error("The file containing job identifiers for default index '{}' does not exist",
                jobsForDefaultIndex.getAbsolutePath());
        System.err.println(msg + ". Exiting program");
        System.exit(1);
    }
    defaultIDs = readLongsFromFile(jobsForDefaultIndex);
    currentJobs = new HashMap<String, IndexRequestMessage>();
    handlers = new EnumMap<RequestType, FileBasedCache<Set<Long>>>(RequestType.class);
    conn = JMSConnectionFactory.getInstance();
    checkIflisteningTimer = new Timer();
}

From source file:org.graphwalker.restful.Util.java

private static EnumMap<Statistics, Integer> getStatistics(Context context) {
    EnumMap<Statistics, Integer> map = new EnumMap<>(Statistics.class);
    map.put(Statistics.TOTAL_NUMBER_OF_VERTICES, context.getModel().getVertices().size());
    map.put(Statistics.TOTAL_NUMBER_OF_UNVISITED_VERTICES,
            context.getProfiler().getUnvisitedVertices(context).size());
    map.put(Statistics.TOTAL_NUMBER_OF_EDGES, context.getModel().getEdges().size());
    map.put(Statistics.TOTAL_NUMBER_OF_UNVISITED_EDGES,
            context.getProfiler().getUnvisitedEdges(context).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS, context.getRequirements().size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_NOT_COVERED,
            context.getRequirements(RequirementStatus.NOT_COVERED).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_PASSED,
            context.getRequirements(RequirementStatus.PASSED).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_FAILED,
            context.getRequirements(RequirementStatus.FAILED).size());
    return map;/*from   www.java 2  s . c  o m*/
}

From source file:org.apache.metron.dataloads.nonbulk.flatfile.LoadOptions.java

public static EnumMap<LoadOptions, Optional<Object>> createConfig(CommandLine cli) {
    EnumMap<LoadOptions, Optional<Object>> ret = new EnumMap<>(LoadOptions.class);
    for (LoadOptions option : values()) {
        ret.put(option, option.handler.getValue(option, cli));
    }//from   w  ww . ja  v  a 2  s.  com
    return ret;
}

From source file:nl.strohalm.cyclos.controls.customization.fields.EditCustomFieldAction.java

public DataBinder<? extends CustomField> getDataBinder(final CustomField.Nature nature) {
    if (dataBinders == null) {
        dataBinders = new EnumMap<CustomField.Nature, DataBinder<? extends CustomField>>(
                CustomField.Nature.class);
        dataBinders.put(CustomField.Nature.MEMBER, getMemberCustomFieldBinder());
        dataBinders.put(CustomField.Nature.ADMIN, getAdminCustomFieldBinder());
        dataBinders.put(CustomField.Nature.OPERATOR, getOperatorCustomFieldBinder());
        dataBinders.put(CustomField.Nature.AD, getAdCustomFieldBinder());
        dataBinders.put(CustomField.Nature.PAYMENT, getPaymentCustomFieldBinder());
        dataBinders.put(CustomField.Nature.LOAN_GROUP, getLoanGroupCustomFieldBinder());
        dataBinders.put(CustomField.Nature.MEMBER_RECORD, getMemberRecordCustomFieldBinder());
    }/*from   w ww  . j  av  a2 s  .c o  m*/
    return dataBinders.get(nature);
}