Examples of EOEditingContext


Examples of com.webobjects.eocontrol.EOEditingContext

      EOEntity anEntity = EOModelGroup.defaultGroup().entityNamed(
          anEntityName);
      EORelationship aRelationship = anEntity.relationshipNamed(aKey);

      if (aRelationship != null) {
        EOEditingContext anEditingContext = editingContext();
        EOGlobalID aGlobalID = anEditingContext.globalIDForObject(this);
        String aModelName = anEntity.model().name();
        EODatabaseContext aDatabaseContext = EOUtilities
            .databaseContextForModelNamed(anEditingContext,
                aModelName);
        aDatabaseContext.lock();
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

   *            temporary global ID, <code>null</code> will be returned.
   * @return the permanent global ID or <code>null</code>
   */
  public EOKeyGlobalID permanentGlobalID(boolean generateIfMissing) {
    if (_permanentGlobalID == null) {
      final EOEditingContext ec = editingContext();

      if (ec != null) {
        final EOGlobalID gid = ec.globalIDForObject(this);

        if (!gid.isTemporary()) {
          _permanentGlobalID = (EOKeyGlobalID) gid;
        }
        else if (generateIfMissing) {
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

   * @param destination the destination object
   * @throws RuntimeException if the editing contexts do not match
   */
  public static void checkMatchingEditingContexts(EOEnterpriseObject source, String relationshipName, EOEnterpriseObject destination) {
    if (destination != null) {
      EOEditingContext sourceEditingContext = source.editingContext();
      EOEditingContext destinationEditingContext = destination.editingContext();
      if (destinationEditingContext != sourceEditingContext && !(sourceEditingContext instanceof EOSharedEditingContext) && !(destinationEditingContext instanceof EOSharedEditingContext)) {
        if (destinationEditingContext == null || sourceEditingContext == null) {
          if (sourceEditingContext == null) {
            if (!(destination instanceof ERXGenericRecord && ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships() && !((ERXGenericRecord)destination)._updateInverseRelationships)) {
              throw new RuntimeException("You crossed editing context boundaries attempting to set the '" + relationshipName + "' relationship of " + source + " (which is not in an editing context) to " + destination + " (in EC " + destinationEditingContext + ").");
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

     * deserialized, it attempts to deserialize the EC, which turns around
     * and tries to deserialize the EO again. The EO is returned in its partially
     * deserialized state, which results in a NullPointerException when the EC
     * starts to try to load values into the EO's dictionary... which is null.
     */
    EOEditingContext ec = (EOEditingContext) in.readObject();
    takeValueForKey(in.readObject(), "object");
  }
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

    out.writeObject(task());
    out.writeObject(entity() == null?null:entity().name());
    out.writeObject(propertyKey());
    out.writeObject(dynamicPage());
    EOEnterpriseObject obj = (EOEnterpriseObject) valueForKey("object");
    EOEditingContext ec = (obj == null || obj.editingContext() == null)?null:obj.editingContext();
    /*
     * The ec must be deserialized before the EO. Otherwise, when the EO is
     * deserialized, it attempts to deserialize the EC, which turns around
     * and tries to deserialize the EO again. The EO is returned in its partially
     * deserialized state, which results in a NullPointerException when the EC
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

      }
      String parts[] = gidString.split("/");
      String ecid = parts[0];
      String entityName = parts[1];
 
      EOEditingContext ec = null;
      if(ecid != null) {
        ec = editingContextForKey(ecid);
      }
      if(ec == null) {
        ec = _editingContextFactory.newEditingContext();
        registerEditingContext(ec);
      }
      ec.lock();
      try {
        String type = null;
        String pk = null;
        if (parts.length > 2) {
          type = parts[2];
          pk = parts[3];
        }
        EOEnterpriseObject eo;
        EOGlobalID gid;
        if(pk != null && pk.length() > 0) {
          if ("T".equals(type)) {
            byte[] bytes = ERXStringUtilities.hexStringToByteArray(pk);
            gid = EOTemporaryGlobalID._gidForRawBytes(bytes);
            eo = ec.objectForGlobalID(gid);
          }
          else {
            pk = ERXStringUtilities.urlDecode(pk);
            gid = ERXEOControlUtilities.globalIDForString(ec, entityName, pk);
            eo = ec.faultForGlobalID(gid, ec);
          }
        }
        else if (_canInsert(entityName)) {
          eo = ERXEOControlUtilities.createAndInsertObject(ec, entityName);
        }
        else {
          eo = null;
        }
        if (eo != null) {
          NSArray<String> attributeNames = _writableAttributeNames(eo);
          NSArray<String> relationshipNames = _includedRelationshipNames(eo);
          for (Iterator iterator = eoDict.keys(); iterator.hasNext();) {
            String key = (String) iterator.next();
            if(!("javaClass".equals(key) || "gid".equals(key))) {
              Object value = eoDict.get(key);
              Object obj = ser.unmarshall(state, null, value);
              if (attributeNames.containsObject(key)) {
                if (obj == null && !relationshipNames.containsObject(key) && (eo.toOneRelationshipKeys().containsObject(key) || eo.toManyRelationshipKeys().containsObject(key))) {
                  // ignore nulls for non-included relationships
                }
                else {
                  eo.takeValueForKey(obj, key);
                }
              }
            }
          }
        }
        state.setSerialized(o, eo);
        return eo;
      }
      finally {
        ec.unlock();
      }
    }
    catch (JSONException e) {
      throw new UnmarshallException("Failed to unmarshall EO.", e);
    }
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

    try {
      EOEnterpriseObject eo = (EOEnterpriseObject) o;
      JSONObject obj = new JSONObject();
      obj.put("javaClass", o.getClass().getName());

      EOEditingContext ec = eo.editingContext();
      String ecid = registerEditingContext(ec);
      String type;
      String pkStr;
      EOGlobalID gid = ec.globalIDForObject(eo);
      if (gid instanceof EOTemporaryGlobalID) {
        type = "T";
        byte[] bytes = ((EOTemporaryGlobalID)gid)._rawBytes();
        pkStr = ERXStringUtilities.byteArrayToHexString(bytes);
      }
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

       
        @Override
        public WOComponent runWithPageConfiguration(String value) {
            WOComponent start = super.runWithPageConfiguration(value);
            EOEnterpriseObject eo;
            EOEditingContext ec = ERXEC.newEditingContext();
            //this.log.debug("runWithPageConfiguration: pc <" + value + "> - " + d2wContext().entity());
            eo = EOUtilities.createAndInsertInstance(ec, d2wContext().entity().name());
            setObject(eo);
            start.takeValueForKey(object(), "object");
            return start;
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

     * @see #reset()
     *
     * @param n NSNotification with EOEditingContext as the object and a dictionary of changes in the userInfo
     */
    public void editingContextDidSaveChanges(NSNotification n) {
        EOEditingContext ec = (EOEditingContext) n.object();
        if(_applicationDidFinishInitialization && ec.parentObjectStore() instanceof EOObjectStoreCoordinator) {
          NSArray<T> releventsInsertedEOs = relevantChanges(n.userInfo(), EOEditingContext.InsertedKey);
          NSArray<T> releventsUpdatedEOs = relevantChanges(n.userInfo(), EOEditingContext.UpdatedKey);
          NSArray<T> releventsDeletedEOs = relevantChanges(n.userInfo(), EOEditingContext.DeletedKey);
          if (_resetOnChange) {
            if (releventsInsertedEOs.count() > 0 || releventsUpdatedEOs.count() > 0 || releventsDeletedEOs.count() > 0) {
View Full Code Here

Examples of com.webobjects.eocontrol.EOEditingContext

     * @return EORecord instance representing eo
     */
    protected EORecord<T> createRecord(EOGlobalID gid, T eo) {
      EORecord<T> record;
      if (_retainObjects) {
        EOEditingContext editingContext = editingContext();
        T localEO = ERXEOControlUtilities.localInstanceOfObject(editingContext, eo);
        if (localEO != null && localEO.isFault()) {
          localEO.willRead();
        }
        record = new EORecord<T>(gid, localEO);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.