/** * Creates a constraint for a path to be IN a named bag. * * @param path the path to apply the constraint to * @param bag the bag name to constrain to * @return a new PathConstraint object */ public static PathConstraintBag in(String path, String bag) { return new PathConstraintBag(path, ConstraintOp.IN, bag); }
/** * Returns all bag names used in constraints on this query. * * @return the bag names used in this query or an empty set */ public synchronized Set<String> getBagNames() { Set<String> bagNames = new HashSet<String>(); for (PathConstraint constraint : constraints.keySet()) { if (constraint instanceof PathConstraintBag) { bagNames.add(((PathConstraintBag) constraint).getBag()); } } return bagNames; }
((PathConstraintAttribute) pathConstraint).getValue()); } else if (pathConstraint instanceof PathConstraintBag) { newPathConstraint = new PathConstraintBag(newPath, op, ((PathConstraintBag) pathConstraint).getBag()); } else if (pathConstraint instanceof PathConstraintLookup) { newPathConstraint = new PathConstraintLookup(newPath,
@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()); }
((PathConstraintAttribute) pathConstraint).getValue()); } else if (pathConstraint instanceof PathConstraintBag) { newPathConstraint = new PathConstraintBag(newPath, op, ((PathConstraintBag) pathConstraint).getBag()); } else if (pathConstraint instanceof PathConstraintLookup) { newPathConstraint = new PathConstraintLookup(newPath,
@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()); } }
/** * Creates a constraint for a path to be NOT IN a named bag. * * @param path the path to apply the constraint to * @param bag the bag name to constrain to * @return a new PathConstraint object */ public static PathConstraintBag notIn(String path, String bag) { return new PathConstraintBag(path, ConstraintOp.NOT_IN, bag); }
/** * Returns all bag names used in constraints on this query. * * @return the bag names used in this query or an empty set */ public synchronized Set<String> getBagNames() { Set<String> bagNames = new HashSet<String>(); for (PathConstraint constraint : constraints.keySet()) { if (constraint instanceof PathConstraintBag) { bagNames.add(((PathConstraintBag) constraint).getBag()); } } return bagNames; }
/** * Creates a constraint for a path to be IN a named bag. * * @param path the path to apply the constraint to * @param bag the bag name to constrain to * @return a new PathConstraint object */ public static PathConstraintBag in(String path, String bag) { return new PathConstraintBag(path, ConstraintOp.IN, bag); }
} else if (constraint.getKey() instanceof PathConstraintBag) { writer.writeAttribute("op", "" + constraint.getKey().getOp()); writer.writeAttribute("value", ((PathConstraintBag) constraint.getKey()).getBag()); } else if (constraint.getKey() instanceof PathConstraintIds) { writer.writeAttribute("op", "" + constraint.getKey().getOp());
/** * Creates a constraint for a path to be NOT IN a named bag. * * @param path the path to apply the constraint to * @param bag the bag name to constrain to * @return a new PathConstraint object */ public static PathConstraintBag notIn(String path, String bag) { return new PathConstraintBag(path, ConstraintOp.NOT_IN, bag); }
String value = ((PathConstraintBag) pc).getBag(); return start + "{\"op\": \"" + op + "\", \"value\": \"" + value + "\"}";
constraint = new PathConstraintBag(path, constraintOp, value); } else if (idArray != null) { List<Integer> ids = new ArrayList<Integer>();
} else if (constraint.getKey() instanceof PathConstraintBag) { writer.writeAttribute("op", "" + constraint.getKey().getOp()); writer.writeAttribute("value", ((PathConstraintBag) constraint.getKey()).getBag()); } else if (constraint.getKey() instanceof PathConstraintIds) { writer.writeAttribute("op", "" + constraint.getKey().getOp());
constraint = new PathConstraintBag(path, constraintOp, value); } else if (idArray != null) { List<Integer> ids = new ArrayList<Integer>();
String value = ((PathConstraintBag) pc).getBag(); return start + "{\"op\": \"" + op + "\", \"value\": \"" + value + "\"}";
String ids = attrs.get("ids"); if (bag != null) { return new PathConstraintBag(path, constraintOp, bag); } else if (ids != null) { String[] idArray = ids.split(",");
String list = ((PathConstraintBag) pc).getBag(); sb.append("\"" + op.toString() + "\""); sb.append(", \"" + list + "\"");