Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEnterpriseObject


    if (editingContext == null) {
      throw new IllegalArgumentException("There was no editing context attached to this rest context.");
    }
    editingContext.lock();
    try {
      EOEnterpriseObject eo = entity.createInstanceWithEditingContext(editingContext, null);
      editingContext.insertObject(eo);
      return eo;
    }
    finally {
      editingContext.unlock();
View Full Code Here


        } catch (NSValidation.ValidationException ex) {
            setErrorMessage(ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSave", ex));
            validationFailedWithException(ex, ex.object(), "saveChangesExceptionKey");
        } catch(EOGeneralAdaptorException ex) {
            if(shouldRecoverFromOptimisticLockingFailure()) {
                EOEnterpriseObject eo = ERXEOAccessUtilities.refetchFailedObject(editingContext(), ex);
                setErrorMessage(ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSavePleaseReapply", d2wContext()));
                validationFailedWithException(ex, eo, "CouldNotSavePleaseReapply");
            } else {
                throw ex;
            }
View Full Code Here

    Object pkValue;
    if (obj == null) {
      pkValue = null;
    }
    else {
      EOEnterpriseObject eo = (EOEnterpriseObject) obj;
      EOEditingContext editingContext = eo.editingContext();
      if (editingContext != null) {
        editingContext.lock();
        try {
          pkValue = ERXEOControlUtilities.primaryKeyObjectForObject(eo);
          if (pkValue == null) {
View Full Code Here

   
    protected NSArray<Document> addedDocumentsForObjects(NSArray<? extends EOEnterpriseObject> objects) {
        NSMutableArray documents = new NSMutableArray();

        for (Enumeration e = objects.objectEnumerator(); e.hasMoreElements();) {
            EOEnterpriseObject eo = (EOEnterpriseObject) e.nextElement();
            if (handlesObject(eo)) {
                Document doc = createDocumentForObject(eo);
                if (doc != null) {
                    documents.addObject(doc);
                }
View Full Code Here

    protected NSArray<Term> deletedTermsForObjects(NSArray<? extends EOEnterpriseObject> objects) {
        NSMutableArray terms = new NSMutableArray();
        Term term;
        for (Enumeration e = objects.objectEnumerator(); e.hasMoreElements();) {
            EOEnterpriseObject eo = (EOEnterpriseObject) e.nextElement();
            if (handlesObject(eo)) {
                term = createTerm(eo);
                if (term != null) {
                    terms.addObject(term);
                }
View Full Code Here

        Object result = c.valueForKeyPath("smartRelationship.destinationEntity.name");
        if(result == null) {
            Object rawObject=c.valueForKey("object");
            String propertyKey=c.propertyKey();
            if (rawObject!=null && rawObject instanceof EOEnterpriseObject && propertyKey != null) {
                EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
                EOEnterpriseObject lastEO=object;
                if (propertyKey.indexOf(".")!=-1) {
                    String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                    Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                    lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
                }
                if (lastEO!=null) {
                    // FIXME: Should be using the model group from the ec of the lastEO.
                    EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                    String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                    result=entity.relationshipNamed(lastKey);
                }
            }
            if (result==null) {
View Full Code Here

   
    @Override
    public Object objectPropertyValue() {
      Object object = super.objectPropertyValue();
      if (object instanceof EOEnterpriseObject) {
        EOEnterpriseObject eo = (EOEnterpriseObject) object;

        String keyWhenRelationship = keyWhenRelationship();
        if (keyWhenRelationship != null || !"userPresentableDescription".equalsIgnoreCase(keyWhenRelationship)) {
          Object val = eo.valueForKey(keyWhenRelationship);
          if(val != null) {
            return val;
          }
        }
        return eo.userPresentableDescription();
      }
      return super.objectPropertyValue();
    }
View Full Code Here

    public Object smartRelationship(D2WContext c) {
        Object result = null;
        Object rawObject=c.valueForKey("object");
        String propertyKey=c.propertyKey();
        if (rawObject!=null && rawObject instanceof EOEnterpriseObject && propertyKey != null) {
            EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
            EOEnterpriseObject lastEO=object;
            if (propertyKey.indexOf(".")!=-1) {
                String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
            }
            if (lastEO!=null) {
                EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                result=entity.relationshipNamed(lastKey);
            }
        }
        if (result==null && propertyKey!=null) {
View Full Code Here

      c.setEntity(entity);
      c.setTask(task);
      // c.takeValueForKey(new NSArray("value"), "displayPropertyKeys");
      setLocalContext(c);
      String entityName = d2wContext().entity().name();
      EOEnterpriseObject object = EOUtilities.createAndInsertInstance(editingContext(), entityName);
      Object value = null;
      if("Boolean".equals(entityName)) {
        value = Boolean.TRUE;
      } else if("Integer".equals(entityName)) {
        value = Integer.valueOf("12345");
      } else if("Decimal".equals(entityName)) {
        value = new BigDecimal("1234.1234");
      } else if("String".equals(entityName)) {
        value = new String("This is a test");
         } else if("NSTimestamp".equals(entityName)) {
        value = new NSTimestamp();
        } else if("NSData".equals(entityName)) {
        value = ERXConstant.EmptyImage;
        } else if("ToOneRelation".equals(entityName)) {
        value = EOUtilities.createAndInsertInstance(editingContext(), "ToOneRelation");
        } else if("ToManyRelation".equals(entityName)) {
        value = new NSArray(EOUtilities.createAndInsertInstance(editingContext(), "ToManyRelation"));
      }
      object.takeValueForKey(value, "value");

      d2wContext().takeValueForKey(object, "object");
      setObject(object);
      setDataSource(new EODatabaseDataSource(editingContext(), d2wContext().entity().name()));
      displayGroup.setDataSource(dataSource());
View Full Code Here

    public WOComponent createObjectAction() {
      WOComponent nextPage = context().page();
      // if creationDelegate binding is provided then just call the delegate with the right params.
      // delegate is responsible for making sure the right page is returned after creating hte object.
      if (useCreationDelegate()) {
        EOEnterpriseObject obj = masterObjectKeyPathForCreationDelegate();
        // defaults to object(), if masterObjectKeyPath is not provided
        obj = (obj == null) ? object() : obj;
        String relationshipName = relationshipName();
        // defaults to key(), if the relationshipName binding is not provided
        relationshipName = relationshipName == null ? key () : relationshipName;
        nextPage = createObjectDelegate().create(obj, (String) valueForBinding ("destinationEntityName"), relationshipName);
      }
      else {
        String editRelationshipConfigurationName = (String)valueForBinding("editRelationshipConfigurationName");
        if(editRelationshipConfigurationName != null && editRelationshipConfigurationName.length() > 0) {
          nextPage = D2W.factory().pageForConfigurationNamed(editRelationshipConfigurationName, session());
          if(nextPage instanceof EditRelationshipPageInterface) {
            EditRelationshipPageInterface epi = (EditRelationshipPageInterface)nextPage;
            epi.setMasterObjectAndRelationshipKey(object(), key());
            epi.setNextPage(context().page());
          } else if(nextPage instanceof EditPageInterface) {
              Object value = d2wContext().valueForKey("useNestedEditingContext");
              boolean createNestedContext = ERXValueUtilities.booleanValue(value);
              EOEnterpriseObject object = ERXEOControlUtilities.editableInstanceOfObject(object(), createNestedContext);
           EOEditingContext ec = object.editingContext();
            ec.lock();
            try {
              EOEnterpriseObject eo = ERXEOControlUtilities.createAndAddObjectToRelationship(ec, object, key(), (String)valueForBinding("destinationEntityName"), null);
              EditPageInterface epi = (EditPageInterface)nextPage;
              epi.setObject(eo);
              epi.setNextPage(context().page());
            } finally {
              ec.unlock();
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.