TypeConverter { public static PathQuery getConversionQuery(List<ApiTemplate> conversionTemplates, Class<? extends InterMineObject> typeA, Class<? extends InterMineObject> typeB, Object bagOrIds) { PathQuery pq = getConversionMapQuery(conversionTemplates, typeA, typeB, bagOrIds); if (pq == null) { return null; } try { List<String> view = pq.getView(); for (String viewElement : view) { Path path = pq.makePath(viewElement); if (path.getLastClassDescriptor().getType().equals(typeA)) { pq.removeView(viewElement); for (OrderElement orderBy : pq.getOrderBy()) { if (orderBy.getOrderPath().equals(viewElement)) { pq.removeOrderBy(viewElement); } } } } return pq; } catch (PathException e) { throw new RuntimeException("Conversion query was 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 testGetConversionQuery() 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.getConversionQuery(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()); List<String> expectedView = new ArrayList<String>(Collections.singleton("Employee.address.id")); Assert.assertEquals(expectedView, resQuery.getView()); }