@DataProvider public void query(Page<DataFile> page, Map<String, Object> parameter) { String hql = "from DataFile where 1=1"; if (parameter != null) { String TopicName = (String) parameter.get("topic_name"); String TemplateName = (String) parameter.get("template_name"); String fileName = (String) parameter.get("file_name"); if (!StringUtils.isEmpty(TopicName)){ hql += " and template.topic.topic_name ='"+TopicName+"'"; } if(!StringUtils.isEmpty(TemplateName)){ hql += " and template.template_name ='"+TemplateName+"'"; } if(!StringUtils.isEmpty(fileName)){ hql += " and file_name like '%"+fileName+"%'"; } } searchHistoryDao.find(page, hql); } @DataProvider public Collection<Topic> getTopic() { Collection<Topic> to=topicDao.getAll(); return to; } @DataProvider public Collection<Template> getAllTemplateByTopicId(Long topic_id) { return templateDao.find("from Template where topic.id=" + topic_id); }
注意hql的写法。
@DataProvider public Collection<Asset> getDefAssetType() { List<String> list = assetService.getDefassetType(); List<Asset> ass = new ArrayList<Asset>(); for (String str : list) { Asset a = new Asset(); a.setAssetType(str); ass.add(a); } return ass; }
以上是不重复的取出assettype的值;