Nickolas Jennings

Greenhorn
+ Follow
since Aug 29, 2014
Nickolas likes ...
Java Mac Spring
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nickolas Jennings

Ok, I will give a bit of background to clarify.

The business problem is that I, as an application user, am making a note on a connector in a system. It would save time to apply this note to all identical connectors. I also want to see connectors that are named the same, but have characteristic differences. This is due to the fact that maybe there is bad data, like data input value of "Body_IP" vs. "Body-IP". So as a user I want to be able to see the bad data to go and fix it.

Now as a programmer, I'm in one method. As for the comments that the comparison should be done in the class of the PlatformConnector, I do not want to do this because I would like to follow suit of the project and keep comparisons in Service classes.


The PlatformConnector class, and the PlatformPin Class


So that defines the classes that I'm working with. As for the method in service that I'm changing. I'll give a bird's eye view of the method



So now you may understand the generality of the problem. I'm comparing connectors to see if they're identical. Identical connectors are easy to present to the user. I just print out the Connector, and say it's identical. For the different connectors I print a difference table out. At the moment I'm only printing out connector level differences. The table is simple, the two connectors at the top, column for each. Then each row has a row header labeling the characteristic type (ie: Gender), and then next two columns display each connectors value for that characteristic. As for the pin row, I just combined the two columns and stated "Pin Differences Exist"

I want to be able to print out the differences between the two tables of pins. So to clarify, connectors and pins have database ids that make them unique but they are not displayed to user.


I have read your comments, and I can't find the ListUtils.difference method. I see the intersection,disjunction, add, subtract, and union. I was not aware of the ListUtils, and I'm really liking this package. I use the apache common libraries but have not completely familiarized myself with it yet. As for the diff function, it seems to work on the command line and not in java. The levenstein distence seems extremely complicated. I always dislike the way wikipedia presents a concept to a person new to it. They overgeneralize it to the point that confuses me.

Thanks you all for your input.
5 years ago
Mike Cox,

Your solution definitely helped me, but it has a problem. When you have this magical function that finds added/removed pins how does it not include 'changed' pins. Feel free to reference my mock table below: There is no way to check a modification vs an addition/removal (That I know even if I'm just eyeing the data versus java calculating it). It's impossible to check for changes since there is no unique key that can be compared across the two connectors. So is Connector1 Pin 2 a modification from Connector 2 or an addition? What about Connector 2 pin 6 F3, a modification or an addition?

Connector 1
Name Function
1 A1
2 B1
3 C1
3 C2
4 D1
4 D2
4 D3
5 E1
5 E2
6 F1
6 F2

Connector 2
Name Function
1 A1
2 B2
3 C1
4 D1
4 D3
5 E1
5 E3
5 E4
6 F1
6 F3
6 F4


My new approach will be very similar to yours, but mutated to fit appropriately.

Just to clarify I'll define PlatformPin


Back to your
-Added pins (exist in List1, not in List2)
-Removed pins (exist in List2, not in List1)

Will be found using mySQL


This will return all rows that don't exist in the other connector. Applying this to both connectors, and removing from each.


Now I can have three parts. (Not all shown but implicitly found)
-A intersect !B
-A intersect B
-B intersect !A

I'd like to present that data in a user friendly way. I believe the best way is two have a "Two" Column Table. One column for one connector. If the pin is in both connectors, display copied data on both sides. If the pin is only on one connector that display only on one column. I also would like the data sorted by name regardless of the fact that it's in one column or the other. This would be sorting the union of these three groups.
5 years ago
Dear All,

I have two ArrayList<Object[]> and I want to be able to compare the differences. At the moment, I have a mediocre way of solving. In a perfect world I have two list next to each other and the differences listed in red or something like that.

Below is the code I'm using. This determines whether there are pinDifferences as a flag and a string. The string and flag are then passed to a jsp to print out. (This is in a service.) The problem I'm running into is if the pins are identical (1-17) but the second one has two options for pin #3. I'm printing out that pin 3-18 are different. Because I've sorted it. What I want to do is show that pin #3 doesn't exist on the other connector. This case could happen both ways and multiple times. Would there be a efficient way to compare two ArrayList<Object> and list out the similarities and and differences. Kind of like what gitHub does with merge conflicts.



So, the important part is from code lines 21-50. I compare every characteristic about the individual objects. I just build a string of the differences and tag it to the seekerId. This will work for 90% of the data, but it's a remedial way to do. I pass the pinDifferenceDetails to a jsp and print accordingly. Personally, I want to have the text "Pin Differences Exist" as a link to a separate page with a beautiful table that display similarities and differences. I hope I explained myself cleanly.

Thanks for your help!
5 years ago