test_class.file: dal-jdbc/src/test/java/org/unidal/dal/jdbc/query/token/resolver/FieldTokenResolverTest.java
test_class.identifier: FieldTokenResolverTest
test_class.superclass: extends AbstractTokenResolverTest
test_case.body: @Test
     public void testFieldAndWhereClause() throws Exception {
        QueryDef query = new QueryDef("test", UserEntity.class, QueryType.SELECT, "SELECT <FIELD name='user-id'/> FROM <TABLE/> WHERE <FIELD name='user-name'/> IS NOT NULL");
        Readset<?> readset = UserEntity.READSET_FULL;
        User user = new User();
        QueryContext ctx = getSelectContext(query, user, readset);
        
        m_queryResolver.resolve(ctx);
        Assert.assertEquals("SELECT u.user_id FROM `user` u WHERE u.full_name IS NOT NULL", ctx.getSqlStatement());
        Assert.assertEquals(true, ctx.isTableResolved());
        Assert.assertEquals("[user-id]", ctx.getOutFields().toString());
     }
test_case.class_method_signature: FieldTokenResolverTest.testFieldAndWhereClause()
test_case.full_signature: @Test public void testFieldAndWhereClause()
test_case.identifier: testFieldAndWhereClause
test_case.invocations: getSelectContext resolve assertEquals getSqlStatement assertEquals isTableResolved assertEquals toString getOutFields
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFieldAndWhereClause()
focal_class.declarator: m_manager
focal_class.modifier: @Inject
     private
focal_class.original_string: @Inject
     private EntityInfoManager m_manager;
focal_class.type: EntityInfoManager
focal_class.var_name: m_manager
focal_class.declarator: m_expressionResolver
focal_class.modifier: @Inject
     private
focal_class.original_string: @Inject
     private ExpressionResolver m_expressionResolver;
focal_class.type: ExpressionResolver
focal_class.var_name: m_expressionResolver
focal_class.declarator: m_naming
focal_class.modifier: @Inject
     private
focal_class.original_string: @Inject
     private QueryNaming m_naming;
focal_class.type: QueryNaming
focal_class.var_name: m_naming
focal_class.file: dal-jdbc/src/main/java/org/unidal/dal/jdbc/query/token/resolver/FieldTokenResolver.java
focal_class.identifier: FieldTokenResolver
focal_class.interfaces: implements TokenResolver
focal_class.class_method_signature: FieldTokenResolver.resolve(Token token, QueryContext ctx)
focal_class.full_signature: public String resolve(Token token, QueryContext ctx)
focal_class.identifier: resolve
focal_class.modifiers: public
focal_class.parameters: (Token token, QueryContext ctx)
focal_class.return: String
focal_class.signature: String resolve(Token token, QueryContext ctx)
focal_method.body: public String resolve(Token token, QueryContext ctx) {
        if (token.getType() != TokenType.FIELD) {
           throw new DalRuntimeException("Internal error: only FIELD token is supported by " + getClass());
        }
  
        SimpleTagToken field = (SimpleTagToken) token;
        String fieldName = field.getAttribute("name", null);
        String tableName = field.getAttribute("table", ctx.getEntityInfo().getLogicalName());
        String[] logicalNameAndAlias = ctx.getEntityInfo().getLogicalNameAndAlias(tableName);
        EntityInfo entityInfo = m_manager.getEntityInfo(logicalNameAndAlias[0]);
        Attribute attribute = entityInfo.getAttribute(fieldName);
  
        if (attribute != null) {
           switch (ctx.getQuery().getType()) {
           case SELECT:
              if (!ctx.isTableResolved()) {
                 DataField f = entityInfo.getFieldByName(fieldName);
  
                 ctx.addOutField(f);
                 ctx.addOutSubObjectName(null);
              }
  
              if (attribute.selectExpr().length() > 0) {
                 return m_expressionResolver.resolve(ctx, attribute.selectExpr());
              } else {
                 String tableAlias = logicalNameAndAlias[1];
  
                 return m_naming.getField(attribute.field(), tableAlias);
              }
           case INSERT:
              return m_naming.getField(attribute.field());
           case UPDATE:
              return m_naming.getField(attribute.field());
           case DELETE:
              return m_naming.getField(attribute.field());
           default:
              throw new DalRuntimeException("TABLE token does not support query type: " + ctx.getQuery().getType());
           }
        } else {
           throw new DalRuntimeException("DataField(" + fieldName + ") is not defined in "
                 + ctx.getQuery().getEntityClass() + ". Query: " + ctx.getQuery());
        }
     }
focal_method.class_method_signature: FieldTokenResolver.resolve(Token token, QueryContext ctx)
focal_method.full_signature: public String resolve(Token token, QueryContext ctx)
focal_method.identifier: resolve
focal_method.invocations: getType getClass getAttribute getAttribute getLogicalName getEntityInfo getLogicalNameAndAlias getEntityInfo getEntityInfo getAttribute getType getQuery isTableResolved getFieldByName addOutField addOutSubObjectName length selectExpr resolve selectExpr getField field getField field getField field getField field getType getQuery getEntityClass getQuery getQuery
focal_method.modifiers: public
focal_method.parameters: (Token token, QueryContext ctx)
focal_method.return: String
focal_method.signature: String resolve(Token token, QueryContext ctx)