Example usage for com.google.common.collect Multimap asMap

List of usage examples for com.google.common.collect Multimap asMap

Introduction

In this page you can find the example usage for com.google.common.collect Multimap asMap.

Prototype

Map<K, Collection<V>> asMap();

Source Link

Document

Returns a view of this multimap as a Map from each distinct key to the nonempty collection of that key's associated values.

Usage

From source file:de.dentrassi.pm.storage.service.jpa.StorageHandlerImpl.java

protected Set<ArtifactInformation> getArtifacts(final ChannelEntity channel) {
    final Multimap<String, String> childs = loadChildMap(channel);
    return Profile.call(this, "getArtifacts", () -> getArtifactsHelper(channel,
            (ae, props) -> StreamServiceHelper.convert(ae, props, childs.asMap())));
}

From source file:de.hzi.helmholtz.Compare.PathwayComparisonUsingModules.java

public Multimap<Double, String> SubsetIdentification(PathwayUsingModules firstPathway,
        PathwayUsingModules secondPathway, BiMap<String, Integer> newSourceGeneIdToPositionMap,
        BiMap<String, Integer> newTargetGeneIdToPositionMap, int Yes) {
    Multimap<Double, String> result = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural());

    Iterator<Module> sourceGeneIt = firstPathway.geneIterator();
    int currentQueryGene = 0;
    while (sourceGeneIt.hasNext()) {
        currentQueryGene++;/*from   w  ww  .  j a  v  a2s .  co m*/
        Module queryGene = sourceGeneIt.next();
        Multimap<Integer, String> resultr = TreeMultimap.create(Ordering.natural(), Ordering.natural());
        int currentTargetGene = 0;
        Multiset<String> qfunction = LinkedHashMultiset.create();
        List<String> qfunctionList = new ArrayList<String>();
        List<String> qactivity = new ArrayList<String>();
        List<Set<String>> qsubstrate = new ArrayList<Set<String>>();
        for (Domain d : queryGene.getDomains()) {
            qfunction.add(d.getDomainFunctionString());
            qfunctionList.add(d.getDomainFunctionString());
            qactivity.add(d.getStatus().toString());
            qsubstrate.add(d.getSubstrates());
        }
        List<String> TargenesSelected = new ArrayList<String>();
        Iterator<Module> targetGeneIt = secondPathway.geneIterator();
        while (targetGeneIt.hasNext()) {
            currentTargetGene++;
            Module targetGene = targetGeneIt.next();
            Multiset<String> tfunction = LinkedHashMultiset.create();
            List<String> tactivity = new ArrayList<String>();
            List<Set<String>> tsubstrate = new ArrayList<Set<String>>();
            List<String> tfunctionList = new ArrayList<String>();
            Iterator<Domain> dIter = targetGene.domainIterator();
            while (dIter.hasNext()) {
                Domain d = dIter.next();
                tfunction.add(d.getDomainFunctionString());
                tfunctionList.add(d.getDomainFunctionString());
                tactivity.add(d.getStatus().toString());
                tsubstrate.add(d.getSubstrates());
            }
            Multiset<String> DomainsCovered = Multisets.intersection(qfunction, tfunction);
            int Differences = Math.max(Math.abs(DomainsCovered.size() - tfunction.size()),
                    Math.abs(DomainsCovered.size() - qfunction.size()));
            if (DomainsCovered.size() == tfunction.size() && tfunction.size() > 4) {
                TargenesSelected.add(Integer.toString(currentTargetGene));
            } else {
                resultr.put(Differences, Integer.toString(currentTargetGene));
            }

        }
        int count = 0;
        if (resultr.size() > 0) {
            int tsize = 0;
            if ((firstPathway.size() > 8 && firstPathway.size() < 10)
                    || (secondPathway.size() > 8 && secondPathway.size() < 10)) {
                tsize = 2;
            } else if ((firstPathway.size() > 2 && firstPathway.size() < 8)
                    && (secondPathway.size() > 2 && secondPathway.size() < 8)) {
                tsize = 4;
            } else {
                tsize = 1;
            }
            while (TargenesSelected.size() < tsize) {
                Multiset<String> k = LinkedHashMultiset.create(resultr.values());
                Multiset<String> t = LinkedHashMultiset.create(TargenesSelected);
                Multiset<String> Covered = Multisets.intersection(k, t);
                if (Covered.size() == k.size()) {
                    break;
                }

                try {
                    TargenesSelected.addAll(
                            resultr.get(Integer.parseInt(resultr.keySet().toArray()[count].toString())));
                } catch (Exception ds) {
                }
                count = count + 1;
            }
        }
        // ////System.out.println(TargenesSelected);
        //  Permutation perm = new Permutation();
        //  List<String> perms = perm.run(TargenesSelected);
        CombinationGenerator c = new CombinationGenerator(10, 10);
        List<String> perms = c.GenerateAllPossibleCombinations(TargenesSelected);
        myFunction sim = new myFunction();
        double score = 0;
        String targetIdentified = "";
        List<Module> targetGenesList = secondPathway.getModules();
        for (String permu : perms) {
            String[] values = permu.replace("[", "").replace("]", "").split(",");
            List<String> mergedTargetgenes = new ArrayList<String>();
            List<Integer> ToRemove = new ArrayList<Integer>();
            List<String> tactivity = new ArrayList<String>();
            List<Set<String>> tsubstrate = new ArrayList<Set<String>>();
            for (String j : values) {
                ToRemove.add(Integer.parseInt(j.trim()));
                for (Domain i : targetGenesList.get(Integer.parseInt(j.trim()) - 1).getDomains()) {

                    mergedTargetgenes.add(i.getDomainFunctionString());
                    tactivity.add(i.getStatus().toString());
                    tsubstrate.add(i.getSubstrates());
                }
            }
            Multimap<Double, Multimap<String, Integer>> FunctionScores = sim.calculate(qfunctionList,
                    mergedTargetgenes);
            Multimap<Double, Multimap<String, Integer>> activityscores = myFunction.calculate(qactivity,
                    tactivity);
            Multimap<Double, Multimap<String, Integer>> substratescores = myFunction
                    .calculate(getSubstrateList(qsubstrate), getSubstrateList(tsubstrate));
            Object FunctionScore = FunctionScores.asMap().keySet().toArray()[0];
            Object activityScore = activityscores.asMap().keySet().toArray()[0];
            Object substrateScore = substratescores.asMap().keySet().toArray()[0];

            double finalScore = Math
                    .round((((2.9 * Double.parseDouble(FunctionScore.toString().trim()))
                            + (0.05 * Double.parseDouble(activityScore.toString().trim()))
                            + (0.05 * Double.parseDouble(substrateScore.toString().trim()))) / 3) * 100.0)
                    / 100.0;
            targetIdentified = permu.replace(",", "+");
            String ConvertedGeneIDs = "";
            if (Yes == 0) {
                ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene),
                        newSourceGeneIdToPositionMap) + "->"
                        + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""),
                                newTargetGeneIdToPositionMap);
            } else {
                ConvertedGeneIDs = reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""),
                        newTargetGeneIdToPositionMap) + "->"
                        + reconstructWithGeneId(Integer.toString(currentQueryGene),
                                newSourceGeneIdToPositionMap);
            }
            // String ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap) + "->" + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""), newTargetGeneIdToPositionMap);

            result.put(finalScore, ConvertedGeneIDs);

            ScoreFunctionMatchMisMatch.putAll(ConvertedGeneIDs, FunctionScores.values());
            ScoreStatusMatchMisMatch.putAll(ConvertedGeneIDs, activityscores.values());
            ScoreSubstrateMatchMisMatch.putAll(ConvertedGeneIDs, substratescores.values());

        }

    }
    return result;
}

From source file:com.facebook.buck.android.apkmodule.APKModuleGraph.java

/**
 * Loop through each of the targets we visited while generating seed modules: If the are exclusive
 * to that module, add them to that module. If they are not exclusive to that module, find or
 * create an appropriate shared module and fill out its dependencies
 *
 * @param apkModuleGraph the current graph we're building
 * @param targetToContainingApkModulesMap the targets mapped to the seed targets they are
 *     reachable from//from w w w. j ava2  s  .  co  m
 */
private void generateSharedModules(MutableDirectedGraph<APKModule> apkModuleGraph,
        Multimap<BuildTarget, String> targetToContainingApkModulesMap) {

    // Sort the module-covers of all targets to determine shared module names.
    TreeSet<TreeSet<String>> sortedContainingModuleSets = new TreeSet<>(new Comparator<TreeSet<String>>() {
        @Override
        public int compare(TreeSet<String> left, TreeSet<String> right) {
            int sizeDiff = left.size() - right.size();
            if (sizeDiff != 0) {
                return sizeDiff;
            }
            Iterator<String> leftIter = left.iterator();
            Iterator<String> rightIter = right.iterator();
            while (leftIter.hasNext()) {
                String leftElement = leftIter.next();
                String rightElement = rightIter.next();
                int stringComparison = leftElement.compareTo(rightElement);
                if (stringComparison != 0) {
                    return stringComparison;
                }
            }
            return 0;
        }
    });
    for (Map.Entry<BuildTarget, Collection<String>> entry : targetToContainingApkModulesMap.asMap()
            .entrySet()) {
        TreeSet<String> containingModuleSet = new TreeSet<>(entry.getValue());
        sortedContainingModuleSets.add(containingModuleSet);
    }

    // build modules based on all entries.
    Map<ImmutableSet<String>, APKModule> combinedModuleHashToModuleMap = new HashMap<>();
    int currentId = 0;
    for (TreeSet<String> moduleCover : sortedContainingModuleSets) {
        String moduleName = moduleCover.size() == 1 ? moduleCover.iterator().next() : "shared" + currentId++;
        APKModule module = APKModule.of(moduleName, modulesWithResources.contains(moduleName));
        combinedModuleHashToModuleMap.put(ImmutableSet.copyOf(moduleCover), module);
    }

    // add Targets per module;
    for (Map.Entry<BuildTarget, Collection<String>> entry : targetToContainingApkModulesMap.asMap()
            .entrySet()) {
        ImmutableSet<String> containingModuleSet = ImmutableSet.copyOf(entry.getValue());
        for (Map.Entry<ImmutableSet<String>, APKModule> existingEntry : combinedModuleHashToModuleMap
                .entrySet()) {
            if (existingEntry.getKey().equals(containingModuleSet)) {
                getBuildTargets(existingEntry.getValue()).add(entry.getKey());
                break;
            }
        }
    }

    // Find the seed modules and add them to the graph
    Map<String, APKModule> seedModules = new HashMap<>();
    for (Map.Entry<ImmutableSet<String>, APKModule> entry : combinedModuleHashToModuleMap.entrySet()) {
        if (entry.getKey().size() == 1) {
            APKModule seed = entry.getValue();
            apkModuleGraph.addNode(seed);
            seedModules.put(entry.getKey().iterator().next(), seed);
            apkModuleGraph.addEdge(seed, rootAPKModuleSupplier.get());
        }
    }

    // Find the shared modules and add them to the graph
    for (Map.Entry<ImmutableSet<String>, APKModule> entry : combinedModuleHashToModuleMap.entrySet()) {
        if (entry.getKey().size() > 1) {
            APKModule shared = entry.getValue();
            apkModuleGraph.addNode(shared);
            apkModuleGraph.addEdge(shared, rootAPKModuleSupplier.get());
            for (String seedName : entry.getKey()) {
                apkModuleGraph.addEdge(seedModules.get(seedName), shared);
            }
        }
    }
}

From source file:eu.itesla_project.modules.topo.TopologyHistory.java

private boolean fixBranchesAlwaysDisconnectAtOneSide(int iteration, Network network) {
    // avoid branches always disconnected at one side => connect it to an isolated bus on disconnected side
    Multimap<String, String> branch2substations = HashMultimap.create();
    for (TopologyChoice topologyChoice : topologyChoices) {
        for (PossibleTopology possibleTopology : topologyChoice.getPossibleTopologies()) {
            for (PossibleTopology.Substation substation : possibleTopology.getMetaSubstation()
                    .getSubstations()) {
                for (PossibleTopology.Bus bus : substation.getBuses()) {
                    for (PossibleTopology.Equipment eq : bus.getEquipments()) {
                        if (eq.isBranch(false)) {
                            branch2substations.put(eq.getId(), substation.getId());
                        }//from   w w  w.ja  v  a  2 s.  c  o  m
                    }
                }
            }
        }
    }
    Set<String> branchesAlwaysDisconnectedAtOneSide = new HashSet<>();
    Multimap<String, String> substation2branches = HashMultimap.create();
    for (Map.Entry<String, Collection<String>> entry : branch2substations.asMap().entrySet()) {
        String branchId = entry.getKey();
        if (entry.getValue().size() == 1) {
            String substationId = entry.getValue().iterator().next();
            TwoTerminalsConnectable branch = network.getLine(branchId);
            if (branch == null) {
                branch = network.getTwoWindingsTransformer(branchId);
            }
            if (branch == null) {
                throw new RuntimeException();
            }
            if (branch.getTerminal1().getVoltageLevel() != branch.getTerminal2().getVoltageLevel()) {
                String otherSubstationId;
                if (branch.getTerminal1().getVoltageLevel().getId().equals(substationId)) {
                    otherSubstationId = branch.getTerminal2().getVoltageLevel().getId();
                } else if (branch.getTerminal2().getVoltageLevel().getId().equals(substationId)) {
                    otherSubstationId = branch.getTerminal1().getVoltageLevel().getId();
                } else {
                    throw new RuntimeException();
                }
                substation2branches.put(otherSubstationId, branchId);
                branchesAlwaysDisconnectedAtOneSide.add(branchId);
            }
        }
    }

    for (TopologyChoice topologyChoice : topologyChoices) {
        for (PossibleTopology possibleTopology : topologyChoice.getPossibleTopologies()) {
            for (PossibleTopology.Substation substation : possibleTopology.getMetaSubstation()
                    .getSubstations()) {
                if (substation2branches.containsKey(substation.getId())) {
                    VoltageLevel vl = network.getVoltageLevel(substation.getId());
                    for (String branchId : substation2branches.asMap().get(substation.getId())) {
                        PossibleTopology.Equipment eq = new PossibleTopology.Equipment(branchId);
                        Connectable obj = vl.getConnectable(eq.getId(), Connectable.class);
                        eq.setType(obj.getType());
                        substation.getBuses().add(new PossibleTopology.Bus(eq));
                    }
                }
            }
        }
    }
    if (branchesAlwaysDisconnectedAtOneSide.size() > 0) {
        LOGGER.debug(
                "Iteration {}: {} branches are always disconnected at one side, a fictive bus (isolated) has been added to disconnected side",
                iteration, branchesAlwaysDisconnectedAtOneSide.size());
        LOGGER.trace("Iteration {}: detailed list of branches always disconnected at one side: {}", iteration,
                branchesAlwaysDisconnectedAtOneSide);
        return true;
    }
    return false;
}

From source file:com.medallia.spider.api.DynamicInputImpl.java

/**
 * Creates a new {@link DynamicInputImpl}
 * @param request from which to read the request parameters
 *//*w  w w .  ja  v  a 2s. c  o m*/
public DynamicInputImpl(HttpServletRequest request) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> reqParams = Maps.newHashMap(request.getParameterMap());
    this.inputParams = reqParams;
    if (ServletFileUpload.isMultipartContent(request)) {
        this.fileUploads = Maps.newHashMap();
        Multimap<String, String> inputParamsWithList = ArrayListMultimap.create();

        ServletFileUpload upload = new ServletFileUpload();
        try {
            FileItemIterator iter = upload.getItemIterator(request);
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String fieldName = item.getFieldName();
                InputStream stream = item.openStream();
                if (item.isFormField()) {
                    inputParamsWithList.put(fieldName, Streams.asString(stream, Charsets.UTF_8.name()));
                } else {
                    final String filename = item.getName();
                    final byte[] bytes = ByteStreams.toByteArray(stream);
                    fileUploads.put(fieldName, new UploadedFile() {
                        @Override
                        public String getFilename() {
                            return filename;
                        }

                        @Override
                        public byte[] getBytes() {
                            return bytes;
                        }

                        @Override
                        public int getSize() {
                            return bytes.length;
                        }
                    });
                }
            }
            for (Entry<String, Collection<String>> entry : inputParamsWithList.asMap().entrySet()) {
                inputParams.put(entry.getKey(), entry.getValue().toArray(new String[0]));
            }
        } catch (IOException | FileUploadException e) {
            throw new IllegalArgumentException("Failed to parse multipart", e);
        }
    } else {
        this.fileUploads = Collections.emptyMap();
    }
}

From source file:alluxio.job.load.LoadDefinition.java

@Override
public Map<WorkerInfo, ArrayList<LoadTask>> selectExecutors(LoadConfig config,
        List<WorkerInfo> jobWorkerInfoList, JobMasterContext jobMasterContext) throws Exception {
    Map<String, WorkerInfo> jobWorkersByAddress = jobWorkerInfoList.stream()
            .collect(Collectors.toMap(info -> info.getAddress().getHost(), info -> info));
    // Filter out workers which have no local job worker available.
    List<String> missingJobWorkerHosts = new ArrayList<>();
    List<BlockWorkerInfo> workers = new ArrayList<>();
    for (BlockWorkerInfo worker : AlluxioBlockStore.create().getAllWorkers()) {
        if (jobWorkersByAddress.containsKey(worker.getNetAddress().getHost())) {
            workers.add(worker);//from www. j a va  2  s .c om
        } else {
            LOG.warn("Worker on host {} has no local job worker", worker.getNetAddress().getHost());
            missingJobWorkerHosts.add(worker.getNetAddress().getHost());
        }
    }
    // Mapping from worker to block ids which that worker is supposed to load.
    Multimap<WorkerInfo, LoadTask> assignments = LinkedListMultimap.create();
    AlluxioURI uri = new AlluxioURI(config.getFilePath());
    for (FileBlockInfo blockInfo : mFileSystem.getStatus(uri).getFileBlockInfos()) {
        List<String> workersWithoutBlock = getWorkersWithoutBlock(workers, blockInfo);
        int neededReplicas = config.getReplication() - blockInfo.getBlockInfo().getLocations().size();
        if (workersWithoutBlock.size() < neededReplicas) {
            String missingJobWorkersMessage = "";
            if (!missingJobWorkerHosts.isEmpty()) {
                missingJobWorkersMessage = ". The following workers could not be used because they have "
                        + "no local job workers: " + missingJobWorkerHosts;
            }
            throw new FailedPreconditionException(String.format(
                    "Failed to find enough block workers to replicate to. Needed %s but only found %s. "
                            + "Available workers without the block: %s" + missingJobWorkersMessage,
                    neededReplicas, workersWithoutBlock.size(), workersWithoutBlock));
        }
        Collections.shuffle(workersWithoutBlock);
        for (int i = 0; i < neededReplicas; i++) {
            String address = workersWithoutBlock.get(i);
            WorkerInfo jobWorker = jobWorkersByAddress.get(address);
            assignments.put(jobWorker, new LoadTask(blockInfo.getBlockInfo().getBlockId()));
        }
    }
    return SerializationUtils.makeValuesSerializable(assignments.asMap());
}

From source file:org.eclipse.xtext.validation.impl.ConcreteSyntaxConstraintProvider.java

protected List<ISyntaxConstraint> createSummarizedAssignments(CompoundElement group,
        List<AbstractElement> candidates, EClass semanticType, boolean optional) {
    Multimap<String, Assignment> feature2ass = HashMultimap.create();
    Multimap<String, AbstractElement> feature2child = HashMultimap.create();
    for (AbstractElement c : candidates) {
        TreeIterator<EObject> i = EcoreUtil2.eAll(c);
        while (i.hasNext()) {
            EObject obj = i.next();// www .  ja  v a  2s .  c  o m
            if (obj instanceof RuleCall || obj instanceof Action || obj instanceof Alternatives)
                return Lists.newArrayList();
            else if (obj instanceof Group) {
                Set<String> names = Sets.newHashSet();
                for (Assignment ass : EcoreUtil2.getAllContentsOfType(obj, Assignment.class))
                    names.add(ass.getFeature());
                if (names.size() > 1)
                    i.prune();
            } else if (obj instanceof Assignment) {
                Assignment a = (Assignment) obj;
                feature2ass.put(a.getFeature(), a);
                feature2child.put(a.getFeature(), c);
                i.prune();
            }
        }
    }
    List<ISyntaxConstraint> result = Lists.newArrayList();
    for (Map.Entry<String, Collection<Assignment>> ent : feature2ass.asMap().entrySet()) {
        if (ent.getValue().size() < 2 || feature2child.get(ent.getKey()).size() < 2)
            continue;
        int required = 0, multiplies = 0;
        for (Assignment assignment : ent.getValue()) {
            AbstractElement e = assignment;
            while (e != group)
                if (isMultipleCardinality(e)) {
                    multiplies++;
                    break;
                } else
                    e = (AbstractElement) e.eContainer();
            e = assignment;
            while (e != group)
                if (isOptionalCardinality(e))
                    break;
                else
                    e = (AbstractElement) e.eContainer();
            if (e == group)
                required++;
        }
        if (required > 1 || multiplies < 1)
            continue;
        candidates.removeAll(feature2child.get(ent.getKey()));
        optional = optional || required < 1;
        result.add(createElement(ConstraintType.ASSIGNMENT, ent.getValue().iterator().next(), semanticType,
                true, optional));
    }
    return result;
}

From source file:com.gdn.x.ui.controller.Evaluation.ScoringWeightController.java

@RequestMapping(value = { "/run-all-evaluation" }, method = RequestMethod.GET)
public ModelAndView runAllGoldenListEvaluation() {
    ModelAndView modelAndView = new ModelAndView();

    List<List<String>> listActualId = new ArrayList<List<String>>();
    List<List<String>> listExpectedId = new ArrayList<List<String>>();
    List<String> RecallCoordinate = Arrays.asList("0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8",
            "0.9", "1.0");
    Multimap<String, List<Double>> listQueryAndPrecision = ArrayListMultimap.create();

    for (int i = 0; i < 20; i++) {
        String parameter = contentGoldenListService.listContentGoldenList().get(i).getQuery();
        String timeStamp = contentGoldenListService.listContentGoldenList().get(i).getTimeStamp();
        try {//  www .j  a va2s .c om
            listActualId.add(searchByQueryEvaluation(parameter));
        } catch (MalformedURLException ex) {
            Logger.getLogger(CommonControllerEvaluation.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SolrServerException ex) {
            Logger.getLogger(CommonControllerEvaluation.class.getName()).log(Level.SEVERE, null, ex);
        }
        listExpectedId.add(contentGoldenListService
                .findContentGoldenListByQueryAndTimeStamp(parameter, timeStamp).get(0).getExpectedResult());
        listQueryAndPrecision.put(parameter, listInterpolatedPrecision(listExpectedId, listActualId).get(i));
    }

    //Method to save parameterWeight To Mongo
    //        SaveParameterWeightToMongo(listExpectedId, listActualId);
    modelAndView.addObject("listParameterWeight", parameterWeightService.findAll());
    //weight Parameter
    modelAndView.addObject("MapList", getParameter());
    // Average precision
    modelAndView.addObject("precisionCoordinate", interpolateAveragePrecision(listExpectedId, listActualId));
    modelAndView.addObject("recallCoordinate", RecallCoordinate);
    //        SaveCoordinateToMongo(interpolateAveragePrecision(listExpectedId, listActualId));
    modelAndView.addObject("listQueryAndPrecision", listQueryAndPrecision.asMap());
    modelAndView.addObject("finalAverage", finalScoreInterpolatedPrecision(listExpectedId, listActualId));
    modelAndView.setViewName("evaluation/field-list");
    return modelAndView;

}

From source file:elaborate.editor.publish.PublishTask.java

private void exportPojectData(List<EntryData> entryData, Map<Long, List<String>> thumbnails,
        Multimap<String, AnnotationIndexData> annotationIndex) {
    File json = new File(jsonDir, "config.json");
    EntityManager entityManager = HibernateUtil.getEntityManager();
    Project project = entityManager.find(Project.class, projectId);
    Map<String, Object> projectData = getProjectData(project, entryData, thumbnails);
    List<String> projectEntryMetadataFields = settings.getProjectEntryMetadataFields();
    projectData.put("entryMetadataFields", projectEntryMetadataFields);
    projectData.put("generated", new Date().getTime());
    cnwKludge(project, projectData, projectEntryMetadataFields);

    entityManager.close();//from w  ww .ja  v  a2  s  .c o  m
    exportJson(json, projectData);

    json = new File(jsonDir, ANNOTATION_INDEX_JSON);
    exportJson(json, annotationIndex.asMap());

    // String indexfilename = "index-" + settings.getProjectType() + ".html.ftl";
    String indexfilename = "index.html.ftl";
    File destIndex = new File(distDir, "index.html");
    String projectType = settings.getProjectType();
    Configuration configuration = Configuration.instance();
    String version = configuration.getSetting("publication.version." + projectType);
    String cdnBaseURL = configuration.getSetting("publication.cdn");
    Map<String, Object> fmRootMap = ImmutableMap.of(//
            "BASE_URL", projectData.get("baseURL"), //
            "TYPE", projectType, //
            "ELABORATE_CDN", cdnBaseURL, //
            "VERSION", version//
    );
    FreeMarker.templateToFile(indexfilename, destIndex, fmRootMap, getClass());
}

From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService.java

@Override
public void delete(String tableName, Multimap<Cell, Long> keys) {
    Map<InetAddress, Map<Cell, Collection<Long>>> keysByHost = partitionMapByHost(keys.asMap().entrySet());
    for (Map.Entry<InetAddress, Map<Cell, Collection<Long>>> entry : keysByHost.entrySet()) {
        deleteOnSingleHost(entry.getKey(), tableName, entry.getValue());
    }//  w  w w. j ava  2s .  com
}