private void convertValues() { for (int i = 0; i < values.length; i++) { if (values[i] instanceof Persistent) { values[i] = ((Persistent) values[i]).getObjectId(); } } }
public void setValue(Object value) { if (value instanceof Persistent){ this.value = ((Persistent)value).getObjectId(); } else { this.value = value; } }
/** * This is used to update faults. */ void updateArcSnapshot(String propertyName, Persistent object) { if (arcSnapshot == null) { arcSnapshot = new HashMap(); } arcSnapshot.put(propertyName, object != null ? object.getObjectId() : null); }
/** * This is used to update faults. */ void updateArcSnapshot(String propertyName, Persistent object) { if (arcSnapshot == null) { arcSnapshot = new HashMap<>(); } arcSnapshot.put(propertyName, object != null ? object.getObjectId() : null); }
ObjectId getArcSnapshotValue(String propertyName) { Object value = arcSnapshot != null ? arcSnapshot.get(propertyName) : null; if (value instanceof Fault) { Persistent target = (Persistent) ((Fault) value).resolveFault(object, propertyName); value = target != null ? target.getObjectId() : null; arcSnapshot.put(propertyName, value); } return (ObjectId) value; }
public String getStringId(Persistent object) { if (object == null) { throw new NullPointerException("Null object"); } ObjectId id = object.getObjectId(); return getStringId(id); }
@Override void postprocess() { if (!objectsByDescriptor.isEmpty()) { Collection<ObjectId> deletedIds = parent.getResultDeletedIds(); for (List<Persistent> objects : objectsByDescriptor.values()) { for (Persistent object : objects) { deletedIds.add(object.getObjectId()); } } } }
@Override public Object value(Object root, String name) { ObjectId id = ((Persistent) root).getObjectId(); if (id.isTemporary()) { // for now supporting only permanent IDs throw new IllegalArgumentException("Can't read from temporary ObjectId: " + id); } return id.getIdSnapshot().get(name); }
ObjectId getArcSnapshotValue(String propertyName) { Object value = arcSnapshot != null ? arcSnapshot.get(propertyName) : null; if (value instanceof Fault) { Persistent source = (Persistent) objectStore.getNode(nodeId); Persistent target = (Persistent) ((Fault) value).resolveFault( source, propertyName); value = target != null ? target.getObjectId() : null; arcSnapshot.put(propertyName, value); } return (ObjectId) value; }
/** * Returns an int primary key value for a persistent object. Only works for * single column numeric primary keys. If an object is transient or has an * ObjectId that can not be converted to an int PK, an exception is thrown. */ public static long longPKForObject(Persistent dataObject) { Object value = pkForObject(dataObject); if (!(value instanceof Number)) { throw new CayenneRuntimeException("PK is not a number: %s", dataObject.getObjectId()); } return ((Number) value).longValue(); }
/** * Returns an int primary key value for a persistent object. Only works for * single column numeric primary keys. If an object is transient or has an * ObjectId that can not be converted to an int PK, an exception is thrown. */ public static int intPKForObject(Persistent dataObject) { Object value = pkForObject(dataObject); if (!(value instanceof Number)) { throw new CayenneRuntimeException("PK is not a number: %s", dataObject.getObjectId()); } return ((Number) value).intValue(); }
/** * Creates an expression that matches the primary key of object in * <code>ObjectId</code>'s <code>IdSnapshot</code> for the argument * <code>object</code>. */ public static Expression matchExp(Persistent object) { return matchAllDbExp(object.getObjectId().getIdSnapshot(), Expression.EQUAL_TO); }
public boolean visitToOne(ToOneProperty property) { Object target = property.readPropertyDirectly(persistent); if (target instanceof Persistent) { Persistent targetDO = (Persistent) target; // make sure it is registered registerNewObject(targetDO); getObjectStore().arcCreated(persistent.getObjectId(), targetDO.getObjectId(), property.getName()); } return true; }
void handleSimplePropertyChange( Persistent object, String propertyName, Object oldValue, Object newValue) { context.getGraphManager().nodePropertyChanged( object.getObjectId(), propertyName, oldValue, newValue); markAsDirty(object); }
/** * @since 1.2 */ void recordObjectDeleted(Persistent object) { object.setPersistenceState(PersistenceState.DELETED); registerDiff(object, new NodeDeleteOperation(object.getObjectId())); }
protected void handleSimplePropertyChange( Persistent object, String propertyName, Object oldValue, Object newValue) { context.getGraphManager().nodePropertyChanged( object.getObjectId(), propertyName, oldValue, newValue); markAsDirty(object); }
private void deleteNew(Persistent object) { object.setPersistenceState(PersistenceState.TRANSIENT); processDeleteRules(object, PersistenceState.NEW); context.getGraphManager().unregisterNode(object.getObjectId()); }
private void deleteNew(Persistent object) throws DeleteDenyException { object.setPersistenceState(PersistenceState.TRANSIENT); processDeleteRules(object, PersistenceState.NEW); // if an object was NEW, we must throw it out context.getGraphManager().unregisterNode(object.getObjectId()); }
/** * Returns class descriptor for the object or null if the object is not * registered with an ObjectContext or descriptor was not found. */ public static ClassDescriptor getClassDescriptor(Persistent object) { ObjectContext context = object.getObjectContext(); if (context == null) { return null; } return context.getEntityResolver().getClassDescriptor(object.getObjectId().getEntityName()); }
private void deletePersistent(Persistent object) throws DeleteDenyException { context.getEntityResolver().getCallbackRegistry().performCallbacks( LifecycleEvent.PRE_REMOVE, object); int oldState = object.getPersistenceState(); object.setPersistenceState(PersistenceState.DELETED); processDeleteRules(object, oldState); context.getGraphManager().nodeRemoved(object.getObjectId()); }