version-control - 如何通过 DFC 代码获取当前版本标签号?
问题描述
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, CURRENT
代替“当前”标签,我想“获取版本号”,如 2.0 或 3.0 等,这是最新的文档版本号。
需要的输出如下:
解决方案
首先,这一行:
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
您现在可以摆脱 CURRENT (或者通常摆脱所有无法解析为浮点数的非值)。
推荐阅读
- python - 没有名为:bert_embedding 的模块。Python
- api - Yii2:如何将数组传递给 RESTful Web 服务
- ios - 如果要使用主故事板文件,应用程序委托必须实现窗口属性
- swift - 将 x.0 浮点数转换为 int 函数
- javascript - 打开刚刚下载的图片
- database - 在云端发送和存储传感器数据
- php - 当我单击导出时,phpmyadmin 中会发生此错误
- php - 以 params guzzle http 形式发送 url
- angular - this.mobilityService.currentMessage.subscribe 不是角度单元测试中的函数
- c# - C# Blazor:如何在后面的代码中使用 @typeparam?(有解决方法)