• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Set String methods for Flattened Relationship Attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set String methods for Flattened Relationship Attributes


  • Subject: Re: Set String methods for Flattened Relationship Attributes
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 19 Oct 2005 14:07:13 -0700


On Oct 19, 2005, at 1:10 PM, Janice Cheung wrote:


Greetings!

How do I define data types and set() and get() methods for attributes of flattened relationships?

I don't see why there would be a difference, let EOF figure it out.


I am unable to manipulate the data for all attributes created by flattening relationships in my EOModeler. For example, I cannot save nor update the values for these attributes, although I am able to happily modify and save the values for all original class attributes that are not derived from flattened relationships. I am confident that my set() methods are the source of the issue, because it is the only deviant code from my set() methods for original class attributes, but I am extremely befuddled as to how to correctly set these strings so they can behave obediently.

More simply, my Server attributes are saving properly and data manipulation is a snap (yay!).
All other attributes in the Server table that are added as a consequence of flattened relationships are NOT saving properly and the data cannot be manipulated. Please help!!


    Code from flattened relationship, Server->ServerContacts:

     public String getEmailContactNames(){
        NSArray pc=(NSArray)storedValueForKey("serverContacts");
        java.util.Enumeration e = pc.objectEnumerator();
        StringBuffer tags=new StringBuffer();
        Set emails=new HashSet();
        while (e.hasMoreElements()){
           ServerContact loc=(ServerContact)e.nextElement();
           String email=loc.contact().fullName();
           if (!emails.contains(email)){
              tags.append(email);
              tags.append(",");
              emails.add(email);
         }
     }
        return tags.toString();
         }


You do know that things don't have to be complex to be right? You want a unique set of e-mail addresses, right?


// First off, prefixing methods with needless "get"s is just gross
// this isn't EJB!
public String emailContactNames(){

//        NSArray pc=(NSArray)storedValueForKey("serverContacts");
// Now you just torturing the code.  That is not nice!
// What does "pc" have to do with server contacts?  There is not even
// a 'p' in server contracts.

// OK, so first off you have an array of ServerContact and you want to get
// the fullName (aka e-mail address I take it from them.
// And you want to exclude duplicates, right?
// Well enough with all this Java already!
NSSet emails = new NSSet((NSArray) serverContracts().valueForKeyPath ("contact.fullName"));


// See?  Read the JavaDocs, you don't need all this bug inducing cruft!
//        java.util.Enumeration e = pc.objectEnumerator();
//        StringBuffer tags=new StringBuffer();
//        Set emails=new HashSet();
//        while (e.hasMoreElements()){
//           ServerContact loc=(ServerContact)e.nextElement();
//           String email=loc.contact().fullName();

// Now this gets border line silly. Toss this:
//           if (!emails.contains(email)){
//              tags.append(email);
//              tags.append(",");
//              emails.add(email);
//         }
//     }
//     return tags.toString();

    return emails.allObjects().componentsJoinedWithString(",");
}

Now, again from the top:

public String emailContactNames(){
NSSet emails = new NSSet((NSArray) serverContracts ().valueForKeyPath("contact.fullName"));
return emails.allObjects().componentsJoinedWithString(",");
}


Oh, and this is NOT NOT NOT an "attribute created by flattening a relationship". At this point I am not at all sure what you are doing.


public void setGetEmailContactNames(String value)

You seem indecisive here. Is it a get method or a set method? Pick one.


{
value=getEmailContactNames (); <============= how do I correctly set this value? ==================>



Are you sure you read this? You pass in a parameter named value, don't use it, then assign the value that you want to replace to it.


Any anyway, this makes no sense. emailContactNames is a calculated value. You can't set it. Even if value is a string of email addresses, which belongs on which ServerContact?

I'm baffled too. Not only do I not know what you are doing wrong, I don't even know what you think you are doing. Time to start again.

Chuck



--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >WOMailDelivery Woes - Data Types incorrectly set? (From: Janice Cheung <email@hidden>)
 >Set String methods for Flattened Relationship Attributes (From: Janice Cheung <email@hidden>)

  • Prev by Date: Re: NSDictionary and FetchSpecificationNamed usage
  • Next by Date: Re: NSDictionary and FetchSpecificationNamed usage
  • Previous by thread: Re: Set String methods for Flattened Relationship Attributes
  • Next by thread: Re: WOMailDelivery Woes - Data Types incorrectly set?
  • Index(es):
    • Date
    • Thread