Skip to Content
0

compare two models using VB script

Mar 14 at 09:19 AM

46

avatar image

Hi,

I want to compare two versions of a Conceptual Data Model. The in-built compare model option doesn't work for me because i want to add custom filters for comparison. Example: If the data type of a column A has changed from BOOLEAN to CHAR, then only it should be marked as a difference in attributes and not in case of any other data types.

Please help me to know how can i achieve this.

--Thanks

Amit

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

George McGeachie Mar 16 at 06:24 AM
0

I haven't got time at the moment to check this out, but I reckon there's a method somewhere that will load a "comparison settings set", which you do before invoking the compare method.

...

OK, take a look at these objects in the metamodel:

ComparisonHelper

ComparisonAction

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi George,

Thanks for having a look into my problem. But I' am not able to understand how to do this exactly. Would be really kind if you could help me with some more details.

--Thanks

Amit

0

I found some script samples in the Help - see "ComparisonHelper". Using that I was able to construct the following script which should restrict the comparison to Domains.

  
Dim newModel, oldModel, idx
Set oldModel = OpenModel("\Playpen\Comparison Test - original domains.cdm", Omf_Hidden)
Set newModel = OpenModel("\Playpen\Comparison Test - changed domains.cdm", Omf_Hidden) output oldModel
output newModel
' Create a comparison Helper
Dim ComparisonHelper
Set ComparisonHelper = OldModel.CreateComparisonHelper(newModel) ComparisonHelper.SetClassComparable "*", FALSE ' turn off all comparisons
ComparisonHelper.SetClassComparable "Domain", TRUE ' turn on domains
ComparisonHelper.SetPropertyComparable "*", "Length", TRUE output " =====Difference Count is:" & ComparisonHelper.GetDifferencesCount() ' Loop on difference
Dim DiffKind, OldObject, NewObject, MemberPublicName, OldValue, NewValue, Str
for Idx = 0 to ComparisonHelper.GetDifferencesCount()
ComparisonHelper.GetDifferenceInformation Idx, DiffKind, OldObject, NewObject, MemberPublicName, OldValue, NewValue
Str = "Difference #" & cstr(Idx) & " is:"
Str = Str & " Kind=" & Cstr(DiffKind)
if not OldObject is nothing then
Str = Str & " Old object=" & cstr(OldObject)
end if
if not NewObject is nothing then
Str = Str & " New object=" & cstr(NewObject)
end if
Str = Str & " Modified property=" & MemberPublicName
Str = Str & " Old=" & cstr(OldValue)
Str = Str & " New=" & cstr(NewValue)
output Str
Next ' difference ' close models without saving
newModel.Close(False)
oldModel.Close(False)

Unfortunately, the line that's supposed to enable comparisons for domains doesn't have that effect:

ComparisonHelper.SetClassComparable "Domain", TRUE

Perhaps I've misunderstood.

1

Hi George,

Thanks a lot again for this reply and solution.

Now I' am somehow trying to make these lines work:

ComparisonHelper.SetClassComparable "Domain", TRUE

If you also come across any solution, please let me know.

--Thanks

Amit

0