Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:io.spring.initializr.web.support.DefaultDependencyMetadataProvider.java

@Override
@Cacheable(cacheNames = "initializr.dependency-metadata", key = "#p1")
public DependencyMetadata get(InitializrMetadata metadata, Version bootVersion) {
    Map<String, Dependency> dependencies = new LinkedHashMap<>();
    for (Dependency d : metadata.getDependencies().getAll()) {
        if (d.match(bootVersion)) {
            dependencies.put(d.getId(), d.resolve(bootVersion));
        }/*from   w w  w.  ja va2 s  .  co  m*/
    }

    Map<String, Repository> repositories = new LinkedHashMap<>();
    for (Dependency d : dependencies.values()) {
        if (d.getRepository() != null) {
            repositories.put(d.getRepository(),
                    metadata.getConfiguration().getEnv().getRepositories().get(d.getRepository()));
        }
    }

    Map<String, BillOfMaterials> boms = new LinkedHashMap<>();
    for (Dependency d : dependencies.values()) {
        if (d.getBom() != null) {
            boms.put(d.getBom(),
                    metadata.getConfiguration().getEnv().getBoms().get(d.getBom()).resolve(bootVersion));
        }
    }
    // Each resolved bom may require additional repositories
    for (BillOfMaterials b : boms.values()) {
        for (String id : b.getRepositories()) {
            repositories.put(id, metadata.getConfiguration().getEnv().getRepositories().get(id));
        }
    }

    return new DependencyMetadata(bootVersion, dependencies, repositories, boms);
}

From source file:ch.gianulli.trelloapi.TrelloList.java

public static TrelloList getList(TrelloAPI api, Board board, String id)
        throws TrelloNotAuthorizedException, TrelloNotAccessibleException {
    try {// w  w  w  .  jav  a  2 s  . c  o  m
        LinkedHashMap<String, String> args = new LinkedHashMap<>();
        args.put("cards", "open");
        args.put("card_fields", "name,desc");
        JSONObject list = api.makeJSONObjectRequest("GET", "lists/" + id, args, true);
        if (list != null) {
            JSONArray cardArray = list.getJSONArray("cards");
            ArrayList<Card> cards = new ArrayList<>(cardArray.length());
            for (int j = 0; j < cardArray.length(); ++j) {
                JSONObject card = cardArray.getJSONObject(j);
                cards.add(new Card(card.getString("id"), null, card.getString("name"), card.getString("desc"))); // list is null for now
            }
            TrelloList trelloList = new TrelloList(list.getString("id"), board, list.getString("name"), cards);
            // add list reference to cards
            for (Card c : cards) {
                c.setList(trelloList);
            }

            return trelloList;
        }
    } catch (JSONException e) {
        throw new TrelloNotAccessibleException("Server answer was not correctly formatted.");
    }

    return null;
}

From source file:hydrograph.ui.expression.editor.util.FieldDataTypeMap.java

/**
 * @param selectedInputFields//from w  w w. j  ava 2  s  .c  o  m
 * @param outputSchema
 * @return
 */
public Map<String, Class<?>> createFieldDataTypeMap(List<String> selectedInputFields,
        List<FixedWidthGridRow> outputSchema) {
    Map<String, Class<?>> fieldMap = new LinkedHashMap<String, Class<?>>();
    if (selectedInputFields != null) {
        for (String fieldName : selectedInputFields) {
            fieldMap.put(fieldName, getFieldDataType(fieldName, outputSchema));
        }
    } else if (outputSchema != null) {
        for (GridRow gridRow : outputSchema) {
            fieldMap.put(gridRow.getFieldName(), getFieldDataType(gridRow.getFieldName(), outputSchema));
        }
    }
    return fieldMap;
}

From source file:cz.muni.fi.mir.services.TaskServiceImpl.java

public TaskServiceImpl() {
    entries = new LinkedHashMap<>();
}

From source file:com.sugaronrest.restapicalls.methodcalls.InsertEntries.java

/**
 * Creates entries [SugarCRM REST method - set_entries].
 *
 *  @param url REST API Url./*from w  w w  .j ava2  s. c  om*/
 *  @param sessionId Session identifier.
 *  @param moduleName SugarCRM module name.
 *  @param entities The entity objects collection to create.
 *  @param selectFields Selected field list.
 *  @return InsertEntriesResponse object.
 */
public static InsertEntriesResponse run(String url, String sessionId, String moduleName, List<Object> entities,
        List<String> selectFields) {

    InsertEntriesResponse insertEntriesResponse = null;
    ErrorResponse errorResponse = null;

    String jsonRequest = new String();
    String jsonResponse = new String();

    ObjectMapper mapper = JsonObjectMapper.getMapper();

    try {
        Map<String, Object> requestData = new LinkedHashMap<String, Object>();
        requestData.put("session", sessionId);
        requestData.put("module_name", moduleName);
        requestData.put("name_value_list", EntitiesToNameValueList(entities, selectFields));

        String jsonRequestData = mapper.writeValueAsString(requestData);

        Map<String, Object> request = new LinkedHashMap<String, Object>();
        request.put("method", "set_entries");
        request.put("input_type", "json");
        request.put("response_type", "json");
        request.put("rest_data", requestData);

        jsonRequest = mapper.writeValueAsString(request);

        request.put("rest_data", jsonRequestData);

        HttpResponse response = Unirest.post(url).fields(request).asString();

        if (response == null) {
            insertEntriesResponse = new InsertEntriesResponse();
            errorResponse = ErrorResponse.format("An error has occurred!", "No data returned.");
            insertEntriesResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            insertEntriesResponse.setError(errorResponse);
        } else {

            jsonResponse = response.getBody().toString();

            if (StringUtils.isNotBlank(jsonResponse)) {
                // First check if we have an error
                errorResponse = ErrorResponse.fromJson(jsonResponse);
                if (errorResponse == null) {
                    insertEntriesResponse = mapper.readValue(jsonResponse, InsertEntriesResponse.class);
                }
            }

            if (insertEntriesResponse == null) {
                insertEntriesResponse = new InsertEntriesResponse();
                insertEntriesResponse.setError(errorResponse);

                insertEntriesResponse.setStatusCode(HttpStatus.SC_OK);
                if (errorResponse != null) {
                    insertEntriesResponse.setStatusCode(errorResponse.getStatusCode());
                }
            } else {
                insertEntriesResponse.setStatusCode(HttpStatus.SC_OK);
            }
        }
    } catch (Exception exception) {
        insertEntriesResponse = new InsertEntriesResponse();
        errorResponse = ErrorResponse.format(exception, exception.getMessage());
        insertEntriesResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        insertEntriesResponse.setError(errorResponse);
    }

    insertEntriesResponse.setJsonRawRequest(jsonRequest);
    insertEntriesResponse.setJsonRawResponse(jsonResponse);

    return insertEntriesResponse;
}

From source file:com.sugaronrest.restapicalls.methodcalls.UpdateEntries.java

/**
 * Updates entries [SugarCRM REST method - set_entries].
 *
 *  @param url REST API Url./*from w ww  .  j  a v a2 s  .co m*/
 *  @param sessionId Session identifier.
 *  @param moduleName SugarCRM module name.
 *  @param entities The entity objects collection to create.
 *  @param selectFields Selected field list.
 *  @return UpdateEntriesResponse object.
 */
public static UpdateEntriesResponse run(String url, String sessionId, String moduleName, List<Object> entities,
        List<String> selectFields) {

    UpdateEntriesResponse updateEntriesResponse = null;
    ErrorResponse errorResponse = null;

    String jsonRequest = new String();
    String jsonResponse = new String();

    ObjectMapper mapper = JsonObjectMapper.getMapper();

    try {
        Map<String, Object> requestData = new LinkedHashMap<String, Object>();
        requestData.put("session", sessionId);
        requestData.put("module_name", moduleName);
        requestData.put("name_value_list", EntitiesToNameValueList(entities, selectFields));

        String jsonRequestData = mapper.writeValueAsString(requestData);

        Map<String, Object> request = new LinkedHashMap<String, Object>();
        request.put("method", "set_entries");
        request.put("input_type", "json");
        request.put("response_type", "json");
        request.put("rest_data", requestData);

        jsonRequest = mapper.writeValueAsString(request);

        request.put("rest_data", jsonRequestData);

        HttpResponse response = Unirest.post(url).fields(request).asString();

        if (response == null) {
            updateEntriesResponse = new UpdateEntriesResponse();
            errorResponse = ErrorResponse.format("An error has occurred!", "No data returned.");
            updateEntriesResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            updateEntriesResponse.setError(errorResponse);
        } else {

            jsonResponse = response.getBody().toString();

            if (StringUtils.isNotBlank(jsonResponse)) {
                // First check if we have an error
                errorResponse = ErrorResponse.fromJson(jsonResponse);
                if (errorResponse == null) {
                    updateEntriesResponse = mapper.readValue(jsonResponse, UpdateEntriesResponse.class);
                }
            }

            if (updateEntriesResponse == null) {
                updateEntriesResponse = new UpdateEntriesResponse();
                updateEntriesResponse.setError(errorResponse);

                updateEntriesResponse.setStatusCode(HttpStatus.SC_OK);
                if (errorResponse != null) {
                    updateEntriesResponse.setStatusCode(errorResponse.getStatusCode());
                }
            } else {
                updateEntriesResponse.setStatusCode(HttpStatus.SC_OK);
            }
        }
    } catch (Exception exception) {
        updateEntriesResponse = new UpdateEntriesResponse();
        errorResponse = ErrorResponse.format(exception, exception.getMessage());
        updateEntriesResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        updateEntriesResponse.setError(errorResponse);
    }

    updateEntriesResponse.setJsonRawRequest(jsonRequest);
    updateEntriesResponse.setJsonRawResponse(jsonResponse);

    return updateEntriesResponse;
}

From source file:au.org.ala.delta.intkey.directives.invocation.ContentsDirectiveInvocation.java

@Override
public boolean execute(IntkeyContext context) {
    try {/*from www  .j ava 2s  . co  m*/
        BufferedReader reader = new BufferedReader(new FileReader(file));

        // use LinkedHashMap to maintain insertion order of keys
        LinkedHashMap<String, String> contentsMap = new LinkedHashMap<String, String>();

        String line;
        while ((line = reader.readLine()) != null) {
            if (line.contains("*")) {
                String[] tokens = line.split("\\*");
                if (tokens.length != 2) {
                    context.getUI()
                            .displayErrorMessage(UIUtils.getResourceString("BadlyFormedContentsFile.error"));
                    return false;
                }

                contentsMap.put(tokens[0].trim(), tokens[1].trim());
            } else {
                String[] tokens = line.split(" ");
                if (tokens.length > 1) {
                    String description = StringUtils.join(Arrays.copyOf(tokens, tokens.length - 1), " ");
                    String fileName = tokens[tokens.length - 1];

                    // TODO hack here. Really should be building
                    // IntkeyDirectiveInvocation objects
                    // from both line formats and passing them to the
                    // contents directive, rather than
                    // getting the contents directive to do directive
                    // parsing.
                    String command = "FILE DISPLAY " + fileName.trim();
                    contentsMap.put(description.trim(), command);
                } else {

                }
            }
        }
        context.getUI().displayContents(contentsMap);
    } catch (IOException ex) {

    }

    return true;
}

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

public M3ConfigModel(IEntityModel e) {
    super();//from  w w w.  j a  v a 2s.c o  m
    this.listUnderConfigSelect = new LinkedHashMap<String, M3ConfigurationInfo>();
    entity = e;
}

From source file:com.alibaba.ims.web.module.screen.System.java

/**
 * /*from www. j a v a 2  s  .  c om*/
 *
 * @return
 */
public ActionResult<Map<String, Object>> doLoadContext() {
    Map<String, Object> context = new LinkedHashMap<String, Object>();
    context.putAll(DictManager.getAll());
    return new ActionResult<Map<String, Object>>(ResultCode.SUCCESS, context);
}

From source file:spring.travel.site.auth.CookieEncoderTest.java

@Test
public void shouldEncodeAndSignMap() throws Exception {
    ReflectionTestUtils.setField(encoder, "cookieName", "TEST_SESSION");

    String signature = "9834793875298375295";
    Map<String, String> values = new LinkedHashMap<>();
    values.put("foo", "bar");
    values.put("moose", "antlers");

    when(mockSigner.sign(anyString())).thenReturn(signature);
    String cookie = encoder.encode(values);
    assertEquals("TEST_SESSION=" + signature + "-foo=bar&moose=antlers", cookie);
}