Next Object Absolute Number

Is there a way to determine what the absolute number will be for the next object that is created in a given module. My first thought would be to go:

int highNum = 0
for o in entire m do {
if o."Absolute Number" > highNum {
highNum = o."Absolute Number"
}
}
return highNum

But this isn't the true value of the counter since purged object absolute numbers can never be used again.
I assume there must be a counter in the module somewhere to track what the next absNo will be. Is there a way to directly get the value of this counter?

Thanks
Peter.Dawson - Mon Jan 18 23:09:31 EST 2010

Re: Next Object Absolute Number
Peter.Dawson - Mon Jan 18 23:16:34 EST 2010

int highNum = 0
for o in entire m do {
    if o."Absolute Number" > highNum {
        highNum = o."Absolute Number"
    }
}
return highNum

Re: Next Object Absolute Number
llandale - Tue Jan 19 17:38:52 EST 2010

Your code will work so long as the last object created was not then purged or not saved.

I know that info is stored in the database as soon as you create an object, even if you don't save the module. I see no method of predicting what it is. But I do see this command, try it out and let us know:

int refcount_ (Module m)

  • Louie

Re: Next Object Absolute Number
Peter.Dawson - Tue Jan 19 18:15:21 EST 2010

llandale - Tue Jan 19 17:38:52 EST 2010
Your code will work so long as the last object created was not then purged or not saved.

I know that info is stored in the database as soon as you create an object, even if you don't save the module. I see no method of predicting what it is. But I do see this command, try it out and let us know:

int refcount_ (Module m)

  • Louie

Doesn't seem to work

Input

int highestAbsNum(){
    Object o
        Module m = current Module
 
        int highNum = 0
        for o in entire m do {
                int absNum = o."Absolute Number"
                if (absNum > highNum) {
                        highNum = o."Absolute Number"
                }
        }     
        return highNum
}
 
print highestAbsNum() "\n"
print refcount_ (current Module) "\n"
print getServerSeqNum_() "\n"
print getClientSeqNum_() "\n"

 


Output

 

 

6019
1
2037
2031



I found getServer/ClientSeqNum_ after looking for every function that returns an int in Command Database v8.2.xls. I hoped that there might be an



 

 

int getModuleSeqNum_(ModRef_ m)



But there was nothing that looked like what I was after.



 

Re: Next Object Absolute Number
llandale - Tue Jan 19 18:21:25 EST 2010

Peter.Dawson - Tue Jan 19 18:15:21 EST 2010

Doesn't seem to work

Input

int highestAbsNum(){
    Object o
        Module m = current Module
 
        int highNum = 0
        for o in entire m do {
                int absNum = o."Absolute Number"
                if (absNum > highNum) {
                        highNum = o."Absolute Number"
                }
        }     
        return highNum
}
 
print highestAbsNum() "\n"
print refcount_ (current Module) "\n"
print getServerSeqNum_() "\n"
print getClientSeqNum_() "\n"

 


Output

 

 

6019
1
2037
2031



I found getServer/ClientSeqNum_ after looking for every function that returns an int in Command Database v8.2.xls. I hoped that there might be an



 

 

int getModuleSeqNum_(ModRef_ m)



But there was nothing that looked like what I was after.



 

refCount must be the number of 'locks' on the module; usually just 1 when you have it open exclusive.

Don't see any other commands.

  • Louie

Re: Next Object Absolute Number
Peter.Dawson - Tue Jan 19 18:43:12 EST 2010

llandale - Tue Jan 19 18:21:25 EST 2010
refCount must be the number of 'locks' on the module; usually just 1 when you have it open exclusive.

Don't see any other commands.

  • Louie

Almost ready to give up on this path and figure out another way. But there are a couple of functions in the command database that spark my interest.

mkNodeBelowLastAbsno
Object create (Last__,int)
Object create(Object, int)
Object create(Module, int)

These don't seem to appear in the reference manual and I can't see that supplying an int to the create function of an object would do (create multiple objects??).

Re: Next Object Absolute Number
SystemAdmin - Tue Jan 19 19:01:26 EST 2010

Peter.Dawson - Tue Jan 19 18:43:12 EST 2010
Almost ready to give up on this path and figure out another way. But there are a couple of functions in the command database that spark my interest.

mkNodeBelowLastAbsno
Object create (Last__,int)
Object create(Object, int)
Object create(Module, int)

These don't seem to appear in the reference manual and I can't see that supplying an int to the create function of an object would do (create multiple objects??).

This might not be optimal, but the only way to do this might be to create a sacrificial object, get it's Absolute Number, then delete and purge the sacrificial object. It's ugly, but it's an option.


Paul Miller

Re: Next Object Absolute Number
Peter.Dawson - Tue Jan 19 19:44:59 EST 2010

SystemAdmin - Tue Jan 19 19:01:26 EST 2010
This might not be optimal, but the only way to do this might be to create a sacrificial object, get it's Absolute Number, then delete and purge the sacrificial object. It's ugly, but it's an option.


Paul Miller

The reason for this whole thread is because a user has requested that 2 similar modules be maintained with a "common area" where changes to any requirement under the common area must be synchronized between both modules (there are reasons why they can't just share a "common module"). At the moment, the absNums in the common area for both modules match up, so changes are easy to sync. But if new objects are created in the common area (whilst other changes are occurring in non-common areas in each module) things become more complex.

Now I think about it, I don't think we can use AbsNums at all in this situation.

Is it clear what I am trying to achieve? If so, will start a new thread to discuss the above. Someone might have done this before.

Re: Next Object Absolute Number
Peter_Albert - Wed Jan 20 02:42:55 EST 2010

Peter.Dawson - Tue Jan 19 19:44:59 EST 2010
The reason for this whole thread is because a user has requested that 2 similar modules be maintained with a "common area" where changes to any requirement under the common area must be synchronized between both modules (there are reasons why they can't just share a "common module"). At the moment, the absNums in the common area for both modules match up, so changes are easy to sync. But if new objects are created in the common area (whilst other changes are occurring in non-common areas in each module) things become more complex.

Now I think about it, I don't think we can use AbsNums at all in this situation.

Is it clear what I am trying to achieve? If so, will start a new thread to discuss the above. Someone might have done this before.

Hmm, I am sure you have considered this, so why can't you just use links between the objects in the common area in the two modules? We routinely do this to monitor deviations in several modules which also must stay synced.

Peter

Re: Next Object Absolute Number
llandale - Wed Jan 20 11:51:56 EST 2010

Peter.Dawson - Tue Jan 19 18:43:12 EST 2010
Almost ready to give up on this path and figure out another way. But there are a couple of functions in the command database that spark my interest.

mkNodeBelowLastAbsno
Object create (Last__,int)
Object create(Object, int)
Object create(Module, int)

These don't seem to appear in the reference manual and I can't see that supplying an int to the create function of an object would do (create multiple objects??).

All the create object perms have a sibling with that int parameter. Comments suggest its an AbsNo value. None seems to work; not using -1, 0, 3, currentAbsNo, nextAbsNo, bigAbsNo. No error, no new object.

I suspect these are residual perms from DOORS version -1 days, where perhaps you could specify an absolute number of the new object.

  • Louie

Re: Next Object Absolute Number
bjjacobgm - Fri Nov 20 16:26:50 EST 2015

SystemAdmin - Tue Jan 19 19:01:26 EST 2010
This might not be optimal, but the only way to do this might be to create a sacrificial object, get it's Absolute Number, then delete and purge the sacrificial object. It's ugly, but it's an option.


Paul Miller

Is there a solution for this? I'm running into an issue where the customer wants to know what the highest absolute number is even if it's from a purged object. If for example the highest absolute number object is 352 but 353 to 500 had been purged. They want the report to say the highest absolute number for the module is 500. Creating a new object each time to get the highest absolute number is not an option as this report can be run numerous times and around many modules in the database.

Re: Next Object Absolute Number
morast - Mon Nov 23 03:35:18 EST 2015

If there is no elegant solution, how about creating a copy of the module and then create a "sacrificial object" in that module copy. 

Re: Next Object Absolute Number
Mathias Mamsch - Mon Nov 23 04:51:41 EST 2015

morast - Mon Nov 23 03:35:18 EST 2015

If there is no elegant solution, how about creating a copy of the module and then create a "sacrificial object" in that module copy. 

There is definitively no elegant solution for this. There might be non-elegant solutions though. You can find the value in the memory of the module structure and you can read them from the database / archives.

Still there is a general problem with this! No report should rely on the next absolute number that is about to be generated. This number should not have any meaning in DOORS. It is simply a value, that is unique inside the module, but there is not more to it.

If the report (or any other DXL program) really depends on this number, then there is definitively something wrong with the architecture. Coming myself from consulting you should go to the customer and tell him, that getting the next highest absolute number on a module is technically non feasible and convince him, that this is not what he really needs. Most probably this is just the wrong solution to a valid requirement.

Just my two cents, regards, Mathias

Re: Next Object Absolute Number
bjjacobgm - Wed Jan 06 11:45:59 EST 2016

Mathias Mamsch - Mon Nov 23 04:51:41 EST 2015

There is definitively no elegant solution for this. There might be non-elegant solutions though. You can find the value in the memory of the module structure and you can read them from the database / archives.

Still there is a general problem with this! No report should rely on the next absolute number that is about to be generated. This number should not have any meaning in DOORS. It is simply a value, that is unique inside the module, but there is not more to it.

If the report (or any other DXL program) really depends on this number, then there is definitively something wrong with the architecture. Coming myself from consulting you should go to the customer and tell him, that getting the next highest absolute number on a module is technically non feasible and convince him, that this is not what he really needs. Most probably this is just the wrong solution to a valid requirement.

Just my two cents, regards, Mathias

I agree that using the next absolute number is undesirable but my customer is insisting on it.  Can you please elaborate on the method you mentioned to do this?

Thank you.

Re: Next Object Absolute Number
DOORSHAM - Wed Jan 06 13:00:42 EST 2016

bjjacobgm - Wed Jan 06 11:45:59 EST 2016

I agree that using the next absolute number is undesirable but my customer is insisting on it.  Can you please elaborate on the method you mentioned to do this?

Thank you.

Sometime you got to do what you got to do.  Here is an example dxl that will give the next Object Number,

 

//Predict Next Object ID
/*This script is for a joke when customer insists on having next Object ID*/
Module m =current
Object o =current
Object ox =create(after( o))
int i = ox."Absolute Number"

I++
print "Next Object ID will be " i ""
hardDelete ox
 

Re: Next Object Absolute Number
bjjacobgm - Wed Jan 06 13:16:46 EST 2016

DOORSHAM - Wed Jan 06 13:00:42 EST 2016

Sometime you got to do what you got to do.  Here is an example dxl that will give the next Object Number,

 

//Predict Next Object ID
/*This script is for a joke when customer insists on having next Object ID*/
Module m =current
Object o =current
Object ox =create(after( o))
int i = ox."Absolute Number"

I++
print "Next Object ID will be " i ""
hardDelete ox
 

I already knew that solution. I was referring to when Mathias mentioned "You can find the value in the memory of the module structure and you can read them from the database / archives."

If there truly is no other way than other than creating then destroying a dummy object, I'll try hard to dissuade the customer from doing this as this report can be run multiple times on a module and across multiple modules within a project, thus making many dummy objects.

Re: Next Object Absolute Number
EHcnck - Wed Jan 06 15:48:49 EST 2016

bjjacobgm - Wed Jan 06 13:16:46 EST 2016

I already knew that solution. I was referring to when Mathias mentioned "You can find the value in the memory of the module structure and you can read them from the database / archives."

If there truly is no other way than other than creating then destroying a dummy object, I'll try hard to dissuade the customer from doing this as this report can be run multiple times on a module and across multiple modules within a project, thus making many dummy objects.

why not just create a trigger to fill-in a module level attribute on the the creation of an object with its id?

Re: Next Object Absolute Number
Costas..Aravidis - Thu Jan 07 03:53:08 EST 2016

EHcnck - Wed Jan 06 15:48:49 EST 2016

why not just create a trigger to fill-in a module level attribute on the the creation of an object with its id?

There is no trigger that is fired on the creation of an object. There is a trigger that it can fire when a specific attribute of an object is changed but still there is issues with deleting objects. Even if that was possible there are a lot of scenarios that would not work. For example what if there are accesses issues. You can propagate create access but on the module level could be a different access or you can login as a database admin and disable the triggers from the command line etc.

 

The best way is to find out on why do you need the next absolute number and if there is a reason for having that for example like predicted requirement ID for change control when you planning your changes then you might need to consider a different solution. You might have a different attribute which you populate a unique number and the next number is kept in the configuration area, or having a change proposal module that you propose the changes before the changes are made permanent or any other solution. It just depends on the use case. The absolute number is an identifier of the object in the module something line a unique id in a table in any database like access or sql or oracle.

 

If you put your use case there might be different ideas around.

Re: Next Object Absolute Number
Mathias Mamsch - Thu Jan 07 05:23:05 EST 2016

bjjacobgm - Wed Jan 06 13:16:46 EST 2016

I already knew that solution. I was referring to when Mathias mentioned "You can find the value in the memory of the module structure and you can read them from the database / archives."

If there truly is no other way than other than creating then destroying a dummy object, I'll try hard to dissuade the customer from doing this as this report can be run multiple times on a module and across multiple modules within a project, thus making many dummy objects.

See its not so complicated to convince the customer, because he has not really the choice.

You can tell him: "DOORS does not support this. I can make you a 'hack', that might crash your DOORS and might cause data loss/corruption at some point, maybe with the next DOORS version, but achieve what you want. Or we can solve the requirement behind it differently."

Because clearly, knowing the next absolute number is NOT the requirement of your customer. Its a solution to a requirement you might not know yet. And this requirement can DEFINITELY be solved differently.

Regards, Mathias

Re: Next Object Absolute Number
chrisroy - Thu Feb 15 12:13:07 EST 2018

I'm still searching for a solution to this because I'm in the same boat.  There must be an internal (_) DOORS function to obtain this number.

morast probably has the best solution [from us hacks lol].  Make a copy of the module and add an object to obtain the next object absolute number.  Then you can delete and purge the module copy.  This should be something you can script as well.  From there, any updating you do can just keep track of what absolute number is coming next.

I was thinking the DOORS object and module history would contain everything you need but I couldn't find a way to identify the object absolute number for the purged object history data.  Objects that were created but not saved also don't show up in history.  So that would work if the last created object wasn't either purged or not committed; which is probably likely but not a fool proof solution.

Regards,

Christopher

Re: Next Object Absolute Number
Mike.Scharnow - Thu Feb 15 12:53:11 EST 2018

chrisroy - Thu Feb 15 12:13:07 EST 2018

I'm still searching for a solution to this because I'm in the same boat.  There must be an internal (_) DOORS function to obtain this number.

morast probably has the best solution [from us hacks lol].  Make a copy of the module and add an object to obtain the next object absolute number.  Then you can delete and purge the module copy.  This should be something you can script as well.  From there, any updating you do can just keep track of what absolute number is coming next.

I was thinking the DOORS object and module history would contain everything you need but I couldn't find a way to identify the object absolute number for the purged object history data.  Objects that were created but not saved also don't show up in history.  So that would work if the last created object wasn't either purged or not committed; which is probably likely but not a fool proof solution.

Regards,

Christopher

Mathias explained it quite well. I also tend to see the "Absolute Number" as having the same semantics as a UUID -- its only purpose is to have a unique ID. Always imagine that the number that is created with the next create() command is completely random, there is no information whatsoever in it, so you cannot give any other meaning to it besides its uniqueness.

 

And technically speaking: Even if there was an internal function, I am sure that it is not available to the DOORS client, I suspect that the number is created on the server, as it is possible that two users open the module in shared mode and create a new object at the same time, so the DOORS client cannot have the "next" number in its memory after opening the module..

Re: Next Object Absolute Number
chrisroy - Thu Feb 15 14:04:50 EST 2018

Mike.Scharnow - Thu Feb 15 12:53:11 EST 2018

Mathias explained it quite well. I also tend to see the "Absolute Number" as having the same semantics as a UUID -- its only purpose is to have a unique ID. Always imagine that the number that is created with the next create() command is completely random, there is no information whatsoever in it, so you cannot give any other meaning to it besides its uniqueness.

 

And technically speaking: Even if there was an internal function, I am sure that it is not available to the DOORS client, I suspect that the number is created on the server, as it is possible that two users open the module in shared mode and create a new object at the same time, so the DOORS client cannot have the "next" number in its memory after opening the module..

Mathias is brilliant and his approach is completely reasonable.  There will exist a number that is the next number issued; it will be the next number after the last number issued in the module.  So maybe we can also ask that question instead (what was the last number issued).  There should be a function that pings the server to get what the next number will be (or what the last number issued was).  What users want to do with that information is besides the point.  Give us capabilities and we'll put our imaginations to work.  That's the whole beauty of DXL.

 

Cheers,

 

Christopher

Re: Next Object Absolute Number
chrisroy - Thu Feb 15 17:04:33 EST 2018

Hey all,

Here's an implementation of the create copy of the module, add an object to retrieve the next Absolute Number, then delete the temporary file.  You will / should uncomment the hard delete portion of the code otherwise it will leave the module where it is and won't be able to run successfully again.  I just don't want to be the source of epic failure if someone tries integrating this script with their own, and they screw something up in the integration process, and it hard deletes the wrong module.   There was something in the copy function that states outgoing links are copied as well.  Hopefully all remains of those links are flushed in the delete and hard delete.  This obviously is a band aid solution that you would only run once every now and again, and not repeatedly in loop or something (slow as molasses).

Still would be delighted if someone can dig up the internal function that retrieves this number or the number indicating the last object created.

 

Regards,

 

Christopher


Attachments

getNextObjectNumber.dxl