public ConcurrencyException(final NakedReference object, final Version updated) { this(object.getVersion().getUser() + " changed " + object.titleString() + " at " + DATE_TIME.format(object.getVersion().getTime()) + "\n\n" + object.getVersion() + " ~ " + updated + "", object.getOid()); }
public void madePersistent(final NakedReference adapter) { Oid oid = adapter.getOid(); /* * WARNING - changing the OID object that is already a key in the identity map messes up the hashing * so it can't be found afterwards. To work properly, remove the identity first then change the oid, * finally re-add to the map. */ identites.remove(oid); NakedObjectsContext.getObjectPersistor().convertTransientToPersistentOid(oid); Assert.assertTrue("Adapter's pojo should exist in pojo map and return the adapter", objectAdapters.get(adapter .getObject()) == adapter); Assert.assertNull("Changed OID should not already map to a known adapter " + oid, identites.get(oid)); identites.put(oid, adapter); adapter.changeState(ResolveState.RESOLVED); }
public void madePersistent(final NakedReference adapter) { Oid oid = adapter.getOid(); /* * WARNING - changing the OID object that is already a key in the identity map messes up the hashing * so it can't be found afterwards. To work properly, remove the identity first then change the oid, * finally re-add to the map. */ identites.remove(oid); NakedObjectsContext.getObjectPersistor().convertTransientToPersistentOid(oid); Assert.assertTrue("Adapter's pojo should exist in pojo map and return the adapter", objectAdapters.get(adapter .getObject()) == adapter); Assert.assertNull("Changed OID should not already map to a known adapter " + oid, identites.get(oid)); identites.put(oid, adapter); adapter.changeState(ResolveState.RESOLVED); }
public static void addObjectMenuOptions(final NakedReference object, final UserActionSet options) { if (object != null) { NakedObjectAction[] actions1 = object.getSpecification().getObjectActions(NakedObjectAction.USER); NakedObjectAction[] actions2 = object.getSpecification().getObjectActions(NakedObjectAction.EXPLORATION); NakedObjectAction[] actions3 = object.getSpecification().getObjectActions(NakedObjectAction.DEBUG); NakedObjectAction[] actions = new NakedObjectAction[actions1.length + actions2.length + actions3.length]; System.arraycopy(actions1, 0, actions, 0, actions1.length); System.arraycopy(actions2, 0, actions, actions1.length, actions2.length); System.arraycopy(actions3, 0, actions, actions1.length + actions2.length, actions3.length); menuOptions(actions, object, options); Oid oid = object.getOid(); boolean isPersistent = oid != null && !oid.isTransient(); if (!(Features.isService(object.getSpecification())) && !(object.getObject() instanceof InstanceCollectionVector) && isPersistent) { options.add(new DisposeObjectOption()); } } }
public void resolveField(final NakedObject object, final NakedObjectField field) { if (field.isValue()) { return; } NakedReference reference = (NakedReference) field.get(object); if (reference == null || reference.getResolveState().isResolved()) { return; } if (!reference.getResolveState().isPersistent()) { return; } if (LOG.isInfoEnabled()) { // don't log object - it's toString() may use the unresolved field or unresolved collection LOG.info("resolve field " + object.getSpecification().getShortName() + "." + field.getId() + ": " + reference.getSpecification().getShortName() + " " + reference.getResolveState().code() + " " + reference.getOid()); } objectStore.resolveField(object, field); }