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

Examples of com.ikanow.infinit.e.data_model.api.knowledge.DocumentPojoApiMap


    ResponsePojo internal_response = ResponsePojo.fromApi(testResult, ResponsePojo.class);
    shallowCopy(response, internal_response.getResponse());
    List<DocumentPojo> docs = null;
    if (response.isSuccess()) {
      docs = ApiManager.mapListFromApi((JsonElement)internal_response.getData(),
                                  DocumentPojo.listType(), new DocumentPojoApiMap());
    }
   
    return docs;
  }
View Full Code Here


      theUrl.append(docid);
      theUrl.append("?returnFullText=").append(returnFullText);
      theUrl.append("?returnRawData=").append(returnRawData);
     
      String getResult = sendRequest(theUrl.toString(), null);
      ResponsePojo internal_responsePojo = ResponsePojo.fromApi(getResult, ResponsePojo.class, DocumentPojo.class, new DocumentPojoApiMap())
      ResponseObject internal_ro = internal_responsePojo.getResponse();
      responseObject = shallowCopy(responseObject, internal_ro);
      return (DocumentPojo)internal_responsePojo.getData();
    }
    catch (Exception ex)
View Full Code Here

      theUrl.append(sourceKey).append("/").append(url);
      theUrl.append("?returnFullText=").append(returnFullText);
      theUrl.append("?returnRawData=").append(returnRawData);
     
      String getResult = sendRequest(theUrl.toString(), null);
      ResponsePojo internal_responsePojo = ResponsePojo.fromApi(getResult, ResponsePojo.class, DocumentPojo.class, new DocumentPojoApiMap())
      ResponseObject internal_ro = internal_responsePojo.getResponse();
      responseObject = shallowCopy(responseObject, internal_ro);
      return (DocumentPojo)internal_responsePojo.getData();
    }
    catch (Exception ex)
View Full Code Here

 
  public static class QueryResults extends BaseApiPojo
  {
    @Override
    public GsonBuilder extendBuilder(GsonBuilder gp) { // Extend the builder to apply standard document deserialization
      return new DocumentPojoApiMap().extendBuilder(gp);
    }
View Full Code Here

            fileURL = dp.getSourceUrl();
          byte[] bytes = FileHarvester.getFile(fileURL, source);
          if ( bytes == null )
          {
            // Try returning JSON instead
            String json = ApiManager.mapToApi(dp, new DocumentPojoApiMap());
            DocumentFileInterface dfp = new DocumentFileInterface();
           
            dfp.bytes = json.getBytes();
            dfp.mediaType = "application/json";
           
            rp.setResponse(new ResponseObject("Doc Info",true,"Document bytes returned successfully"));
            rp.setData(dfp, null);
            return rp;
          }
          else
          {           
            DocumentFileInterface dfp = new DocumentFileInterface();
            dfp.bytes = bytes;
            dfp.mediaType = getMediaType(fileURL);
            rp.setResponse(new ResponseObject("Doc Info",true,"Document bytes returned successfully"));
            rp.setData(dfp, null);
            return rp;
          }
        }
        else
        {       
          String json = ApiManager.mapToApi(dp, new DocumentPojoApiMap());
          DocumentFileInterface dfp = new DocumentFileInterface();
         
          dfp.bytes = json.getBytes();
          dfp.mediaType = "application/json";
         
          rp.setResponse(new ResponseObject("Doc Info",true,"Document bytes returned successfully"));
          rp.setData(dfp, null);
          return rp;
        }       
      }
      rp.setData(dp, new DocumentPojoApiMap());
      rp.setResponse(new ResponseObject("Doc Info",true,"Feed info returned successfully"));
    }//(end full text vs raw data)
    catch (Exception e)
    {
      // If an exception occurs log the error
View Full Code Here

 
  public static class QueryResults extends BaseApiPojo
  {
    @Override
    public GsonBuilder extendBuilder(GsonBuilder gp) { // Extend the builder to apply standard document deserialization
      return new DocumentPojoApiMap().extendBuilder(gp);
    }
View Full Code Here

        message = message + "\n" + sbApiMapErr.toString();
      }//TESTED (by hand)
     
      if ((null != source.getHarvestStatus()) && (HarvestEnum.error == source.getHarvestStatus().getHarvest_status())) {
        rp.setResponse(new ResponseObject("Test Source",false,"source error: " + message));     
        rp.setData(toAdd, new DocumentPojoApiMap());       
      }
      else {
        if ((null == message) || message.isEmpty()) {
          message = "no messages from harvester";
        }
        rp.setResponse(new ResponseObject("Test Source",true,"successfully returned " + toAdd.size() + " docs: " + message));     
        try {
          // If grabbing full text
          // Also some logstash specific logic - these aren't docs so just output the entire record
          boolean isLogstash = (null != source.getExtractType()) && source.getExtractType().equalsIgnoreCase("logstash");
          List<BasicDBObject> logstashRecords = null;
          if (bReturnFullText || isLogstash) {
            for (DocumentPojo doc: toAdd) {
              if (isLogstash) {
                if (null == logstashRecords) {
                  logstashRecords = new ArrayList<BasicDBObject>(toAdd.size());                 
                }
                BasicDBObject dbo = (BasicDBObject) doc.getMetadata().get("logstash_record")[0];
                Object test = dbo.get("_id");
                if ((null != test) && (test instanceof ObjectId)) {
                  dbo.remove("_id"); // (unless it's a custom _id added from logstash then remove it)
                }
                logstashRecords.add(dbo);
              }//TESTED
              else if (bReturnFullText) {
                doc.makeFullTextNonTransient();
              }
            }
          }//TESTED
          if (null != logstashRecords) {
            rp.setData(logstashRecords, (BasePojoApiMap<BasicDBObject>)null);           
          }//TESTED
          else {
            rp.setData(toAdd, new DocumentPojoApiMap());
          }//TESTED
         
          //Test deserialization:
          rp.toApi();
        }
View Full Code Here

//    docApiDbo.remove("mediaType");
    // (sourceKey in <key>#<community> format)
//    docApiDbo.put("sourceKey", docApiDbo.getString("sourceKey")+"#doc_api_test");
    // (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));
View Full Code Here

 
  public static class QueryResults extends BaseApiPojo
  {
    @Override
    public GsonBuilder extendBuilder(GsonBuilder gp) { // Extend the builder to apply standard document deserialization
      return new DocumentPojoApiMap().extendBuilder(gp);
    }
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.api.knowledge.DocumentPojoApiMap

Copyright © 2018 www.massapicom. 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.