1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +02:00

[207178] use array of fileTypes for multi queries, instead of just one

This commit is contained in:
David McKnight 2007-11-05 14:58:34 +00:00
parent 3e67ac8165
commit 19c1d8e469
8 changed files with 109 additions and 58 deletions

View file

@ -1071,7 +1071,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{ {
DataElement[] subjects = getSubjectsFor(remoteParents, names); DataElement[] subjects = getSubjectsFor(remoteParents, names);
dsQueryCommandMulti(subjects, null, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); // construct default array of commands
String[] queryStrings = new String[remoteParents.length];
for (int i = 0; i < queryStrings.length; i++)
{
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT;
}
dsQueryCommandMulti(subjects, null, queryStrings, monitor);
return convertToHostFiles(subjects, "*"); //$NON-NLS-1$ return convertToHostFiles(subjects, "*"); //$NON-NLS-1$
} }
@ -1564,7 +1571,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
case IFileServiceConstants.FILE_TYPE_FOLDERS: case IFileServiceConstants.FILE_TYPE_FOLDERS:
queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS; queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS;
break; break;
case IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS: case IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS:
default: default:
@ -1574,6 +1581,30 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
return queryString; return queryString;
} }
private String[] getQueryStrings(int[] fileTypes)
{
String[] queryStrings = new String[fileTypes.length];
for (int i = 0; i < fileTypes.length; i++)
{
switch (fileTypes[i])
{
case IFileServiceConstants.FILE_TYPE_FILES:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FILES;
break;
case IFileServiceConstants.FILE_TYPE_FOLDERS:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS;
break;
case IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS:
default:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_ALL;
break;
}
}
return queryStrings;
}
public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor) public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor)
{ {
String queryString = getQueryString(fileType); String queryString = getQueryString(fileType);
@ -1582,12 +1613,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
public IHostFile[] listMulti(String[] remoteParents, public IHostFile[] listMulti(String[] remoteParents,
String[] fileFilters, int fileType, IProgressMonitor monitor) String[] fileFilters, int[] fileTypes, IProgressMonitor monitor)
throws SystemMessageException throws SystemMessageException
{ {
String queryString = getQueryString(fileType); String[] queryStrings = getQueryStrings(fileTypes);
return fetchMulti(remoteParents, fileFilters, queryString, monitor); return fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
} }
protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles) protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles)
@ -1688,11 +1719,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
* *
* @param remoteParents the parents to query * @param remoteParents the parents to query
* @param fileFilters the filters for each parent to query * @param fileFilters the filters for each parent to query
* @param queryType the type of query (files, folders, both, etc) * @param queryTypes the type of queries (for each parent) - files, folders, both, etc
* @param monitor the progress monitor * @param monitor the progress monitor
* @return the results * @return the results
*/ */
protected IHostFile[] fetchMulti(String[] remoteParents, String[] fileFilters, String queryType, IProgressMonitor monitor) protected IHostFile[] fetchMulti(String[] remoteParents, String[] fileFilters, String[] queryTypes, IProgressMonitor monitor)
{ {
DataStore ds = getDataStore(); DataStore ds = getDataStore();
if (ds == null) if (ds == null)
@ -1720,7 +1751,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
argses[i] = args; argses[i] = args;
} }
List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryType, monitor); List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryTypes, monitor);
List convertedResults = new ArrayList(); List convertedResults = new ArrayList();
for (int r = 0; r < consolidatedResults.size(); r++) for (int r = 0; r < consolidatedResults.size(); r++)
{ {

View file

@ -90,12 +90,12 @@ public abstract class AbstractDStoreService implements IDStoreService
} }
/** /**
* query * query the the remote system
* @param subject * @param subject the subject of the query
* @param args * @param args the arguments for the query
* @param command * @param command the query command
* @param monitor * @param monitor
* @return * @return the array of results
*/ */
protected DataElement[] dsQueryCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor) protected DataElement[] dsQueryCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor)
{ {
@ -146,20 +146,20 @@ public abstract class AbstractDStoreService implements IDStoreService
return new DataElement[0]; return new DataElement[0];
} }
protected List dsQueryCommandMulti(DataElement[] subjects, String command, IProgressMonitor monitor) protected List dsQueryCommandMulti(DataElement[] subjects, String[] commands, IProgressMonitor monitor)
{ {
return dsQueryCommandMulti(subjects, null, command, monitor); return dsQueryCommandMulti(subjects, null, commands, monitor);
} }
/** /**
* Query multiple subjects in one shot * Query multiple subjects in one shot
* @param subjects the subjects to query * @param subjects the subjects to query
* @param command the query command * @param commands the query commands
* @param args args for the command - may be null * @param argses arguments for the command - may be null
* @param monitor the progress monitor * @param monitor the progress monitor
* @return a list of DataElement[]s containing the results of each query * @return a list of DataElement[]s containing the results of each query
*/ */
protected List dsQueryCommandMulti(DataElement[] subjects, ArrayList[] argses, String command, IProgressMonitor monitor) protected List dsQueryCommandMulti(DataElement[] subjects, ArrayList[] argses, String[] commands, IProgressMonitor monitor)
{ {
List statuses = new ArrayList(); List statuses = new ArrayList();
DataStore ds = getDataStore(); DataStore ds = getDataStore();
@ -170,7 +170,7 @@ public abstract class AbstractDStoreService implements IDStoreService
{ {
DataElement subject = subjects[i]; DataElement subject = subjects[i];
DataElement queryCmd = getCommandDescriptor(subject, command); DataElement queryCmd = getCommandDescriptor(subject, commands[i]);
if (queryCmd != null && ds != null) if (queryCmd != null && ds != null)
{ {
DataElement status = null; DataElement status = null;

View file

@ -52,13 +52,13 @@ public abstract class AbstractFileService implements IFileService
} }
public IHostFile[] listMulti(String[] remoteParents, public IHostFile[] listMulti(String[] remoteParents,
String[] fileFilters, int fileType, IProgressMonitor monitor) String[] fileFilters, int fileTypes[], IProgressMonitor monitor)
throws SystemMessageException { throws SystemMessageException {
List files = new ArrayList(); List files = new ArrayList();
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
{ {
IHostFile[] result = list(remoteParents[i], fileFilters[i], fileType, monitor); IHostFile[] result = list(remoteParents[i], fileFilters[i], fileTypes[i], monitor);
for (int j = 0; j < result.length; j++) for (int j = 0; j < result.length; j++)
{ {
files.add(result[j]); files.add(result[j]);

View file

@ -182,14 +182,17 @@ public interface IFileService extends IService
* system from which to retrieve the collective child list. * system from which to retrieve the collective child list.
* @param fileFilters - a set of strings that can be used to filter the children. Only * @param fileFilters - a set of strings that can be used to filter the children. Only
* those files matching the filter corresponding to it's remoteParent make it into the list. The interface * those files matching the filter corresponding to it's remoteParent make it into the list. The interface
* does not dictate where the filtering occurs. * does not dictate where the filtering occurs. For each remoteParent, there must be a corresponding
* @param fileType - indicates whether to query files, folders, both or some other type * fileFilter.
* @param fileTypes - indicates whether to query files, folders, both or some other type. For
* each remoteParent, there must be a corresponding fileType.
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return the collective list of host files that reside in each of the remoteParents with it's corresponding filter. * @return the collective list of host files that reside in each of the remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family. * Typically this would be one of those in the RemoteFileException family.
*/ */
public IHostFile[] listMulti(String[] remoteParents, String[] fileFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException; public IHostFile[] listMulti(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
/** /**

View file

@ -371,10 +371,10 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
* by the given file name filter. It can be null for no subsetting. * by the given file name filter. It can be null for no subsetting.
* @param parents The parent folders to list folders and files in * @param parents The parent folders to list folders and files in
* @param fileNameFilters The name patterns to subset the file list by, or null to return all files. * @param fileNameFilters The name patterns to subset the file list by, or null to return all files.
* @param fileType - indicates whether to query files, folders, both or some other type * @param fileTypes - indicates whether to query files, folders, both or some other type
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
{ {
String[] parentPaths = new String[parents.length]; String[] parentPaths = new String[parents.length];
for (int i = 0; i < parents.length; i++) for (int i = 0; i < parents.length; i++)
@ -382,7 +382,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
parentPaths[i] = parents[i].getAbsolutePath(); parentPaths[i] = parents[i].getAbsolutePath();
} }
IHostFile[] results = getFileService().listMulti(parentPaths, fileNameFilters, fileType, monitor); IHostFile[] results = getFileService().listMulti(parentPaths, fileNameFilters, fileTypes, monitor);
RemoteFileContext context = getDefaultContext(); RemoteFileContext context = getDefaultContext();
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
@ -418,15 +418,15 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
/** /**
* Return a list of remote folders and files in the given folder. * Return a list of remote folders and/or files in the given folder.
* <p> * <p>
* The files part of the list is subsetted by the given file name filter. * The files part of the list is filtered by the given file name filter.
* It can be null for no subsetting. * It can be null for no filtering.
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s). * This version is called by RemoteFileSubSystemImpl's resolveFilterString(s).
* @param parent The parent folder to list folders and files in * @param parent The parent folder to list folders and files in
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. * @param fileNameFilter The name pattern to subset the file list by, or null to return all files.
* @param context The holder of state information * @param context The holder of state information
* @param fileType the type of file to query * @param fileType indicates whether to filter files, folders, both or something else
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, int fileType, IProgressMonitor monitor) throws SystemMessageException public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, int fileType, IProgressMonitor monitor) throws SystemMessageException

View file

@ -109,60 +109,71 @@ public interface IRemoteFileSubSystem extends ISubSystem {
/** /**
* Return a list of all remote folders and files in the given folder. The list is not subsetted. * Return a list of all remote folders and/or files in the given folders. This list is not filtered.
* @param parents The parent folders to list folders and files in *
* @param fileType - indicates whether to query files, folders, both or some other type * @param parents The parent folders to list folders and/or files in
* @param fileTypes - indicates whether to query files, folders, both or some other type. There
* should be exactly one fileType specified per parent.
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] listMulti(IRemoteFile[] parents, int fileType, IProgressMonitor monitor) throws SystemMessageException; public IRemoteFile[] listMulti(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Return a list of remote folders and files in the given folder. Only file names are subsettable * Return a list of remote folders and/or files in the given folder. Only file names are filtered
* by the given file name filter. It can be null for no subsetting. * by the given file name filters. It can be null for no sub-setting.
*
* @param parents The parent folders to list folders and files in * @param parents The parent folders to list folders and files in
* @param fileNameFilters The name patterns to subset the file list by, or null to return all files. * @param fileNameFilters The name patterns to subset the file list by, or null to return all files.
* @param fileType - indicates whether to query files, folders, both or some other type * There should be exactly one fileNameFilter per parent.
* @param fileTypes - indicates whether to query files, folders, both or some other type. There
* should be exactly one fileType specified per parent.
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException; public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Return a list of all remote folders and files in the given folder. The list is not subsetted. * Return a list of all remote folders and/or files in the given folder. The list is not filtered.
* @param parent The parent folder to list folders and files in *
* @param parent The parent folder to list folders and/or files in
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] list(IRemoteFile parent, IProgressMonitor monitor) throws SystemMessageException; public IRemoteFile[] list(IRemoteFile parent, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Return a list of all remote folders and files in the given folder. The list is not subsetted. * Return a list of all remote folders and/or files in the given folder. The list is not filtered.
*
* @param parent The parent folder to list folders and files in * @param parent The parent folder to list folders and files in
* @param fileType - indicates whether to query files, folders, both or some other type * @param fileType - indicates whether to query files, folders, both or some other type.
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] list(IRemoteFile parent, int fileType, IProgressMonitor monitor) throws SystemMessageException; public IRemoteFile[] list(IRemoteFile parent, int fileType, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Return a list of remote folders and files in the given folder. Only file names are subsettable * Return a list of remote folders and/or files in the given folder. Only file names are filtered
* by the given file name filter. It can be null for no subsetting. * by the given file name filter. It can be null for no filtering.
*
* @param parent The parent folder to list folders and files in * @param parent The parent folder to list folders and files in
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. * @param fileNameFilter The name pattern to subset the file list by, or null to return all files.
* @param fileType - indicates whether to query files, folders, both or some other type * @param fileType - indicates whether to query files, folders, both or some other type.
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException; public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Return a list of remote folders and files in the given folder. * Return a list of remote folders and/or files in the given folder. The files part of the list is filtered
* <p> * by the given file name filter. It can be null for no filtering.
* The files part of the list is subsetted by the given file name filter. *
* It can be null for no subsetting.
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s).
* @param parent The parent folder to list folders and files in * @param parent The parent folder to list folders and files in
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. * @param fileNameFilter The name pattern to subset the file list by, or null to return all files.
* @param context The holder of state information * @param context The holder of state information
* - indicates whether to query files, folders, both or some other type * - indicates whether to query files, folders, both or some other type
* @param fileType - indicates whether to query files, folders, both or some other type * @param fileType - indicates whether to query files, folders, both or some other type
* For the default list of available file types see <code>IFileServiceContants</code>
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */

View file

@ -867,10 +867,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
/** /**
* Return a list of all remote folders and files in the given folder. The list is not subsetted. * Return a list of all remote folders and files in the given folder. The list is not subsetted.
* @param parents The parent folders to list folders and files in * @param parents The parent folders to list folders and files in
* @param fileType - indicates whether to query files, folders, both or some other type * @param fileTypes - indicates whether to query files, folders, both or some other type
* @param monitor the progress monitor * @param monitor the progress monitor
*/ */
public IRemoteFile[] listMulti(IRemoteFile[] parents, int fileType, IProgressMonitor monitor) throws SystemMessageException public IRemoteFile[] listMulti(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
{ {
String[] fileNameFilters = new String[parents.length]; String[] fileNameFilters = new String[parents.length];
for (int i = 0; i < parents.length; i++) for (int i = 0; i < parents.length; i++)
@ -878,7 +878,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$ fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$
} }
return listMulti(parents, fileNameFilters, fileType, monitor); return listMulti(parents, fileNameFilters, fileTypes, monitor);
} }
/** /**

View file

@ -357,7 +357,13 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase
long t3 = System.currentTimeMillis(); long t3 = System.currentTimeMillis();
try try
{ {
results = ss.listMulti(remoteFiles, IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS, new NullProgressMonitor()); int[] types = new int[remoteFiles.length];
for (int t = 0; t < remoteFiles.length; t++)
{
types[t] = IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS;
}
results = ss.listMulti(remoteFiles, types, new NullProgressMonitor());
} }
catch (Exception e){ catch (Exception e){
exception = e; exception = e;