0
public static IDfCollection getVersions() {
    IDfQuery query = clientX.getQuery();// obtain an idfObject
    query.setDQL(
            "select r_object_id,object_name,r_version_label,owner_name from dm_document(all) where i_chronicle_id='090008868006d5be'");
    IDfCollection collection = null;
    try {
        collection = query.execute(SessionFile.getSession(), IDfQuery.DF_READ_QUERY);
    } catch (DfException e) {
        e.printStackTrace();
    }
    return collection;

}

public class Versions {
public static void main(String[] args) {
    IDfCollection collection = AllOperations.getVersions();
    try {
        int versionsCount = collection.getValueCount("r_object_id");
        //IDfSysObject dfSysObject=(IDfSysObject) SessionFile.getSession().getObject(new DfId("09000886800a143e"));
        while (collection.next()) {
            //String versionNum = dfSysObject.getVersionLabels().getImplicitVersionLabel();
            int i = 0;
            while (i < versionsCount) {
                System.out.println(collection.getRepeatingValue("r_version_label", i));
                i++;
            }
        }
    } catch (DfException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}

Output of the above code is: 1.0, 1.1, 1.2, CURRENT

enter image description here

in place of "CURRENT" label, I want to "get version number" like 2.0 or 3.0 etc which is latest document version number.

needed output like below :

enter image description here

paramesh
  • 45
  • 9

2 Answers2

1

First of all, this line:

int versionsCount = collection.getValueCount("r_object_id");

should rather be

int versionsCount = collection.getValueCount("r_version_label");

and has to be in the while(collection.next()) loop, this way it will properly iterate over all r_version_label values, so the code will now output:

1.0
1.1
1.2 
CURRENT
2.0

you can now get rid of CURRENT (or in general get rid of all non values which can't be parsed to a float number).

KarolBe
  • 356
  • 2
  • 10
  • If I add this below line int versionsCount = collection.getValueCount("r_version_label"); I got this error Exception in thread "main" com.documentum.fc.client.impl.typeddata.MissingValueException: attribute 'r_version_label' does not have a value yet @KarolBe – paramesh Jul 24 '18 at 04:42
  • 1
    You have to move the line below "while (collection.next())" – KarolBe Jul 24 '18 at 14:18
  • Thanks it is working now, if you like my question please up vote, thank you @KarolBe – paramesh Jul 25 '18 at 04:32
0
IDfDocument doc = (IDfDocument) session.getObject(colDocuments.getId("r_object_id")); 
String versionLabel = doc.getAllRepeatingStrings("r_version_label", null);
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103