Package org.jiql.db.objs

Examples of org.jiql.db.objs.jiqlTableInfo


     //Object o = sqp.getSelectParser().getSelectValue().getValue();
      //int  i = sqp.getSelectParser().getSelectValue().getType();


      jiqlTableInfo ti = sqp.getJiqlTableInfo();
    //  ti.setPrefix(sqp.hasPrefix());
    //  ti.setPrefixName(sqp.getPrefixValue());
    //  ti.setTableLeafs(sqp.hasTableleafs());


      Hashtable hash = sqp.getHash();
      //Enumeration en = hash.keys();
      Hashtable dv = sqp.getDefaultValues();
      Enumeration dven = dv.keys();
      //(dv + " createTable " + hash);
      //{yesno=share titbit, countf=22} createTable {name=varchar(18), yesno=varchar(5), countf=int}
     
      String n = null;
      String v = null;
      int ml = 0;
          while(dven.hasMoreElements())
      {
        n = dven.nextElement().toString();
        v = (String)hash.get(n);
      if(v == null)
        throw JGException.get("no_column_for_default_value","No Column for default value " + n);
      if (v.startsWith("varchar(")){
    v = v.substring("varchar(".length(),v.length()-1);
    ml =  Integer.parseInt(v);
    v = (String)dv.get(n);
    if (v.length() > ml)
        throw JGException.get("default_value_cannot_exceed_max_column_length",v + " Default value cannot exceed max column length " + n);

      }
     
       
      }
          Gateway gappe = Gateway.get(sqp.getProperties());
 
      gappe.writeTableInfo(sqp.getTable(),hash);


     
      //jiqlDBMgr.get(sqp.getProperties()).getCommand("addPrimaryKeys").execute(sqp);
      Enumeration en = sqp.getPrimaryKeys().elements();
      while (en.hasMoreElements())
        ti.addPrimaryKey(en.nextElement().toString());
 
      Hashtable df = sqp.getDefaultValues();
         en = df.keys();
      //  String n = null;
      while (en.hasMoreElements()){
        n = en.nextElement().toString();
        ti.addDefaultValues(n,df.get(n));
      }
     
      en = sqp.getNotNulls().elements();
      while (en.hasMoreElements())
        ti.addNotNull(en.nextElement().toString());
     
       
      //ti.setDefaultValues(sqp.getDefaultValues());
      //ti.setNotNulls(sqp.getNotNulls());
      jiqlDBMgr.get(sqp.getProperties()).saveTableInfo(sqp.getTable(),ti);
View Full Code Here


      String va = n.substring(i + 1,n.length());
      va = va.trim();
      n =n.substring(0,i);
      n = n.trim();

      jiqlTableInfo ti = sqp.getJiqlTableInfo();
      if (ti.getFieldList().contains(n))
        throw new SQLException(n + " FIELD ALREADY EXISTS ON TABLE " + sqp.getTable());
      String tok = null;
      i = va.indexOf(" ");

      /*if (n.toLowerCase().equals("primary") && va.toLowerCase().startsWith("key"))
      {
        va = va.substring("key".length(),va.length());
        va = va.trim();
        va = va.substring( 1,va.length());
        va = va.trim();
        while (!va.endsWith(")")){
          ct = ct + 1;
          va = va + "," + v.elementAt(ct).toString();
        }
        va = va.trim();

        va = va.substring( 0,va.length() -1);
        va = va.trim();
        primaryKeys = new EZArrayList(new StringTokenizer(va,","),true);
      }
     
      else*/ if (i > 0)
      {
        tok = va.substring(i,va.length());
        va = va.substring(0,i);
        tok = tok.trim();
        va = va.trim();
        if (va.endsWith("("))
        {
          i = tok.indexOf(")");
          va = va + tok.substring(0,i + 1);
          tok = tok.substring(i + 1,tok.length());
          tok = tok.trim();
          va = va.trim();
        }
        else if (tok.startsWith("("))
        {
          i = tok.indexOf(")");
          va = va + tok.substring(0,i + 1);
          tok = tok.substring(i + 1,tok.length());
          tok = tok.trim();
          va = va.trim();
        }

        String tok2 = tok.toLowerCase();
        i = tok2.indexOf("not ");
        if (i > -1 && tok2.indexOf(" null") > i)
        {
          if (!sqp.getNotNulls().contains(n)){

            sqp.getNotNulls().add(n);
          }
        }
        i = tok2.indexOf("primary ");
          if (i > -1 && tok2.indexOf(" key") > i)
        {
          n = StringUtil.trimQuotes(new StringBuffer(n)).toString();
          if (!sqp.getPrimaryKeys().contains(n))
            sqp.getPrimaryKeys().add(n);
        }
        i = tok2.indexOf("default ");
          if (i > -1 )
        {
          tok = tok.substring(i + "default ".length(),tok.length());
          tok = tok.trim();
         
          if (tok.startsWith("'"))
          {
          tok = tok.substring(1,tok.length());
          i = tok.indexOf("'");
          tok2 = tok.substring(0,i);
          tok = tok.substring(i + 1,tok.length());
          tok = tok.trim();
          tok2 = sqp.decode(tok2);
          sqp.getDefaultValues().put(n,tok2);
           
          }
          else{
         
          i = tok.indexOf(" ");
          if (i > 0)
            tok = tok.substring(0,i);
          tok = tok.trim();
          tok = StringUtil.getTrimmedValue(tok);
          tok = sqp.decode(tok);
          sqp.getDefaultValues().put(n,tok);
          }
         
        }
            if (!JGUtil.validFieldType(va,sqp))
              throw JGException.get("invalid_field_type",n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());

        //  throw new SQLException (n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());

        sqp.getHash().put(n,sqp.convert(va,n));
        ti.addFieldList(n);
     
      else{
        if (!JGUtil.validFieldType(va,sqp))
          throw JGException.get("invalid_field_type",n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());

          //throw new SQLException (n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());
   
      sqp.getHash().put(n,sqp.convert(va,n));
      ti.addFieldList(n);
      }
  sqp.setAction("AlterAddField");
  sqp.setSpecial(true);
  sqp.setStatementProcessor(spro);
  return true;
View Full Code Here

return true;
}
          //Indicates whether a write on the designated column will definitely succeed.
public int   isNullable(int column)throws SQLException{
  String cn = getColumnName(column);
  jiqlTableInfo jti = sqp.getJiqlTableInfo();
  if (jti == null)
  {
   
    resLog(cn + " isNullable NOT jiqlTableInfo " + column  + ":" + sqp.getTable());
    return columnNullableUnknown;
  }
boolean nn = jti.getNotNulls().contains(cn);
resLog(cn + " isNullable " + column  + ":" + nn + ":" + sqp.getTable());
if (nn)
return columnNoNulls;
  return columnNullable;
}
View Full Code Here

TOP

Related Classes of org.jiql.db.objs.jiqlTableInfo

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.