• 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: Programmatically finding an entity's subclasses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatically finding an entity's subclasses


  • Subject: Re: Programmatically finding an entity's subclasses
  • From: Johnny Miller <email@hidden>
  • Date: Fri, 26 Oct 2012 10:50:56 -1000

I suspect that you are just confusing yourself and making a trivial thing hard.  If you have an EO, you can just

Well, it wouldn't be the first time that is for sure.  Maybe I'm just doing something that is wrong but I have a piece of code that I want to work even if I add more subclasses to this entity.  Since I won't know ahead of time what the name of this entity will be I don't know how to convert an entity name to something that makes sense for the user.  Maybe the code is easier to understand?

NSMutableArray<ReportForPaymentType> reports = new NSMutableArray<ReportForPaymentType>();
EOEntity entity = new EOEnterpriseObjectClazz<EOEnterpriseObject>(MESAbstractPaymentInfo.ENTITY_NAME).entity();
NSArray<EOEntity> subEntities = entity.subEntities();
NSMutableArray<EOQualifier> qualifiers = new NSMutableArray<EOQualifier>();

qualifiers.addObject(MESAbstractPaymentInfo.DISPATCH.dot(MESDispatch.RESERVATION_DATE).greaterThanOrEqualTo(controller().startDate()));
qualifiers.addObject(MESAbstractPaymentInfo.DISPATCH.dot(MESDispatch.RESERVATION_DATE).lessThanOrEqualTo(controller().endDate()));


for(EOEntity subEntity : subEntities) {

NSMutableArray<EOQualifier> subEntityQualifiers = (NSMutableArray<EOQualifier>)qualifiers.clone();
subEntityQualifiers.addObject(subEntity.restrictingQualifier());
NSArray<MESAbstractPaymentInfo> subEntityPayments = MESAbstractPaymentInfo.fetchMESAbstractPaymentInfos(controller().ec(), new EOAndQualifier(subEntityQualifiers), null);


if(subEntityPayments.size() > 0) {

// This is the part I want to change
// I'd like to somehow get the "displayName" without having to get an object.
// So that even if the result is 0 I can still create a report for the sub entity.
MESAbstractPaymentInfo paymentInfo = subEntityPayments.get(0);
ReportForPaymentType report = new ReportForPaymentType();
report.setPaymentType(paymentInfo.displayName());
report.setDispatchCount(subEntityPayments.size());
report.setTotalRevenue((BigDecimal)subEntityPayments.valueForKey("@sum.amount"));
reports.addObject(report);
}


}

I hope that makes some kind of sense...

Johnny

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
  • Follow-Ups:
    • Re: Programmatically finding an entity's subclasses
      • From: Chuck Hill <email@hidden>
References: 
 >Programmatically finding an entity's subclasses (From: Johnny Miller <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Chuck Hill <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: David Avendasora <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Chuck Hill <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Johnny Miller <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Chuck Hill <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Johnny Miller <email@hidden>)
 >Re: Programmatically finding an entity's subclasses (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: JDK really necessary for deployment?
  • Next by Date: Re: Programmatically finding an entity's subclasses
  • Previous by thread: Re: Programmatically finding an entity's subclasses
  • Next by thread: Re: Programmatically finding an entity's subclasses
  • Index(es):
    • Date
    • Thread