Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEnterpriseObject


    public WOComponent submit() {
        NSArray existingListArray = (NSArray) objectKeyPathValue();
        errorMessage=null;
        String key=key();
        String subKey;
        EOEnterpriseObject subObject;
        if (key.indexOf('.') > 0) {
            String firstSubKey = key.substring(0, key.lastIndexOf('.'));
            subKey = key.substring(key.lastIndexOf('.') + 1);
            subObject = (EOEnterpriseObject)object().valueForKeyPath(firstSubKey);
        } else {
            subObject = object();
            subKey = key;
        }
        if (log.isDebugEnabled()) {
            log.debug("Original Array: "+existingListArray);
            log.debug("subObject: "+ subObject);
            log.debug("subKey: "+ subKey);
        }
       
        for (Enumeration e= existingListArray.objectEnumerator(); e.hasMoreElements();){
            EOEnterpriseObject anItem = (EOEnterpriseObject)e.nextElement();
            if(!selections().containsObject(anItem)){               
                subObject.removeObjectFromBothSidesOfRelationshipWithKey(anItem, subKey);
                if (log.isDebugEnabled())
                    log.debug("removing: "+ anItem);
            }
        }
        for (Enumeration e=selections().objectEnumerator(); e.hasMoreElements();){
            EOEnterpriseObject anItem = (EOEnterpriseObject)e.nextElement();
            if(!existingListArray.containsObject(anItem)){
                subObject.addObjectToBothSidesOfRelationshipWithKey(anItem, subKey);
                if (log.isDebugEnabled())
                    log.debug("adding: "+ anItem);
            }
View Full Code Here


                    // in an shared editing context
                    EOEditingContext ec = ERXEC.newEditingContext();
                    ec.lock();
                    try {
                        ec.setSharedEditingContext(null);
                        EOEnterpriseObject object = EOUtilities.localInstanceOfObject(ec, object());
                        ec.deleteObject(object);
                        ec.saveChanges();
                    } finally {
                        ec.unlock();
                        ec.dispose();
                    }
                } else {
                    editingContext.deleteObject(object());
                    if (ERXEOControlUtilities.isNewObject(object())) {
                        // This is necessary to force state synching, e.g., for display groups, etc.
                        editingContext.processRecentChanges();
                    } else {
                        // Only save if the object is NOT new.
                        editingContext.saveChanges();
                    }
                }
            } catch (EOObjectNotAvailableException e) {
                exception = ERXValidationFactory.defaultFactory().createCustomException(object(), "EOObjectNotAvailableException");
            } catch (EOGeneralAdaptorException e) {
              @SuppressWarnings("unchecked") NSDictionary userInfo = e.userInfo();
              if(userInfo != null) {
                EODatabaseOperation op = (EODatabaseOperation)userInfo.objectForKey(EODatabaseContext.FailedDatabaseOperationKey);
                if(op.databaseOperator() == EODatabaseOperation.DatabaseDeleteOperator) {
                  exception = ERXValidationFactory.defaultFactory().createCustomException(object(), "EOObjectNotAvailableException");
                }
              }
              if(exception == null) {
                exception = ERXValidationFactory.defaultFactory().createCustomException(object(), "Database error: " + e.getMessage());
              }
            } catch (NSValidation.ValidationException e) {
                exception = e;
            }
            if(exception != null) {
                if (exception instanceof ERXValidationException) {
                    ERXValidationException ex = (ERXValidationException) exception;
                    D2WContext context = d2wContext();
                    Object o = ex.object();

                    if (o instanceof EOEnterpriseObject) {
                        EOEnterpriseObject eo = (EOEnterpriseObject) o;
                        context.takeValueForKey(eo.entityName(), "entityName");
                        context.takeValueForKey(ex.propertyKey(), "propertyKey");
                    }
                    ((ERXValidationException) exception).setContext(context);
                   
                    log.info("Validation Exception: " + exception + exception.getMessage());
View Full Code Here

        }
        return value;
    }

    public WOComponent view() {
        EOEnterpriseObject eo = object();
        Object value = objectKeyPathValue();
        if (value instanceof EOEnterpriseObject) {
            eo = (EOEnterpriseObject) value;
        }
        String pageConfigurationName = (String)valueForBinding("editConfigurationName");
View Full Code Here

                NSArray array = EOUtilities.objectsMatchingKeyAndValue(GSVOtherMethods._editingContext, entityName, key, attribute);
                if( array.count() == 0 ){
                    return true;
                } else if( array.count() == 1 ) {
                    //it could be that the object found is itself
                    EOEnterpriseObject localObject = EOUtilities.localInstanceOfObject(GSVOtherMethods._editingContext, (EOEnterpriseObject)object);
                    return ( (EOEnterpriseObject)array.objectAtIndex(0) == localObject );
                }
            }
        }
        return false;
View Full Code Here

    }
   
    // accessors
    public EODetailDataSource detailDataSource() {
      if (detailDataSource == null) {
        EOEnterpriseObject object = (EOEnterpriseObject) valueForBinding("object");
        detailDataSource = new EODetailDataSource(object.classDescription(), key());
        detailDataSource.qualifyWithRelationshipKey(key(), object);
        detailDataSource.fetchObjects();
      } return detailDataSource;
    }
View Full Code Here

   
    @SuppressWarnings("unchecked")
  public void setMasterObjectAndRelationshipKey(NSArray a) {}
   
    public EOEnterpriseObject masterObject() {
      EOEnterpriseObject obj = (EOEnterpriseObject) valueForBinding("masterObject");
      return obj;
    }
View Full Code Here

        private EOEnterpriseObject decodeEO(NSDictionary dictionary) {
            String entityName = (String)dictionary.objectForKey(SerializationKeys.EntityName);
            String pk = (String)dictionary.objectForKey(SerializationKeys.PrimaryKey);
            EOEntity entity = ERXEOAccessUtilities.entityNamed(null, entityName);
            EOAttribute primaryKeyAttribute;
            EOEnterpriseObject eo = null;
            if (entity != null) {
                primaryKeyAttribute = ERXArrayUtilities.firstObject(entity.primaryKeyAttributes());
                Object primaryKeyObject = pk;
                if (log.isDebugEnabled()) log.debug("decodeEO with dict: " + dictionary);
View Full Code Here

      for (Enumeration anEnum = theMutableDictionary.keyEnumerator(); anEnum.hasMoreElements();) {
        String key = (String) anEnum.nextElement();
        Object value = theMutableDictionary.objectForKey(key);

        if (value instanceof EOEnterpriseObject && !ERXEOControlUtilities.isNewObject((EOEnterpriseObject)value)) {
                    EOEnterpriseObject eo = (EOEnterpriseObject)value;
                    NSMutableDictionary encodedDict = encodeEO(eo);
          theMutableDictionary.setObjectForKey(encodedDict, key);
        } else if (value instanceof NSDictionary) {
          theMutableDictionary.setObjectForKey(encodeDictionaryWithEOs((NSDictionary) value), key);
        }
View Full Code Here

   * to 'create'
   */
  public WOComponent newObjectAction() {
    EOEditingContext newEc = ERXEC.newEditingContext(masterObject().editingContext());
    EOClassDescription relatedObjectClassDescription = masterObject().classDescriptionForDestinationKey(relationshipKey());
    EOEnterpriseObject relatedObject = EOUtilities.createAndInsertInstance(newEc, relatedObjectClassDescription.entityName());
    EOEnterpriseObject localObj = EOUtilities.localInstanceOfObject(relatedObject.editingContext(), masterObject());
    if (localObj instanceof ERXGenericRecord) {
      ((ERXGenericRecord)localObj).setValidatedWhenNested(false);
    }
    localObj.addObjectToBothSidesOfRelationshipWithKey(relatedObject, relationshipKey());
    setSelectedObject(relatedObject);
    setInlineTaskSafely("create");
    return null;
  }
View Full Code Here

 
  /**
   * Perform the selectAction. Called by inline select page.
   */
  public WOComponent selectAction() {
    EOEnterpriseObject selected = (objectToAddToRelationship() != null) ? EOUtilities.localInstanceOfObject(masterObject().editingContext(), objectToAddToRelationship()) : null;
   
    if (selected != null) {
     
      masterObject().addObjectToBothSidesOfRelationshipWithKey(selected, relationshipKey());
     
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.