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();
}
}}
上述代码的输出为: 1.0、1.1、1.2,当前

代替“当前”标签,我想要“获得版本号”,如2.0或3.0等,这是最新的文档版本号。
所需产出如下:

发布于 2018-07-23 14:55:56
首先,这一行:
int versionsCount = collection.getValueCount("r_object_id");应该是
int versionsCount = collection.getValueCount("r_version_label");并且必须在while(collection.next())循环中,这样才能正确地迭代所有r_version_label值,因此代码现在将输出:
1.0
1.1
1.2
CURRENT
2.0您现在可以摆脱当前(或者,一般情况下,去掉不能解析为浮点数的所有非值)。
发布于 2022-06-30 11:25:58
IDfDocument doc = (IDfDocument) session.getObject(colDocuments.getId("r_object_id"));
String versionLabel = doc.getAllRepeatingStrings("r_version_label", null);https://stackoverflow.com/questions/51471655
复制相似问题