Package org.jitterbit.integration.data.script.Transform

Examples of org.jitterbit.integration.data.script.Transform.Token


  public void checkDataTypeWarningForOneToOneMapping(Node target) throws TreeMapperException
  {
    assert target!=null : "checkIfOneToOneMapping() should not be called with target being null.";
    if(!target.isFolder() && m_stackVector!=null && m_stackVector.size()==1){
      Token token=m_stackVector.get(0);
      if(token.m_id==Transform.t_DE){
        String str=token.m_str;
        Node source=m_sourceTreeComponent.findNode(str);
        if(source!=null && !source.isFolder()){
          setDataTypeWarning(target, source);
View Full Code Here


      Transform trans = new Transform();
      trans.initTokenizer(expr, start, end);

      boolean isAtStart=true, hasValidLHS=false;
      Token t;
      while((t=trans.nextToken(isAtStart,hasValidLHS))!=null){
        int id=t.getId();
        if(id==Transform.t_End)break;
        if(id==Transform.t_Unknown){
          return null;
        }
        if(id==Transform.t_DE){
          //String oldDeName=t.getStr();
          // if oldDeName does not contains instance tag
          String oldDe0=t.getStr(),newDe0=mapTable.get(oldDe0);
          if(newDe0!=null){
            newExpr.append(newDe0);
          } else {
            StringTokenizer tk=new StringTokenizer(oldDe0,"#.",true);
            String str="";
            StringBuilder oldDe=new StringBuilder();
            String newDe=""; // oldDe0, newDe0 have '#', but oldDe, newDe don't
            boolean bPrompt=false;
            while(tk.hasMoreTokens()){
              String token=tk.nextToken();
              if(token.charAt(0)=='#'){
                StringBuilder tag=new StringBuilder("#"); // tag is the substring between '#' and '.' including '#' and '.'
                while(tk.hasMoreTokens()){
                  token=tk.nextToken();
                  tag.append(token);
                  if(token.charAt(0)=='.')break;
                }
                oldDe.append('.');
                int last_len=newDe.length();
                String newDe_tmp=mapTable.get("["+oldDe+"]");
                if(newDe_tmp==null){
                  bPrompt=true;
                          continue;
                } else if(newDe_tmp.charAt(0)=='['){
                  newDe=newDe_tmp.substring(1,newDe_tmp.length()-1);
                }
                int len=newDe.length();
                if(newDe.charAt(len-1)=='.'){ // this subnode terminate with '.'
                  str+=newDe.substring(last_len,len-1)+tag;
                }
                else {// subnode terminate with '$'
                  str+=newDe.substring(last_len,len);
                }
              }
              else {
                oldDe.append(token);
              }
            }
            int last_len=newDe.length();
            newDe=mapTable.get(oldDe.toString());
            if(newDe!=null){
              if(last_len<newDe.length()){
                str+=newDe.substring(last_len,newDe.length());
              }
              if(bPrompt){
                String title = "Target: "+targetDE;
                str=migration.manualConversion(title, oldDe0, str);
              }
              if(str!=null)newExpr.append(str);
            }
            if(str==null||newDe==null) {
              String title = "Target: "+targetDE;
              String err_message =
                "Failed to translate node: "+oldDe0+
                "\nin the following expression:";
              String question = "Do you want to skip the migration for this mapping?";

              if(migration.checkToContinue(title,err_message,expr,question)){
                        return null;
                      }
                      else {
                        throw new ScriptException(
                            "Error in migrating the mapping\n"+
                    "\nThe target node: "+ targetDE +
                    "\nFailed to translate the node:\n"+oldDe0+
                    "\nin the expression\n" + expr);
                      }
            }
          }
        } else {
          newExpr.append(t.getStr());
        }
        if(id!=Transform.t_Space && id!=Transform.t_Comment){
          hasValidLHS=(id==Transform.t_Set||id==Transform.t_GlobalDE||id==Transform.t_LocalDE);
          isAtStart=(id==Transform.t_Set||id==Transform.t_LP||id==Transform.t_Fcn||
            id==Transform.t_And||id==Transform.t_Or||id==Transform.t_NE||id==Transform.t_EQ||
View Full Code Here

        }
       
        private boolean isAssignment(List<Token> tokens, int current) {
            int bracketCount = 0;
            for (int index = current, size = tokens.size(); index < size; ++index) {
                Token t = tokens.get(index);
                switch (t.m_id) {
                case Transform.t_Set:
                    return true;
                case Transform.t_Space:
                case Transform.t_Comment:
View Full Code Here

        }
       
        private String getFirstStringArgument(List<Token> tokens, int current) {
            String name = null;
            for (int index = current, size = tokens.size(); index < size; ++index) {
                Token t = tokens.get(index);
                switch (t.m_id) {
                case Transform.t_StrC:
                    name = removeBeginAndEndQuotes(t);
                    break;
                case Transform.t_Space:
View Full Code Here

    List<Token> list = transform.tokenize(expression);
    Iterator<Token> it = list.iterator();
    String tagPrefix = idToPrefix(idClass);
    int skip = tagPrefix.length() + 1;
    while (it.hasNext()) {
            Token t = it.next();
      boolean isOurFunction = t.m_id==Transform.t_Fcn && (t.getStr().equals(func) );
      if (isOurFunction) {
        boolean hasStringArg = it.hasNext() && (t=it.next()).m_id==Transform.t_StrC;
        if (hasStringArg) {
          try {
              // "op.9a768b3b-2a2d-490d-baec-7506e4286851" --> 9a768b3b-2a2d-490d-baec-7506e4286851
            String idAsString = t.getStr().substring(skip,skip + /*GUID-length*/36);
            IntegrationEntityId id = createIdFromFunctionArg(idAsString, tagPrefix);
            if (idClass.isInstance(id)) {
              ids.add(idClass.cast(id));
            }
          } catch (Exception e) {
                      String funcName = stripTrailingBrace(func);
            ErrorLog.log(idClass, "Could not resolve the argument '" + t.getStr() + "' of '" +
                funcName + "' to an id. " + locationForLog, e);
          }
        }
      }
    }
View Full Code Here

            // This probably means something went wrong in tokenize.
            return ids;
        }
    Iterator<Token> it = list.iterator();
    while ( it.hasNext() ) {
      Token t = it.next();
      if (isFunctionCallWithProjectItems(t)) {
        String funcName = stripTrailingBrace(t.getStr());
        boolean hasStringArg = it.hasNext() && (t=it.next()).m_id==Transform.t_StrC;
        if (hasStringArg) {
          try {
            ProjectItemFunction f = (ProjectItemFunction)FunctionRegistry.getRegistry().getFunctionByName(funcName);
            String prefix = f.getProjectPrefixes(); // there's only one prefix per function for now
            int skip = prefix.length() + 2;
            String idAsString = t.getStr().substring(skip,t.getStr().length()-1); // "op.9a768b3b-2a2d-490d-baec-7506e4286851" --> 9a768b3b-2a2d-490d-baec-7506e4286851
            IntegrationEntityId id = createIdFromFunctionArg(idAsString, prefix);
            if (id != null) {
                          ids.add(id);
            } else {
                throw new Exception("createIdFromFunctionArg returned null");
            }
          } catch (Exception e) {
            ErrorLog.log(GrammarUtils.class, "Could not resolve the argument '" + t.getStr() + "' of '" +
                funcName + "' to an id. " + locationForLog, e);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.jitterbit.integration.data.script.Transform.Token

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.