001/*
002 * Copyright (c) 2004-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: crawl $'
006 * '$Date: 2015-08-24 22:47:39 +0000 (Mon, 24 Aug 2015) $' 
007 * '$Revision: 33633 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.srb;
031
032import java.util.StringTokenizer;
033import java.util.Vector;
034
035import edu.sdsc.grid.io.GeneralFile;
036import edu.sdsc.grid.io.MetaDataCondition;
037import edu.sdsc.grid.io.MetaDataRecordList;
038import edu.sdsc.grid.io.MetaDataSelect;
039import edu.sdsc.grid.io.MetaDataSet;
040import edu.sdsc.grid.io.MetaDataTable;
041import edu.sdsc.grid.io.local.LocalFile;
042import edu.sdsc.grid.io.srb.SRBFile;
043import edu.sdsc.grid.io.srb.SRBFileSystem;
044import edu.sdsc.grid.io.srb.SRBMetaDataSet;
045import ptolemy.actor.NoTokenException;
046import ptolemy.actor.TypedAtomicActor;
047import ptolemy.actor.TypedIOPort;
048import ptolemy.data.ArrayToken;
049import ptolemy.data.ObjectToken;
050import ptolemy.data.StringToken;
051import ptolemy.data.Token;
052import ptolemy.data.type.ArrayType;
053import ptolemy.data.type.BaseType;
054import ptolemy.gui.GraphicalMessageHandler;
055import ptolemy.kernel.CompositeEntity;
056import ptolemy.kernel.util.Attribute;
057import ptolemy.kernel.util.IllegalActionException;
058import ptolemy.kernel.util.NameDuplicationException;
059
060//////////////////////////////////////////////////////////////////////////
061//// SRBQueryMD
062/**
063 * <p>
064 * Query the metadata. Get all files satisfying the conditions. Queries the SRB
065 * metadata from a specific location with user defined conditions.
066 * </p>
067 * <p>
068 * The conditions are generated as follows:
069 * </p>
070 * <p>
071 * <b>SRBCreateQueryInterface</b>: Creates an html interface for querying the
072 * SRB metadata. Will be replaced with a jsp page within a Kepler server.
073 * </p>
074 * <p>
075 * 
076 * <b>SRBCreateQueryConditions</b>: Creates conditions for querying the SRB
077 * metadata from a user xml string conditions, returned by the BrowserUI actor.
078 * </p>
079 * <p>
080 * The following actor expects as input a reference to the SRB file system. This
081 * reference connection is obtained via the SRBConnect Actor in Kepler. <i>See
082 * SRBConnect and its documentation.</i>
083 * </p>
084 * <p>
085 * The file reference system is created with a unique SRB user account and with
086 * this connection reference as input the SRBQueryMD actor is able to gain
087 * access to the SRB file space. Once an alive SRB file connection system has
088 * been established the actor gets the remote SRB file/directory and the
089 * appropriate metadata conditions. The SRB files are then queried with the
090 * metadata constraints via jargon API methods.
091 * </p>
092 * <p>
093 * <B>Actor Input:</B> Accepts a reference to the SRB files system, an SRB
094 * remote file/directory path and conditions.
095 * </p>
096 * <p>
097 * There exist separate conditions format for metadatas for datasets,
098 * collections and pre-defined metadata.
099 * </p>
100 * <p>
101 * The conditions for files and directories are specified as follows: { metadata
102 * for datasets, "|", metadata for collections, "|", predefined metadata}
103 * </p>
104 * <p>
105 * E.g. {"a = 5", "b = 3", "|", "x = 8", "|", "owner = efrat"}
106 * </p>
107 * <p>
108 * Straight slashes ("|") separate between the different metadata types. Both
109 * slashes are MANDATORY, even if no condition is specified!
110 * </p>
111 * <p>
112 * The following operators apply: =, !=, not=, <, lt, num_lt, <=, le, num_le, >,
113 * gt, num_gt, >=, ge, num_ge, in, notin, not_in, between, num_between,
114 * notbetween, not_between, num_not_between, like, notlike, not_like, in,
115 * contains, notin, not_in, , not_contains sounds_like, sounds_not_like,
116 * sounds_not_like
117 * 
118 * </p>
119 * <p>
120 * <B>Actor Output:</B> Returns an array of all the file paths satisfying the
121 * constraints.
122 * 
123 * </p>
124 * <p>
125 * The following actor accesses SRB file reference system and SRB file space
126 * with the SRB Jargon API provided. The JARGON is a pure API for developing
127 * programs with a data grid interface and I/O for SRB file systems.
128 * </p>
129 * <A href="http://www.sdsc.edu/srb"><I>Further information on SRB</I> </A>
130 * 
131 * @author Efrat Jaeger
132 * @version $Id: SRBQueryMD.java 33633 2015-08-24 22:47:39Z crawl $
133 * @category.name srb
134 * @category.name put
135 */
136public class SRBQueryMD extends TypedAtomicActor {
137
138        /**
139         * Construct a constant source with the given container and name. Create the
140         * <i>value</i> parameter, initialize its value to the default value of an
141         * IntToken with value 1.
142         * 
143         * @param container
144         *            The container.
145         * @param name
146         *            The name of this actor.
147         * @exception IllegalActionException
148         *                If the entity cannot be contained by the proposed
149         *                container.
150         * @exception NameDuplicationException
151         *                If the container already has an actor with this name.
152         */
153        public SRBQueryMD(CompositeEntity container, String name)
154                        throws NameDuplicationException, IllegalActionException {
155                super(container, name);
156
157                SRBFileSystem = new TypedIOPort(this, "SRBFileSystem", true, false);
158                SRBFileSystem.setTypeEquals(BaseType.GENERAL);
159                new Attribute(SRBFileSystem, "_showName");
160
161                srbFilePath = new TypedIOPort(this, "srbFilePath", true, false);
162                srbFilePath.setTypeEquals(BaseType.STRING); // or should it be an array
163                                                                                                        // of strings.
164                new Attribute(srbFilePath, "_showName");
165
166                conditions = new TypedIOPort(this, "conditions", true, false);
167                conditions.setTypeEquals(new ArrayType(BaseType.STRING));
168                new Attribute(conditions, "_showName");
169
170                filePaths = new TypedIOPort(this, "filePaths", false, true);
171                filePaths.setTypeEquals(new ArrayType(BaseType.STRING));
172                new Attribute(filePaths, "_showName");
173
174                _attachText("_iconDescription", "<svg>\n" + "<rect x=\"0\" y=\"0\" "
175                                + "width=\"150\" height=\"40\" " + "style=\"fill:white\"/>\n"
176                                + "<text x=\"7\" y=\"30\""
177                                + "style=\"font-size:12; fill:black; font-family:SansSerif\">"
178                                + "SRB$</text>\n" + "<text x=\"41\" y=\"31\""
179                                + "style=\"font-size:14; fill:blue; font-family:SansSerif\">"
180                                + "Query MetaData</text>\n" + "</svg>\n");
181        }
182
183        /**
184         * pointer to the SRB file system.
185         */
186        public TypedIOPort SRBFileSystem;
187
188        /**
189         * Collection path to begin querying from
190         */
191        public TypedIOPort srbFilePath;
192
193        /**
194         * {"dataset_att op val", "|","collection_att op val", "|",
195         * "predefined_att op val"}
196         * <P>
197         * The conditions for files and directories are specified as follows:
198         * Straight slashes ("|") separate between the different metadata types.
199         * Both slashes are MANDATORY, even if no condition was specified!
200         * 
201         * { metadata for datasets, "|", metadata for collections, "|", predefined
202         * metadata} E.g. {"a = 5", "b > 3", "|", "x < 8", "|", "owner = efrat"}
203         * <P>
204         * The following operators apply: =, !=, not=, <, lt, num_lt, <=, le,
205         * num_le, >, gt, num_gt, >=, ge, num_ge, in, notin, not_in, between,
206         * num_between, notbetween, not_between, num_not_between, like, notlike,
207         * not_like, in, contains, notin, not_in, , not_contains sounds_like,
208         * sounds_not_like, sounds_not_like
209         */
210        public TypedIOPort conditions;
211
212        /**
213         * Matching files paths.
214         */
215        public TypedIOPort filePaths;
216
217        // /////////////////////////////////////////////////////////////////
218        // // public methods ////
219        /**
220         * Returns an array of all the file paths satisfying the constraints.
221         * 
222         * The conditions for files and directories are specified as follows: {
223         * metadata for datasets, "|", metadata for collections, "|", predefined
224         * metadata} E.g. {"a = 5", "b = 3", "|", "x = 8", "|", "owner = efrat"}
225         * 
226         * Straight slashes ("|") separate between the different metadata types.
227         * Both slashes are MANDATORY, even if no condition is specified!
228         * 
229         * The following operators apply: =, !=, not=, <, lt, num_lt, <=, le,
230         * num_le, >, gt, num_gt, >=, ge, num_ge, in, notin, not_in, between,
231         * num_between, notbetween, not_between, num_not_between, like, notlike,
232         * not_like, in, contains, notin, not_in, , not_contains sounds_like,
233         * sounds_not_like, sounds_not_like
234         * 
235         * @exception IllegalActionException
236         *                If it is thrown if the SRB file cannot be accessed or the
237         *                current directory cannot be broadcasted.
238         */
239        public void fire() throws IllegalActionException {
240
241                SRBFile srbFile;
242                LocalFile localFile;
243                String localFilePath;
244                String _exitCode = "";
245
246                try {
247                        // make sure there is an alive connection.
248                        try {
249                                srbFileSystem.getHost();
250                        } catch (Exception ex) { // connection was closed.
251                                srbFileSystem = null;
252                                ObjectToken SRBConOT = null;
253                                try { // try to get a new connection in case the previous one
254                                                // has terminated.
255                                        SRBConOT = (ObjectToken) SRBFileSystem.get(0);
256                                } catch (NoTokenException ntex) {
257                                }
258                                if (SRBConOT != null) {
259                                        srbFileSystem = (SRBFileSystem) SRBConOT.getValue();
260                                }
261                        }
262                        if (srbFileSystem == null) {
263                                throw new IllegalActionException(this,
264                                                "No SRB connection available in actor "
265                                                                + this.getName() + ".");
266                        }
267
268                        String srbFileStr = ((StringToken) srbFilePath.get(0))
269                                        .stringValue();
270                        srbFile = new SRBFile(srbFileSystem, srbFileStr);
271
272                        if (srbFile.exists()) {
273                                Token[] conds = ((ArrayToken) conditions.get(0)).arrayValue();
274                                int numConds = conds.length;
275                                // String[][] definableMetaDataValues = new String[numConds][2];
276                                // int operators[] = new int[numConds];
277
278                                Vector conditionsVec = new Vector();
279                                Vector conditionTableVec = new Vector();
280
281                                int j = 0;
282
283                                // ///////////////////////
284                                // METADATA FOR DATASETS
285                                // ///////////////////////
286                                String condition = ((StringToken) conds[j++]).stringValue();
287                                while (!condition.equals("|")) { // getting datasets metadata.
288                                        conditionTableVec.add(condition);
289                                        condition = ((StringToken) conds[j++]).stringValue();
290                                }
291
292                                MetaDataTable mdt = null;
293                                // creating the metadata table for file conditions.
294                                if (conditionTableVec.size() > 0) {
295                                        // creating an srb metadata table for the datasets
296                                        // constraints.
297                                        mdt = _createMDT(conditionTableVec);
298                                        // creating an SRB metadata condition for datasets
299                                        conditionsVec.add(MetaDataSet.newCondition(
300                                                        SRBMetaDataSet.DEFINABLE_METADATA_FOR_FILES, mdt));
301                                } else {
302                                        _debug("no user defined metadata for files");
303                                        System.out.println("no user defined metadata for files");
304                                }
305
306                                conditionTableVec.clear();
307
308                                // //////////////////////////
309                                // METADATA FOR COLLECTIONS
310                                // //////////////////////////
311                                condition = ((StringToken) conds[j++]).stringValue();
312                                while (!condition.equals("|")) {
313                                        conditionTableVec.add(condition);
314                                        condition = ((StringToken) conds[j++]).stringValue();
315                                }
316
317                                // creating the metadata table for collection conditions.
318                                if (conditionTableVec.size() > 0) {
319                                        // creating an srb metadata table for the collections
320                                        // constraints.
321                                        mdt = _createMDT(conditionTableVec);
322                                        // creating an SRB metadata condition for collections
323                                        conditionsVec.add(MetaDataSet.newCondition(
324                                                        SRBMetaDataSet.DEFINABLE_METADATA_FOR_DIRECTORIES,
325                                                        mdt));
326                                } else {
327                                        _debug("no user defined metadata for collections");
328                                        System.out
329                                                        .println("no user defined metadata for collections");
330                                }
331
332                                // /////////////////////
333                                // PREDEFINED METADATA (the above is user defined metadata)
334                                // /////////////////////
335                                for (int i = j; i < numConds; i++) {
336                                        condition = ((StringToken) conds[i]).stringValue();
337                                        StringTokenizer st = new StringTokenizer(condition);
338
339                                        String att = _getAttribute(st.nextToken());
340                                        if (att.equals(""))
341                                                GraphicalMessageHandler
342                                                                .error("query attribute is null");
343                                        String opStr = st.nextToken();
344                                        int op = _getOperator(opStr);
345                                        if (op <= MetaDataCondition.GREATER_OR_EQUAL) {
346                                                // this is an equality term.
347                                                String val = st.nextToken();
348                                                conditionsVec.add(MetaDataSet
349                                                                .newCondition(att, op, val));
350                                        } else if (op >= MetaDataCondition.IN
351                                                        && op <= MetaDataCondition.NOT_IN) {
352                                                Vector valuesVec = new Vector();
353                                                while (st.hasMoreTokens()) {
354                                                        String token = st.nextToken();
355                                                        int commaInd = token.indexOf(",");
356                                                        if (commaInd == -1) {
357                                                                valuesVec.add(token);
358                                                        } else {
359                                                                while (commaInd != -1) {
360                                                                        valuesVec.add(token.substring(0, commaInd));
361                                                                        token = token.substring(commaInd);
362                                                                        commaInd = token.indexOf(",");
363                                                                }
364                                                                valuesVec.add(token);
365                                                        }
366
367                                                }
368                                                String[] values = new String[valuesVec.size()];
369                                                valuesVec.toArray(values);
370                                                conditionsVec.add(MetaDataSet.newCondition(att, op,
371                                                                values));
372                                                /*
373                                                 * if (opStr.equals("in") || opStr.equals("not_in")) {
374                                                 * // create an array of val } else { // this is
375                                                 * contains. // create an array of val?? // create an
376                                                 * array of att. }
377                                                 */
378                                        } else if (op == MetaDataCondition.BETWEEN
379                                                        || op == MetaDataCondition.NOT_BETWEEN) {
380                                                String val1 = st.nextToken();
381                                                String val2 = st.nextToken();
382                                                conditionsVec.add(MetaDataSet.newCondition(att, op,
383                                                                val1, val2));
384                                        } else if ((op >= MetaDataCondition.LIKE && op <= MetaDataCondition.NOT_LIKE)
385                                                        || (op >= MetaDataCondition.SOUNDS_LIKE && op <= MetaDataCondition.SOUNDS_NOT_LIKE)) {
386                                                String val = st.nextToken();
387                                                conditionsVec.add(MetaDataSet
388                                                                .newCondition(att, op, val));
389                                        }
390                                }
391                                // query for the conditions and the select fields.
392
393                                if (conditionsVec.size() == 0) {
394                                        _debug("no conditions were specified");
395                                        System.out.println("no conditions were specified");
396                                }
397                                MetaDataCondition mdconditions[] = new MetaDataCondition[conditionsVec
398                                                .size()];
399                                conditionsVec.toArray(mdconditions);
400
401                                // The field selected in the query result.
402                                String[] selectFieldNames = {
403                                                SRBMetaDataSet.DEFINABLE_METADATA_FOR_DIRECTORIES,
404                                                SRBMetaDataSet.DEFINABLE_METADATA_FOR_FILES };
405                                MetaDataSelect selects[] = MetaDataSet
406                                                .newSelection(selectFieldNames);
407
408                                // Querying for files that satisfy the metadata constraints.
409                                MetaDataRecordList[] rl = ((GeneralFile) srbFile).query(
410                                                mdconditions, selects);
411                                _sendQueryResults(rl);
412
413                        } else
414                                GraphicalMessageHandler.error(srbFile.getAbsolutePath()
415                                                + "does not exist.");
416
417                } catch (Exception ex) {
418                        srbFileSystem = SRBUtil.closeConnection(srbFileSystem);
419                        ex.printStackTrace();
420                        throw new IllegalActionException(this, ex.getMessage()
421                                        + ". in actor " + this.getName());
422                }
423        } // end of fire.
424
425        /**
426         * Initialize the srb file system to null.
427         */
428        public void initialize() throws IllegalActionException {
429                super.initialize();
430                srbFileSystem = null;
431        }
432
433        /**
434         * Disconnect from SRB.
435         */
436        public void wrapup() {
437                srbFileSystem = SRBUtil.closeConnection(srbFileSystem);
438        }
439
440        // /////////////////////////////////////////////////////////////////
441        // // private methods ////
442
443        /**
444         * Create a metadata table of the user defined conditions.
445         */
446        private MetaDataTable _createMDT(Vector conds) {
447                Vector ufmdVec = new Vector();
448                Vector opVec = new Vector();
449                String[] singleMD;
450                for (int i = 0; i < conds.size(); i++) {
451                        StringTokenizer st = new StringTokenizer((String) conds.get(i));
452                        String att = st.nextToken();
453                        if (att.equals(""))
454                                GraphicalMessageHandler.error("query attribute is null");
455                        singleMD = new String[2];
456                        singleMD[0] = att;
457                        String opStr = st.nextToken();
458                        int op = _getOperator(opStr);
459                        if (op <= MetaDataCondition.GREATER_OR_EQUAL) {
460                                // this is an equality term.
461                                opVec.add(new Integer(op));
462                                String val = st.nextToken();
463                                singleMD[1] = val;
464                                ufmdVec.add(singleMD);
465                        } else if (op >= MetaDataCondition.IN
466                                        && op <= MetaDataCondition.NOT_IN) {
467                                opVec.add(new Integer(op));
468                                String val = st.nextToken();
469                                while (st.hasMoreTokens()) {
470                                        val += "," + st.nextToken();
471                                }
472                                singleMD[1] = val;
473                                ufmdVec.add(singleMD);
474                                /*
475                                 * if (opStr.equals("in") || opStr.equals("not_in")) { // create
476                                 * an array of val } else { // this is contains. // create an
477                                 * array of val?? // create an array of att. }
478                                 */
479                        } else if (op == MetaDataCondition.BETWEEN) {
480                                opVec.add(new Integer(MetaDataCondition.GREATER_OR_EQUAL));
481                                String val = st.nextToken();
482                                singleMD[1] = val;
483                                ufmdVec.add(singleMD);
484
485                                singleMD = new String[2];
486                                singleMD[0] = att;
487                                opVec.add(new Integer(MetaDataCondition.LESS_OR_EQUAL));
488                                val = st.nextToken();
489                                singleMD[1] = val;
490                                ufmdVec.add(singleMD);
491                        } else if (op == MetaDataCondition.NOT_BETWEEN) {
492                                opVec.add(new Integer(MetaDataCondition.LESS_THAN));
493                                String val = st.nextToken();
494                                singleMD[1] = val;
495                                ufmdVec.add(singleMD);
496
497                                opVec.add(new Integer(MetaDataCondition.GREATER_THAN));
498                                val = st.nextToken();
499                                singleMD[1] = val;
500                                ufmdVec.add(singleMD);
501                        } else if ((op >= MetaDataCondition.LIKE && op <= MetaDataCondition.NOT_LIKE)
502                                        || (op >= MetaDataCondition.SOUNDS_LIKE && op <= MetaDataCondition.SOUNDS_NOT_LIKE)) {
503                                opVec.add(new Integer(op));
504                                String val = st.nextToken();
505                                singleMD[1] = val;
506                                ufmdVec.add(singleMD);
507                        }
508                }
509                String[][] definableMetaData = new String[ufmdVec.size()][2];
510                // for (int i=0; i<ufmdVec.size(); i++) {
511                // definableMetaData[i] = (String[])ufmdVec.get(i);
512                // }
513                ufmdVec.toArray(definableMetaData);
514                int[] operators = new int[opVec.size()];
515                for (int i = 0; i < opVec.size(); i++) {
516                        operators[i] = ((Integer) opVec.get(i)).intValue();
517                }
518
519                return new MetaDataTable(operators, definableMetaData);
520        }
521
522        /**
523         * Get the desired attribute name for predefined attributes.
524         * 
525         * @param att
526         *       */
527        private String _getAttribute(String att) {
528                att = att.trim().toLowerCase();
529                if (att.equals("annotation"))
530                        return SRBMetaDataSet.FILE_ANNOTATION;
531                if (att.equals("annotator"))
532                        return SRBMetaDataSet.FILE_ANNOTATION_USERNAME;
533                if (att.equals("owner"))
534                        return SRBMetaDataSet.OWNER;
535                if (att.equals("dataName"))
536                        return SRBMetaDataSet.FILE_NAME;
537                if (att.equals("collName"))
538                        return SRBMetaDataSet.DIRECTORY_NAME;
539                if (att.equals("dataType"))
540                        return SRBMetaDataSet.FILE_TYPE_NAME;
541                return "";
542        }
543
544        /**
545         * Get the operator int representation for an operator string
546         * 
547         * @param op
548         *       */
549        private int _getOperator(String op) {
550                // currently only equality operators are supported.
551                // if no operator is found assume it is equal.
552                op = op.trim().toLowerCase();
553
554                if (op.equals("="))
555                        return MetaDataCondition.EQUAL;
556                if (op.equals("!=") || op.equals("not="))
557                        return MetaDataCondition.NOT_EQUAL;
558                if (op.equals("<") || op.equals("lt") || op.equals("num_lt"))
559                        return MetaDataCondition.LESS_THAN;
560                if (op.equals("<=") || op.equals("le") || op.equals("num_le"))
561                        return MetaDataCondition.LESS_OR_EQUAL;
562                if (op.equals(">") || op.equals("gt") || op.equals("num_gt"))
563                        return MetaDataCondition.GREATER_THAN;
564                if (op.equals(">=") || op.equals("ge") || op.equals("num_ge"))
565                        return MetaDataCondition.GREATER_OR_EQUAL;
566                if (op.equals("in"))
567                        return MetaDataCondition.IN;
568                if (op.equals("notin") || op.equals("not_in"))
569                        return MetaDataCondition.NOT_IN;
570                if (op.equals("between") || op.equals("num_between"))
571                        return MetaDataCondition.BETWEEN;
572                if (op.equals("notbetween") || op.equals("not_between")
573                                || op.equals("num_not_between"))
574                        return MetaDataCondition.NOT_BETWEEN;
575                if (op.equals("like"))
576                        return MetaDataCondition.LIKE;
577                if (op.equals("notlike") || op.equals("not_like"))
578                        return MetaDataCondition.NOT_LIKE;
579                if (op.equals("in") || op.equals("contains"))
580                        return MetaDataCondition.IN;
581                if (op.equals("notin") || op.equals("not_in")
582                                || op.equals("not_contains"))
583                        return MetaDataCondition.NOT_IN;
584                if (op.equals("sounds_like"))
585                        return MetaDataCondition.SOUNDS_LIKE;
586                if (op.equals("sounds_not_like") || op.equals("sounds_not_like"))
587                        return MetaDataCondition.SOUNDS_NOT_LIKE;
588                System.out.println("operator " + op
589                                + " is unsupported. Treated as equal.");
590                return MetaDataCondition.EQUAL;
591        }
592
593        /**
594         * broadcast the query results.
595         * 
596         * @param rl
597         * @throws IllegalActionException
598         */
599        private void _sendQueryResults(MetaDataRecordList[] rl)
600                        throws IllegalActionException {
601                if (rl != null && rl.length > 0) { // Nothing in the database matched
602                                                                                        // the query
603                        Token[] results = new Token[rl.length];
604                        for (int i = 0; i < rl.length; i++) {
605                                int collInd = rl[i]
606                                                .getFieldIndex(SRBMetaDataSet.DIRECTORY_NAME);
607                                String fileName = rl[i].getStringValue(collInd);
608                                int dataInd = rl[i].getFieldIndex(SRBMetaDataSet.FILE_NAME);
609                                if (dataInd != -1) { // this is a file.
610                                        fileName = fileName + "/" + rl[i].getStringValue(dataInd);
611                                }
612                                System.out.println(fileName);
613                                results[i] = new StringToken(fileName);
614                        }
615                        filePaths.broadcast(new ArrayToken(results));
616                }
617        }
618
619        // /////////////////////////////////////////////////////////////////
620        // // private members ////
621
622        /**
623         * An srb file system variable.
624         */
625        private SRBFileSystem srbFileSystem = null;
626
627}