Example usage for java.util.concurrent ConcurrentMap get

List of usage examples for java.util.concurrent ConcurrentMap get

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.alibaba.dubbo.governance.sync.RegistryServerSync.java

public void notify(List<URL> urls) {
    if (urls == null || urls.isEmpty()) {
        return;//from w  ww. j  av  a  2 s.  c om
    }
    // Map<category, Map<servicename, Map<Long, URL>>>
    final Map<String, Map<String, Map<Long, URL>>> categories = new HashMap<String, Map<String, Map<Long, URL>>>();
    for (URL url : urls) {
        String category = url.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
        if (Constants.EMPTY_PROTOCOL.equalsIgnoreCase(url.getProtocol())) { // ?empty??groupversion*
            ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category);
            if (services != null) {
                String group = url.getParameter(Constants.GROUP_KEY);
                String version = url.getParameter(Constants.VERSION_KEY);
                // ?empty??groupversion*
                if (!Constants.ANY_VALUE.equals(group) && !Constants.ANY_VALUE.equals(version)) {
                    services.remove(url.getServiceKey());
                } else {
                    for (Map.Entry<String, Map<Long, URL>> serviceEntry : services.entrySet()) {
                        String service = serviceEntry.getKey();
                        if (Tool.getInterface(service).equals(url.getServiceInterface())
                                && (Constants.ANY_VALUE.equals(group)
                                        || StringUtils.isEquals(group, Tool.getGroup(service)))
                                && (Constants.ANY_VALUE.equals(version)
                                        || StringUtils.isEquals(version, Tool.getVersion(service)))) {
                            services.remove(service);
                        }
                    }
                }
            }
        } else {
            Map<String, Map<Long, URL>> services = categories.get(category);
            if (services == null) {
                services = new HashMap<String, Map<Long, URL>>();
                categories.put(category, services);
            }
            String service = url.getServiceKey();
            Map<Long, URL> ids = services.get(service);
            if (ids == null) {
                ids = new HashMap<Long, URL>();
                services.put(service, ids);
            }
            ids.put(ID.incrementAndGet(), url);
        }
    }
    for (Map.Entry<String, Map<String, Map<Long, URL>>> categoryEntry : categories.entrySet()) {
        String category = categoryEntry.getKey();
        ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category);
        if (services == null) {
            services = new ConcurrentHashMap<String, Map<Long, URL>>();
            registryCache.put(category, services);
        }
        services.putAll(categoryEntry.getValue());
    }
}

From source file:com.github.podd.example.ExamplePoddClient.java

/**
 * @param potUriMap// w w w.  ja  v a 2 s  .  c  o  m
 * @param plantId
 * @param nextProjectID
 * @param nextTrayURI
 * @return
 * @throws PoddClientException
 * @throws GraphUtilException
 */
private URI getPotUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> potUriMap, final String plantId,
        final InferredOWLOntologyID nextProjectID, final URI nextTrayURI)
        throws PoddClientException, GraphUtilException {
    URI nextPotURI;
    if (potUriMap.containsKey(plantId)) {
        nextPotURI = potUriMap.get(plantId).keySet().iterator().next();
    } else {
        final Model plantIdSparqlResults = this.doSPARQL(
                String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS,
                        RenderUtils.escape(plantId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_POT)),
                Arrays.asList(nextProjectID));

        if (plantIdSparqlResults.isEmpty()) {
            this.log.debug(
                    "Could not find an existing container for pot barcode, assigning a temporary URI: {} {}",
                    plantId, nextProjectID);

            nextPotURI = RestletPoddClientImpl.vf
                    .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "pot:" + UUID.randomUUID().toString());
        } else {
            nextPotURI = GraphUtil.getUniqueSubjectURI(plantIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_POT);
        }

        ConcurrentMap<URI, URI> nextPotUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, URI> putIfAbsent2 = potUriMap.putIfAbsent(plantId, nextPotUriMap);
        if (putIfAbsent2 != null) {
            nextPotUriMap = putIfAbsent2;
        }
        nextPotUriMap.put(nextPotURI, nextTrayURI);
    }
    return nextPotURI;
}

From source file:com.github.podd.example.ExamplePoddClient.java

private void populateGenotypeUriMap(
        final ConcurrentMap<String, ConcurrentMap<URI, InferredOWLOntologyID>> projectUriMap,
        final ConcurrentMap<URI, ConcurrentMap<URI, Model>> genotypeUriMap) throws PoddClientException {
    for (final String nextProjectName : projectUriMap.keySet()) {
        final ConcurrentMap<URI, InferredOWLOntologyID> nextProjectNameMapping = projectUriMap
                .get(nextProjectName);/*w ww. ja  v  a 2s.  co m*/
        for (final URI projectUri : nextProjectNameMapping.keySet()) {
            final InferredOWLOntologyID artifactId = nextProjectNameMapping.get(projectUri);
            final Model nextSparqlResults = this.doSPARQL(
                    String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_ALL_PROPERTIES,
                            RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_GENOTYPE)),
                    Arrays.asList(artifactId));
            if (nextSparqlResults.isEmpty()) {
                this.log.debug("Could not find any existing genotypes for project: {} {}", nextProjectName,
                        projectUri);
            }

            for (final Resource nextGenotype : nextSparqlResults
                    .filter(null, RDF.TYPE, PODD.PODD_SCIENCE_GENOTYPE).subjects()) {
                if (!(nextGenotype instanceof URI)) {
                    this.log.error("Found genotype that was not assigned a URI: {} artifact={}", nextGenotype,
                            artifactId);
                } else {
                    ConcurrentMap<URI, Model> nextGenotypeMap = new ConcurrentHashMap<>();
                    final ConcurrentMap<URI, Model> putIfAbsent = genotypeUriMap.put(projectUri,
                            nextGenotypeMap);
                    if (putIfAbsent != null) {
                        nextGenotypeMap = putIfAbsent;
                    }
                    final Model putIfAbsent2 = nextGenotypeMap.putIfAbsent((URI) nextGenotype,
                            nextSparqlResults);
                    if (putIfAbsent2 != null) {
                        this.log.info(
                                "Found existing description for genotype URI within the same project: {} {}",
                                projectUri, nextGenotype);
                    }
                }
            }
        }
    }
}

From source file:com.github.podd.example.ExamplePoddClient.java

public ConcurrentMap<InferredOWLOntologyID, InferredOWLOntologyID> uploadArtifacts(
        final ConcurrentMap<InferredOWLOntologyID, Model> uploadQueue) throws PoddClientException {
    final ConcurrentMap<InferredOWLOntologyID, InferredOWLOntologyID> resultMap = new ConcurrentHashMap<>();
    for (final InferredOWLOntologyID nextUpload : uploadQueue.keySet()) {
        try {//from  w  w w.j  a  v a2  s . com
            final StringWriter writer = new StringWriter(4096);
            Rio.write(uploadQueue.get(nextUpload), writer, RDFFormat.RDFJSON);
            final InferredOWLOntologyID newID = this.appendArtifact(nextUpload,
                    new ByteArrayInputStream(writer.toString().getBytes(Charset.forName("UTF-8"))),
                    RDFFormat.RDFJSON);

            if (newID == null) {
                this.log.error("Did not find a valid result from append artifact: {}", nextUpload);
            } else if (nextUpload.equals(newID)) {
                this.log.error("Result from append artifact was not changed, as expected. {} {}", nextUpload,
                        newID);
            } else {
                resultMap.putIfAbsent(nextUpload, newID);
            }
        } catch (final RDFHandlerException e) {
            this.log.error("Found exception generating upload body: ", e);
        }
    }
    return resultMap;
}

From source file:com.github.podd.example.ExamplePoddClient.java

/**
 * @param trayUriMap//from  w  w  w. j av  a2  s  . co m
 * @param trayId
 * @param nextProjectID
 * @param nextExperimentUri
 * @return
 * @throws PoddClientException
 * @throws GraphUtilException
 */
private URI getTrayUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> trayUriMap, final String trayId,
        final InferredOWLOntologyID nextProjectID, final URI nextExperimentUri)
        throws PoddClientException, GraphUtilException {
    // Check whether trayId already has an assigned URI
    URI nextTrayURI;
    if (trayUriMap.containsKey(trayId)) {
        nextTrayURI = trayUriMap.get(trayId).keySet().iterator().next();
    } else {
        final Model trayIdSparqlResults = this.doSPARQL(
                String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS,
                        RenderUtils.escape(trayId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_TRAY)),
                Arrays.asList(nextProjectID));

        if (trayIdSparqlResults.isEmpty()) {
            this.log.debug(
                    "Could not find an existing container for tray barcode, assigning a temporary URI: {} {}",
                    trayId, nextProjectID);

            nextTrayURI = RestletPoddClientImpl.vf
                    .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "tray:" + UUID.randomUUID().toString());
        } else {
            nextTrayURI = GraphUtil.getUniqueSubjectURI(trayIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_TRAY);
        }

        ConcurrentMap<URI, URI> nextTrayUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, URI> putIfAbsent2 = trayUriMap.putIfAbsent(trayId, nextTrayUriMap);
        if (putIfAbsent2 != null) {
            nextTrayUriMap = putIfAbsent2;
        }
        nextTrayUriMap.put(nextTrayURI, nextExperimentUri);
    }
    return nextTrayURI;
}

From source file:com.github.podd.example.ExamplePoddClient.java

private void populateExperimentUriMap(
        final ConcurrentMap<String, ConcurrentMap<URI, InferredOWLOntologyID>> projectUriMap,
        final ConcurrentMap<String, ConcurrentMap<URI, URI>> experimentUriMap) throws PoddClientException {
    for (final String nextProjectName : projectUriMap.keySet()) {
        final ConcurrentMap<URI, InferredOWLOntologyID> nextProjectNameMapping = projectUriMap
                .get(nextProjectName);/*from   w  w w .  j av a  2 s.co  m*/
        for (final URI projectUri : nextProjectNameMapping.keySet()) {
            final InferredOWLOntologyID artifactId = nextProjectNameMapping.get(projectUri);
            final Model nextSparqlResults = this.doSPARQL(
                    String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE,
                            RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_EXPERIMENT)),
                    Arrays.asList(artifactId));

            if (nextSparqlResults.isEmpty()) {
                this.log.info("Could not find any existing experiments for project: {} {}", nextProjectName,
                        projectUri);
            }

            for (final Resource nextExperiment : nextSparqlResults
                    .filter(null, RDF.TYPE, PODD.PODD_SCIENCE_EXPERIMENT).subjects()) {
                if (!(nextExperiment instanceof URI)) {
                    this.log.error("Found experiment that was not assigned a URI: {} artifact={}",
                            nextExperiment, artifactId);
                } else {
                    final Model label = nextSparqlResults.filter(nextExperiment, RDFS.LABEL, null);

                    // DebugUtils.printContents(label);

                    if (label.isEmpty()) {
                        this.log.error("Experiment did not have a label: {} {}", artifactId, nextExperiment);
                    } else {
                        for (final Value nextLabel : label.objects()) {
                            if (!(nextLabel instanceof Literal)) {
                                this.log.error("Project had a non-literal label: {} {} {}", artifactId,
                                        nextExperiment, nextLabel);
                            } else {
                                String nextLabelString = nextLabel.stringValue();

                                // take off any descriptions and leave the
                                // project number behind
                                nextLabelString = nextLabelString.split(" ")[0];

                                final Matcher matcher = ExampleSpreadsheetConstants.REGEX_EXPERIMENT
                                        .matcher(nextLabelString);

                                if (!matcher.matches()) {
                                    this.log.error(
                                            "Found experiment label that did not start with expected format: {}",
                                            nextLabel);
                                } else {
                                    this.log.debug(
                                            "Found experiment label with the expected format: '{}' original=<{}>",
                                            nextLabelString, nextLabel);

                                    final int nextProjectYear = Integer.parseInt(matcher.group(1));
                                    final int nextProjectNumber = Integer.parseInt(matcher.group(2));
                                    final int nextExperimentNumber = Integer.parseInt(matcher.group(3));

                                    nextLabelString = String.format(
                                            ExampleSpreadsheetConstants.TEMPLATE_EXPERIMENT, nextProjectYear,
                                            nextProjectNumber, nextExperimentNumber);

                                    this.log.debug("Reformatted experiment label to: '{}' original=<{}>",
                                            nextLabelString, nextLabel);

                                    ConcurrentMap<URI, URI> labelMap = new ConcurrentHashMap<>();
                                    final ConcurrentMap<URI, URI> putIfAbsent = experimentUriMap
                                            .putIfAbsent(nextLabelString, labelMap);
                                    if (putIfAbsent != null) {
                                        this.log.error(
                                                "Found duplicate experiment name, inconsistent results may follow: {} {} {}",
                                                artifactId, nextExperiment, nextLabel);
                                        // Overwrite our reference with the one that already
                                        // existed
                                        labelMap = putIfAbsent;
                                    }
                                    final URI existingProject = labelMap.putIfAbsent((URI) nextExperiment,
                                            projectUri);
                                    // Check for the case where project name maps to different
                                    // artifacts
                                    if (existingProject != null && !existingProject.equals(projectUri)) {
                                        this.log.error(
                                                "Found duplicate experiment name across different projects, inconsistent results may follow: {} {} {} {}",
                                                artifactId, existingProject, projectUri, nextLabel);
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }
    }
}

From source file:com.github.podd.example.ExamplePoddClient.java

/**
 * Gets a material URI matching the given pot and genotype URIs, creating a new entry if
 * necessary and giving it a temporary URI.
 * //from www . j av  a  2s  .  co  m
 * @param materialUriMap
 * @param nextProjectID
 * @param nextPotUri
 * @return
 */
private URI getMaterialUri(final ConcurrentMap<URI, ConcurrentMap<URI, Model>> materialUriMap,
        final URI nextGenotypeUri, final InferredOWLOntologyID nextProjectID, final URI nextPotUri,
        final String potNumber, final String lineNumber, final String control) {
    URI nextMaterialURI = null;
    if (materialUriMap.containsKey(nextPotUri)) {
        final ConcurrentMap<URI, Model> nextPotMaterialMap = materialUriMap.get(nextPotUri);

        for (final URI existingMaterialURI : nextPotMaterialMap.keySet()) {
            final Model nextModel = nextPotMaterialMap.get(existingMaterialURI);

            if (nextModel.contains(existingMaterialURI, PODD.PODD_SCIENCE_REFERS_TO_GENOTYPE,
                    nextGenotypeUri)) {
                nextMaterialURI = existingMaterialURI;
            } else {
                this.log.debug("Did not find any materials with the given genotype in this pot: {} {}",
                        nextPotUri, nextGenotypeUri);
            }
        }
    }

    // If no material was found, then create a new description and assign it a temporary URI
    if (nextMaterialURI == null) {
        this.log.debug(
                "Could not find an existing material for description provided, assigning a temporary URI: {} {} {}",
                nextProjectID, nextPotUri, nextGenotypeUri);

        nextMaterialURI = RestletPoddClientImpl.vf
                .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "material:" + UUID.randomUUID().toString());

        final Model newModel = new LinkedHashModel();
        newModel.add(nextPotUri, PODD.PODD_SCIENCE_HAS_MATERIAL, nextMaterialURI);
        newModel.add(nextMaterialURI, RDF.TYPE, PODD.PODD_SCIENCE_MATERIAL);

        newModel.add(nextMaterialURI, RDFS.LABEL, RestletPoddClientImpl.vf
                .createLiteral("Material for pot " + potNumber + " containing line " + lineNumber));
        newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_REFERS_TO_GENOTYPE, nextGenotypeUri);
        if (control.equalsIgnoreCase("Yes")) {
            newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_YES);
        } else if (control.equalsIgnoreCase("No")) {
            newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_NO);
        } else {
            this.log.warn("Did not recognise control label: {} (should be Yes or No", control);
            newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_UNKNOWN);
        }

        ConcurrentMap<URI, Model> nextGenotypeUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, Model> putIfAbsent = materialUriMap.putIfAbsent(nextPotUri,
                nextGenotypeUriMap);
        if (putIfAbsent != null) {
            nextGenotypeUriMap = putIfAbsent;
        }
        final Model putIfAbsent2 = nextGenotypeUriMap.putIfAbsent(nextMaterialURI, newModel);
        if (putIfAbsent2 != null) {
            this.log.error("ERROR: Generated two temporary Material URIs that were identical! : {} {}",
                    nextPotUri, nextMaterialURI);
        }
    }
    return nextMaterialURI;

}

From source file:com.github.podd.example.ExamplePoddClient.java

/**
 * Gets a genotype URI matching the given genus, species, and plantName (line) from the given
 * cache, creating a new entry if necessary and giving it a temporary URI.
 * // www  .j  a va 2  s  .c  om
 * @param genotypeUriMap
 * @param genus
 * @param species
 * @param plantName
 * @param control
 * @param nextProjectID
 * @param nextProjectUri
 * @return
 */
private URI getGenotypeUri(final ConcurrentMap<URI, ConcurrentMap<URI, Model>> genotypeUriMap,
        final String genus, final String species, final String plantName, final String plantLineNumber,
        final String control, final InferredOWLOntologyID nextProjectID, final URI nextProjectUri) {
    URI nextGenotypeURI = null;
    if (genotypeUriMap.containsKey(nextProjectUri)) {
        final ConcurrentMap<URI, Model> nextProjectGenotypeMap = genotypeUriMap.get(nextProjectUri);

        for (final URI existingGenotypeURI : nextProjectGenotypeMap.keySet()) {
            final Model nextModel = nextProjectGenotypeMap.get(existingGenotypeURI);

            if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_GENUS,
                    RestletPoddClientImpl.vf.createLiteral(genus))) {
                if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_SPECIES,
                        RestletPoddClientImpl.vf.createLiteral(species))) {
                    if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE,
                            RestletPoddClientImpl.vf.createLiteral(plantName))) {
                        nextGenotypeURI = existingGenotypeURI;
                        break;
                    } else {
                        this.log.debug(
                                "Did not find any genotypes with the given genus and species and line in this project: {} {} {} {}",
                                nextProjectUri, genus, species, plantName);
                    }
                } else {
                    this.log.debug(
                            "Did not find any genotypes with the given genus and species in this project: {} {} {}",
                            nextProjectUri, genus, species);
                }
            } else {
                this.log.debug("Did not find any genotypes with the given genus in this project: {} {}",
                        nextProjectUri, genus);
            }
        }
    }

    // If no genotype was found, then create a new description and assign it a temporary URI
    if (nextGenotypeURI == null) {
        this.log.debug(
                "Could not find an existing genotype for description provided, assigning a temporary URI: {} {} {} {}",
                nextProjectID, genus, species, plantName);

        nextGenotypeURI = RestletPoddClientImpl.vf.createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX
                + "genotype:" + plantLineNumber + ":" + UUID.randomUUID().toString());

        final Model newModel = new LinkedHashModel();
        newModel.add(nextProjectUri, PODD.PODD_SCIENCE_HAS_GENOTYPE, nextGenotypeURI);
        newModel.add(nextGenotypeURI, RDF.TYPE, PODD.PODD_SCIENCE_GENOTYPE);
        newModel.add(nextGenotypeURI, RDFS.LABEL,
                RestletPoddClientImpl.vf.createLiteral(genus + " " + species + " (" + plantName + ")"));
        newModel.add(nextGenotypeURI, RDFS.COMMENT, RestletPoddClientImpl.vf.createLiteral("Plant line in : "
                + genus + " " + species + " named, " + plantName + " : labelled as number " + plantLineNumber));
        newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_GENUS,
                RestletPoddClientImpl.vf.createLiteral(genus));
        newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_SPECIES,
                RestletPoddClientImpl.vf.createLiteral(species));
        newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE,
                RestletPoddClientImpl.vf.createLiteral(plantName));
        newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE_NUMBER,
                RestletPoddClientImpl.vf.createLiteral(plantLineNumber));

        ConcurrentMap<URI, Model> nextGenotypeUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, Model> putIfAbsent = genotypeUriMap.putIfAbsent(nextProjectUri,
                nextGenotypeUriMap);
        if (putIfAbsent != null) {
            nextGenotypeUriMap = putIfAbsent;
        }
        final Model putIfAbsent2 = nextGenotypeUriMap.putIfAbsent(nextGenotypeURI, newModel);
        if (putIfAbsent2 != null) {
            this.log.error("ERROR: Generated two temporary Genotype URIs that were identical! : {} {}",
                    nextProjectUri, nextGenotypeURI);
        }
    }
    return nextGenotypeURI;

}

From source file:com.fhzz.dubbo.sync.RegistryServerSync.java

@PostConstruct
public void start() {
    registry.subscribe(SUBSCRIBE, new NotifyListener() {
        @Override/*from   ww  w.  j a  va 2  s  .c om*/
        //  ???override?subcribe?route?Provider????
        public void notify(List<URL> urls) {
            if (urls == null || urls.isEmpty()) {
                return;
            }
            // Map<category, Map<servicename, Map<Long, URL>>>
            final Map<String, Map<String, Map<Long, URL>>> categories = new HashMap<String, Map<String, Map<Long, URL>>>();
            for (URL url : urls) {
                String category = url.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
                if (Constants.EMPTY_PROTOCOL.equalsIgnoreCase(url.getProtocol())) { // ?empty??groupversion*
                    ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category);
                    if (services != null) {
                        String group = url.getParameter(Constants.GROUP_KEY);
                        String version = url.getParameter(Constants.VERSION_KEY);
                        // ?empty??groupversion*
                        if (!Constants.ANY_VALUE.equals(group) && !Constants.ANY_VALUE.equals(version)) {
                            services.remove(url.getServiceKey());
                        } else {
                            for (Map.Entry<String, Map<Long, URL>> serviceEntry : services.entrySet()) {
                                String service = serviceEntry.getKey();
                                if (Tool.getInterface(service).equals(url.getServiceInterface())
                                        && (Constants.ANY_VALUE.equals(group)
                                                || StringUtils.isEquals(group, Tool.getGroup(service)))
                                        && (Constants.ANY_VALUE.equals(version)
                                                || StringUtils.isEquals(version, Tool.getVersion(service)))) {
                                    services.remove(service);
                                }
                            }
                        }
                    }
                } else {
                    Map<String, Map<Long, URL>> services = categories.get(category);
                    if (services == null) {
                        services = new HashMap<String, Map<Long, URL>>();
                        categories.put(category, services);
                    }
                    String service = url.getServiceKey();
                    Map<Long, URL> ids = services.get(service);
                    if (ids == null) {
                        ids = new HashMap<Long, URL>();
                        services.put(service, ids);
                    }
                    ids.put(ID.incrementAndGet(), url);
                }
            }
            for (Map.Entry<String, Map<String, Map<Long, URL>>> categoryEntry : categories.entrySet()) {
                String category = categoryEntry.getKey();
                ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category);
                if (services == null) {
                    services = new ConcurrentHashMap<String, Map<Long, URL>>();
                    registryCache.put(category, services);
                }
                services.putAll(categoryEntry.getValue());
            }
        }
    });
}

From source file:com.github.podd.example.ExamplePoddClient.java

/**
 * @param projectUriMap/* w  ww.  j av a  2s. c  o  m*/
 * @param baseProjectName
 * @return
 * @throws PoddClientException
 */
private Map<URI, InferredOWLOntologyID> getProjectDetails(
        final ConcurrentMap<String, ConcurrentMap<URI, InferredOWLOntologyID>> projectUriMap,
        final String baseProjectName) throws PoddClientException {
    if (!projectUriMap.containsKey(baseProjectName)) {
        this.log.error("Did not find an existing project for a line in the CSV file: {}", baseProjectName);

        // TODO: Create a new project?
        // return;

        throw new PoddClientException(
                "Did not find an existing project for a line in the CSV file: " + baseProjectName);
    }

    return projectUriMap.get(baseProjectName);
}