Package com.trikke.exception

Examples of com.trikke.exception.ParserException


          }
          table.addField( type, info.get( "name" ).asString(), constraints );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the fields in this table." );
      }
      if ( jsontable.names().contains( "constraints" ) )
      {
        try
        {
          for ( JsonValue jsoninfo : jsontable.get( "constraints" ).asArray() )
          {
            JsonObject info = (JsonObject) jsoninfo;
            String definition = info.get( "definition" ).asString();
            if ( definition.toLowerCase().contains( "primary key" ) )
            {
              // skip if primary key already set
              if ( table.hasPrimaryKey() )
              {
                continue;
              }

              final Field field = table.getFieldByName( info.get( "name" ).asString() );
              if ( field != null )
              {
                table.setPrimaryKey( field );
              }
            }
            table.addConstraint( info.names().contains( "name" ) ? info.get( "name" ).asString() : null, definition );
          }
        } catch ( NullPointerException e )
        {
          throw new ParserException( "Couldn't parse the constraints in this table." );
        }
      }
      mModel.addTable( table );
    }
  }
View Full Code Here


          JsonObject info = (JsonObject) jsoninfo;
          view.addSelect( (info.names().contains( "as" )) ? info.get( "as" ).asString() : null, info.get( "select" ).asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the selects in this view." );
      }

      try
      {
        for ( JsonValue jsoninfo : jsonview.get( "from" ).asArray() )
        {
          view.addFromTable( jsoninfo.asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the from tables in this view." );
      }

      try
      {
        for ( JsonValue jsoninfo : jsonview.get( "on" ).asArray() )
        {
          view.addJoinOn( jsoninfo.asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the fields on which to join in this view." );
      }
      try
      {
        if ( jsonview.names().contains( "order" ) )
        {
          for ( JsonValue jsoninfo : jsonview.get( "order" ).asArray() )
          {
            JsonObject info = (JsonObject) jsoninfo;
            view.addOrder( info.get( "by" ).asString(), (info.names().contains( "sort" )) ? info.get( "sort" ).asString() : "ASC" );
          }
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the ordering in this view." );
      }
      try
      {
        if ( jsonview.names().contains( "group" ) )
        {
          for ( JsonValue jsoninfo : jsonview.get( "group" ).asArray() )
          {
            view.addGroup( jsoninfo.asString() );
          }
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the grouping in this view." );
      }
      if ( jsonview.names().contains( "join" ) )
      {
        view.jointype = jsonview.get( "join" ).asString();
      }
View Full Code Here

TOP

Related Classes of com.trikke.exception.ParserException

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.