You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@oodt.apache.org by "Starch, Michael D (388L)" <Mi...@jpl.nasa.gov> on 2011/05/27 19:04:06 UTC

XMLValidation layer modifyElement

All,

I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.

Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element.  Is this intended behavior, or have I missed something?

I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element.  If this is not the intended purpose I will find a workaround.

-Michael Starch



Re: XMLValidation layer modifyElement

Posted by "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov>.
Hi Michael,

> The function does save out the file but, it does not update the in-memory product to element map.   This leaves the two in-memory maps out of synch, until the fm is restarted and the updated files are re-read.

Yeah see my recent reply to Brian Foster's email -- there is definitely a bug there.
> 
> On this note, I am also getting a rather nasty crash when writing the file back to disk, but I have not sorted out whither it is user-error or a bug.  If it is a bug, I will do my best to report it and fix it.  More on this hopefully on Tuesday.

It's a bug, check out OODT-197 [1], I'm seeing it too. About to commit a fix for it.

Cheers,
Chris

[1] http://issues.apache.org/jira/browse/OODT-197

> 
> 
> ________________________________________
> From: holenoter [holenoter@me.com]
> Sent: Saturday, May 28, 2011 11:33 PM
> To: dev@oodt.apache.org
> Cc: dev@oodt.apache.org
> Subject: Re: XMLValidation layer modifyElement
> 
> hey chris,
> 
> if you modify an element then call getElements(ProductType) you will not get the modified element because the product type element map was not updated. . . .hope hawaii was a good time dude!
> 
> -brian
> 
> On May 28, 2011, at 10:46 PM, "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov> wrote:
> 
> Hi Michael,
> 
>> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.
> 
> It looks like it's modifying the elements that get put into the product type element map, indeed. The function consists of:
> 
> {code}
> elementMap.put(element.getElementId(), element);
> saveElementsAndMappings();
> {code}
> 
> It first takes in the new element, updates the element map, and then saves out the new map file with the updated element definition. The product type element map is left unmodified, so as long as the element has the same identifier as was used to originally link it, it will get saved through fine.
> 
>> 
>> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?
> 
> See above.
> 
>> 
>> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.
> 
> Let me know if I'm misunderstanding you, but I think it works fine...
> 
> Cheers,
> Chris
> 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Chris Mattmann, Ph.D.
> Senior Computer Scientist
> NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
> Office: 171-266B, Mailstop: 171-246
> Email: chris.a.mattmann@nasa.gov<ma...@nasa.gov>
> WWW: http://sunset.usc.edu/~mattmann/<http://sunset.usc.edu/%7Emattmann/>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Adjunct Assistant Professor, Computer Science Department
> University of Southern California, Los Angeles, CA 90089 USA
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: chris.a.mattmann@nasa.gov
WWW:   http://sunset.usc.edu/~mattmann/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


RE: XMLValidation layer modifyElement

Posted by "Starch, Michael D (388L)" <Mi...@jpl.nasa.gov>.
Right.

The function does save out the file but, it does not update the in-memory product to element map.   This leaves the two in-memory maps out of synch, until the fm is restarted and the updated files are re-read.

On this note, I am also getting a rather nasty crash when writing the file back to disk, but I have not sorted out whither it is user-error or a bug.  If it is a bug, I will do my best to report it and fix it.  More on this hopefully on Tuesday.

-Michael


________________________________________
From: holenoter [holenoter@me.com]
Sent: Saturday, May 28, 2011 11:33 PM
To: dev@oodt.apache.org
Cc: dev@oodt.apache.org
Subject: Re: XMLValidation layer modifyElement

hey chris,

if you modify an element then call getElements(ProductType) you will not get the modified element because the product type element map was not updated. . . .hope hawaii was a good time dude!

-brian

On May 28, 2011, at 10:46 PM, "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov> wrote:

Hi Michael,

> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.

It looks like it's modifying the elements that get put into the product type element map, indeed. The function consists of:

{code}
elementMap.put(element.getElementId(), element);
saveElementsAndMappings();
{code}

It first takes in the new element, updates the element map, and then saves out the new map file with the updated element definition. The product type element map is left unmodified, so as long as the element has the same identifier as was used to originally link it, it will get saved through fine.

>
> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?

See above.

>
> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.

Let me know if I'm misunderstanding you, but I think it works fine...

Cheers,
Chris

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: chris.a.mattmann@nasa.gov<ma...@nasa.gov>
WWW: http://sunset.usc.edu/~mattmann/<http://sunset.usc.edu/%7Emattmann/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Re: XMLValidation layer modifyElement

Posted by "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov>.
Hey Brian,

On May 28, 2011, at 11:33 PM, holenoter wrote:

> 
> hey chris,
> 
> if you modify an element then call getElements(ProductType) you will not get the modified element because the product type element map was not updated. . .

Are you sure about this? 

The class stores 2 maps, one of:

Element Map: String elementId:->Element 
Product Type Element Map: String productTypeId:->List of Elements

Oh wait, I see. The Elements stored in both maps are references created in the same load function, so both maps reference (initially at least) the same Element instances, which was the intention. However, when the new Element comes in via #modifyElement and is used to set the element definition in the element map, instead of looking up the crossed referenced Element instance, and updating it (thereby keeping both maps up to date, at the same time), I went ahead and just updated the Element Map with the new local instance containing the new definition. This is definitely a bug.

I've attached a unit test to OODT-195 that exposes this issue. In the future, feel free to do this yourself too -- it's a good way to quickly demonstrating the issue and saving investigation :-)

If no one addresses this by tomorrow, I'll probably just go ahead and a commit a fix that looks up the existing Element reference, and then updates it, which should fix the issue.

> .hope hawaii was a good time dude!

Thanks! I had a great time and the workshop went really well!

Cheers,
Chris

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: chris.a.mattmann@nasa.gov
WWW:   http://sunset.usc.edu/~mattmann/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Re: XMLValidation layer modifyElement

Posted by holenoter <ho...@me.com>.
hey chris,

if you modify an element then call getElements(ProductType) you will not get the modified element because the product type element map was not updated. . . .hope hawaii was a good time dude!

-brian

On May 28, 2011, at 10:46 PM, "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov> wrote:

> Hi Michael,
>
> > I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.
>
> It looks like it's modifying the elements that get put into the product type element map, indeed. The function consists of:
>
> {code}
> elementMap.put(element.getElementId(), element);
> saveElementsAndMappings();
> {code}
>
> It first takes in the new element, updates the element map, and then saves out the new map file with the updated element definition The product type element map is left unmodified, so as long as the element has the same identifier as was used to originally link it, it will get saved through fine.
>
> >
> > Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?
>
> See above.
>
> >
> > I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.
>
> Let me know if I'm misunderstanding you, but I think it works fine...
>
> Cheers,
> Chris
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Chris Mattmann, Ph.D.
> Senior Computer Scientist
> NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
> Office: 171-266B, Mailstop: 171-246
> Email: chris.a.mattmann@nasa.gov
> WWW: http://sunset.usc.edu/~mattmann/
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Adjunct Assistant Professor, Computer Science Department
> University of Southern California, Los Angeles, CA 90089 USA
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>

Re: XMLValidation layer modifyElement

Posted by "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov>.
Hi Michael,

> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.

It looks like it's modifying the elements that get put into the product type element map, indeed. The function consists of:

{code}
        elementMap.put(element.getElementId(), element);
        saveElementsAndMappings();
{code}

It first takes in the new element, updates the element map, and then saves out the new map file with the updated element definition. The product type element map is left unmodified, so as long as the element has the same identifier as was used to originally link it, it will get saved through fine.

> 
> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element.  Is this intended behavior, or have I missed something?

See above.

> 
> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element.  If this is not the intended purpose I will find a workaround.

Let me know if I'm misunderstanding you, but I think it works fine...

Cheers,
Chris

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: chris.a.mattmann@nasa.gov
WWW:   http://sunset.usc.edu/~mattmann/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Re: XMLValidation layer modifyElement

Posted by "Mattmann, Chris A (388J)" <ch...@jpl.nasa.gov>.
On May 27, 2011, at 11:18 AM, holenoter wrote:

> hey michael,
> 
> looks like a bug . . . you want to write the patch for this? . . . make an issue first in JIRA (https://issues.apache.org/jira/browse/OODT) -- you can sign up for an account on the site if you don't have one . . . my recommendation for a fix to this would be to change:
> 
>     private HashMap<String, List<Element>> productTypeElementMap = new HashMap<String, List<Element>>();
> 
> to
>     private HashMap<String, List<String>> productTypeElementMap = new HashMap<String, List<String>>();
> 
> where the List<String> is a list of Element ids . . . then you will have to modify the method getElements(ProductType) such that it first gets the list of Element ids from productTypeElementMap and then creates a return List<Element> by getting the elements from the elementMap . . . then a simple mod to XmlStructFactory.writeProductTypeMapXmLDocument such that it works with the new map type (simple fix since all it uses is the Element ids anyway)
> 
> oh course, if you have a better idea feel free to explain it in the issue description when you create it . . . and i'm sure other developers may have strong opinions on this fix.

LOL you're hilarious. See my previous reply to Michael, I'd like to get confirmation that this is even a bug. The function as written was not intended to modify the product type element mapping -- just the element information itself.

Cheers,
Chris

> 
> On May 27, 2011, at 10:04 AM, "Starch, Michael D (388L)" <Mi...@jpl.nasa.gov> wrote:
> 
>> All,
>> 
>> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.
>> 
>> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?
>> 
>> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.
>> 
>> -Michael Starch
>> 
>> 


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: chris.a.mattmann@nasa.gov
WWW:   http://sunset.usc.edu/~mattmann/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Re: XMLValidation layer modifyElement

Posted by holenoter <ho...@me.com>.
hey michael,

looks like a bug . . . you want to write the patch for this? . . . make an issue first in JIRA (https://issues.apache.org/jira/browse/OODT) -- you can sign up for an account on the site if you don't have one . . . my recommendation for a fix to this would be to change:

    private HashMap<String, List<Element>> productTypeElementMap = new HashMap<String, List<Element>>();

to
    private HashMap<String, List<String>> productTypeElementMap = new HashMap<String, List<String>>();

where the List<String> is a list of Element ids . . . then you will have to modify the method getElements(ProductType) such that it first gets the list of Element ids from productTypeElementMap and then creates a return List<Element> by getting the elements from the elementMap . . . then a simple mod to XmlStructFactory.writeProductTypeMapXmLDocument such that it works with the new map type (simple fix since all it uses is the Element ids anyway)

oh course, if you have a better idea feel free to explain it in the issue description when you create it . . . and i'm sure other developers may have strong opinions on this fix.

-brian


On May 27, 2011, at 10:04 AM, "Starch, Michael D (388L)" <Mi...@jpl.nasa.gov> wrote:

> All,
>
> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.
>
> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?
>
> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.
>
> -Michael Starch
>
>

Re: XMLValidation layer modifyElement

Posted by holenoter <ho...@me.com>.
hey michael,

looks like a bug . . . you want to write the patch for this? . . . make an issue first in JIRA (https://issues.apache.org/jira/browse/OODT) -- you can sign up for an account on the site if you don't have one . . . my recommendation for a fix to this would be to change:

    private HashMap<String, List<Element>> productTypeElementMap = new HashMap<String, List<Element>>();

to
    private HashMap<String, List<String>> productTypeElementMap = new HashMap<String, List<String>>();

where the List<String> is a list of Element ids . . . then you will have to modify the method getElements(ProductType) such that it first gets the list of Element ids from productTypeElementMap and then creates a return List<Element> by getting the elements from the elementMap . . . then a simple mod to XmlStructFactory.writeProductTypeMapXmLDocument such that it works with the new map type (simple fix since all it uses is the Element ids anyway)

oh course, if you have a better idea feel free to explain it in the issue description when you create it . . . and i'm sure other developers may have strong opinions on this fix.

-brian

On May 27, 2011, at 10:04 AM, "Starch, Michael D (388L)" <Mi...@jpl.nasa.gov> wrote:

> All,
>
> I looked at the XMLValidation layer's modifyElement function, and it doesn't appear to modify elements that get put into the productTypeElementMap.
>
> Thus an element will be modified in the elements map (element id to element) but if it is already mapped to a product type the product type to element map will maintain a reference to the unmodified element. Is this intended behavior, or have I missed something?
>
> I had intended to use the modifyElement function, but with the purpose of updating any occurrence of that element. If this is not the intended purpose I will find a workaround.
>
> -Michael Starch
>
>