当前位置:   article > 正文

NC 获取语义模型里的sql_nc怎么把语义模型转换为sql

nc怎么把语义模型转换为sql
package junit;

import java.util.List;

import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.core.service.IFwLogin;
import nc.bs.framework.test.AbstractTestCase;
import nc.itf.uap.IUAPQueryBS;
import nc.pub.smart.context.SmartContext;
import nc.pub.smart.exception.SmartException;
import nc.pub.smart.model.SmartModel;
import nc.pub.smart.model.descriptor.Descriptor;
import nc.pub.smart.provider.Provider;
import nc.vo.pub.BusinessException;
import nc.vo.smart.SmartDefVO;

public class Test extends AbstractTestCase{
	public void test(){
		try {
			IUAPQueryBS lookup = NCLocator.getInstance().lookup(IUAPQueryBS .class);
			List<SmartDefVO> defvo = (List<SmartDefVO>) lookup.retrieveByClause(SmartDefVO.class," defcode='test_fei'" );
			SmartModel smartmodel = defvo.get(0).getSmartmodel();
			SmartContext context = smartmodel.getInitialContext();
			Descriptor[] descriptors = smartmodel.getDescriptors();
			String provideSQL = smartmodel.provideSQL(context, descriptors);
			Provider[] providers = smartmodel.getProviders();
			for (Provider provider : providers) {
				String tableSql = provider.provideScript(context);
				System.out.println("初始sql:"+tableSql);
			}
			System.out.println("解析sql:"+provideSQL);
		} catch (SmartException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		} catch (BusinessException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}
	
	@Override
	public void setUp() throws Exception{
		super.setUp();
		InvocationInfoProxy.getInstance().setUserCode("feifei");//模拟客户端设置用户,否则报invalid secrity token 
		NCLocator.getInstance().lookup(IFwLogin.class).login("feifei","1234qwer" , null);//模拟后台设置token,否则报invalid secrity token(null)
	}
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/433384
推荐阅读
相关标签
  

闽ICP备14008679号