7878 "applicationInformation" ,
7979 "authorization" ,
8080 "subscription" ,
81+ "retailCustomer" ,
8182 "content"
8283})
8384@ XmlSeeAlso ({
9091 Subscription .class ,
9192 ElectricPowerQualitySummary .class ,
9293 IntervalBlock .class ,
93- ReadingType .class
94+ ReadingType .class ,
95+ ApplicationInformation .class ,
96+ Authorization .class ,
97+ Subscription .class ,
98+ RetailCustomer .class
9499})
100+
95101public class ContentType {
96102
97103 @ XmlElementRefs ({
@@ -155,6 +161,13 @@ public class ContentType {
155161 @ XmlAnyElement (lax = true )
156162 protected Subscription subscription ;
157163
164+ // TODO note that the namespace here may be incorrect??
165+ @ XmlElementRefs ({
166+ @ XmlElementRef (name = "RetailCustomer" , namespace = "http://naesb.org/espi" , type = JAXBElement .class , required = false ),
167+ })
168+ @ XmlAnyElement (lax = true )
169+ protected RetailCustomer retailCustomer ;
170+
158171 @ XmlMixed
159172 @ XmlAnyElement (lax = true )
160173 protected List <Object > content ;
@@ -217,12 +230,6 @@ public void setAuthorization(Authorization authorization){
217230 this .authorization = authorization ;
218231 }
219232
220- public Subscription getSubscription () {
221- return this .subscription ;
222- }
223- public void setSubscription (Subscription subscription ){
224- this .subscription = subscription ;
225- }
226233 /**
227234 * The Atom content construct is defined in section 4.1.3 of the format spec.
228235 * Gets the value of the content property.
@@ -341,6 +348,13 @@ public Map<QName, String> getOtherAttributes() {
341348 return otherAttributes ;
342349 }
343350
351+ public RetailCustomer getRetailCustomer () {
352+ return this .retailCustomer ;
353+ }
354+ public void setRetailCustomer (RetailCustomer retailCustomer ){
355+ this .retailCustomer = retailCustomer ;
356+ }
357+
344358 public void setReadingType (ReadingType readingType ) {
345359 this .readingType = readingType ;
346360 }
@@ -364,6 +378,14 @@ public ElectricPowerQualitySummary getElectricPowerQualitySummary() {
364378 public void setElectricPowerQualitySummary (ElectricPowerQualitySummary electricPowerQualitySummary ) {
365379 this .electricPowerQualitySummary = electricPowerQualitySummary ;
366380 }
381+
382+ public Subscription getSubscription () {
383+ return this .subscription ;
384+ }
385+ public void setSubscription (Subscription subscription ){
386+ this .subscription = subscription ;
387+ }
388+
367389
368390 public TimeConfiguration getLocalTimeParameters () {
369391 return localTimeParameters ;
@@ -448,5 +470,169 @@ public TimeConfiguration getTimeConfiguration() {
448470 // TODO Auto-generated method stub
449471 return null ;
450472 }
473+
474+ public Long getContentId (Class resourceClass ) {
475+ // TODO its ugly right now, clean it up when templates are done
476+ Long result = 1L ;
477+ if (this .getApplicationInformation () != null ) {
478+ if (ApplicationInformation .class .equals (resourceClass )) {
479+ return this .getApplicationInformation ().getId ();
480+ }
481+ }
482+ if (this .getAuthorization () != null ) {
483+ if (Authorization .class .equals (resourceClass )) {
484+ return this .getAuthorization ().getId ();
485+ }
486+ }
487+ if (this .getElectricPowerQualitySummary () != null ) {
488+ if (ElectricPowerQualitySummary .class .equals (resourceClass )) {
489+ return this .getElectricPowerQualitySummary ().getId ();
490+ }
491+ }
492+ if (this .getElectricPowerUsageSummary () != null ) {
493+ if (ElectricPowerUsageSummary .class .equals (resourceClass )) {
494+ return this .getElectricPowerUsageSummary ().getId ();
495+ }
496+ }
497+ if (this .getIntervalBlocks () != null ) {
498+ // TODO this one is not right, but may not be needed??
499+ if (IntervalBlock .class .equals (resourceClass )) {
500+ return this .getIntervalBlocks ().get (0 ).getId ();
501+ }
502+ }
503+ if (this .getLocalTimeParameters () != null ) {
504+ if (TimeConfiguration .class .equals (resourceClass )) {
505+ return this .getLocalTimeParameters ().getId ();
506+ }
507+ }
508+ if (this .getMeterReading () != null ) {
509+ if (MeterReading .class .equals (resourceClass )) {
510+ return this .getMeterReading ().getId ();
511+ }
512+ }
513+ if (this .getReadingType () != null ) {
514+ if (ReadingType .class .equals (resourceClass )) {
515+ return this .getReadingType ().getId ();
516+ }
517+ }
518+ if (this .getRetailCustomer () != null ) {
519+ if (RetailCustomer .class .equals (resourceClass )) {
520+ return this .getRetailCustomer ().getId ();
521+ }
522+ }
523+ if (this .getSubscription () != null ) {
524+ if (Subscription .class .equals (resourceClass )) {
525+ return this .getSubscription ().getId ();
526+ }
527+ }
528+ if (this .getUsagePoint () != null ) {
529+ if (UsagePoint .class .equals (resourceClass )) {
530+ return this .getUsagePoint ().getId ();
531+ }
532+ }
533+ return result ;
534+ }
535+
536+ public String buildSelfHref (String hrefFragment ) {
537+ // TODO its ugly right now, clean it up when templates are done
538+ String result = "" ;
539+ if (this .getApplicationInformation () != null ) {
540+ return "/ApplicationInformation/" + this .getApplicationInformation ().getId ();
541+ }
542+ if (this .getAuthorization () != null ) {
543+ return "/Authorization/" + this .getAuthorization ().getId ();
544+ }
545+ if (this .getElectricPowerQualitySummary () != null ) {
546+ UsagePoint usagePoint = this .getElectricPowerQualitySummary ().getUsagePoint ();
547+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
548+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/ElectricPowerQualitySummary/" + this .getElectricPowerQualitySummary ().getId ();
549+ }
550+ if (this .getElectricPowerUsageSummary () != null ) {
551+ UsagePoint usagePoint = this .getElectricPowerUsageSummary ().getUsagePoint ();
552+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
553+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/ElectricPowerUsageSummary/" + this .getElectricPowerUsageSummary ().getId ();
554+ }
555+ if (this .getIntervalBlocks () != null ) {
556+ MeterReading meterReading = this .getIntervalBlocks ().get (0 ).getMeterReading ();
557+ UsagePoint usagePoint = meterReading .getUsagePoint ();
558+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
559+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/MeterReading/" + meterReading .getId () + "/IntervalBlock/" + this .getIntervalBlocks ().get (0 ).getId ();
560+ }
561+ if (this .getLocalTimeParameters () != null ) {
562+ UsagePoint usagePoint = this .getLocalTimeParameters ().getUsagePoint ();
563+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
564+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/LocalTimeParameters/" + this .getLocalTimeParameters ().getId ();
565+ }
566+ if (this .getMeterReading () != null ) {
567+ UsagePoint usagePoint = this .getMeterReading ().getUsagePoint ();
568+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
569+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/MeterReading/" + this .getMeterReading ().getId ();
570+ }
571+ if (this .getReadingType () != null ) {
572+ MeterReading meterReading = this .getReadingType ().getMeterReading ();
573+ UsagePoint usagePoint = meterReading .getUsagePoint ();
574+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
575+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/MeterReading/" + meterReading .getId () + "/ReadingType/" + this .getReadingType ().getId ();
576+ }
577+ if (this .getRetailCustomer () != null ) {
578+ return "/RetailCustomer/" + this .getRetailCustomer ().getId ();
579+ }
580+ if (this .getSubscription () != null ) {
581+ return "/Subscription/" + this .getSubscription ().getId ();
582+
583+ }
584+ if (this .getUsagePoint () != null ) {
585+ RetailCustomer retailCustomer = this .getUsagePoint ().getRetailCustomer ();
586+ return "/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + this .getUsagePoint ().getId ();
587+ }
588+ return result ;
589+ }
590+
591+ public List <String > buildRelHref (String hrefFragment ) {
592+ // TODO its ugly right now, clean it up when templates are done
593+ List <String > result = new ArrayList <String >();
594+
595+ if (this .getApplicationInformation () != null ) {
596+ return result ;
597+ }
598+ if (this .getAuthorization () != null ) {
599+ return result ;
600+ }
601+ if (this .getElectricPowerQualitySummary () != null ) {
602+ return result ;
603+ }
604+ if (this .getElectricPowerUsageSummary () != null ) {
605+ return result ;
606+ }
607+ if (this .getIntervalBlocks () != null ) {
608+ return result ;
609+ }
610+ if (this .getLocalTimeParameters () != null ) {
611+ return result ; }
612+ if (this .getMeterReading () != null ) {
613+ UsagePoint usagePoint = this .getMeterReading ().getUsagePoint ();
614+ RetailCustomer retailCustomer = usagePoint .getRetailCustomer ();
615+ ReadingType readingType = this .getMeterReading ().getReadingType ();
616+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/MeterReading/" + this .getMeterReading ().getId () + "/IntervalBlock" );
617+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + usagePoint .getId () + "/MeterReading/" + this .getMeterReading ().getId () + "/ReadingType/" + readingType .getId ());
618+ return result ; }
619+ if (this .getReadingType () != null ) {
620+ return result ; }
621+ if (this .getRetailCustomer () != null ) {
622+ return result ; }
623+ if (this .getSubscription () != null ) {
624+ return result ;
625+ }
626+ if (this .getUsagePoint () != null ) {
627+ RetailCustomer retailCustomer = this .getUsagePoint ().getRetailCustomer ();
628+ TimeConfiguration timeConfiguration = this .getUsagePoint ().getLocalTimeParameters ();
629+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + this .getUsagePoint ().getId () + "/MeterReading" );
630+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + this .getUsagePoint ().getId () + "/ElectricPowerQualitySummary" );
631+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + this .getUsagePoint ().getId () + "/ElectricPowerUsageSummary" );
632+ result .add ("/RetailCustomer/" + retailCustomer .getId () + "/UsagePoint/" + this .getUsagePoint ().getId () + "/LocalTimeParameters/" + timeConfiguration .getId ());
633+ return result ;
634+ }
635+ return result ;
636+ }
451637
452638}
0 commit comments