Larry,

I like your solution to this problem, but I wonder if it is necessary
to track the modifications to all of the attributes. As soon as a
single attribute value has been modified, you could flag the whole
feature as in need of an update.

In this case our code might look like this:

// Declare a boolean flag to determine if the feature has been modified.
private boolean isModified;

public void setAttribute(int attributeIndex, Object newAttribute)
{
   // Existing code here.
   this.isModified = true;
   // Existing code here.
}

public void setAttributes(Object[] attributes)
{
   // Existing code here.
   this.isModified = true;
   // Existing code here.
}

public boolean isFeatureModified()
{
   return this.isModified;
}

Your technique would allow us to add a method indicating that an
individual attribute had been modified. This would be useful, but I
think it would only take a single change to trigger a database update.
I suppose there would be a performance penalty if you were needlessly
writing all of the attribute values to a database in a Feature with
many attributes, but it might also slow you down to verify which
attributes to write out. It might be quicker (and easier) to just
write out all the attribute values for a modified feature. There is
probably no way to no without some tests.

However, I think if we use the technique you mentioned we should add a
method to indicate if a specific attribute value has been modified. We
are doing most of that work anyways. :]

The Sunburned Surveyor

On Wed, Apr 1, 2009 at 2:01 PM, Larry Becker <becker.la...@gmail.com> wrote:
> Hi,
>
>   As I mentioned in the other thread, before the problem of partial database
> updates can be solved, we must first be able to determine if a Feature has
> been modified.  This is not currently possible in all of the JUMP variants
> that I am familiar with, although Kosmo may have implemented it.
>
> The simplest way of implementing it that I can see is to modify BasicFeature
> to include:
>
> private int[] attributeModCount;  //this is a parallel array to Object[]
> attributes
>
> Then it would be necessary to allocate the attributeModCount array when
> setAttributes(Object[] attributes) is called.
>
> In addition each time setAttribute(int attributeIndex, Object newAttribute)
> is called, add the line of code:
>
> attributeModCount[attributeIndex]++
>
> With these modifications we could then define:
>
> public boolean isFeatureModified() {
>     for (int i=0; i<attributeModCount.length; i++) {
>       if (attributeModCount[i] > 1)  //modified is defined as setting an
> attribute more than once
>          return true;
>     }
> return false;
> }
>
> Would this work and does this seem like something we should consider?
>
> regards,
> Larry
> --
> http://amusingprogrammer.blogspot.com/
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>

------------------------------------------------------------------------------
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to