Example usage for org.json.simple JSONObject JSONObject

List of usage examples for org.json.simple JSONObject JSONObject

Introduction

In this page you can find the example usage for org.json.simple JSONObject JSONObject.

Prototype

JSONObject

Source Link

Usage

From source file:org.kitodo.data.elasticsearch.index.type.RulesetType.java

@SuppressWarnings("unchecked")
@Override//  w  w w . jav  a2s  . c om
public HttpEntity createDocument(Ruleset ruleset) {

    JSONObject rulesetObject = new JSONObject();
    rulesetObject.put("title", ruleset.getTitle());
    rulesetObject.put("file", ruleset.getFile());
    rulesetObject.put("orderMetadataByRuleset", ruleset.isOrderMetadataByRuleset());
    rulesetObject.put("fileContent", "");

    return new NStringEntity(rulesetObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.HistoryType.java

@SuppressWarnings("unchecked")
@Override/*  w  ww .  j  a  va 2 s  .c om*/
public HttpEntity createDocument(History history) {

    JSONObject historyObject = new JSONObject();
    historyObject.put("numericValue", history.getNumericValue());
    historyObject.put("stringValue", history.getStringValue());
    historyObject.put("type", history.getHistoryType().getValue());
    String date = history.getDate() != null ? formatDate(history.getDate()) : null;
    historyObject.put("date", date);
    Integer process = history.getProcess() != null ? history.getProcess().getId() : null;
    historyObject.put("process", process);

    return new NStringEntity(historyObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.TemplateType.java

@SuppressWarnings("unchecked")
@Override//from   w  w w  . ja  va2  s. c om
public HttpEntity createDocument(Template template) {

    JSONObject templateObject = new JSONObject();
    templateObject.put("origin", template.getOrigin());
    Integer process = template.getProcess() != null ? template.getProcess().getId() : null;
    templateObject.put("process", process);
    templateObject.put("properties", addObjectRelation(template.getProperties()));

    return new NStringEntity(templateObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.WorkpieceType.java

@SuppressWarnings("unchecked")
@Override//from   w w w  .  java2 s .  com
public HttpEntity createDocument(Workpiece workpiece) {

    JSONObject workpieceObject = new JSONObject();
    Integer process = workpiece.getProcess() != null ? workpiece.getProcess().getId() : null;
    workpieceObject.put("process", process);
    workpieceObject.put("properties", addObjectRelation(workpiece.getProperties()));

    return new NStringEntity(workpieceObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.UserGroupType.java

@SuppressWarnings("unchecked")
@Override/*from  w  w  w  . j av  a  2  s  .  c o m*/
public HttpEntity createDocument(UserGroup userGroup) {

    JSONObject userGroupObject = new JSONObject();
    userGroupObject.put("title", userGroup.getTitle());
    userGroupObject.put("permission", userGroup.getPermission());
    userGroupObject.put("users", addObjectRelation(userGroup.getUsers()));

    return new NStringEntity(userGroupObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.aerothai.database.os.OsService.java

public JSONObject GetOsAll() throws Exception {

    Connection dbConn = null;//from   w  w  w .  j  a va  2s.  c om
    JSONObject obj = new JSONObject();
    JSONArray objList = new JSONArray();

    int no = 1;
    //obj.put("draw", 2);
    obj.put("tag", "list");
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        String query = "SELECT * FROM os";
        System.out.println(query);
        ResultSet rs = stmt.executeQuery(query);

        while (rs.next()) {

            JSONObject jsonData = new JSONObject();
            jsonData.put("id", rs.getInt("idos"));
            jsonData.put("name", rs.getString("name"));
            jsonData.put("no", no);
            objList.add(jsonData);
            no++;
        }
        obj.put("msg", "done");
        obj.put("status", true);
        obj.put("data", objList);
    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj;
}

From source file:cv_vacature_bank.Jsonhandler.java

public void CVJson(CV cv) {
    if (cv == null) {
        return;//from ww  w  .  j  a va2 s  .  com
    }
    JSONObject cvj = new JSONObject();
    cvj.put("url", cv.getUrl());
    cvj.put("geplaatst", cv.getGeplaatst());
    cvj.put("beroep", cv.getBeroep());
    cvj.put("vakgebied", cv.getVakgebied());
    cvj.put("werkervaring", cv.getWerkervaring());
    cvj.put("opleidingsNiveau", cv.getOpleidingsNiveau());
    cvj.put("opleiding", cv.getOpleiding());
    cvj.put("zoekt", cv.getZoekt());
    cvj.put("woonplaats", cv.getWoonplaats());
    cvj.put("provincie", cv.getProvincie());
    cvj.put("geslacht", cv.getGeslacht());
    cvj.put("leeftijd", cv.getLeeftijd());
    cvj.put("rijbewijs", cv.getRijbewijs());
    cvj.put("auto", cv.getAuto());

    objs.add(cvj);

    if (objs.size() == 20) {
        createFile("CV");
        objs.clear();
    }

}

From source file:com.aerothai.database.dept.DeptService.java

public JSONObject GetDeptAll() throws Exception {

    Connection dbConn = null;/*from   ww w  . jav  a 2  s  .c om*/
    JSONObject obj = new JSONObject();
    JSONArray objList = new JSONArray();

    int no = 1;
    //obj.put("draw", 2);
    obj.put("tag", "list");
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        String query = "SELECT * FROM dept";
        System.out.println(query);
        ResultSet rs = stmt.executeQuery(query);

        while (rs.next()) {

            JSONObject jsonData = new JSONObject();
            jsonData.put("id", rs.getInt("iddept"));
            jsonData.put("name", rs.getString("name"));
            jsonData.put("shortname", rs.getString("shortname"));
            jsonData.put("no", no);
            objList.add(jsonData);
            no++;
        }
        obj.put("msg", "done");
        obj.put("status", true);
        obj.put("data", objList);
    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj;
}

From source file:org.kitodo.data.elasticsearch.index.type.TaskType.java

@SuppressWarnings("unchecked")
@Override//from ww  w  . j  a va2 s  .  c o m
public HttpEntity createDocument(Task task) {
    JSONObject taskObject = new JSONObject();
    taskObject.put("title", task.getTitle());
    taskObject.put("priority", task.getPriority());
    taskObject.put("ordering", task.getOrdering());
    Integer processingStatus = task.getProcessingStatusEnum() != null
            ? task.getProcessingStatusEnum().getValue()
            : null;
    taskObject.put("processingStatus", processingStatus);
    String processingTime = task.getProcessingTime() != null ? formatDate(task.getProcessingTime()) : null;
    taskObject.put("processingTime", processingTime);
    String processingBegin = task.getProcessingBegin() != null ? formatDate(task.getProcessingBegin()) : null;
    taskObject.put("processingBegin", processingBegin);
    String processingEnd = task.getProcessingEnd() != null ? formatDate(task.getProcessingEnd()) : null;
    taskObject.put("processingEnd", processingEnd);
    taskObject.put("homeDirectory", String.valueOf(task.getHomeDirectory()));
    taskObject.put("typeMetadata", String.valueOf(task.isTypeMetadata()));
    taskObject.put("typeAutomatic", String.valueOf(task.isTypeAutomatic()));
    taskObject.put("typeImportFileUpload", String.valueOf(task.isTypeImportFileUpload()));
    taskObject.put("typeExportRussian", String.valueOf(task.isTypeExportRussian()));
    taskObject.put("typeImagesRead", String.valueOf(task.isTypeImagesRead()));
    taskObject.put("typeImagesWrite", String.valueOf(task.isTypeImagesWrite()));
    taskObject.put("typeModuleName", task.getTypeModuleName());
    taskObject.put("batchStep", String.valueOf(task.isBatchStep()));
    Integer processingUser = task.getProcessingUser() != null ? task.getProcessingUser().getId() : null;
    taskObject.put("processingUser", processingUser);
    Integer process = task.getProcess() != null ? task.getProcess().getId() : null;
    taskObject.put("process", process);
    taskObject.put("users", addObjectRelation(task.getUsers()));
    taskObject.put("userGroups", addObjectRelation(task.getUserGroups()));

    return new NStringEntity(taskObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:cc.sferalabs.libs.telegram.bot.api.types.ReplyMarkup.java

/**
 * /*from   w  ww . j av a  2  s.c o m*/
 * @param fields
 *            the fields-values pairs
 */
@SuppressWarnings("unchecked")
public ReplyMarkup(Object[]... fields) {
    JSONObject obj = new JSONObject();
    for (Object[] field : fields) {
        if (field[1] != null) {
            obj.put(field[0], field[1]);
        }
    }
    this.jsonString = obj.toString();
}