Package com.ikanow.infinit.e.data_model.driver

Examples of com.ikanow.infinit.e.data_model.driver.InfiniteDriver


    if (testRedirects) {
      // GET
      String rootUrl = args[1];
      String username = args[2];
      String password = args[3];
      InfiniteDriver infDriver = new InfiniteDriver(rootUrl);
      System.out.println("LOGIN=" + infDriver.login(username, password, new ResponseObject()));
     
      //POST
      AdvancedQueryPojo query = new AdvancedQueryPojo();
      QueryTermPojo qt = new QueryTermPojo();
      qt.etext = "*";
      query.qt = Arrays.asList(qt);
      ResponseObject response = new ResponseObject();
      ObjectId communityId = new ObjectId("4c927585d591d31d7b37097a");
      ResponsePojo retVal = infDriver.sendQuery(query, communityId, response);
     
      System.out.println("RETURNED " + retVal.getStats().found  + " docs");
     
      return;
    }   
   
    // Aliases:   
   
    boolean bTestAliases = false;
    if (bTestAliases) { // will need to set some variables...
   
      String rootUrl = "http://infinite.ROOT.com/api/";
      String apiKey = "API_KEY";
     
      InfiniteDriver infDriver = new InfiniteDriver(rootUrl, apiKey);
     
      String aliasCommIdStr = "4d38b72c054548f038a0414a";
      String emptyAliasCommIdStr = "506afc85e4b01d98fcf9bf5f";
      ResponseObject response = new ResponseObject();
      Map<String, List<SharePojo>> aliasMapping = new HashMap<String, List<SharePojo>>();
      Map<String, EntityFeaturePojo> aliases = infDriver.getAliases(aliasCommIdStr, aliasMapping, response);
     
      if (response.isSuccess()) {
        System.out.println("ALIASES: " + new com.google.gson.Gson().toJson(aliases));
        System.out.println("ALIAS MAPPINGS: " + new com.google.gson.Gson().toJson(aliasMapping));
      }
      else {
        System.out.println("FAIL: " + response.getMessage());
      }
      // Change 1 of the aliases
      Iterator<EntityFeaturePojo> it = aliases.values().iterator();
      EntityFeaturePojo alias = it.next();
      alias.addToSemanticLinks(Arrays.asList("AlexTest"));
      EntityFeaturePojo alias2 = it.next();
      alias2.addAlias("XXXXX/person");
      Set<String> failures = infDriver.updateAliases(Arrays.asList(alias, alias2), aliasCommIdStr, false, response);
      if (!response.isSuccess()) {
        System.out.println("UPDATE TOTAL FAILURE: " + response.getMessage());
      }
      else if (!failures.isEmpty()) {
        System.out.println("UPDATE FAILURES: " + Arrays.toString(failures.toArray()));
      }
      else {
        System.out.println("UPDATED " + alias.getIndex() + " AND " + alias2.getIndex());
      }
      // Check upserting (failure and success) into an existing share
      // upsert fail:
      String savedAlias = alias.getIndex();
      alias.setIndex("testXXX/person");
      if (aliases.containsKey("testXXX/person")) {
        System.out.println("(skipping upsert fail, target index exists)");
      }
      else {
        failures = infDriver.updateAliases(Arrays.asList(alias, alias2), aliasCommIdStr, false, response);
        if (!response.isSuccess()) {
          System.out.println("UPDATE TOTAL FAILURE (CORRECT IF ONLY 1 ALIAS SPECIFIED): " + response.getMessage() + " " + Arrays.toString(failures.toArray()));
        }
        else if (!failures.isEmpty()) {
          System.out.println("UPSERT CORRECTLY FAILS: " + Arrays.toString(failures.toArray()));
        }
        else {
          System.out.println("INCORRECTLY UPDATED " + alias.getIndex());
        }
      }
      // upsert success:
      failures = infDriver.updateAliases(Arrays.asList(alias), aliasCommIdStr, true, response);
      if (!response.isSuccess()) {
        System.out.println("UPDATE TOTAL FAILURE: " + response.getMessage());
      }
      else if (!failures.isEmpty()) {
        System.out.println("UPDATE FAILURES: " + Arrays.toString(failures.toArray()));
      }
      else {
        System.out.println("UPDATED " + alias.getIndex());
      }
      // Check upserting into a new community     
      failures = infDriver.updateAliases(Arrays.asList(alias), emptyAliasCommIdStr, true, response);
      if (!response.isSuccess()) {
        System.out.println("UPDATE TOTAL FAILURE: " + response.getMessage());
      }
      else if (!failures.isEmpty()) {
        System.out.println("UPDATE FAILURES: " + Arrays.toString(failures.toArray()));
      }
      else {
        System.out.println("UPDATED " + alias.getIndex());
      }
      // Check removal
      boolean bRemoval = true;
      if (bRemoval) {
        failures = infDriver.removeAliases(Arrays.asList(alias.getIndex()), emptyAliasCommIdStr, response);
        if (!response.isSuccess()) {
          System.out.println("REMOVE TOTAL FAILURE: " + response.getMessage());
        }
        else if (!failures.isEmpty()) {
          System.out.println("REMOVE FAILURES: " + Arrays.toString(failures.toArray()));
        }
        else {
          System.out.println("REMOVE " + alias.getIndex());
        }
        failures = infDriver.removeAliases(Arrays.asList(alias.getIndex()), aliasCommIdStr, response);
        if (!response.isSuccess()) {
          System.out.println("REMOVE TOTAL FAILURE: " + response.getMessage());
        }
        else if (!failures.isEmpty()) {
          System.out.println("REMOVE FAILURES: " + Arrays.toString(failures.toArray()));
        }
        else {
          System.out.println("REMOVE " + alias.getIndex());
        }
        // Reset old shares back again
        alias.setIndex(savedAlias);
        if (null != alias.getSemanticLinks()) {
          alias.getSemanticLinks().remove("AlexTest");
        }
        alias.getAlias().remove("XXXXX/person");
        if (null != alias2.getSemanticLinks()) {
          alias2.getSemanticLinks().remove("AlexTest");
        }
        alias2.getAlias().remove("XXXXX/person");
        failures = infDriver.updateAliases(Arrays.asList(alias, alias2), aliasCommIdStr, false, response);
        System.out.println("RESET: " + response.isSuccess() + " " + (2 - failures.size()));
      }
    }//(end alias testing)
   
/////////////////////////////////////////////////////////////////////////////
View Full Code Here


  {
    // Authentication:
    HashSet<String> communityIds = null;
   

    _driver = new InfiniteDriver("http://localhost:8080/api/");
    //DEBUG
    //_driver = new InfiniteDriver("http://localhost:8184/");
    //_driver = new InfiniteDriver("http://URL/api/", "APIKEY");
   
    _driver.useExistingCookie(_cookie);
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.driver.InfiniteDriver

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.