Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEnterpriseObject


    out.writeBoolean(frame());
    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


      if (value != null) {
        String inverse = object.classDescription().inverseForRelationshipKey(key);
        if (inverse != null) {
          ERXEnterpriseObject eo = (ERXEnterpriseObject) value;
          if (!eo.isToManyKey(inverse)) {
            EOEnterpriseObject inverseValue = (EOEnterpriseObject) eo.valueForKey(inverse);
            if (inverseValue != object) {
              boolean oldUpdateInverseRelationship = eo._setUpdateInverseRelationships(false);
              try {
                eo.takeValueForKey(object, inverse);
              }
View Full Code Here

                  newValueEO._setUpdateInverseRelationships(oldUpdateInverseRelationship);
                }
              }
            }
            else {
              EOEnterpriseObject inverseOldValue = (EOEnterpriseObject) newValueEO.valueForKey(inverse);
              if (inverseOldValue != object) {
                boolean oldUpdateInverseRelationship = newValueEO._setUpdateInverseRelationships(false);
                try {
                  newValueEO.takeStoredValueForKey(object, inverse);
                }
View Full Code Here

        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);
                }
              }
            }
          }
        }
View Full Code Here

    }
  }

  public Object marshall(SerializerState state, Object p, Object o) throws MarshallException {
    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);
      }
      else {
        type = "K";
        pkStr = ERXEOControlUtilities.primaryKeyStringForObject(eo);
        pkStr = ERXStringUtilities.urlEncode(pkStr);
      }
      obj.put("gid", ecid + "/" + eo.entityName() "/" + type + "/" + pkStr);

      addAttributes(state, eo, obj);
      return obj;
    }
    catch (JSONException e) {
View Full Code Here

     */
    private NSArray<T> relevantChanges(NSDictionary dict, String key) {
      NSMutableArray<T> releventEOs = null;
        NSArray<EOEnterpriseObject> eos = (NSArray<EOEnterpriseObject>) dict.objectForKey(key);
        for (Enumeration enumeration = eos.objectEnumerator(); enumeration.hasMoreElements();) {
            EOEnterpriseObject eo = (EOEnterpriseObject) enumeration.nextElement();
            if(eo.entityName().equals(entityName())) {
              if (releventEOs == null) {
                releventEOs = new NSMutableArray();
              }
              releventEOs.addObject((T)eo);
            }
View Full Code Here

        // allows units stored in the user info of the attribute to take the form of @project.unit
        // this method resolves the @keyPath..
        if(userInfoUnitString!=null && userInfoUnitString.indexOf("@")>-1){
            String keyPath = userInfoUnitString.substring(1);
            String PropertyKeyWithoutLastProperty = KeyValuePath.keyPathWithoutLastProperty(prefixKeyPath);
            EOEnterpriseObject objectForPropertyDisplayed = null;
            if(PropertyKeyWithoutLastProperty!=null){
                objectForPropertyDisplayed = object!=null ? (EOEnterpriseObject)object.valueForKeyPath(PropertyKeyWithoutLastProperty) : null;
            }else{
                objectForPropertyDisplayed = object;
            }
            userInfoUnitString = objectForPropertyDisplayed!=null ? (String)objectForPropertyDisplayed.valueForKeyPath(keyPath) : null;
        }
        return userInfoUnitString;
    }
View Full Code Here

            String entityName=object.entityName();
            entity=EOModelGroup.defaultGroup().entityNamed(entityName);
            lastKey=key;
        } else {
            String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(key);
            EOEnterpriseObject objectForPropertyDisplayed=(EOEnterpriseObject)object.valueForKeyPath(partialKeyPath);
            if (objectForPropertyDisplayed!=null) {
                entity=EOModelGroup.defaultGroup().entityNamed(objectForPropertyDisplayed.entityName());
                lastKey=KeyValuePath.lastPropertyKeyInKeyPath(key);
            }
        }
        if (entity!=null && lastKey!=null) {
            Object property=entity.attributeNamed(lastKey);
View Full Code Here

            if(editConfigurationName != null && editConfigurationName.length() > 0) {
                epi = (EditPageInterface)D2W.factory().pageForConfigurationNamed(editConfigurationName,session());
            } else {
                epi = D2W.factory().editPageForEntityNamed(object().entityName(),session());
            }           
            EOEnterpriseObject eo = (EOEnterpriseObject)browserSelections.objectAtIndex(0);
            epi.setObject(eo);
            epi.setNextPage(context().page());
            result = (WOComponent)epi;
        }
        return result;
View Full Code Here

  @SuppressWarnings("unchecked")
  protected NSArray<T> relevantChanges(EOEditingContext editingContext, NSDictionary dict, String key) {
    NSArray allObjects = (NSArray) dict.objectForKey(key);
    NSMutableArray<T> changedObjects = new NSMutableArray<T>();
    for (Enumeration enumeration = allObjects.objectEnumerator(); enumeration.hasMoreElements();) {
      EOEnterpriseObject eo = (EOEnterpriseObject) enumeration.nextElement();
      String changedEntityName = eo.entityName();
      if (isRelevant(editingContext, changedEntityName)) {
        changedObjects.addObject((T) eo);
        if (!_trackAllChanges) {
          break;
        }
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOEnterpriseObject

Copyright © 2018 www.massapicom. 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.