Examples of AssociationSpecPojo


Examples of com.ikanow.infinit.e.data_model.store.config.source.StructuredAnalysisConfigPojo.AssociationSpecPojo

          {
            for (String[] assocToCreate : assocsToCreate)
            {
              JSONObject currIt = new JSONObject();
             
              AssociationSpecPojo newAssoc = new AssociationSpecPojo();
              // Entity1
              if (assocToCreate[0] !=null) {
                newAssoc.setEntity1_index(assocToCreate[0].replace("$", "${$}"));
                currIt.put("entity1_index", assocToCreate[0]);
              }
              else {
                newAssoc.setEntity1(esp.getEntity1());
                newAssoc.setEntity1_index(esp.getEntity1_index());
              }
             
              // Entity2
              if (assocToCreate[1] !=null) {
                newAssoc.setEntity2_index(assocToCreate[1].replace("$", "${$}"));
                currIt.put("entity2_index", assocToCreate[1]);
              }
              else {
                newAssoc.setEntity2(esp.getEntity2());
                newAssoc.setEntity2_index(esp.getEntity2_index());
              }
             
              // Geo_index
              if (assocToCreate[2] !=null) {
                newAssoc.setGeo_index(assocToCreate[2].replace("$", "${$}"));
                currIt.put("geo_index", assocToCreate[2]);
              }
              else { newAssoc.setGeo_index(esp.getGeo_index()); }
             
              // Time_start
              if (assocToCreate[3] !=null) {
                newAssoc.setTime_start(assocToCreate[3].replace("$", "${$}"));
                currIt.put("time_start", assocToCreate[3]);
              }
              else { newAssoc.setTime_start(esp.getTime_start()); }
             
              // Time_end
              if (assocToCreate[4] !=null) {
                newAssoc.setTime_end(assocToCreate[4].replace("$", "${$}"));
                currIt.put("time_end", assocToCreate[4]);
              }
              else { newAssoc.setTime_end(esp.getTime_end()); }
             
              // Misc. Fields to copy from the original pojo
              newAssoc.setCreationCriteriaScript(esp.getCreationCriteriaScript());
              newAssoc.setVerb(esp.getVerb());
              newAssoc.setVerb_category(esp.getVerb_category());
              newAssoc.setAssoc_type(esp.getAssoc_type());
              newAssoc.setGeotag(esp.getGeotag());

              // Create an association from the AssociationSpecPojo and document
              JSONObject savedIterator = _iterator; // (just in case this needs to be retained - i don't think it does)
              if (null != _scriptEngine) { // (in case no script engine specified)
                _iterator = currIt;
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.config.source.StructuredAnalysisConfigPojo.AssociationSpecPojo

    ArrayList<AssociationSpecPojo> newAssocEntries = null;
   
    if (null != s.getAssociations()) { 
      Iterator<AssociationSpecPojo> assocSpecIt = s.getAssociations().iterator();
      while (assocSpecIt.hasNext()) {
        AssociationSpecPojo assocS = assocSpecIt.next();
        if ((null != assocS.getIterateOver()) && (assocS.getIterateOver().contains(".")))
        {
          // For associations only: included here so it doesn't get forgotten in cut-and-pastes...
          if (assocS.getIterateOver().contains(",") || assocS.getIterateOver().contains("/")) {
            continue;
          }//TESTED
          if (null == nestedAssocMap) { // (do need this map)
            nestedAssocMap = new HashMap<String, AssociationSpecPojo>();
          }
          if (null == newAssocEntries) {
            newAssocEntries = new ArrayList<AssociationSpecPojo>(10);           
          }
          AssociationSpecPojo prevLevelSpec = null;         
          String iterateOver = assocS.getIterateOver() + "."; // (end with "." to make life easier)
          assocS.setIterateOver(null); // (this is now the end of the chain)
          assocSpecIt.remove(); // (so remove from the list)
         
          boolean bChainBroken = false;
          for (int nCurrDot = iterateOver.indexOf('.'), nLastDot = -1;
              nCurrDot >= 0;
            nLastDot = nCurrDot, nCurrDot = iterateOver.indexOf('.', nCurrDot + 1))
          {           
            String currLevel = iterateOver.substring(0, nCurrDot); // (eg a, a.b, a.b.c)
            String lastComp_currLevel = iterateOver.substring(nLastDot + 1, nCurrDot); // (eg a, b, c)
           
            AssociationSpecPojo currLevelSpec = null;
            if (!bChainBroken) {
              currLevelSpec = nestedAssocMap.get(currLevel);
            }
            if (null == currLevelSpec) {
              bChainBroken = true; // (no point in doing any more lookups)
              currLevelSpec = new AssociationSpecPojo();
              nestedAssocMap.put(currLevel, currLevelSpec);
              currLevelSpec.setIterateOver(lastComp_currLevel);
              if (null != prevLevelSpec) { // add myself to the next level
                if (null == prevLevelSpec.getAssociations()) {
                  prevLevelSpec.setAssociations(new ArrayList<AssociationSpecPojo>(5));
                }
                prevLevelSpec.getAssociations().add(currLevelSpec);               
              }
              else { // I am the first level, add myself to entity list
                newAssocEntries.add(currLevelSpec); // (this is now the head of the chain)                         
              }
              prevLevelSpec = currLevelSpec;
            }//TESTED
            else { // We're already have this level, so carry on:
              prevLevelSpec = currLevelSpec; //(in case this was the last level...)
              continue;
            }//TESTED
           
          } //(end loop over expansion levels)

          // Add entS (ie the spec with the content) to the end of the chain
         
          if (null != prevLevelSpec) { // (probably an internal logic error if not)
            if (null == prevLevelSpec.getAssociations()) {
              prevLevelSpec.setAssociations(new ArrayList<AssociationSpecPojo>(5));
            }
            prevLevelSpec.getAssociations().add(assocS);
          }//TESTED         
         
        }//(end found entity with expandable iterateOver)
        else if (null != assocS.getIterateOver()) { // Non-nested case, simpler
          // For associations only: included here so it doesn't get forgotten in cut-and-pastes...
          if (assocS.getIterateOver().contains(",") || assocS.getIterateOver().contains("/")) {
            continue;
          }//TESTED
          if (null == nestedAssocMap) { // (do need this map)
            nestedAssocMap = new HashMap<String, AssociationSpecPojo>();
          }         
          //(and logic is different enough that it makes most sense to do separately rather than grovel to save a few lines)
         
          AssociationSpecPojo currSpec = nestedAssocMap.get(assocS.getIterateOver());
          if (null != currSpec) {
            assocSpecIt.remove();
            if (null == currSpec.getAssociations()) {
              currSpec.setAssociations(new ArrayList<AssociationSpecPojo>(5));
            }
            assocS.setIterateOver(null);
            currSpec.getAssociations().add(assocS);           
          }
          else {
            nestedAssocMap.put(assocS.getIterateOver(), assocS);
          }
        }//TESTED
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.config.source.StructuredAnalysisConfigPojo.AssociationSpecPojo

   
    System.out.println("TEST1: ENTITY ITERATION EXPANSION: ");
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(s));
   
    s.setAssociations(new ArrayList<AssociationSpecPojo>(20));
    AssociationSpecPojo assoc = null;
    assoc = new AssociationSpecPojo();
    //a1
    assoc.setIterateOver("a");
    assoc.setEntity1("a.test1");
    s.getAssociations().add(assoc);
    //a2
    assoc = new AssociationSpecPojo();
    assoc.setIterateOver("a");
    assoc.setEntity1("a.test2");
    s.getAssociations().add(assoc);
    //x1
    assoc = new AssociationSpecPojo();
    assoc.setIterateOver("x");
    assoc.setEntity1("x.test1");
    s.getAssociations().add(assoc);
    //a.b1
    assoc = new AssociationSpecPojo();
    assoc.setIterateOver("a.b");
    assoc.setEntity1("a.b.test1");
    s.getAssociations().add(assoc);
    //a.b.c.d1
    assoc =new AssociationSpecPojo();
    assoc.setIterateOver("a.b.c.d");
    assoc.setEntity1("a.b.c.d.test1");
    s.getAssociations().add(assoc);
    //a.b2
    assoc =new AssociationSpecPojo();
    assoc.setIterateOver("a.b");
    assoc.setEntity1("a.b.test2");
    s.getAssociations().add(assoc);
    //p.q1
    assoc =new AssociationSpecPojo();
    assoc.setIterateOver("p.q");
    assoc.setEntity1("p.q.test1");
    s.getAssociations().add(assoc);
    //"," case
    assoc =new AssociationSpecPojo();
    assoc.setIterateOver("p.q,RR");
    assoc.setEntity1("ITERATE OVER p.q,RR");
    s.getAssociations().add(assoc);
    //"/" case
    assoc =new AssociationSpecPojo();
    assoc.setIterateOver("p.q/SS");
    assoc.setEntity1("ITERATE OVER p.q/SS");
    s.getAssociations().add(assoc);
    // null case
    assoc =new AssociationSpecPojo();
    assoc.setEntity1("(null iterator)");
    s.getAssociations().add(assoc);
   
    //SHOULD HAVE TEST FOR ITERATE OVER p,q (now hand tested anyway)
   
    expandIterationLoops(s);
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.