/** * Create a new object of the given class and give it a unique ID. * @param c the class * @param <C> the type of the class * @return the new InterMineObject */ public <C extends InterMineObject> C createObject(Class<C> c) { C o = DynamicUtil.simpleCreateObject(c); o.setId(new Integer(idCounter)); idCounter++; return o; }
/** * Create a new object of the given class and give it a unique ID. * @param c the class * @param <C> the type of the class * @return the new InterMineObject */ public <C extends InterMineObject> C createObject(Class<C> c) { C o = DynamicUtil.simpleCreateObject(c); o.setId(new Integer(idCounter)); idCounter++; return o; }
/** * Create a copy of given InterMineObject with *no* id set and copies of collections * * @param obj object to copy * @param <O> The object type * @return the copied object * @throws IllegalAccessException if problems with reflection */ public static <O extends InterMineObject> O copyInterMineObject(O obj) throws IllegalAccessException { O newObj = cloneInterMineObject(obj, true); newObj.setId(null); return newObj; }
protected void setIds(Collection<FastPathObject> c) throws Exception { int i=1; for (Object o : c) { if (o instanceof InterMineObject) { ((InterMineObject) o).setId(new Integer(i++)); } } } }
public void store(Object nimo) throws ObjectStoreException { if (nimo instanceof InterMineObject) { InterMineObject o = (InterMineObject) nimo; if (o.getId() == null) { Integer newId = getSerial(); o.setId(newId); storedObjects.put(newId, o); } else { storedObjects.put(o.getId(), o); } } }
LOG.info("InterMine Id " + ((InterMineObject) o).toString()); InterMineObject io = (InterMineObject) o; io.setId(new Integer(idCounter++));
LOG.info("InterMine Id " + ((InterMineObject) o).toString()); InterMineObject io = (InterMineObject) o; io.setId(new Integer(idCounter++));
newObj.setId(newId);
newObj.setId(newId);
public void testPopulateTemplateWithObjectWrongType() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Department.class); obj.setId(101); try { TemplatePopulator.populateTemplateWithObject(simple, obj); fail("Expected a TemplatePopulatorException"); } catch (TemplatePopulatorException e) { } }
public void testPopulateTemplateWithObjectNotOneConstraint() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Employee.class); obj.setId(101); try { TemplatePopulator.populateTemplateWithObject(twoConstraints, obj); fail("Expected a TemplatePopulatorException"); } catch (TemplatePopulatorException e) { } }
public void testPopulateTemplateWithObject() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Employee.class); obj.setId(101); TemplateQuery res = TemplatePopulator.populateTemplateWithObject(simple, obj); assertEquals(0, res.getEditableConstraints("Employee").size()); assertEquals(0, res.getEditableConstraints("Employee.name").size()); assertEquals(1, res.getEditableConstraints("Employee.id").size()); PathConstraint resCon = res.getEditableConstraints().get(0); assertEquals(ConstraintOp.EQUALS, resCon.getOp()); assertEquals("101", ((PathConstraintAttribute) resCon).getValue()); }
InterMineObject destObj = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); destObj.setId(destId); cs.addConstraint(new ContainsConstraint(new QueryObjectReference(qc, fieldName), ConstraintOp.CONTAINS, destObj));
InterMineObject destObj = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); destObj.setId(destId); cs.addConstraint(new ContainsConstraint(new QueryObjectReference(qc, fieldName), ConstraintOp.CONTAINS, destObj));