Пример #1
0
  @POST
  @Path("/addNewParentTestField")
  @Produces("text/plain")
  @Consumes(MediaType.APPLICATION_JSON)
  public String addNewParentField(JSONObject obj) {
    try {
      JSONArray data = obj.getJSONArray("parentfileds");
      Set<ParentTestFields> ParentFieldList = new HashSet<ParentTestFields>();
      for (int curr = 0; curr < data.length(); curr++) {
        ParentTestFields pf = new ParentTestFields();
        pf.setParentField_IDName("PF");
        pf.setParent_FieldName(data.getJSONObject(curr).getString("parent_FieldName"));
        // pf.setfTest_RangeID(testFieldsRangeDBDriver.getTestFieldRangeByID(Integer.parseInt(data.getJSONObject(curr).getString("fTest_RangeID"))));
        pf.setfTest_NameID(
            testNamesDBDriver.getTestNameByID(
                Integer.parseInt(data.getJSONObject(curr).getString("fTest_NameID"))));
        ParentFieldList.add(pf);
      }

      for (ParentTestFields pf : ParentFieldList) {
        parentfieldDBDriver.addNewParentTestField(pf);
      }

    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    } catch (Exception e) {
      System.out.println(e.getMessage());
      return null;
    }
    return "TRUE";
  }
Пример #2
0
 @GET
 @Path("/getMaxParentID")
 @Produces(MediaType.APPLICATION_JSON)
 public String GetMAxParentID() {
   String MaxID = parentfieldDBDriver.getMaxParentID();
   JSONSerializer serializer = new JSONSerializer();
   return serializer.exclude("*.class").serialize(MaxID);
 }
Пример #3
0
 @GET
 @Path("/getAllParenTestFields/{ID}")
 @Produces(MediaType.APPLICATION_JSON)
 public String getAllParenTestFieldsByID(@PathParam("ID") int TestID) {
   List<ParentTestFields> parentTestFIeldsList = parentfieldDBDriver.getParentField(TestID);
   JSONSerializer serializer = new JSONSerializer();
   return serializer.exclude("*.class").serialize(parentTestFIeldsList);
 }
Пример #4
0
 @GET
 @Path("/getAllParenTestFields")
 @Produces(MediaType.APPLICATION_JSON)
 public String getAllParenTestFields() {
   List<ParentTestFields> parentTestFIeldsList = parentfieldDBDriver.getParentTeatFieldsList();
   JSONSerializer serializer = new JSONSerializer();
   return serializer
       .include("fTest_NameID.test_Name")
       .exclude("*.class", "fTest_NameID.*")
       .serialize(parentTestFIeldsList);
 }