TypeConverter { public static PathQuery getConversionMapQuery(List<ApiTemplate> conversionTemplates, Class<? extends InterMineObject> typeA, Class<? extends InterMineObject> typeB, Object bagOrIds) { ApiTemplate tq = getConversionTemplates(conversionTemplates, typeA).get(typeB); if (tq == null) { return null; } tq = tq.clone(); String node = tq.getEditablePaths().iterator().next(); PathConstraint c = tq.getEditableConstraints(node).iterator().next(); try { String parent = tq.makePath(node).getPrefix().getNoConstraintsString(); if (bagOrIds instanceof InterMineBag) { InterMineBag bag = (InterMineBag) bagOrIds; tq.replaceConstraint(c, Constraints.in(parent, bag.getName())); } else if (bagOrIds instanceof Collection) { @SuppressWarnings("unchecked") Collection<Integer> ids = (Collection<Integer>) bagOrIds; tq.replaceConstraint(c, Constraints.inIds(parent, ids)); } return tq; } catch (PathException e) { throw new RuntimeException("Template is invalid", e); } } private  TypeConverter(); static Map<InterMineObject, List<InterMineObject>> getConvertedObjectMap(List<ApiTemplate> conversionTemplates,
            Class<? extends InterMineObject> typeA,
            Class<? extends InterMineObject> typeB,
            Object bagOrIds, ObjectStore os); static PathQuery getConversionMapQuery(List<ApiTemplate> conversionTemplates,
                                                Class<? extends InterMineObject> typeA,
                                                Class<? extends InterMineObject> typeB,
                                                Object bagOrIds); static PathQuery getConversionQuery(List<ApiTemplate> conversionTemplates,
            Class<? extends InterMineObject> typeA,
            Class<? extends InterMineObject> typeB,
            Object bagOrIds); static Map<Class, ApiTemplate> getConversionTemplates(
            List<ApiTemplate> conversionTemplates, Class typeA);  }
@Test public void testGetConversionMapQuery() throws Exception { List<String> classKeys = new ArrayList<String>(); classKeys.add("name"); InterMineBag bag = new InterMineBag("Fred", "Employee", "Test bag", new Date(), BagState.CURRENT, os, null, uosw, classKeys); PathQuery resQuery = TypeConverter.getConversionMapQuery(conversionTemplates, Employee.class, Address.class, bag); Assert.assertEquals(1, resQuery.getConstraints().size()); PathConstraintBag resCon = (PathConstraintBag) resQuery.getConstraints().keySet().iterator().next(); Assert.assertNotNull(resCon); Assert.assertEquals("Employee", resCon.getPath()); Assert.assertEquals(ConstraintOp.IN, resCon.getOp()); Assert.assertEquals(bag.getName(), resCon.getBag()); }