Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

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

Prototype

public 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.silverpeas.gallery.web.MediaEntityMatcher.java

@SuppressWarnings("unchecked")
public static AbstractMediaEntity from(LinkedHashMap<String, Object> media) {
    MediaType mediaType = MediaType.from((String) media.get("type"));
    AbstractMediaEntity mediaEntity = null;
    switch (mediaType) {
    case Unknown:
        throw new IllegalArgumentException();
    case Photo:/*from  w  w w  .j a va 2 s .c  o  m*/
        mediaEntity = new PhotoEntity();
        ((PhotoEntity) mediaEntity).withPreviewUrl(URI.create((String) media.get("previewUrl")));
        break;
    case Video:
        mediaEntity = new VideoEntity();
        break;
    case Sound:
        mediaEntity = new SoundEntity();
        break;
    case Streaming:
        mediaEntity = new StreamingEntity();
        break;
    }
    mediaEntity.setType(mediaType);
    mediaEntity.withURI(URI.create((String) media.get("uri")));
    mediaEntity.withParentURI(URI.create((String) media.get("parentURI")));
    mediaEntity.withOriginalUrl(URI.create((String) media.get("url")));
    mediaEntity.withThumbUrl(URI.create((String) media.get("thumbUrl")));
    mediaEntity.setId((String) media.get("id"));
    mediaEntity.setTitle((String) media.get("title"));
    mediaEntity.setDescription((String) media.get("description"));
    return mediaEntity;
}

From source file:com.silverpeas.gallery.web.AlbumEntityMatcher.java

@SuppressWarnings("unchecked")
public static AlbumEntity from(LinkedHashMap<String, Object> album) {
    AlbumEntity albumEntity = new AlbumEntity();
    albumEntity.withURI(URI.create((String) album.get("uri")));
    albumEntity.withParentURI(URI.create((String) album.get("parentURI")));
    albumEntity.setId((String) album.get("id"));
    albumEntity.setTitle((String) album.get("title"));
    albumEntity.setDescription((String) album.get("description"));
    LinkedHashMap<String, LinkedHashMap<String, Object>> mediaList = (LinkedHashMap<String, LinkedHashMap<String, Object>>) album
            .get("mediaList");
    for (Map.Entry<String, LinkedHashMap<String, Object>> mediaEntry : mediaList.entrySet()) {
        albumEntity.addMedia(MediaEntityMatcher.from(mediaEntry.getValue()));
    }//from ww w  .  jav a2  s.  co m
    return albumEntity;
}

From source file:org.neo4j.nlp.examples.wikipedia.main.java

private static List<Map<String, Object>> getWikipediaArticles() throws IOException {
    final String txUri = "http://localhost:7474/db/data/" + "transaction/commit";
    WebResource resource = Client.create().resource(txUri);

    String query = "MATCH (n:Page) WITH n, rand() as sortOrder " + "ORDER BY sortOrder " + "LIMIT 1000 "
            + "RETURN n.title as title";

    String payload = "{\"statements\" : [ {\"statement\" : \"" + query + "\"} ]}";
    ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON)
            .entity(payload).post(ClientResponse.class);

    ObjectMapper objectMapper = new ObjectMapper();
    HashMap<String, Object> result;
    try {/*from www .  java  2 s.  c  o  m*/
        result = objectMapper.readValue(response.getEntity(String.class), HashMap.class);
    } catch (Exception e) {
        throw e;
    }
    response.close();

    List<Map<String, Object>> results = new ArrayList<>();

    ArrayList resultSet = ((ArrayList) result.get("results"));
    List<LinkedHashMap<String, Object>> dataSet = (List<LinkedHashMap<String, Object>>) resultSet.stream()
            .map(a -> (LinkedHashMap<String, Object>) a).collect(Collectors.toList());

    List<LinkedHashMap> rows = (List<LinkedHashMap>) ((ArrayList) (dataSet.get(0).get("data"))).stream()
            .map(m -> (LinkedHashMap) m).collect(Collectors.toList());
    ArrayList cols = (ArrayList) (dataSet.get(0).get("columns"));

    for (LinkedHashMap row : rows) {
        ArrayList values = (ArrayList) row.get("row");
        Map<String, Object> resultRecord = new HashMap<>();
        for (int i = 0; i < values.size(); i++) {
            resultRecord.put(cols.get(i).toString(), values.get(i));
        }
        results.add(resultRecord);
    }
    return results;
}

From source file:com.softtek.medicine.java.util.MedicineRestClientUtil.java

public static List<Incident> getAllIncidents() throws ParseException {
    List<Incident> incList = new ArrayList<Incident>();
    RestTemplate restTemplate = new RestTemplate();
    List<LinkedHashMap> emps = restTemplate.getForObject(SERVER_URI + "/dr/incidents/request", List.class);
    System.out.println(emps.size());

    /**/*from ww w.ja  v  a2s  .com*/
     * Trecho comentado para no fazer uppdate de todos incidentes durante
     * os testes
     */
    for (LinkedHashMap map : emps) {
        //System.out.println("incidentNumber=" + map.get("incidentNumber"));
        Incident in = new Incident();
        in.setIncidentNumber(map.get("incidentNumber").toString());
        in.setPriority(Integer.parseInt(map.get("priority").toString()));
        in.setImpact(Integer.parseInt(map.get("impact").toString()));
        in.setUrgency(Integer.parseInt(map.get("urgency").toString()));
        in.setServiceType(Integer.parseInt(map.get("serviceType").toString()));
        in.setContactCompany(map.get("contactCompany").toString());
        in.setCategorizationTier1(map.get("categorizationTier1").toString());
        in.setCategorizationTier2(map.get("categorizationTier2").toString());
        in.setPhoneNumber(map.get("phoneNumber").toString());
        in.setFirstName(map.get("firstName").toString());
        in.setLastName(map.get("lastName").toString());
        in.setDescription(map.get("description").toString());
        //            in.setProductCategorizationTier1(map.get("productCategorizationTier1").toString());
        //            in.setProductCategorizationTier2(map.get("productCategorizationTier2").toString());
        //            in.setProductCategorizationTier3(map.get("productCategorizationTier3").toString());
        in.setEntryId(map.get("entryId").toString());
        in.setSubmitter(map.get("submitter").toString());
        //            in.setSubmitDate((Date) formatter.parse(map.get("submitDate").toString()));
        in.setTemplate(map.get("template").toString());
        in.setLastModifiedBy(map.get("lastModifiedBy").toString());
        //            in.setLastModifiedDate((Date) formatter.parse(map.get("lastModifiedDate").toString()));
        in.setStatus(Integer.parseInt(map.get("status").toString()));
        in.setCreatedBy(map.get("createdBy").toString());
        in.setCustomer(map.get("customer").toString());
        in.setCompany(map.get("company").toString());
        in.setFullName(map.get("fullName").toString());
        incList.add(in);
    }

    //        Incident in = new Incident();
    //        in.setIncidentNumber(emps.get(0).get("incidentNumber").toString());
    //        incList.add(in);
    return incList;
}

From source file:com.hatta.consumer.App.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void listAllCustomers(AuthTokenInfo tokenInfo) {

    Assert.notNull(tokenInfo, "Authenticate first please......");

    RestTemplate restTemplate = new RestTemplate();
    ////w w  w .  ja  va 2  s  . c  o m
    //        HttpHeaders headers = new HttpHeaders();
    //        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

    HttpEntity<String> request = new HttpEntity<String>(getHeaders());
    ResponseEntity<List> response = restTemplate.exchange(
            REST_SERVICE_URI + "/api/user" + QPM_ACCESS_TOKEN + tokenInfo.getAccess_token(), HttpMethod.GET,
            request, List.class);
    List<LinkedHashMap<String, Object>> customerMap = (List<LinkedHashMap<String, Object>>) response.getBody();
    //         
    //        List<LinkedHashMap<String, Object>> customerMap = restTemplate.getForObject(REST_SERVICE_URI + "/api/user", List.class);

    if (customerMap != null) {
        System.out.println("Retrieve all customers:");
        for (LinkedHashMap<String, Object> map : customerMap) {
            System.out.println("Customer : id=" + map.get("id") + ", Name=" + map.get("name") + ", Address="
                    + map.get("email") + ", Email=" + map.get("password") + map.get("enabled"));
        }
    } else {
        System.out.println("No customer exist----------");
    }
}

From source file:max.hubbard.Factoring.Graphing.java

private static XYDataset createDataset(LinkedList<LinkedHashMap<Float, Integer>> list, String orig) {

    final XYSeries series1 = new XYSeries(orig);

    for (double i = -10; i < 11; i++) {
        float v = 0;
        for (LinkedHashMap<Float, Integer> map : list) {
            for (Float f : map.keySet()) {
                if (map.get(f) != 0) {
                    v = v + f * (float) Math.pow(i, map.get(f));
                } else {
                    v = v + f;/*from w w w  .  ja  v a  2 s.  c o  m*/
                }
            }
        }
        series1.add(i, v);
    }

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);

    return dataset;

}

From source file:org.neo4j.nlp.examples.sentiment.main.java

private static boolean testOnText(String text, String label) {

    JsonObject jsonParam = new JsonObject();
    jsonParam.add("text", new JsonPrimitive(text));

    String jsonPayload = new Gson().toJson(jsonParam);

    String input = executePost("http://localhost:7474/service/graphify/classify", jsonPayload);

    System.out.println(input);//from w w w  .ja  v  a2  s. c om

    ObjectMapper objectMapper = new ObjectMapper();
    Map<String, Object> hashMap = new HashMap<>();
    try {
        hashMap = (Map<String, Object>) objectMapper.readValue(input, HashMap.class);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Validate guess
    ArrayList classes = (ArrayList) hashMap.get("classes");

    if (classes.size() > 0) {
        LinkedHashMap className = (LinkedHashMap) classes.stream().findFirst().get();

        return className.get("class").equals(label);
    } else {
        return false;
    }
}

From source file:com.hatta.consumer.App.java

@SuppressWarnings({ "unchecked" })
private static AuthTokenInfo sendTokenRequest() {
    RestTemplate restTemplate = new RestTemplate();

    HttpEntity<String> request = new HttpEntity<String>(getHeadersWithClientCredentials());
    ResponseEntity<Object> response = restTemplate.exchange(AUTH_SERVER_URI + QPM_PASSWORD_GRANT,
            HttpMethod.POST, request, Object.class);
    LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) response.getBody();
    AuthTokenInfo tokenInfo = null;/*from  ww w  .  ja  v  a 2 s.  com*/

    if (map != null) {
        tokenInfo = new AuthTokenInfo();
        tokenInfo.setAccess_token((String) map.get("access_token"));
        tokenInfo.setToken_type((String) map.get("token_type"));
        tokenInfo.setRefresh_token((String) map.get("refresh_token"));
        tokenInfo.setExpires_in((int) map.get("expires_in"));
        tokenInfo.setScope((String) map.get("scope"));
        System.out.println(tokenInfo);
        System.out.println("access_token =" + map.get("access_token") + ", token_type=" + map.get("token_type")
                + ", refresh_token=" + map.get("refresh_token") + ", expires_in=" + map.get("expires_in")
                + ", scope=" + map.get("scope"));
        ;
    } else {
        System.out.println("No user exist----------");

    }
    return tokenInfo;
}

From source file:org.zaizi.sensefy.api.utils.SensefyUserMapper.java

@SuppressWarnings("unchecked")
public static SensefyUser getSensefyUserFromPrincipal(Principal user) {

    SensefyUser sensefyUser = new SensefyUser();

    if (user != null) {
        OAuth2Authentication authUser = (OAuth2Authentication) user;
        if (authUser != null) {

            LinkedHashMap<String, Object> details = (LinkedHashMap<String, Object>) authUser
                    .getUserAuthentication().getDetails();

            if (details != null && !details.isEmpty() && details.containsKey("principal")) {
                LinkedHashMap<String, Object> principal = (LinkedHashMap<String, Object>) details
                        .get("principal");

                if (principal != null && !principal.isEmpty()) {
                    try {
                        BeanUtils.populate(sensefyUser, principal);
                    } catch (IllegalAccessException e) {
                        logger.debug(e.getMessage());
                    } catch (InvocationTargetException e) {
                        logger.debug(e.getMessage());
                    }/*w  w  w.j av  a2  s .  c o m*/
                }

            }

        }

    }
    return sensefyUser;
}

From source file:com.app.model.m3.M3ConfigModel.java

public static List<String> formatUIConfig(LinkedHashMap<String, M3ConfigurationInfo> conf) {
    ArrayList<String> l = new ArrayList<>();
    if (conf != null) {
        for (String c : conf.keySet()) {
            l.add(conf.get(c).getName() + " (" + conf.get(c).getDescription() + ")");
        }//from   w  w  w . j a v a 2s.  co  m
    }
    return l;
}