Genesys CTI User Forum

Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: calcium on January 09, 2015, 06:21:39 AM

Title: PSDK 8.5 - How to work out if ConfObjectDelta contains any differences?
Post by: calcium on January 09, 2015, 06:21:39 AM
Hello [edited to re-word problem],
I am using the new java PSDK 8.5, specifically the ConfObject and the ConfObjectDelta classes.

So I have 2 ConfObject instances and I need to work out if the 2 objects are different.

There is a ConfDeltaUtility.createDelta(ConfObject originalObject, ConfObject changedObject)
which returns a ConfObjectDelta. This is really handy.

My problem is that when the 2 objects have identical values, it still returns a ConfObjectDelta
and I cannot work out if there was a difference at all in the result.

This resulting ConfObjectDelta when both objects are the same looks like the following,
with only the DBID (which has to be present)

[code]
ConfObjectDelta(CfgDeltaDN) {
"deltaDN" = ConfObject(CfgDN) {
"DBID" = 10982
}
}
[/code]

I want to know how one would work out if the objects are the the same.
There is no way I can see to 'examine/access' this object to see that there are
no attributes apart from the DBID.

Doing an .equals() wont work for me cos the it's not the same instance, just an instance with same values.

Any ideas?

Many thanks in advance,
Chai
Title: Re: PSDK 8.5 - How to work out if ConfObjectDelta contains any differences?
Post by: calcium on January 19, 2015, 04:30:32 AM
OK... I've not worked it out but for reference, my workaround is to compare the toStrings of each object.

sourceConfObject.toString().equalsIgnoreCase(targetConfObject.toString())

This would tell me if the delta has any legitimate differences.

Of course, you will need to either strip out the DBIDs or make them the same in the
event that the 2 objects have different DBIDs.
Title: Re: PSDK 8.5 - How to work out if ConfObjectDelta contains any differences?
Post by: Kubig on January 19, 2015, 12:38:20 PM
I am not using this comparing of two configuration object, but from my point of view the way through the toString methods is not good. ToString method in general is not good to use :) Or it is necessary to use it properly.
Title: Re: PSDK 8.5 - How to work out if ConfObjectDelta contains any differences?
Post by: calcium on January 28, 2015, 04:05:35 AM
[quote author=Kubig link=topic=8662.msg38435#msg38435 date=1421671100]
I am not using this comparing of two configuration object, but from my point of view the way through the toString methods is not good. ToString method in general is not good to use :) Or it is necessary to use it properly.
[/quote]

Yes, obviously :-) but failing any alternative.

Anyways, for future reference, in case Genesys not add anymore functions to the ConfObjectDelta class,
this is another way it can be done.

Apologies but am using python syntax (cos that is what I use for this).

Given we have a ConfObjectDelta instance called confObjectDelta and it is a result of comparing 2 CFGDns.

Get the conf object inside the ConfObjectDelta
        confObject = confObjectDelta.getOrCreatePropertyValue("deltaDN")

Iterate through all the attributes, can use either getIndex() or getMappingName()

        isDifferent = False
        for attributes in confObject.getClassInfo().getAttributes():
            if confObject.getPropertyValue(attributes.getMappingName()) == "DBID":
                continue
            if confObject.getPropertyValue(attributes.getIndex()) is not None:
                isDifferent = True
                break

There :-)

It would have been much easier if the ConfDeltaUtility.createDelta() returned a null or something
to indicate that there are no changes. Or so I think.

Hope this helps someone in the future.

Or maybe I have missed something somewhere.