Package com.ikanow.infinit.e.data_model.api

Examples of com.ikanow.infinit.e.data_model.api.ResponsePojo.toApi()


        // (just has "alex")     
    }
   
    // And now in the other direction, ie deserializing....
    ResponsePojo rpRecreated = ResponsePojo.fromApi(sRPSingleObject, ResponsePojo.class, SourcePojo.class, new SourcePojoApiMap(null, communities, communities));
    System.out.println("RECREATED RP_SRC=" + rpRecreated.toApi());
    System.out.println("RECREATED SRC(RP_SRC)=" + ((BasicDBObject)((SourcePojo)rpRecreated.getData()).toDb()).toString());
    rpRecreated = ResponsePojo.listFromApi(sRPList, ResponsePojo.class, SourcePojo.listType(), new SourcePojoApiMap(null, communities, communities));
    System.out.println("RECREATED RP_LSRC=" + rpRecreated.toApi());
   
    rpRecreated = ResponsePojo.fromApi(sRPSingleObject, ResponsePojo.class);
View Full Code Here


    // And now in the other direction, ie deserializing....
    ResponsePojo rpRecreated = ResponsePojo.fromApi(sRPSingleObject, ResponsePojo.class, SourcePojo.class, new SourcePojoApiMap(null, communities, communities));
    System.out.println("RECREATED RP_SRC=" + rpRecreated.toApi());
    System.out.println("RECREATED SRC(RP_SRC)=" + ((BasicDBObject)((SourcePojo)rpRecreated.getData()).toDb()).toString());
    rpRecreated = ResponsePojo.listFromApi(sRPList, ResponsePojo.class, SourcePojo.listType(), new SourcePojoApiMap(null, communities, communities));
    System.out.println("RECREATED RP_LSRC=" + rpRecreated.toApi());
   
    rpRecreated = ResponsePojo.fromApi(sRPSingleObject, ResponsePojo.class);
    System.out.println("RECREATED RAW(RP_SRC)=" + ((JsonElement)rpRecreated.getData()));
    sp = ApiManager.mapFromApi((JsonElement)rpRecreated.getData(), SourcePojo.class, new SourcePojoApiMap(null, communities, communities));
    System.out.println("RECREATED SRC(RAW(RP_SRC))=" + ((JsonElement)rpRecreated.getData()));
View Full Code Here

   
    // Testing ResponsePojo code on serialization
    rp1.setData(aqp);
    sRPSingleObject = rp1.toApi();
    rpRecreated = ResponsePojo.fromApi(sRPSingleObject, ResponsePojo.class, AdvancedQueryPojo.class);
    System.out.println("RECREATED RP_AQP=" + rpRecreated.toApi());
    System.out.println("RECREATED AQP(RP_AQP)=" + ((AdvancedQueryPojo)(rpRecreated.getData())).toApi());
   
    //API: Get a list of objects   
    sQueryJson = "{ 'logic': 'chris' }";
    AdvancedQueryPojo aqp2 = AdvancedQueryPojo.fromApi(sQueryJson, AdvancedQueryPojo.class);
View Full Code Here

    sRPList = rp1.toApi();
    System.out.println("RP=" + sRPList);
    // This won't compile because didn't write a listType() for AQP (since it's never actually used in this way)
    //rpRecreated = ResponsePojo.listFromApi(sRPList, ResponsePojo.class, AdvancedQueryPojo.listType());
    rpRecreated = ResponsePojo.listFromApi(sRPList, ResponsePojo.class, new TypeToken<List<AdvancedQueryPojo>>(){});
    System.out.println("RECREATED RP_AQP=" + rpRecreated.toApi());
   
    ////////////////////////////////////////////////
    //CANONICAL EXAMPLE:
    sQueryJson = " [ { 'logic': 'alex' } , { 'logic': 'chris' } ] ";
    list2 = AdvancedQueryPojo.listFromApi(sQueryJson, new TypeToken<List<AdvancedQueryPojo>>(){});
View Full Code Here

    BasicDBObject db01 = new BasicDBObject("index", 1);
    BasicDBObject db02 = new BasicDBObject("index", 2);
    BasicDBObject db03 = new BasicDBObject("index", 3);
    dbl.addAll(Arrays.asList(db01, db02, db03));
    ResponsePojo rp2 = new ResponsePojo(null, dbl, (BasePojoApiMap<BasicDBList>)null);
    System.out.println("DBO=" + rp2.toApi());
   
    //API: test the V0 DocumentPojo, which has a few differences (including a static version for raw modification)
    BasicDBObject docApiDbo = (BasicDBObject) DbManager.getDocument().getMetadata().findOne();
    // (remove a few things to tidy up display)
    docApiDbo.remove("entities");
View Full Code Here

    // (display results of API mappings)
    DocumentPojo docApi = DocumentPojo.fromDb(docApiDbo, DocumentPojo.class);
    ResponsePojo rp3 = new ResponsePojo(null, docApi, new DocumentPojoApiMap());

    System.out.println("TIME_DOC_API1_CREATED="+docApi.getCreated());
    System.out.println("DOC_API1=" + rp3.toApi());
    DocumentPojoApiMap.mapToApi(docApiDbo);
    System.out.println("DOC_API2=" + BaseApiPojo.getDefaultBuilder().setPrettyPrinting().create().toJson(docApiDbo));
    DocumentPojo docFromApi = ApiManager.mapFromApi(ApiManager.mapToApi(docApi, null), DocumentPojo.class, null);
    System.out.println("TIME_DOC_API1_CREATED_INV="+docFromApi.getCreated());
   
View Full Code Here

    return new StringRepresentation(data, mediaType);
  }   
 
  protected StringRepresentation returnError(String queryType, String errorString) {
    ResponsePojo rp = returnErrorPojo(queryType, errorString);
    return new StringRepresentation(rp.toApi(), MediaType.APPLICATION_JSON);
  }
  protected ResponsePojo returnErrorPojo(String queryType, String errorString) {
    ResponsePojo rp = new ResponsePojo();
    rp.setResponse(new ResponseObject(queryType, false, errorString));
    return rp;
View Full Code Here

     }
     else
     {
       //there are no actions that shouldn't require cookies
     }
     return new StringRepresentation(rp.toApi(),MediaType.APPLICATION_JSON);
  }
 
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.