Source Code Cross Referenced for Windward.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » common » catalog » transformation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.common.catalog.transformation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.griphyn.common.catalog.transformation;
002:
003:        import org.griphyn.cPlanner.classes.Profile;
004:
005:        import org.griphyn.common.catalog.TransformationCatalog;
006:        import org.griphyn.common.catalog.TransformationCatalogEntry;
007:
008:        import org.griphyn.common.classes.Arch;
009:        import org.griphyn.common.classes.Os;
010:        import org.griphyn.common.classes.TCType;
011:        import org.griphyn.common.classes.SysInfo;
012:
013:        import org.griphyn.cPlanner.common.PegasusProperties;
014:        import org.griphyn.cPlanner.common.LogManager;
015:
016:        import edu.isi.ikcap.workflows.ac.ProcessCatalog;
017:        import edu.isi.ikcap.workflows.ac.ProcessCatalogFactory;
018:
019:        import edu.isi.ikcap.workflows.ac.classes.TransformationCharacteristics;
020:        import edu.isi.ikcap.workflows.ac.classes.EnvironmentVariable;
021:
022:        import edu.isi.ikcap.workflows.sr.template.Component;
023:
024:        import edu.isi.ikcap.workflows.util.FactoryException;
025:
026:        import java.util.List;
027:        import java.util.LinkedList;
028:        import java.util.Iterator;
029:        import java.util.Properties;
030:
031:        /**
032:         * The implementation that allows us to inteface with Windward Process Catalogs.
033:         * Only a subset of query functions are implemented.
034:         *
035:         * @author Karan Vahi
036:         * @version $Revision$
037:         */
038:        public class Windward implements  TransformationCatalog {
039:
040:            /**
041:             * The property that designates which Process catalog impl to pick up.
042:             */
043:            public static final String PROCESS_CATALOG_IMPL_PROPERTY = "pegasus.catalog.transformation.windward";
044:
045:            /**
046:             * The handle to the ProcessCatalog API.
047:             */
048:            protected ProcessCatalog mProcessCatalog;
049:
050:            /**
051:             * The name of the Process Catalog implementation to interface to.
052:             */
053:            protected String mPCImpl;
054:            /**
055:             * The handle to PegasusProperties.
056:             */
057:            protected PegasusProperties mProps;
058:
059:            /**
060:             * The handle to the log manager.
061:             */
062:            protected LogManager mLogger;
063:
064:            /**
065:             * Returns an instance of the File TC.
066:             *
067:             * @return TransformationCatalog
068:             */
069:            public static TransformationCatalog getInstance() {
070:                return new Windward();
071:
072:            }
073:
074:            /**
075:             * The default constructor.
076:             */
077:            public Windward() {
078:                //live with this till we change the factory totally
079:                mProps = PegasusProperties.nonSingletonInstance();
080:                mPCImpl = mProps
081:                        .getProperty(this .PROCESS_CATALOG_IMPL_PROPERTY);
082:                mLogger = LogManager.getInstance();
083:
084:                //instantiate the process catalog in the connect method
085:                this .connect(mProps.matchingSubset(
086:                        "pegasus.catalog.transformation.windward", false));
087:            }
088:
089:            /**
090:             * Add an single entry into the transformation catalog.
091:             *
092:             * @param namespace String The namespace of the transformation to be
093:             *   added (Can be null)
094:             * @param name String The name of the transformation to be added.
095:             * @param version String The version of the transformation to be added.
096:             *   (Can be null)
097:             * @param physicalname String The physical name/location of the
098:             *   transformation to be added.
099:             * @param type TCType The type of the physical transformation.
100:             * @param resourceid String The resource location id where the
101:             *   transformation is located.
102:             * @param lfnprofiles List The List of Profile objects associated with a
103:             *   Logical Transformation. (can be null)
104:             * @param pfnprofiles List The List of Profile objects associated with a
105:             *   Physical Transformation. (can be null)
106:             * @param sysinfo SysInfo The System information associated with a
107:             *   physical transformation.
108:             * @throws Exception
109:             * @return boolean Returns true if succesfully added, returns false if
110:             *   error and throws exception.
111:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
112:             *   method
113:             */
114:            public boolean addTCEntry(String namespace, String name,
115:                    String version, String physicalname, TCType type,
116:                    String resourceid, List lfnprofiles, List pfnprofiles,
117:                    SysInfo sysinfo) throws Exception {
118:                return false;
119:            }
120:
121:            /**
122:             * Add multiple TCEntries to the Catalog.
123:             *
124:             * @param tcentry List Takes a list of TransformationCatalogEntry
125:             *   objects as input
126:             * @throws Exception
127:             * @return boolean Return true if succesful, false if error. Exception
128:             *   is thrown when error occurs.
129:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
130:             *   method
131:             */
132:            public boolean addTCEntry(List tcentry) throws Exception {
133:                return false;
134:            }
135:
136:            /**
137:             * Add single TCEntry object temporarily to the in memory Catalog.
138:             *
139:             * @param tcentry Takes a single TransformationCatalogEntry object as
140:             *   input
141:             * @param write boolean enable write commits to backed catalog or not.
142:             * @throws Exception
143:             * @return boolean Return true if succesful, false if error. Exception
144:             *   is thrown when error occurs.
145:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
146:             *   method
147:             */
148:            public boolean addTCEntry(TransformationCatalogEntry tcentry,
149:                    boolean write) throws Exception {
150:                return false;
151:            }
152:
153:            /**
154:             * Add single TCEntry to the Catalog.
155:             *
156:             * @param tcentry Takes a single TransformationCatalogEntry object as
157:             *   input
158:             * @throws Exception
159:             * @return boolean Return true if succesful, false if error. Exception
160:             *   is thrown when error occurs.
161:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
162:             *   method
163:             */
164:            public boolean addTCEntry(TransformationCatalogEntry tcentry)
165:                    throws Exception {
166:                return false;
167:            }
168:
169:            /**
170:             * Add additional profile to a logical transformation .
171:             *
172:             * @param namespace String The nsamespace of the transformation to be
173:             *   added. (can be null)
174:             * @param name String The name of the transformation to be added.
175:             * @param version String The version of the transformation to be added.
176:             *   (can be null)
177:             * @param profiles List The List of Profile objects that are to be added
178:             *   to the transformation.
179:             * @return boolean Returns true if success, false if error.
180:             * @throws Exception
181:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
182:             *   method
183:             */
184:            public boolean addTCLfnProfile(String namespace, String name,
185:                    String version, List profiles) throws Exception {
186:                return false;
187:            }
188:
189:            /**
190:             * Add additional profile to a physical transformation.
191:             *
192:             * @param pfn String The physical name of the transformation
193:             * @param type TCType The type of transformation that the profile is
194:             *   associated with.
195:             * @param resourcename String The resource on which the physical
196:             *   transformation exists
197:             * @param profiles List The List of Profile objects that are to be added
198:             *   to the transformation.
199:             * @return boolean Returns true for success, false for error.
200:             * @throws Exception
201:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
202:             *   method
203:             */
204:            public boolean addTCPfnProfile(String pfn, TCType type,
205:                    String resourcename, List profiles) throws Exception {
206:                return false;
207:            }
208:
209:            /**
210:             * Explicitely free resources before the garbage collection hits.
211:             *
212:             * @todo Implement this org.griphyn.common.catalog.Catalog method
213:             */
214:            public void close() {
215:            }
216:
217:            /**
218:             * Establishes a link between the implementation and the thing the
219:             * implementation is build upon.
220:             *
221:             * @param props contains all necessary data to establish the link.
222:             * @return true if connected now, or false to indicate a failure.
223:             */
224:            public boolean connect(Properties props) {
225:                boolean connect = true;
226:                //figure out how to specify via properties
227:                try {
228:                    mProcessCatalog = ProcessCatalogFactory.loadInstance(
229:                            mPCImpl, props);
230:                } catch (FactoryException e) {
231:                    connect = false;
232:                    mLogger.log("Unable to connect ot process catalog "
233:                            + e.convertException(),
234:                            LogManager.DEBUG_MESSAGE_LEVEL);
235:                }
236:                return connect;
237:            }
238:
239:            /**
240:             * Deletes the entire transformation catalog.
241:             *
242:             * @return boolean Returns true if delete succeeds, false if any error
243:             *   occurs.
244:             * @throws Exception
245:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
246:             *   method
247:             */
248:            public boolean deleteTC() throws Exception {
249:                return false;
250:            }
251:
252:            /**
253:             * Delete a list of profiles or all the profiles associated with a
254:             * logical transformation.
255:             *
256:             * @param namespace String The namespace of the logical transformation.
257:             * @param name String The name of the logical transformation.
258:             * @param version String The version of the logical transformation.
259:             * @param profiles List The List of profiles to be deleted. If
260:             *   <B>NULL</B> then all profiles for the logical transformation are
261:             *   deleted.
262:             * @return boolean Returns true if success, false if any error occurs.
263:             * @throws Exception
264:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
265:             *   method
266:             */
267:            public boolean deleteTCLfnProfile(String namespace, String name,
268:                    String version, List profiles) throws Exception {
269:                return false;
270:            }
271:
272:            /**
273:             * Delete a list of profiles or all the profiles associated with a pfn on
274:             * a resource and of a type.
275:             *
276:             * @param physicalname String The physical name of the transformation.
277:             * @param type TCType The type of the transformation.
278:             * @param resourceid String The resource of the transformation.
279:             * @param profiles List The list of profiles to be deleted. If
280:             *   <B>NULL</B> then all profiles for that pfn+resource+type are
281:             *   deleted.
282:             * @return boolean Returns true if success, false if any error occurs.
283:             * @throws Exception
284:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
285:             *   method
286:             */
287:            public boolean deleteTCPfnProfile(String physicalname, TCType type,
288:                    String resourceid, List profiles) throws Exception {
289:                return false;
290:            }
291:
292:            /**
293:             * Delete all entries in the transformation catalog for a give logical
294:             * tranformation and/or on a resource and/or of a particular type
295:             *
296:             * @param namespace String The namespace of the transformation to be
297:             *   added. (can be null)
298:             * @param name String The name of the transformation to be added.
299:             * @param version String The version of the transformation to be added.
300:             *   ( can be null)
301:             * @param resourceid String The resource id for which the transformation
302:             *   is to be deleted. If <B>NULL</B> then transformation on all
303:             *   resource are deleted
304:             * @param type TCType The type of the transformation. If <B>NULL</B>
305:             *   then all types are deleted for the transformation.
306:             * @throws Exception
307:             * @return boolean Returns true if success , false if there is any error.
308:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
309:             *   method
310:             */
311:            public boolean deleteTCbyLogicalName(String namespace, String name,
312:                    String version, String resourceid, TCType type)
313:                    throws Exception {
314:                return false;
315:            }
316:
317:            /**
318:             * Delete all entries in the transformation catalog for pair of logical
319:             * and physical transformation.
320:             *
321:             * @param physicalname String The physical name of the transformation
322:             * @param namespace String The namespace assocaited in the logical name
323:             *   of the transformation.
324:             * @param name String The name of the logical transformation.
325:             * @param version String The version number of the logical
326:             *   transformation.
327:             * @param resourceid String The resource on which the transformation is
328:             *   to be deleted. If <B>NULL</B> then it searches all the resource id.
329:             * @param type TCType The type of transformation. If <B>NULL</B> then it
330:             *   search and deletes entries for all types.
331:             * @throws Exception
332:             * @return boolean Returns true if sucess, false if any error occurs.
333:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
334:             *   method
335:             */
336:            public boolean deleteTCbyPhysicalName(String physicalname,
337:                    String namespace, String name, String version,
338:                    String resourceid, TCType type) throws Exception {
339:                return false;
340:            }
341:
342:            /**
343:             * Delete all entries on a particular resource from the transformation
344:             * catalog.
345:             *
346:             * @param resourceid String The resource which you want to remove.
347:             * @throws Exception
348:             * @return boolean Returns true if successm false if any error occurs.
349:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
350:             *   method
351:             */
352:            public boolean deleteTCbyResourceId(String resourceid)
353:                    throws Exception {
354:                return false;
355:            }
356:
357:            /**
358:             * Deletes entries from the catalog which have a particular system
359:             * information.
360:             *
361:             * @param sysinfo SysInfo The System Information by which you want to
362:             *   delete
363:             * @return boolean Returns true for success, false if any error occurs.
364:             * @throws Exception
365:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
366:             *   method
367:             */
368:            public boolean deleteTCbySysInfo(SysInfo sysinfo) throws Exception {
369:                return false;
370:            }
371:
372:            /**
373:             * Delete a paricular type of transformation, and/or on a particular
374:             * resource
375:             *
376:             * @param type TCType The type of the transformation
377:             * @param resourceid String The resource on which the transformation
378:             *   exists. If <B>NULL</B> then that type of transformation is deleted
379:             *   from all the resources.
380:             * @throws Exception
381:             * @return boolean Returns true if success, false if any error occurs.
382:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
383:             *   method
384:             */
385:            public boolean deleteTCbyType(TCType type, String resourceid)
386:                    throws Exception {
387:                return false;
388:            }
389:
390:            /**
391:             * List all the contents of the TC
392:             *
393:             * @return List Returns a List of TransformationCatalogEntry objects.
394:             * @throws Exception
395:             * @todo Implement this org.griphyn.common.catalog.TransformationCatalog
396:             *   method
397:             */
398:            public List getTC() throws Exception {
399:                return null;
400:            }
401:
402:            /**
403:             * Returns TC entries for a particular logical transformation and/or on a
404:             * number of resources and/or of a particular type.
405:             *
406:             * @param namespace String The namespace of the logical transformation.
407:             * @param name String the name of the logical transformation.
408:             * @param version String The version of the logical transformation.
409:             * @param resourceids List The List resourceid where the transformation
410:             *   is located. If <b>NULL</b> it returns all resources.
411:             * @param type TCType The type of the transformation to search for. If
412:             *   <b>NULL</b> it returns all types.
413:             * @return List Returns a list of TransformationCatalogEntry objects
414:             *   containing the corresponding entries from the TC. Returns null if
415:             *   no entry found.
416:             */
417:            public List getTCEntries(String namespace, String name,
418:                    String version, List resourceids, TCType type)
419:                    throws Exception {
420:
421:                List result = new LinkedList();
422:
423:                //Iterate through the list of resourceid
424:                for (Iterator it = resourceids.iterator(); it.hasNext();) {
425:                    String resourceid = (String) it.next();
426:                    List r = this .getTCEntries(namespace, name, version,
427:                            resourceid, type);
428:                    if (r != null) {
429:                        result.addAll(r);
430:                    }
431:                }
432:
433:                return result.isEmpty() ? null : result;
434:
435:            }
436:
437:            /**
438:             * Returns TC entries for a particular logical transformation and/or on a
439:             * particular resource and/or of a particular type.
440:             *
441:             * @param namespace String The namespace of the logical transformation.
442:             * @param name String the name of the logical transformation.
443:             * @param version String The version of the logical transformation.
444:             * @param resourceid String The resourceid where the transformation is
445:             *   located. If <B>NULL</B> it returns all resources.
446:             * @param type TCType The type of the transformation to search for. If
447:             *   <B>NULL</b> it returns all types.
448:             *
449:             * @return List Returns a list of TransformationCatalogEntry objects
450:             *   containing the corresponding entries from the TC. Returns null if
451:             *   no entry found.
452:             *
453:             */
454:            public List getTCEntries(String namespace, String name,
455:                    String version, String resourceid, TCType type)
456:                    throws Exception {
457:
458:                //fix the disconnect. get from ptmc the id?
459:                Component c = new Component(namespace, name, version);
460:                List locs = mProcessCatalog.getDeploymentRequirements(c,
461:                        resourceid);
462:                List result = new LinkedList();
463:
464:                boolean all = type == null;
465:
466:                //iterate through the candidate locations
467:                for (Iterator it = locs.iterator(); it.hasNext();) {
468:                    TransformationCharacteristics txChar = (TransformationCharacteristics) it
469:                            .next();
470:
471:                    if (all || //do no matching
472:                            txChar
473:                                    .getCharacteristic(
474:                                            TransformationCharacteristics.COMPILATION_METHOD)
475:                                    .equals(type.toString())) {//types match
476:
477:                        result.add(Adapter.convert(txChar));
478:                    }
479:
480:                }
481:
482:                //System.out.println( "Returning  " + result );
483:
484:                return result.isEmpty() ? null : result;
485:
486:            }
487:
488:            /**
489:             * Get the list of Profiles associated with a particular logical
490:             * transformation.
491:             *
492:             * @param namespace String The namespace of the transformation to search
493:             *   for.
494:             * @param name String The name of the transformation to search for.
495:             * @param version String The version of the transformation to search for.
496:             *
497:             * @return List Returns a list of Profile Objects containing profiles
498:             *   assocaited with the transformation. Returns <B>NULL</B> if no
499:             *   profiles found.
500:             *
501:             *
502:             * @throws UnsupportedOperationException
503:             */
504:            public List getTCLfnProfiles(String namespace, String name,
505:                    String version) throws Exception {
506:
507:                throw new UnsupportedOperationException(
508:                        "No Notion of PFN Profiles. Unsupported operation getTCLfnProfiles( String, String, String)");
509:
510:            }
511:
512:            /**
513:             * Get the list of LogicalNames available on a particular resource.
514:             *
515:             * @param resourceid String The id of the resource on which you want to
516:             *   search
517:             * @param type TCType The type of the transformation to search for. <BR>
518:             *   (Enumerated type includes source, binary, dynamic-binary, pacman,
519:             *   installed)<BR> If <B>NULL</B> then return logical name for all
520:             *   types.
521:             * @return List Returns a list of String Arrays. Each array contains the
522:             *   resourceid, logical transformation in the format
523:             *   namespace::name:version and type. The last entry in the list is an
524:             *   array of integers specifying the column length for pretty print.
525:             *   Returns <B>NULL</B> if no results found.
526:             *
527:             * @throws UnsupportedOperationException
528:             */
529:            public List getTCLogicalNames(String resourceid, TCType type)
530:                    throws Exception {
531:                throw new UnsupportedOperationException(
532:                        "Unsupported operation getTCLogicalNames( String,  TCType )");
533:            }
534:
535:            /**
536:             * Returns the TC implementation being used
537:             *
538:             * @return String
539:             */
540:            public String getTCMode() {
541:                return "TC Implementation to interface with Windward Process Catalog";
542:            }
543:
544:            /**
545:             * Get the list of Profiles associated with a particular physical
546:             * transformation.
547:             *
548:             * @param pfn The physical file name to search the transformation by.
549:             * @param resourceid String The id of the resource on which you want to
550:             *   search.
551:             * @param type TCType The type of the transformation to search for. <br>
552:             *   (Enumerated type includes source, binary, dynamic-binary, pacman,
553:             *   installed)<br>
554:             * @throws Exception NotImplementedException if not implemented.
555:             *
556:             * @return List Returns a list of Profile Objects containing profiles
557:             *   assocaited with the transformation. Returns <B>NULL</B> if no
558:             *   profiless found.
559:             *
560:             * @throws UnsupportedOperationException
561:             */
562:            public List getTCPfnProfiles(String pfn, String resourceid,
563:                    TCType type) throws Exception {
564:
565:                throw new UnsupportedOperationException(
566:                        "No Notion of PFN Profiles. Unsupported operation getTCPfnProfiles( String, String, String, String, TCType )");
567:
568:            }
569:
570:            /**
571:             * Get the list of PhysicalNames for a particular transformation on a
572:             * site/sites for a particular type/types;
573:             *
574:             * @param namespace String The namespace of the transformation to search
575:             *   for.
576:             * @param name String The name of the transformation to search for.
577:             * @param version String The version of the transformation to search for.
578:             * @param resourceid String The id of the resource on which you want to
579:             *   search. <BR> If <B>NULL</B> then returns entries on all resources
580:             * @param type TCType The type of the transformation to search for. <BR>
581:             *   (Enumerated type includes source, binary, dynamic-binary, pacman,
582:             *   installed)<BR> If <B>NULL</B> then returns entries of all types.
583:             * @return List Returns a list of String Arrays. Each array contains the
584:             *   resourceid, the physical transformation, the type of the tr and the
585:             *   systeminfo. The last entry in the List is a int array containing
586:             *   the column lengths for pretty print. Returns <B>NULL</B> if no
587:             *   results found.
588:             *
589:             * @throws UnsupportedOperationException
590:             */
591:            public List getTCPhysicalNames(String namespace, String name,
592:                    String version, String resourceid, TCType type)
593:                    throws Exception {
594:
595:                throw new UnsupportedOperationException(
596:                        "Unsupported operation getTCPhysicalNames( String, String, String, String, TCType )");
597:            }
598:
599:            /**
600:             * Get the list of Resource ID's where a particular transformation may
601:             * reside.
602:             *
603:             * @param namespace String The namespace of the transformation to search
604:             *   for.
605:             * @param name String The name of the transformation to search for.
606:             * @param version String The version of the transformation to search for.
607:             * @param type TCType The type of the transformation to search for.<BR>
608:             *   (Enumerated type includes SOURCE, STATIC-BINARY, DYNAMIC-BINARY,
609:             *   PACMAN, INSTALLED, SCRIPT)<BR> If <B>NULL</B> it returns all types.
610:             *
611:             * @return List Returns a list of Resource Id's as strings. Returns
612:             *   <B>NULL</B> if no results found.
613:             */
614:            public List getTCResourceIds(String namespace, String name,
615:                    String version, TCType type) throws Exception {
616:
617:                //fix the disconnect. get from ptmc the id?
618:                Component c = new Component(namespace, name, version);
619:                List locs = mProcessCatalog.findCandidateInstallations(c);
620:                List result = new LinkedList();
621:
622:                boolean all = type == null;
623:
624:                //iterate through the candidate locations
625:                for (Iterator it = locs.iterator(); it.hasNext();) {
626:                    TransformationCharacteristics txChar = (TransformationCharacteristics) it
627:                            .next();
628:
629:                    if (all || //do no matching
630:                            txChar
631:                                    .getCharacteristic(
632:                                            TransformationCharacteristics.COMPILATION_METHOD)
633:                                    .equals(type.toString())) {//types match
634:                        result
635:                                .add(txChar
636:                                        .getCharacteristic(TransformationCharacteristics.SITE_HANDLE));
637:                    }
638:
639:                }
640:
641:                return result.isEmpty() ? result : null;
642:            }
643:
644:            /**
645:             * Predicate to check, if the connection with the catalog's
646:             * implementation is still active.
647:             *
648:             * @return true, if the implementation is disassociated, false otherwise.
649:             * @todo Implement this org.griphyn.common.catalog.Catalog method
650:             */
651:            public boolean isClosed() {
652:                return mProcessCatalog == null;
653:            }
654:        }
655:
656:        /**
657:         * An adapter class that converts the TransformationCharacterisitcs object into
658:         * a TransformationCatalogEntry object.
659:         *
660:         * @author Karan Vahi
661:         * @version $Revision$
662:         */
663:        class Adapter {
664:
665:            /**
666:             * Converts a TransformationCharacteristics object to TransformationCatalogEntry
667:             * object.
668:             *
669:             * @param from   the TransformationCharacteristics object that has to be converted.
670:             *
671:             * @return TransformationCatalogEntry object.
672:             */
673:            public static TransformationCatalogEntry convert(
674:                    TransformationCharacteristics from) {
675:                TransformationCatalogEntry result = new TransformationCatalogEntry(
676:                        null,
677:                        (String) from
678:                                .getCharacteristic(TransformationCharacteristics.NAME),
679:                        null);
680:
681:                //set the tc type
682:                result
683:                        .setType(TCType
684:                                .fromString((String) from
685:                                        .getCharacteristic(TransformationCharacteristics.COMPILATION_METHOD)));
686:
687:                //do a sanity check on glibc
688:                String glibc = (String) from
689:                        .getCharacteristic(TransformationCharacteristics.DEPENDANT_LIBRARY);
690:                if (glibc != null && glibc.startsWith("glibc_")) {
691:                    glibc = glibc.substring(glibc.indexOf("glibc_"));
692:                }
693:
694:                //set the sysinfo
695:                result
696:                        .setSysInfo(new SysInfo(
697:                                (String) from
698:                                        .getCharacteristic(TransformationCharacteristics.ARCHITECTURE),
699:                                (String) from
700:                                        .getCharacteristic(TransformationCharacteristics.OPERATING_SYSTEM),
701:                                glibc));
702:
703:                //put the site handle and the location
704:                result
705:                        .setPhysicalTransformation((String) from
706:                                .getCharacteristic(TransformationCharacteristics.CODE_LOCATION));
707:                result
708:                        .setResourceId((String) from
709:                                .getCharacteristic(TransformationCharacteristics.SITE_HANDLE));
710:
711:                //convert all the environment variables to profiles
712:                List envs = (List) from
713:                        .getCharacteristic(TransformationCharacteristics.ENVIRONMENT_VARIABLE);
714:                for (Iterator it = envs.iterator(); it.hasNext();) {
715:                    EnvironmentVariable env = (EnvironmentVariable) it.next();
716:                    result.setProfile(new Profile(Profile.ENV, env.getKey(),
717:                            env.getValue()));
718:                }
719:
720:                //convert to globus profiles the runtime information etc
721:                //To do still.
722:
723:                return result;
724:            }
725:
726:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.