本文整理了Java中org.intermine.metadata.Model.getInstanceByName()
方法的一些代码示例,展示了Model.getInstanceByName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.getInstanceByName()
方法的具体详情如下:
包路径:org.intermine.metadata.Model
类名称:Model
方法名:getInstanceByName
[英]Return a Model for specified model name (loading Model if necessary)
[中]返回指定模型名称的模型(如有必要,加载模型)
代码示例来源:origin: org.intermine/intermine-model
/**
* Set the model to be used.
* @param modelName the model to be used
*/
public void setModel(String modelName) {
try {
model = Model.getInstanceByName(modelName);
} catch (Exception e) {
throw new BuildException(e);
}
}
代码示例来源:origin: intermine/intermine
public void testGetInstanceByNameSameInstance() throws Exception {
Model model1 = Model.getInstanceByName("basicmodel");
Model model2 = Model.getInstanceByName("basicmodel");
assertTrue(model1 == model2);
}
代码示例来源:origin: intermine/intermine
public void testGetInstanceByWrongName() throws Exception {
try {
Model.getInstanceByName("wrong_name");
fail("Expected IllegalArgumentException, wrong model name");
} catch (IllegalArgumentException e) {
}
}
代码示例来源:origin: intermine/intermine
private PathQuery createQuery(String fileName) {
String path = "PathQueryBindingUnmarshal/" + fileName;
InputStream is = getClass().getClassLoader().getResourceAsStream(path);
if (is == null) {
throw new RuntimeException("Could not find the required XML file: " + path);
}
Model.getInstanceByName("testmodel");
PathQuery ret = PathQueryBinding.unmarshalPathQueries(new InputStreamReader(is), 1).values().iterator().next();
return ret;
}
}
代码示例来源:origin: intermine/intermine
public void testMultipleQueries() {
String path = "PathQueryBindingUnmarshal/MultipleQueries.xml";
InputStream is = getClass().getClassLoader().getResourceAsStream(path);
Model.getInstanceByName("testmodel");
Collection<PathQuery> pqlist = PathQueryBinding.unmarshalPathQueries(new InputStreamReader(is), 1).values();
assertEquals(pqlist.size(), 2);
}
代码示例来源:origin: intermine/intermine
public void testParse() throws Exception {
Model model = Model.getInstanceByName("testmodel");
InputStream is = getClass().getClassLoader().getResourceAsStream("TagHandlerTest.xml");
if (is == null) {
throw new IllegalArgumentException("is was null");
}
TagHandler handler = new TagHandler(pm, username);
SAXParser.parse(new InputSource(is), handler);
int count = handler.getCount();
assertEquals(20, count);
}
}
代码示例来源:origin: intermine/intermine
public void setUp() throws Exception {
parser = new InterMineModelParser();
testModel = Model.getInstanceByName("testmodel");
emptyModel = new Model("testModel", "org.intermine.model.testmodel", Collections.EMPTY_SET);
}
代码示例来源:origin: intermine/intermine
private PathQuery getPQ() {
PathQuery pq = new PathQuery(Model.getInstanceByName("testmodel"));
pq.addViews(
"Company.name",
"Company.departments.name",
"Company.departments.employees.name",
"Company.departments.employees.age",
"Company.departments.employees.address.address",
"Company.secretarys.name",
"Company.vatNumber");
return pq;
}
代码示例来源:origin: intermine/intermine
public void testCandidateLoopsNoViewNoOuterJoins() throws Exception {
Model model = Model.getInstanceByName("testmodel");
PathQuery q = new PathQuery(model);
assertEquals("There are no candidate loops on a freshly minted query",
Collections.emptySet(), q.getCandidateLoops("Employee.department.employees.department.employees"));
}
代码示例来源:origin: intermine/intermine
public void testCandidateLoopsOneViewNoOuterJoins() throws Exception {
Model model = Model.getInstanceByName("testmodel");
PathQuery q = new PathQuery(model);
q.addView("Employee.age");
assertEquals("A rooted query will report candidate loops",
new HashSet<String>(Arrays.asList("Employee", "Employee.department.employees")),
q.getCandidateLoops("Employee.department.employees.department.employees"));
}
代码示例来源:origin: intermine/intermine
public void testNewPathQuery() throws Exception {
Model model = Model.getInstanceByName("testmodel");
PathQuery q = getQuery1(model);
assertEquals("<query name=\"test\" model=\"testmodel\" view=\"Employee.name\" longDescription=\"\"><constraint path=\"Employee.age\" op=\"<\" value=\"50\"/></query>", PathQueryBinding.marshal(q, "test", "testmodel", 1));
}
代码示例来源:origin: intermine/intermine
public void testNewPathQuery2() throws Exception {
Model model = Model.getInstanceByName("testmodel");
PathQuery q = getQuery2(model);
assertEquals("<query name=\"test\" model=\"testmodel\" view=\"Employee.name Employee.department.name\" longDescription=\"Flibble\" sortOrder=\"Employee.age asc\" constraintLogic=\"A or B\"><join path=\"Employee.department\" style=\"INNER\"/><pathDescription pathString=\"Employee.name\" description=\"Albert\"/><constraint path=\"Employee.age\" code=\"A\" op=\"<\" value=\"50\"/><constraint path=\"Employee.department.name\" code=\"B\" op=\"=\" value=\"Fred\"/></query>", PathQueryBinding.marshal(q, "test", "testmodel", 1));
}
代码示例来源:origin: intermine/intermine
public void testViewUpdated() throws Exception {
TemplateQueryUpdate templateQueryUpdate = new TemplateQueryUpdate(templateQuery,
Model.getInstanceByName("oldtestmodel"));
templateQueryUpdate.update(renamedClasses, renamedFields);
ApiTemplate newTemplateQuery = templateQueryUpdate.getNewTemplateQuery();
//verify view
List<String> expected = Arrays.asList("CEO.name", "CEO.title", "CEO.company.name", "CEO.salary");
assertEquals(expected, newTemplateQuery.getView());
}
代码示例来源:origin: intermine/intermine
public void testNeq() {
PathQuery q = new PathQuery(Model.getInstanceByName("testmodel"));
q.addConstraint(Constraints.neq("Employee.name", "monkey"));
assertEquals("<query name=\"query\" model=\"testmodel\" view=\"\" longDescription=\"\"><constraint path=\"Employee.name\" op=\"!=\" value=\"monkey\"/></query>", q.toXml(1));
}
代码示例来源:origin: intermine/intermine
public void testOrderByUpdate() throws Exception {
TemplateQueryUpdate templateQueryUpdate = new TemplateQueryUpdate(templateQuery,
Model.getInstanceByName("oldtestmodel"));
templateQueryUpdate.update(renamedClasses, renamedFields);
ApiTemplate newTemplateQuery = templateQueryUpdate.getNewTemplateQuery();
//verify order by
assertEquals(2, newTemplateQuery.getOrderBy().size());
assertEquals("CEO.name", newTemplateQuery.getOrderBy().get(0).getOrderPath());
assertEquals("CEO.salary", newTemplateQuery.getOrderBy().get(1).getOrderPath());
}
代码示例来源:origin: intermine/intermine
public void testNotIn() {
PathQuery q = new PathQuery(Model.getInstanceByName("testmodel"));
q.addConstraint(Constraints.notIn("Employee", "1"));
assertEquals("<query name=\"query\" model=\"testmodel\" view=\"\" longDescription=\"\"><constraint path=\"Employee\" op=\"NOT IN\" value=\"1\"/></query>", q.toXml(1));
}
代码示例来源:origin: intermine/intermine
public void testOuterJoinsUpdate() throws Exception {
TemplateQueryUpdate templateQueryUpdate = new TemplateQueryUpdate(templateQuery,
Model.getInstanceByName("oldtestmodel"));
templateQueryUpdate.update(renamedClasses, renamedFields);
ApiTemplate newTemplateQuery = templateQueryUpdate.getNewTemplateQuery();
//verify outer join
assertEquals(OuterJoinStatus.OUTER, newTemplateQuery.getOuterJoinStatus("CEO.company"));
}
代码示例来源:origin: intermine/intermine
public void testNullConstraints() throws Exception {
PathQuery pq = new PathQuery(Model.getInstanceByName("testmodel"));
pq.addViews("Department.name");
pq.addConstraint(new PathConstraintNull("Department.manager", ConstraintOp.IS_NULL));
pq.addOrderBy("Department.name", OrderDirection.ASC);
assertEquals(pq.toString(), savedQueries.get("nullConstraint").toString());
}
代码示例来源:origin: intermine/intermine
@BeforeClass
public static void oneTimeSetUp() throws Exception {
os = new ObjectStoreTranslatingImpl(
Model.getInstanceByName("testmodel"),
ObjectStoreFactory.getObjectStore("os.unittest"),
new DummyTranslator());
ObjectStoreTestCase.oneTimeSetUp(os, "osw.unittest", "testmodel", "testmodel_data.xml");
}
代码示例来源:origin: intermine/intermine
public void testNameDescCommentUnchanged() throws Exception {
TemplateQueryUpdate templateQueryUpdate = new TemplateQueryUpdate(templateQuery,
Model.getInstanceByName("oldtestmodel"));
templateQueryUpdate.update(renamedClasses, renamedFields);
ApiTemplate newTemplateQuery = templateQueryUpdate.getNewTemplateQuery();
assertEquals("test", newTemplateQuery.getName());
assertEquals("title", newTemplateQuery.getTitle());
assertEquals("comment", newTemplateQuery.getComment());
}
内容来源于网络,如有侵权,请联系作者删除!