ucGetRemoveAdv SearchFields
Purpose
When creating Advanced Search Filters this method is used to remove the fields passed into the method.
Applies To
Search & Reporting Methods
Signature
public String[] ucGetRemoveAdvSearchFields(
Connection dbconn,
SesameSession session)
Notes
Example
This example of ucGetRemoveAdvSearchFields shows how when called, the method will go through all of the user defied fields that exist in the Data Dictionary, and be able to pick out certain fields if they are configured for a project that is either not the default project nor the current user’s project. It then removes fields that do not exist in the default project, or the users current project, to enable them to not have advanced search access to those particular fields.
public String[] ucGetRemoveAdvSearchFields (Connection dbconn, SesameSession session) {
String userRole = session.getUserRole();
String projectId = Integer.toString(session.getProject() );
if (ROLE__ADMIN.equals(userRole)
|| ROLE__COORDINATOR.equals(userRole)
|| ROLE__IMPORT_SECURITY.equals(userRole) )
return null;
HashMap udfNameIds = DataDictionary.getUdfNameIds();
if (udfNameIds == null) {
Z.log.writeToLog(Z.log.WARN, "DataDictionary UDF Name list is empty!");
return null;
}
// go through list of UDF fields in Data Dictionary and collect all
// fields configured for a project different than current,
// ignoring default project
ArrayList fieldList = new ArrayList();
Iterator i = udfNameIds.keySet().iterator();
while (i.hasNext() ) {
String udfName = (String) i.next();
DDEntry dde = DataDictionary.getDDEntry(dbconn, udfName);
if (dde != null) {
String udfProjectId = dde.getProjectId();
if (! "0".equals(udfProjectId) && ! projectId.equals(udfProjectId) ) {
fieldList.add(udfName);
}
}
}
String[] fieldsToRemove = arrayListToStringArray(fieldList);
Z.log.writeToLog(Z.log.WARN,
"Removing fields from Advanced Search: " + fieldList);
return fieldsToRemove;
}