Page 1 of 1
Manually Set Version Number/Letter
PostPosted:Mon Nov 16, 2015 6:31 pm
by alexwgordon
Hi All!
I've started setting up my production instance of OpenKM and have a ton of existing files. I'm using a versioning system that goes from A-Z and then to AA-AZ, etc (instead of 1, 2, 3...). I currently have many of my files that are not on their first revision and are just now going into a true revision control, i.e. most are on rev C, D, etc. Is there an easier way of altering the version (A, B, etc) to what the current one is without changing the versioning java code? I feel like that could save me a ton of time. Any help on the situation would be amazing! Thanks everyone!
Re: Manually Set Version Number/Letter
PostPosted:Mon Nov 16, 2015 11:12 pm
by alexwgordon
So in the mean time, I've decided to just create multiple instances of the LetterVersionAdapter.class file, each having different start values. Then I just switch which vernum I'm using, restart OpenKM and upload all the files of the same revision.
So now I have:
LetterVersionAdapter.class
LetterVersionAdapterB.class
LetterVersionAdapterC.class
etc
Still wondering if there is another solution though!
Re: Manually Set Version Number/Letter
PostPosted:Wed Nov 18, 2015 4:39 pm
by jllort
Could you provide here a clear example with one problematic file version and which should be the good ?
Re: Manually Set Version Number/Letter
PostPosted:Wed Nov 18, 2015 7:16 pm
by alexwgordon
So I have a file that is not currently in OpenKM and it's revision is set to C:
file revC.pdf
I want to add this into OpenKM, but if I use the standard LetterVersionAdapter.class when it is added, it will add it as revision A:
file revC.pdf – OpenKM revision shows A
How can I change the file to actually be revision C without having to change my LetterVersionAdapter.class code?
Hopefully that makes more sense.
Re: Manually Set Version Number/Letter
PostPosted:Wed Nov 18, 2015 8:08 pm
by alexwgordon
Building off of my current issue, is it possible to have a certain folder within OpenKM implement a different version.numeration.adapter?
Basically I have a prototype folder that will use the same revision scheme (A-ZZ), but will start at a different letter. Instead of starting at A it will start at ZZ (the last revision in the LetterVersionAdapter.class array of revisions). I want to do this so that once the revision goes up, it will start over at A. Is this possible??
Re: Manually Set Version Number/Letter
PostPosted:Thu Nov 19, 2015 4:49 pm
by jllort
I think two ways for doing it:
- Importing ( with .okm file -> then you can set there the version you wish )
- Import to especific folder document named -> document_version_A.doc -> process the name and then change version executing SQL.
Re: Manually Set Version Number/Letter
PostPosted:Thu Nov 19, 2015 8:02 pm
by alexwgordon
Is there any documentation on creating a .okm file? or what's the easiest way to generating one I can use as a template?
What do you mean "change version executing SQL"? Can you explain further please?
Thanks jllort!
Re: Manually Set Version Number/Letter
PostPosted:Fri Nov 20, 2015 6:37 pm
by alexwgordon
Ah okay, the .okm file example could just be exporting a single file/folder from Adminstration > Export. I'm thinking this way may just end up being the easiest, but seems like a lot of typing.
Also, I attempted to do the import using an .okm file and if I change the version, it still places it as "A" instead of what I set it to (B in this case)
This is from the log after attempting to import
Code: Select all3964 2015-11-20 13:28:37,207 [http-apr-0.0.0.0-8080-exec-3] INFO com.openkm.util.impexp.RepositoryImporter- File: C:\Test\Vacation Policy-RevA.pdf
3965 2015-11-20 13:28:37,207 [http-apr-0.0.0.0-8080-exec-3] INFO com.openkm.util.impexp.RepositoryImporter- Document: C:\Test\Vacation Policy-RevA.pdf
3966 2015-11-20 13:28:37,207 [http-apr-0.0.0.0-8080-exec-3] INFO com.openkm.util.impexp.RepositoryImporter- Document Metadata File: C:\Test\Vacation Policy-RevA.pdf.okm
3967 2015-11-20 13:28:37,207 [http-apr-0.0.0.0-8080-exec-3] INFO com.openkm.util.impexp.RepositoryImporter- Document Metadata: {uuid=null, author=agordon, name=Vacation Policy-RevA.pdf, path=/okm:root/Vacation Policy-RevA.pdf, created=null, lastModified=null, language=, title=null, description=null, keywords=[], categories=[], subscriptors=[], scripting=null, notes=[], propertyGroups=[], version={author=agordon, name=B, created=null, size=0, mimeType=null, comment=null}, grantedUsers={okmAdmin=15, agordon=15}, grantedRoles={ROLE_USER=3}}
3968 2015-11-20 13:28:37,285 [http-apr-0.0.0.0-8080-exec-3] INFO com.openkm.util.impexp.RepositoryImporter- Created document '/okm:root/Vacation Policy-RevA.pdf'
Re: Manually Set Version Number/Letter
PostPosted:Sat Nov 21, 2015 9:57 am
by jllort
.okm file is a json object. Take a look at RepositoryExporter.java and the method exportDocument.
http://sourceforge.net/p/openkm/code/HE ... orter.java
If you import a single version of the document, then should take a look at this two lines:
Code: Select allDocumentMetadata dmd = ma.getMetadata(docChild);
String json = gson.toJson(dmd);
Re: Manually Set Version Number/Letter
PostPosted:Fri Dec 11, 2015 6:27 pm
by alexwgordon
The way I actually ended up accomplishing this is by modifying my vernum adapter to parse the file name for something like, "file rev D.txt" and determine what the initial rev should be from that. Then I had the the " rev D" portion removed from the filename and uploaded.
Re: Manually Set Version Number/Letter
PostPosted:Sat Dec 12, 2015 9:56 am
by jllort
Also could be done some script or crontab task for it. If you have some pattern in filename like [vernum=AAA], you could do some query in repository for name="[vernum=]" and then apply some database table update directly ( an rename the file at the end ). With LegacyDAO.java class you can execute your own SQL directly ( and update openkm table values, must be used with care ! ).