cancel
Showing results for 
Search instead for 
Did you mean: 

compare two models using VB script

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

GeorgeMcGeachie
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

GeorgeMcGeachie
Active Contributor

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.

Former Member
0 Kudos

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