Example usage for com.google.gson.internal LinkedTreeMap get

List of usage examples for com.google.gson.internal LinkedTreeMap get

Introduction

In this page you can find the example usage for com.google.gson.internal LinkedTreeMap get.

Prototype

@Override
    public V get(Object key) 

Source Link

Usage

From source file:services.UsersResource.java

@POST
@Produces("application/json")
@Consumes("application/json")
@Path("getUserByDepAndRole")
public List<Users> getUserByDepAndRole(String data, @Context HttpServletRequest req) {
    //  UUID userId = WebSession.getUserId();
    LinkedTreeMap obj = new Gson().fromJson(data, LinkedTreeMap.class);

    return usersFacade.getUserByDepAndRole(obj.get("depId").toString(), obj.get("roleId").toString());
}

From source file:services.UsersResource.java

@POST
@Produces("application/json")
@Consumes("application/json")
@Path("getUserByRole")
public List<Users> getUserByRole(String data, @Context HttpServletRequest req) {
    //  UUID userId = WebSession.getUserId();
    LinkedTreeMap obj = new Gson().fromJson(data, LinkedTreeMap.class);
    return usersFacade.getUserByRole(obj.get("roleId").toString());
}

From source file:services.UsersResource.java

@POST
@Produces("application/json")
@Consumes("application/json")
@Path("login")
public Users login(String data, @Context HttpServletRequest req) {
    //TODO return proper representation object
    Users user = null;/*from  ww w.  j  av a  2s .c  om*/
    //  Gson gson = new Gson();       
    LinkedTreeMap obj = new Gson().fromJson(data, LinkedTreeMap.class);
    user = obj != null ? usersFacade.login(obj.get("username").toString(), obj.get("password").toString())
            : null;
    WebSession.addUserSession(req.getSession(true), user);

    return user;
}

From source file:services.WorkflowResource.java

@POST
@Path("getNextStage")
@Produces(MediaType.APPLICATION_JSON)/*from  w  ww.  j av a  2  s  .  c  o  m*/
public WorkFlow getNextStage(String data, @Context HttpServletRequest req) throws IOException {
    LinkedTreeMap obj = new Gson().fromJson(data, LinkedTreeMap.class);
    String temp = obj.get("workFlowId").toString();
    String step = obj.get("step").toString();
    WorkFlow workFlow = new Gson().fromJson(temp, WorkFlow.class);
    return workFlowFacade.getObjectByStep(workFlow, Integer.parseInt(step));
    // return workFlowFacade.getById(workFlowId);
    //return null;    
}

From source file:services.WorkflowResource.java

@POST
@Path("getByAppId")
@Produces(MediaType.APPLICATION_JSON)/*  w w w .  ja v  a 2s. co m*/
@Consumes(MediaType.APPLICATION_JSON)
//@Consumes("application/json")   
public WorkFlow getByAppId(String data) {
    // WorkFlow workflow ;
    Gson gson = new Gson();
    LinkedTreeMap obj = gson.fromJson(data, LinkedTreeMap.class);
    //TODO return proper representation object
    return workFlowFacade.getObjectByAppId(obj.get("appId").toString(), (double) obj.get("workFlowStep"));
}

From source file:session.WebSession.java

public static void addEachWebSession(HttpSession mysession, String data) {
    String key = "";
    Object value;//from  w  ww  . j  a v  a  2  s .c o m
    Gson gson = new Gson();
    LinkedTreeMap obj = gson.fromJson(data, LinkedTreeMap.class);
    for (Object e : obj.keySet()) {
        SessionListener.setSessionAttribute(mysession, String.valueOf(e), obj.get(e));
    }
}

From source file:StorageHelper.CreatorHelper.java

License:Apache License

/**
 * create a data storage from given data using the right type it really is
 * method finds out the type of the object and then adds it to collection the right way for that type
 * @param data Object of data//ww  w.  j ava 2  s.com
 * @return DataStorage with data populated
 */
public static Storage createDataStorage(Object data) {
    boolean alreadyEntered = false;
    Storage store = new Storage();
    //if it is a default type then don't let it match anything else
    Class[] dataTypes = { Integer.class, String.class, int.class, Double.class, double.class, boolean.class,
            Boolean.class };

    //if data is null we can return an empty data storage
    if (data == null) {
        return store;
    }

    //skip all of these things if it is a data type not collection
    if (!Arrays.asList(dataTypes).contains(data.getClass())) {

        //find what type the Object data is and cast it to that
        //add to collection as the right type it is
        if (data.getClass().getTypeName().contains("ArrayList")) {
            store.addArray((ArrayList) data);
            alreadyEntered = true;
        } else if (data.getClass().getTypeName().contains("HashMap")) {
            store.addMap((HashMap) data);
            alreadyEntered = true;
        } else if (data.getClass().getTypeName().contains("JSONArray")) {
            store.addJson((JSONArray) data);
            alreadyEntered = true;
        } else if (data.getClass().getTypeName().contains("JSONObject")) {
            store.addJson((JSONObject) data);
            alreadyEntered = true;
        }

        //gson uses this linked tree map type, this will convert it to Data Storage
        else {
            if (data.getClass().getTypeName().contains("LinkedTreeMap")) {
                LinkedTreeMap<String, Object> treeData = (LinkedTreeMap) data;
                for (String key : treeData.keySet())
                    store.put(key, treeData.get(key));
            }
            //this could be many things, but not a string
            else if (!data.getClass().getTypeName().contains("String"))
                if (!data.toString().isEmpty())
                    store.addModel(data);
            alreadyEntered = true;
        }
    }

    //if nothing is added just add the object at index 0
    if (store.size() < 1 && !data.toString().isEmpty() && !alreadyEntered)
        store.put("0", data);

    return store;
}

From source file:tech.mcprison.prison.ranks.data.RankLadder.java

License:Open Source License

public RankLadder(Document document) {
    this.id = RankUtil.doubleToInt(document.get("id"));
    this.name = (String) document.get("name");
    List<LinkedTreeMap<String, Object>> ranksLocal = (List<LinkedTreeMap<String, Object>>) document
            .get("ranks");

    this.ranks = new ArrayList<>();
    for (LinkedTreeMap<String, Object> rank : ranksLocal) {
        ranks.add(new PositionRank(RankUtil.doubleToInt(rank.get("position")),
                RankUtil.doubleToInt((rank.get("rankId")))));
    }//  ww w .ja v  a2 s .co  m
}

From source file:tech.mcprison.prison.ranks.data.RankPlayer.java

License:Open Source License

public RankPlayer(Document document) {
    this.uid = UUID.fromString((String) document.get("uid"));
    LinkedTreeMap<String, Object> ranksLocal = (LinkedTreeMap<String, Object>) document.get("ranks");
    LinkedTreeMap<String, Object> prestigeLocal = (LinkedTreeMap<String, Object>) document.get("prestige");

    this.ranks = new HashMap<>();
    for (String key : ranksLocal.keySet()) {
        ranks.put(key, RankUtil.doubleToInt(ranksLocal.get(key)));
    }//from   w w  w  .ja  v a 2  s.c om
    this.prestige = new HashMap<>();
    for (String key : prestigeLocal.keySet()) {
        prestige.put(key, RankUtil.doubleToInt(prestigeLocal.get(key)));
    }
}