Need some help - Determining Object Property Existence

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Need some help - Determining Object Property Existence

Matt Davis - NOAA Federal
Hi Qooxdoo team and contributors,

I use Qooxdoo in relation to a massive project of the U.S. National Weather Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x, and our frontend is around 875k lines. Your project is outstanding, and helping to protect the public. Thank you!

I've run into something likely above my knowledge level, and seem to be getting results I cannot debug.

We have a qx object model of a weather/earth science observation. It may have some number of several hundred possible properties.

I need to determine if the property exists, and if so, whether it meets certain criteria.

I've read all I can on how this works and am still baffled. In some cases, I can have results of which a console.log of the typeof returns nothing, not null, not undefined, just nothing. This is throwing our various conditionals into fits. I'd thought I'd fixed it with catching the qxobject.get(element) error to determine existence, but this too is throwing strange results. I have tried the 'in' operator and the 'hasOwnProperty' method without success.

The basic code is something like thing this. Element would be the raw property ID. For instance, if the object has a 'getDewpoint()' method, element would be 'dewpoint'.

try {
if (object.get(element)) {
    value = object.get(element);
    return value;
} else {
// No element assigned
return null;
} catch(error) {
// It appears element was not set on object, so also return null
return null;
}

I'm sure I'm missing something here. Consider several hundred observations being sent through a member function
encasing the above code. As a programmer, I'd expect either the value or null, but logging it every way I know how shows
it justing "skipping" values with no element.

I'm hoping someone can enlighten me on my misunderstanding of this.

Thank you much,
Matt

--
Iris, iNWS, and Impact Catalog Technical Lead
OS&T/MDL/DAB
La Crosse, Wisconsin


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Dietrich Streifert
Hi Matt,

the simpliest solution would be to write:

var theRawPropertyID = 'dewpoint';

var methodName = 'get'+capitaliseFirstLetter(theRawPropertyID);
if(object[methodName]) {
    value = object[methodName].call(object);
    return value;
} else {
    return null;
}

where capitaliseFirstLetter is a yet to write function (http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript)

Regards
Dietrich

Am 16.02.2015 um 01:00 schrieb Matt Davis - NOAA Federal:
Hi Qooxdoo team and contributors,

I use Qooxdoo in relation to a massive project of the U.S. National Weather Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x, and our frontend is around 875k lines. Your project is outstanding, and helping to protect the public. Thank you!

I've run into something likely above my knowledge level, and seem to be getting results I cannot debug.

We have a qx object model of a weather/earth science observation. It may have some number of several hundred possible properties.

I need to determine if the property exists, and if so, whether it meets certain criteria.

I've read all I can on how this works and am still baffled. In some cases, I can have results of which a console.log of the typeof returns nothing, not null, not undefined, just nothing. This is throwing our various conditionals into fits. I'd thought I'd fixed it with catching the qxobject.get(element) error to determine existence, but this too is throwing strange results. I have tried the 'in' operator and the 'hasOwnProperty' method without success.

The basic code is something like thing this. Element would be the raw property ID. For instance, if the object has a 'getDewpoint()' method, element would be 'dewpoint'.

try {
if (object.get(element)) {
    value = object.get(element);
    return value;
} else {
// No element assigned
return null;
} catch(error) {
// It appears element was not set on object, so also return null
return null;
}

I'm sure I'm missing something here. Consider several hundred observations being sent through a member function
encasing the above code. As a programmer, I'd expect either the value or null, but logging it every way I know how shows
it justing "skipping" values with no element.

I'm hoping someone can enlighten me on my misunderstanding of this.

Thank you much,
Matt

--
Iris, iNWS, and Impact Catalog Technical Lead
OS&T/MDL/DAB
La Crosse, Wisconsin



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

fritz
See also

qx.string.firstUp() and perhaps qx.lang.String.capitalize(),
qx.lang.String.camelCase()

Cheers,
Fritz

P.S.: Is your application publically accessible? Just curious ...

On Mon, 16 Feb 2015, Dietrich Streifert wrote:

> Hi Matt,
>
> the simpliest solution would be to write:
>
> var theRawPropertyID = 'dewpoint';
>
> var methodName = 'get'+capitaliseFirstLetter(theRawPropertyID);
> if(object[methodName]) {
>    value = object[methodName].call(object);
>    return value;
> } else {
>    return null;
> }
>
> where capitaliseFirstLetter is a yet to write function
> (http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript)
>
> Regards
> Dietrich
>
> Am 16.02.2015 um 01:00 schrieb Matt Davis - NOAA Federal:
>> Hi Qooxdoo team and contributors,
>>
>> I use Qooxdoo in relation to a massive project of the U.S. National Weather
>> Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x,
>> and our frontend is around 875k lines. Your project is outstanding, and
>> helping to protect the public. Thank you!
>>
>> I've run into something likely above my knowledge level, and seem to be
>> getting results I cannot debug.
>>
>> We have a qx object model of a weather/earth science observation. It may
>> have some number of several hundred possible properties.
>>
>> I need to determine if the property exists, and if so, whether it meets
>> certain criteria.
>>
>> I've read all I can on how this works and am still baffled. In some cases,
>> I can have results of which a console.log of the typeof returns nothing,
>> not null, not undefined, just nothing. This is throwing our various
>> conditionals into fits. I'd thought I'd fixed it with catching the
>> qxobject.get(element) error to determine existence, but this too is
>> throwing strange results. I have tried the 'in' operator and the
>> 'hasOwnProperty' method without success.
>>
>> The basic code is something like thing this. Element would be the raw
>> property ID. For instance, if the object has a 'getDewpoint()' method,
>> element would be 'dewpoint'.
>>
>> try {
>> if (object.get(element)) {
>>   value = object.get(element);
>>   return value;
>> } else {
>> // No element assigned
>> return null;
>> } catch(error) {
>> // It appears element was not set on object, so also return null
>> return null;
>> }
>>
>> I'm sure I'm missing something here. Consider several hundred observations
>> being sent through a member function
>> encasing the above code. As a programmer, I'd expect either the value or
>> null, but logging it every way I know how shows
>> it justing "skipping" values with no element.
>>
>> I'm hoping someone can enlighten me on my misunderstanding of this.
>>
>> Thank you much,
>> Matt
>>
>> --
>> /Iris, iNWS, and Impact Catalog Technical Lead/
>> /OS&T/MDL/DAB/
>> La Crosse, Wisconsin
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>
>>
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
Oetiker+Partner AG              tel: +41 62 775 9903 (direct)
Fritz Zaucker                        +41 62 775 9900 (switch board)
Aarweg 15                            +41 79 675 0630 (mobile)
CH-4600 Olten                   fax: +41 62 775 9905
Schweiz                         web: www.oetiker.ch

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Dietrich Streifert
In reply to this post by Dietrich Streifert
qooxdoo brings It's own method for capitalizing the first letter of a string, so you would write:

    var methodName = 'get'+qx.lang.String.firstUp(theRawPropertyID);

You could even be smarter by checking if the "introspected" method is a function:

    if(qx.lang.Type.isFunction(object[methodName])) {
        value = object[methodName].call(object);
        return value;
    }
    else {
        return null;
    }

Am 16.02.2015 um 08:42 schrieb Dietrich Streifert:
Hi Matt,

the simpliest solution would be to write:

var theRawPropertyID = 'dewpoint';

var methodName = 'get'+capitaliseFirstLetter(theRawPropertyID);
if(object[methodName]) {
    value = object[methodName].call(object);
    return value;
} else {
    return null;
}

where capitaliseFirstLetter is a yet to write function (http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript)

Regards
Dietrich

Am 16.02.2015 um 01:00 schrieb Matt Davis - NOAA Federal:
Hi Qooxdoo team and contributors,

I use Qooxdoo in relation to a massive project of the U.S. National Weather Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x, and our frontend is around 875k lines. Your project is outstanding, and helping to protect the public. Thank you!

I've run into something likely above my knowledge level, and seem to be getting results I cannot debug.

We have a qx object model of a weather/earth science observation. It may have some number of several hundred possible properties.

I need to determine if the property exists, and if so, whether it meets certain criteria.

I've read all I can on how this works and am still baffled. In some cases, I can have results of which a console.log of the typeof returns nothing, not null, not undefined, just nothing. This is throwing our various conditionals into fits. I'd thought I'd fixed it with catching the qxobject.get(element) error to determine existence, but this too is throwing strange results. I have tried the 'in' operator and the 'hasOwnProperty' method without success.

The basic code is something like thing this. Element would be the raw property ID. For instance, if the object has a 'getDewpoint()' method, element would be 'dewpoint'.

try {
if (object.get(element)) {
    value = object.get(element);
    return value;
} else {
// No element assigned
return null;
} catch(error) {
// It appears element was not set on object, so also return null
return null;
}

I'm sure I'm missing something here. Consider several hundred observations being sent through a member function
encasing the above code. As a programmer, I'd expect either the value or null, but logging it every way I know how shows
it justing "skipping" values with no element.

I'm hoping someone can enlighten me on my misunderstanding of this.

Thank you much,
Matt

--
Iris, iNWS, and Impact Catalog Technical Lead
OS&T/MDL/DAB
La Crosse, Wisconsin



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Dietrich Streifert
And here is the sum up version, implemented by a mixin which could be
added somewhere in the class hierarchy, or may even be applied to an
existing class hierarchy by using qx.Class.patch:


qx.Mixin.define("MCallGetter",
{
   members :
   {
     callGetter : function(propertyName) {
       var methodName = 'get'+qx.lang.String.firstUp(propertyName);

       if(qx.lang.Type.isFunction(object[methodName])) {
         value = object[methodName].call(object);
         return value;
       }
       else {
         return null;
       }
   }
});


All object instances of classes having the mixin may now simply execute:

     var value = object.callGetter('dewpoint');


Regards
Dietrich



Am 16.02.2015 um 08:55 schrieb Dietrich Streifert:

> qooxdoo brings It's own method for capitalizing the first letter of a
> string, so you would write:
>
>     var methodName = 'get'+qx.lang.String.firstUp(theRawPropertyID);
>
> You could even be smarter by checking if the "introspected" method is
> a function:
>
>     if(qx.lang.Type.isFunction(object[methodName])) {
>         value = object[methodName].call(object);
>         return value;
>     }
>     else {
>         return null;
>     }


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Dietrich Streifert
Am 16.02.2015 um 09:30 schrieb Dietrich Streifert:
> And here is the sum up version, implemented by a mixin which could be
> added somewhere in the class hierarchy, or may even be applied to an
> existing class hierarchy by using qx.Class.patch:

Sorry. I meant qx.Class.include not qx.Class.patch as qx.Class.patch is
evil.

Now I'll stop talking to myself ;-)

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Mustafa Sak-5
In reply to this post by Matt Davis - NOAA Federal

Hi Matt,

 

as my previous speakers said there are different ways in order to achieve the goal. One of them could be the function qx.Class.hasProperty [1]

 

example:

if(qx.Class.hasProperty(object.constructor, element)) { …

 

 

[1]          http://demo.qooxdoo.org/current/apiviewer/#qx.Class~hasProperty!method_public

http://demo.qooxdoo.org/current/apiviewer/#qx.util.OOUtil~hasProperty!method_public

 

Gruß

Mustafa Sak


Applications & Integration

1&1 Internet AG | Ernst-Frey-Straße 10 | 76135 Karlsruhe | Germany

 

Von: Matt Davis - NOAA Federal [mailto:[hidden email]]
Gesendet: Montag, 16. Februar 2015 01:00
An: [hidden email]
Betreff: [qooxdoo-devel] Need some help - Determining Object Property Existence

 

Hi Qooxdoo team and contributors,

 

I use Qooxdoo in relation to a massive project of the U.S. National Weather Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x, and our frontend is around 875k lines. Your project is outstanding, and helping to protect the public. Thank you!

 

I've run into something likely above my knowledge level, and seem to be getting results I cannot debug.

 

We have a qx object model of a weather/earth science observation. It may have some number of several hundred possible properties.

 

I need to determine if the property exists, and if so, whether it meets certain criteria.

 

I've read all I can on how this works and am still baffled. In some cases, I can have results of which a console.log of the typeof returns nothing, not null, not undefined, just nothing. This is throwing our various conditionals into fits. I'd thought I'd fixed it with catching the qxobject.get(element) error to determine existence, but this too is throwing strange results. I have tried the 'in' operator and the 'hasOwnProperty' method without success.

 

The basic code is something like thing this. Element would be the raw property ID. For instance, if the object has a 'getDewpoint()' method, element would be 'dewpoint'.

 

try {

if (object.get(element)) {

    value = object.get(element);

    return value;

} else {

// No element assigned

return null;

} catch(error) {

// It appears element was not set on object, so also return null

return null;

}

 

I'm sure I'm missing something here. Consider several hundred observations being sent through a member function

encasing the above code. As a programmer, I'd expect either the value or null, but logging it every way I know how shows

it justing "skipping" values with no element.

 

I'm hoping someone can enlighten me on my misunderstanding of this.

 

Thank you much,

Matt

 

--

Iris, iNWS, and Impact Catalog Technical Lead

OS&T/MDL/DAB
La Crosse, Wisconsin


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Need some help - Determining Object Property Existence

Matt Davis - NOAA Federal
In reply to this post by Dietrich Streifert
Thank you so much Dietrich, Fritz, and Mustafa. That looks to be exactly what I need. I appreciate the help. Unfortunately, it is not publically accessible, as much of it would not make sense to non-meteorologists. Hopefully now that I'm on the list, I can return the favor of the help. 

Matt

On Mon, Feb 16, 2015 at 1:42 AM, Dietrich Streifert <[hidden email]> wrote:
Hi Matt,

the simpliest solution would be to write:

var theRawPropertyID = 'dewpoint';

var methodName = 'get'+capitaliseFirstLetter(theRawPropertyID);
if(object[methodName]) {
    value = object[methodName].call(object);
    return value;
} else {
    return null;
}

where capitaliseFirstLetter is a yet to write function (http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript)

Regards
Dietrich

Am 16.02.2015 um 01:00 schrieb Matt Davis - NOAA Federal:
Hi Qooxdoo team and contributors,

I use Qooxdoo in relation to a massive project of the U.S. National Weather Service. We're not exactly new to Qooxdoo, we've been using qx since 1.x, and our frontend is around 875k lines. Your project is outstanding, and helping to protect the public. Thank you!

I've run into something likely above my knowledge level, and seem to be getting results I cannot debug.

We have a qx object model of a weather/earth science observation. It may have some number of several hundred possible properties.

I need to determine if the property exists, and if so, whether it meets certain criteria.

I've read all I can on how this works and am still baffled. In some cases, I can have results of which a console.log of the typeof returns nothing, not null, not undefined, just nothing. This is throwing our various conditionals into fits. I'd thought I'd fixed it with catching the qxobject.get(element) error to determine existence, but this too is throwing strange results. I have tried the 'in' operator and the 'hasOwnProperty' method without success.

The basic code is something like thing this. Element would be the raw property ID. For instance, if the object has a 'getDewpoint()' method, element would be 'dewpoint'.

try {
if (object.get(element)) {
    value = object.get(element);
    return value;
} else {
// No element assigned
return null;
} catch(error) {
// It appears element was not set on object, so also return null
return null;
}

I'm sure I'm missing something here. Consider several hundred observations being sent through a member function
encasing the above code. As a programmer, I'd expect either the value or null, but logging it every way I know how shows
it justing "skipping" values with no element.

I'm hoping someone can enlighten me on my misunderstanding of this.

Thank you much,
Matt

--
Iris, iNWS, and Impact Catalog Technical Lead
OS&T/MDL/DAB
La Crosse, Wisconsin



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel




--
Iris, iNWS, and Impact Catalog Technical Lead
OS&T/MDL/DAB
La Crosse, Wisconsin
Office: (608) 784-8275 x486
Telework: (608) 406-0537

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel