Example usage for com.google.common.collect ArrayListMultimap create

List of usage examples for com.google.common.collect ArrayListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect ArrayListMultimap create.

Prototype

public static <K, V> ArrayListMultimap<K, V> create() 

Source Link

Document

Creates a new, empty ArrayListMultimap with the default initial capacities.

Usage

From source file:jp.ac.ipu.ds.nekottyo.toolmaven.CrowlInternetArchive.java

public static ListMultimap<Integer, String> crowlPastRDF(String baseURL) throws InterruptedException {
    ListMultimap result = ArrayListMultimap.create();
    try {//from ww  w.  j av a 2 s  .c  o m
        String queryString = queryURL + baseURL + "*";
        //            System.setProperty("http.proxyHost", "27.96.46.110");
        //            System.setProperty("http.proxyPort", "80");
        //            System.out.println(queryString);

        //            String command = "";
        //            String osName = System.getProperty("os.name").toLowerCase();
        //            if (osName.contains("windows")) {
        //                command = "./downloadArchive.bat " + queryString + " " + baseURL.replaceAll("/", ".") + ".html";
        //            } else if (osName.contains("mac")) {
        //                command = "./downloadArchive.sh " + queryString + " " + baseURL.replaceAll("/", ".") + ".html";
        //            }
        //            ProcessBroker pb = new ProcessBroker(command.split(" "));
        //            pb.execute();
        //            Document document = Jsoup.connect(queryString)
        //                    .timeout(2000000000)
        //                    .userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36")
        //                    .get();
        //            Document document = Jsoup.parse(new File(htmlFile + baseURL.replaceAll("/", ".") + ".html"), "UTF-8");
        Stream<String> htmlStream = Files.lines(Paths.get(htmlFile + baseURL.replaceAll("/", ".") + ".html"),
                Charset.defaultCharset());
        //            Elements elements = document.select(".url a");

        htmlStream.parallel().filter(s -> s.contains(baseURL)).map(s -> s.replaceAll("<.+?>", "").trim())
                //                    .filter(s -> s.text().endsWith("rdf"))
                //                    .filter(s -> s.text().endsWith("rdf") || s.text().endsWith("nt") || s.text().endsWith("n3"))
                //                    .filter(s -> s.text().contains("foaf"))
                .limit(20000).forEach((String e) -> {
                    //                        System.out.println("checking -> " + e);
                    result.put(getStatusCode(e), e);
                });

        result.keySet().stream().forEach(k -> {
            //                System.out.println(k + " " + result.get(k));
        });

        return result;

    } catch (IOException ex) {
        LOG.severe(ex.toString());
    }
    return result;
}

From source file:com.dotweblabs.friendscube.app.client.local.widgets.SearchItemWidget.java

@EventHandler("itemHeader")
public void clickSearchItem(ClickEvent event) {
    event.preventDefault();/*from w  w  w .ja v  a  2  s.  c o  m*/
    //temporary just to be able to see other user's profile
    Multimap<String, String> state = ArrayListMultimap.create();
    state.put("friend", item.generateUrl());
    userFeedsPage.go(state);
}

From source file:eu.esdihumboldt.hale.common.align.extension.function.FunctionParameter.java

/**
 * Create a function parameter definition.
 * //ww  w  .j  a va  2  s  .  c o  m
 * @param conf the configuration element
 */
public FunctionParameter(IConfigurationElement conf) {
    super(conf);
    String scriptableAttr = conf.getAttribute("scriptable");
    scriptable = scriptableAttr == null ? false : Boolean.valueOf(scriptableAttr);
    IConfigurationElement[] bindingElement = conf.getChildren("functionParameterBinding");
    if (bindingElement.length > 0) {
        this.enumeration = null;

        // default to String
        String clazz = bindingElement[0].getAttribute("class");
        if (clazz == null)
            this.binding = String.class;
        else
            this.binding = ExtensionUtil.loadClass(bindingElement[0], "class");

        IConfigurationElement[] validatorElement = bindingElement[0].getChildren("validator");
        if (validatorElement.length > 0) {
            Validator validator = null;
            try {
                validator = (Validator) validatorElement[0].createExecutableExtension("class");
                ListMultimap<String, String> parameters = ArrayListMultimap.create();
                for (IConfigurationElement parameter : validatorElement[0].getChildren("validatorParameter"))
                    parameters.put(parameter.getAttribute("name"), parameter.getAttribute("value"));
                validator.setParameters(parameters);
            } catch (CoreException e) {
                log.error("Error creating validator from extension", e);
            }
            this.validator = validator;
        } else
            this.validator = null;
    } else {
        this.binding = null;
        this.validator = null;
        // must be present, otherwise xml is invalid
        IConfigurationElement[] enumerationElement = conf.getChildren("functionParameterEnumeration");
        IConfigurationElement[] enumerationValues = enumerationElement[0].getChildren("enumerationValue");
        List<String> enumeration = new ArrayList<String>(enumerationValues.length);
        for (IConfigurationElement value : enumerationValues)
            enumeration.add(value.getAttribute("value"));
        this.enumeration = Collections.unmodifiableList(enumeration);
    }
}

From source file:org.openflexo.foundation.cg.templates.CGTemplateRepository.java

@Override
public void update() {
    commonTemplates.update();/*from   www . j  a  v  a2s  .  c  o m*/
    for (TargetType target : availableTargets) {
        TargetSpecificCGTemplateSet specificTargetSet = getTemplateSetForTarget(target);
        if (specificTargetSet != null) {
            specificTargetSet.update();
        }
    }
    ArrayListMultimap<String, CGTemplate> templates = ArrayListMultimap.create();
    for (CGTemplate t : commonTemplates.findAllTemplates()) {
        templates.put(t.getName(), t);
    }
    for (TargetType target : availableTargets) {
        TargetSpecificCGTemplateSet specificTargetSet = getTemplateSetForTarget(target);
        if (specificTargetSet != null) {
            for (CGTemplate t : specificTargetSet.findAllTemplates()) {
                templates.put(t.getName(), t);
            }
        }
    }
    for (String key : templates.keySet()) {
        List<CGTemplate> t = templates.get(key);
        if (t.size() == 1) {
            continue;
        }
        CGTemplate ref = t.get(0);
        for (CGTemplate template : t) {
            if (template != ref && template.getLastUpdate().getTime() == ref.getLastUpdate().getTime()) {

            }
        }
    }
}

From source file:de.bund.bfr.knime.pmmlite.views.fittedparameterview.FittedParameterViewReader.java

public FittedParameterViewReader(PmmPortObject input) throws UnitException {
    ListMultimap<String, PrimaryModel> modelsById = ArrayListMultimap.create();

    for (PrimaryModel model : input.getData(PrimaryModel.class)) {
        modelsById.put(model.getFormula().getId(), model);
    }/*from   w  w  w . ja v  a2  s . com*/

    ids = new ArrayList<>();
    colorCounts = new ArrayList<>();
    plotables = new LinkedHashMap<>();
    legend = new LinkedHashMap<>();
    stringValues = new LinkedHashMap<>();
    stringValues.put(PmmUtils.PARAMETER, new ArrayList<>());
    stringValues.put(PmmUtils.MODEL, new ArrayList<>());
    visibleColumns = new LinkedHashSet<>(Arrays.asList(PmmUtils.PARAMETER, PmmUtils.MODEL));
    conditionValues = ViewUtils.initConditionsValues(PmmUtils.getData(modelsById.values()));

    for (List<PrimaryModel> currentModels : Multimaps.asMap(modelsById).values()) {
        PrimaryModelFormula formula = currentModels.get(0).getFormula();
        Map<String, Plotable> currentPlotables = Plotables.readFittedParameters(currentModels);

        for (Parameter param : formula.getParams()) {
            plotables.put(createId(formula, param), currentPlotables.get(param.getName()));
        }
    }

    Map<String, PmmUnit> units = ViewUtils.getMostCommonUnits(plotables.values());

    for (List<PrimaryModel> currentModels : Multimaps.asMap(modelsById).values()) {
        PrimaryModelFormula formula = currentModels.get(0).getFormula();
        Map<String, ConditionValue> condRanges = new LinkedHashMap<>();
        List<Map<String, Condition>> conditionsByName = new ArrayList<>();

        for (PrimaryModel model : currentModels) {
            conditionsByName.add(PmmUtils.getByName(model.getData().getConditions()));
        }

        for (String cond : conditionValues.keySet()) {
            double min = Double.POSITIVE_INFINITY;
            double max = Double.NEGATIVE_INFINITY;

            for (Map<String, Condition> byName : conditionsByName) {
                Condition condition = byName.get(cond);

                if (condition != null) {
                    double value = PmmUtils.convertTo(MathUtils.nullToNan(condition.getValue()),
                            condition.getUnit(), units.get(cond));

                    if (Double.isFinite(value)) {
                        min = Math.min(min, value);
                        max = Math.max(max, value);
                    }
                }
            }

            condRanges.put(cond, new ConditionValue(!Double.isInfinite(min) ? min : null,
                    !Double.isInfinite(max) ? max : null));
        }

        for (Parameter param : formula.getParams()) {
            String id = createId(formula, param);

            ids.add(id);
            legend.put(id, param.getName() + " (" + formula.getName() + ")");
            colorCounts.add(plotables.get(id).getNumberOfCombinations());
            stringValues.get(PmmUtils.PARAMETER).add(param.getName());
            stringValues.get(PmmUtils.MODEL).add(formula.getName());

            for (Map.Entry<String, List<ConditionValue>> entry : conditionValues.entrySet()) {
                entry.getValue().add(condRanges.get(entry.getKey()));
            }
        }
    }

    conditionValues = PmmUtils.addUnitToKey(conditionValues, units);
}

From source file:org.zalando.logbook.servlet.TeeResponse.java

@Override
public Multimap<String, String> getHeaders() {
    final Multimap<String, String> headers = ArrayListMultimap.create();

    for (final String header : getHeaderNames()) {
        headers.putAll(header, getHeaders(header));
    }//  w  w w .j  ava  2s.c  o m

    return headers;
}

From source file:org.fcrepo.auth.webac.LinkHeaderProvider.java

@Override
public Multimap<String, String> createHttpHeadersForResource(final UriInfo uriInfo,
        final FedoraResource resource) {

    final FedoraSession internalSession = sessionFactory.getInternalSession();
    final IdentifierConverter<Resource, FedoraResource> translator = new DefaultIdentifierTranslator(
            getJcrSession(internalSession));
    final ListMultimap<String, String> headers = ArrayListMultimap.create();

    LOGGER.debug("Adding WebAC Link Header for Resource: {}", resource.getPath());
    // Get the correct Acl for this resource
    WebACRolesProvider.getEffectiveAcl(resource).ifPresent(acls -> {
        // If the Acl is present we need to use the internal session to get its URI
        nodeService.find(internalSession, acls.resource.getPath()).getTriples(translator, PROPERTIES)
                .collect(toModel()).listObjectsOfProperty(createProperty(WEBAC_ACCESS_CONTROL_VALUE))
                .forEachRemaining(linkObj -> {
                    if (linkObj.isURIResource()) {
                        final Resource acl = linkObj.asResource();
                        final String aclPath = translator.convert(acl).getPath();
                        final URI aclUri = uriInfo.getBaseUriBuilder().path(aclPath).build();
                        headers.put("Link", Link.fromUri(aclUri).rel("acl").build().toString());
                    }//from   w w w  . jav  a2 s.c  o  m
                });
    });

    return headers;
}

From source file:com.zimbra.soap.account.type.Prop.java

public static Multimap<String, String> toMultimap(List<Prop> props, String userPropKey) {
    Multimap<String, String> map = ArrayListMultimap.create();
    for (Prop p : props) {
        map.put(userPropKey, p.getSerialization());
    }// w  w w .  ja  v a2  s .c  o  m
    return map;
}

From source file:org.mousephenotype.dcc.exportlibrary.traverser.SpecimenCommandImpl.java

public SpecimenCommandImpl(HibernateManager hibernateManager) {
    this.hibernateManager = hibernateManager;
    this.validationSet = new ValidationSet();
    this.validCentreSpecimens = new ArrayList<>();
    this.validSpecimens = ArrayListMultimap.create();
    this.specimenValidations = HashBasedTable.create();
    this.centreSpecimenValidations = ArrayListMultimap.create();
}

From source file:eu.mondo.driver.fourstore.FourStoreGraphDriverReadOnly.java

@Override
public Multimap<Long, Long> collectEdges(final String type) throws IOException {
    final Multimap<Long, Long> edges = ArrayListMultimap.create();

    final String query = String.format("SELECT ?a ?b WHERE { ?a %s ?b }", RDFUtil.brackets(type));
    final BufferedReader reader = runQuery(query);

    // collecting ids
    final Pattern pattern = Pattern.compile("#x(.*?)>");
    String line;/*from  w w  w  .  ja va 2s  .  c  o  m*/
    while ((line = reader.readLine()) != null) {
        final Matcher matcher = pattern.matcher(line);

        if (matcher.find()) {
            final String sourceString = matcher.group(1);
            if (matcher.find()) {
                final String destinationString = matcher.group(1);
                final Long source = new Long(sourceString);
                final Long destination = new Long(destinationString);
                edges.put(source, destination);
            }
        }
    }

    return edges;
}