0

我正在尝试构建自定义搜索,并遵循红皮书中的示例。但是,我没有创建新功能,而是通过修改在 FileNet 数据库上执行的查询来修改当前的搜索行为。根据示例,仅设置和显示了几个默认属性。我正在努力设置其他文档属性。

  private static void buildResultStructure(JSONResultSetResponse jsonResultSet, MessageResources resources, Locale clientLocale) { 
    String[] states = new String[1]; 
    states[0] = "isLocked"; 
    jsonResultSet.addColumn(new JSONResultSetColumn(" ", "multiStateIcon", false, states));
    jsonResultSet.addColumn(new JSONResultSetColumn(" ", "17px", "mimeTypeIcon", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.id"), "200px", "ID", null, false));
    jsonResultSet.addColumn(new JSONResultSetColumn("Class Name", "125px", "className", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.lastModifiedByUser"), "125px", "ModifiedBy", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.lastModifiedTimestamp"), "175px", "LastModified", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.version"), "50px", "Version", null, false));
    jsonResultSet.addMagazineColumn(new JSONResultSetColumn("thumbnail", "60px", "thumbnail", null, null)); 
    com.ibm.json.java.JSONArray fieldsToDisplay = new com.ibm.json.java.JSONArray();
    com.ibm.json.java.JSONObject jsonObj = new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "className");
    jsonObj.put("displayName", "Class"); 
    fieldsToDisplay.add(jsonObj); 
    jsonObj =new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "ModifiedBy");
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.lastModifiedByUser")); 
    fieldsToDisplay.add(jsonObj);
    jsonObj = new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "LastModified");
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.lastModifiedTimestamp"));
    fieldsToDisplay.add(jsonObj);
    jsonObj = new com.ibm.json.java.JSONObject();
    jsonObj.put("field", "Version"); 
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.version"));
    fieldsToDisplay.add(jsonObj); 
    
    jsonResultSet.addMagazineColumn(new JSONResultSetColumn("content", "100%", "content", fieldsToDisplay, null));
  }
4

1 回答 1

1

首先进入文件 SamplePluginSearchServiceP8.java 和 buildP8ResultStructure 函数。删除不必要的列。使用相关格式添加新列

jsonResultSet.addColumn(new JSONResultSetColumn(" ", 你的列宽, 你的字段名, sortable?, false));

完成此操作后,转到同一 java 文件上的 executeP8Search,查看第 122 行,迭代使用查询中的值返回的 searchResults,为每一行添加相关值。

JSONResultSetRow row = new JSONResultSetRow(sbId.toString(), doc.get_Name(), doc.get_MimeType(), 特权);

row.addAttribute("你的字段名", doc.isLocked(), JSONResultSetRow.TYPE_BOOLEAN, null, (new Boolean(doc.isLocked())).toString()); //***请注意添加相关类型,字符串到字符串值,int,bool等。

jsonResultSet.addRow(row);

不要忘记以相同的方式修复 ContinueQueryService.java。

于 2020-08-23T07:39:58.630 回答