Source Code Cross Referenced for TransformationCatalogEntry.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » common » catalog » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found in file GTPL, or at
004:         * http://www.globus.org/toolkit/download/license.html. This notice must
005:         * appear in redistributions of this file, with or without modification.
006:         *
007:         * Redistributions of this Software, with or without modification, must
008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009:         * some other similar material which is provided with the Software (if
010:         * any).
011:         *
012:         * Copyright 1999-2004 University of Chicago and The University of
013:         * Southern California. All rights reserved.
014:         */
015:
016:        package org.griphyn.common.catalog;
017:
018:        /**
019:         * An object of this class corresponds to a
020:         * tuple in the Transformation Catalog.
021:         * @author Gaurang Mehta
022:         * @$Revision: 50 $
023:         *
024:         * @see org.griphyn.common.classes.SysInfo
025:         * @see org.griphyn.common.classes.TCType
026:         */
027:
028:        import org.griphyn.cPlanner.classes.Profile;
029:        import org.griphyn.common.classes.SysInfo;
030:        import org.griphyn.common.classes.TCType;
031:        import org.griphyn.common.util.ProfileParser;
032:        import org.griphyn.common.util.Separator;
033:
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:        import java.util.List;
037:
038:        public class TransformationCatalogEntry implements  CatalogEntry {
039:
040:            /**
041:             * The logical namespace of the transformation
042:             */
043:
044:            private String namespace;
045:
046:            /**
047:             * The version of the transformation.
048:             */
049:            private String version;
050:
051:            /**
052:             *  The logical name of the transformation.
053:             */
054:            private String name;
055:
056:            /**
057:             *  The Id of the resource on which the transformation
058:             *  is installed.
059:             */
060:            private String resourceid;
061:
062:            /**
063:             * The physical path on the resource for a particual arch, os and type.
064:             */
065:            private String physicalname;
066:
067:            /**
068:             * The profiles associated with the transformation;
069:             */
070:            private List profiles;
071:
072:            /**
073:             * The System Info for the transformation.
074:             */
075:            private SysInfo sysinfo;
076:
077:            /**
078:             * The type of transformation. Takes one of the predefined enumerated type TCType.
079:             */
080:            private TCType type = TCType.INSTALLED;
081:
082:            /**
083:             * The basic constructor
084:             */
085:            public TransformationCatalogEntry() {
086:                namespace = null;
087:                name = null;
088:                version = null;
089:                resourceid = null;
090:                physicalname = null;
091:                profiles = null;
092:                sysinfo = null;
093:            }
094:
095:            /**
096:             * Optimized Constructor
097:             *
098:             * @param namespace String
099:             * @param name String
100:             * @param version String
101:             */
102:            public TransformationCatalogEntry(String namespace, String name,
103:                    String version) {
104:                this .namespace = namespace;
105:                this .version = version;
106:                this .name = name;
107:            }
108:
109:            /**
110:             *  Optimized Constructor
111:             * @param namespace String
112:             * @param name String
113:             * @param version String
114:             * @param resourceid String
115:             * @param physicalname String
116:             * @param type TCType
117:             * @param profiles List
118:             * @param sysinfo SysInfo
119:             */
120:            public TransformationCatalogEntry(String namespace, String name,
121:                    String version, String resourceid, String physicalname,
122:                    TCType type, List profiles, SysInfo sysinfo) {
123:                this .namespace = namespace;
124:                this .version = version;
125:                this .name = name;
126:                this .resourceid = resourceid;
127:                this .physicalname = physicalname;
128:                this .profiles = profiles;
129:                this .sysinfo = sysinfo;
130:                this .type = type;
131:
132:            }
133:
134:            /**
135:             * creates a new instance of this object and returns
136:             * you it. A shallow clone.
137:             * TO DO : Gaurang correct the clone method.
138:             *
139:             * @return Object
140:             */
141:            public Object clone() {
142:                return new TransformationCatalogEntry(namespace, name, version,
143:                        resourceid, physicalname, type, profiles, sysinfo);
144:            }
145:
146:            /**
147:             * gets the String version of the
148:             * data class
149:             * @return String
150:             */
151:            public String toString() {
152:                String st = "\n "
153:                        + "\n Logical Namespace : "
154:                        + this .namespace
155:                        + "\n Logical Name      : "
156:                        + this .name
157:                        + "\n Version           : "
158:                        + this .version
159:                        + "\n Resource Id       : "
160:                        + this .resourceid
161:                        + "\n Physical Name     : "
162:                        + this .physicalname
163:                        + "\n SysInfo           : "
164:                        + ((this .sysinfo == null) ? "" : this .sysinfo
165:                                .toString()) + "\n TYPE              : "
166:                        + ((this .type == null) ? "" : type.toString());
167:                if (profiles != null) {
168:                    for (Iterator i = profiles.listIterator(); i.hasNext();) {
169:                        st = st + "\n Profile           : "
170:                                + ((Profile) i.next()).toString();
171:                    }
172:                }
173:                return st;
174:
175:            }
176:
177:            /**
178:             * Prints out a TC file format String.
179:             * @return String
180:             */
181:            public String toTCString() {
182:                String st = this .getResourceId() + "\t"
183:                        + this .getLogicalTransformation() + "\t"
184:                        + this .getPhysicalTransformation() + "\t"
185:                        + this .getType() + "\t" + this .getSysInfo() + "\t";
186:                if (profiles != null) {
187:                    st += ProfileParser.combine(profiles);
188:                } else {
189:                    st += "NULL";
190:                }
191:                return st;
192:            }
193:
194:            /**
195:             * Returns an xml output of the contents of the data class.
196:             * @return String
197:             */
198:            public String toXML() {
199:                String xml = "\t\t<pfn physicalName=\""
200:                        + this .getPhysicalTransformation() + "\""
201:                        + " siteid=\"" + this .getResourceId() + "\""
202:                        + " type=\"" + this .getType() + "\"" + " sysinfo=\""
203:                        + this .getSysInfo() + "\"";
204:                if (this .profiles != null) {
205:                    xml += " >\n";
206:                    for (Iterator iter = this .profiles.iterator(); iter
207:                            .hasNext();) {
208:                        Profile profile = (Profile) iter.next();
209:                        xml += "\t\t\t" + profile.toXML() + "\n";
210:                    }
211:                    xml += "\t\t</pfn>\n";
212:                } else {
213:                    xml += " />\n";
214:                }
215:
216:                return xml;
217:            }
218:
219:            /**
220:             * Set the logical transformation with a fully qualified tranformation String of the format NS::NAME:Ver
221:             * @param logicaltransformation String
222:             */
223:            public void setLogicalTransformation(String logicaltransformation) {
224:                String[] ltr;
225:                ltr = splitLFN(logicaltransformation);
226:                this .namespace = ltr[0];
227:                this .name = ltr[1];
228:                this .version = ltr[2];
229:            }
230:
231:            /**
232:             * Set the logical transformation by providing the namespace, name and version as seperate strings.
233:             * @param namespace String
234:             * @param name String
235:             * @param version String
236:             */
237:            public void setLogicalTransformation(String namespace, String name,
238:                    String version) {
239:                this .namespace = namespace;
240:                this .name = name;
241:                this .version = version;
242:            }
243:
244:            /**
245:             * Set the logical namespace of the transformation.
246:             * @param namespace String
247:             */
248:            public void setLogicalNamespace(String namespace) {
249:                this .namespace = namespace;
250:            }
251:
252:            /**
253:             * Set the logical name of the transformation.
254:             * @param name String
255:             */
256:            public void setLogicalName(String name) {
257:                this .name = name;
258:            }
259:
260:            /**
261:             * Set the logical version of the transformation.
262:             * @param version String
263:             */
264:            public void setLogicalVersion(String version) {
265:                this .version = version;
266:            }
267:
268:            /**
269:             *  Set the resourceid where the transformation is available.
270:             * @param resourceid String
271:             */
272:            public void setResourceId(String resourceid) {
273:                this .resourceid = resourceid;
274:            }
275:
276:            /**
277:             * Set the type of the transformation.
278:             * @param type TCType
279:             */
280:            public void setType(TCType type) {
281:                this .type = (type == null) ? TCType.INSTALLED : type;
282:            }
283:
284:            /**
285:             * Set the physical location of the transformation.
286:             * @param physicalname String
287:             */
288:            public void setPhysicalTransformation(String physicalname) {
289:                this .physicalname = physicalname;
290:            }
291:
292:            /**
293:             * Set the System Information associated with the transformation.
294:             * @param sysinfo SysInfo
295:             */
296:            public void setSysInfo(SysInfo sysinfo) {
297:                this .sysinfo = (sysinfo == null) ? new SysInfo() : sysinfo;
298:            }
299:
300:            /**
301:             * Allows you to add one profile at a time to the transformation.
302:             * @param profile Profile  A single profile consisting of namespace, key and value
303:             */
304:            public void setProfile(Profile profile) {
305:                if (profile != null) {
306:                    if (this .profiles == null) {
307:                        this .profiles = new ArrayList(5);
308:                    }
309:                    this .profiles.add(profile);
310:                }
311:            }
312:
313:            /**
314:             * Allows you to add multiple profiles to the transformation.
315:             * @param profiles List of Profile objects containing the profile information.
316:             */
317:            public void setProfiles(List profiles) {
318:                if (profiles != null) {
319:                    if (this .profiles == null) {
320:                        this .profiles = new ArrayList(profiles.size());
321:                    }
322:                    this .profiles.addAll(profiles);
323:                }
324:            }
325:
326:            /**
327:             * Gets the Fully Qualified Transformation name in the format NS::Name:Ver.
328:             * @return String
329:             */
330:            public String getLogicalTransformation() {
331:                return joinLFN(namespace, name, version);
332:            }
333:
334:            /**
335:             * Returns the Namespace associated with the logical transformation.
336:             * @return String Returns null if no namespace associated with the transformation.
337:             */
338:            public String getLogicalNamespace() {
339:                return this .namespace;
340:            }
341:
342:            /**
343:             * Returns the Name of the logical transformation.
344:             * @return String
345:             */
346:            public String getLogicalName() {
347:                return this .name;
348:            }
349:
350:            /**
351:             * Returns the version of the logical transformation.
352:             * @return String Returns null if no version assocaited with the transformation.
353:             */
354:            public String getLogicalVersion() {
355:                return this .version;
356:            }
357:
358:            /**
359:             * Returns the resource where the transformation is located.
360:             * @return String
361:             */
362:            public String getResourceId() {
363:                return this .resourceid;
364:            }
365:
366:            /**
367:             * Returns the type of the transformation.
368:             * @return TCType
369:             */
370:            public TCType getType() {
371:                return this .type;
372:            }
373:
374:            /**
375:             * Returns the physical location of the transformation.
376:             * @return String
377:             */
378:            public String getPhysicalTransformation() {
379:                return this .physicalname;
380:            }
381:
382:            /**
383:             * Returns the system information associated with the transformation in the formation ARCH::OS:OSver:GlibVer
384:             * @return SysInfo
385:             */
386:            public SysInfo getSysInfo() {
387:                return this .sysinfo;
388:            }
389:
390:            /**
391:             * Returns the list of profiles associated with the transformation.
392:             * @return List Returns null if no profiles associated.
393:             */
394:            public List getProfiles() {
395:                return this .profiles;
396:            }
397:
398:            /**
399:             * Returns the profiles for a particular Namespace.
400:             * @param namespace String The namespace of the profile
401:             * @return List   List of Profile objects. returns null if none are found.
402:             */
403:            public List getProfiles(String namespace) {
404:                List results = null;
405:                if (profiles != null) {
406:                    for (Iterator i = profiles.iterator(); i.hasNext();) {
407:                        Profile p = (Profile) i.next();
408:                        if (p.getProfileNamespace().equalsIgnoreCase(namespace)) {
409:                            if (results == null) {
410:                                results = new ArrayList();
411:                            }
412:                            results.add(p);
413:                        }
414:                    }
415:                    return results;
416:                } else {
417:                    return results;
418:                }
419:            }
420:
421:            /**
422:             * Joins the 3 components into a fully qualified logical name of the format NS::NAME:VER
423:             * @param namespace String
424:             * @param name String
425:             * @param version String
426:             * @return String
427:             */
428:            private static String joinLFN(String namespace, String name,
429:                    String version) {
430:                return Separator.combine(namespace, name, version);
431:            }
432:
433:            /**
434:             * Splits the full qualified logical transformation into its components.
435:             * @param logicaltransformation String
436:             * @return String[]
437:             */
438:            private static String[] splitLFN(String logicaltransformation) {
439:                return Separator.split(logicaltransformation);
440:            }
441:
442:            /**
443:             * Converts the file profile string to a list of Profiles.
444:             * @param profiles String The profile string.
445:             * @return List Returns a list of profile objects
446:             */
447:            /* public List stringToProfiles( String profiles ) {
448:                 if ( profiles == null ) {
449:                     return null;
450:                 }
451:                 List resultprofiles = new ArrayList();
452:                 String[] namespaces = profiles.split( ";" );
453:                 for ( int i = 0; i < namespaces.length; i++ ) {
454:                     String[] nsprofiles = namespaces[ i ].split( "::", 2 );
455:                     if ( nsprofiles.length == 2 ) {
456:                         String ns = nsprofiles[ 0 ].trim();
457:                         String[] keyvalues = nsprofiles[ 1 ].trim().split( "," );
458:                         for ( int j = 0; j < keyvalues.length; j++ ) {
459:                             String[] keyvalue = keyvalues[ j ].trim().split( "=", 2 );
460:                             String key = null;
461:                             String value = null;
462:                             if ( keyvalue.length == 2 ) {
463:                                 key = keyvalue[ 0 ].trim();
464:                                 value = keyvalue[ 1 ].trim();
465:                             }
466:                             if ( key != null && !key.equals( "" ) && value != null ) {
467:                                 Profile p = new Profile( ns, key, value );
468:                                 resultprofiles.add( p );
469:                             }
470:                         }
471:                     }
472:                 }
473:                 return resultprofiles;
474:             }
475:             */
476:
477:            /*
478:             * Generates a file type profiles String.
479:             * @param listprofiles List
480:             * @return String
481:             */
482:            /*    public String profilesToString( List listprofiles ) {
483:                    String lprofiles = null;
484:            //        String temp = null;
485:                    if ( listprofiles != null ) {
486:                        lprofiles=ProfileParser.combine( listprofiles );
487:                    }
488:                        String currentns = "";
489:                        for ( Iterator i = listprofiles.iterator(); i.hasNext(); ) {
490:                            Profile p = ( Profile ) i.next();
491:             if ( !currentns.equalsIgnoreCase( p.getProfileNamespace() ) ) {
492:                                currentns = p.getProfileNamespace();
493:                                if ( lprofiles != null ) {
494:             lprofiles = lprofiles + temp + ";" + currentns + "::";
495:                                    temp = null;
496:                                } else {
497:                                    lprofiles = currentns + "::";
498:                                }
499:                            }
500:                            if ( temp != null ) {
501:                                temp = temp + "," + p.getProfileKey() + "=" +
502:                                    p.getProfileValue();
503:                            } else {
504:                                temp = p.getProfileKey() + "=" + p.getProfileValue();
505:                            }
506:                        }
507:                        lprofiles += temp;
508:                    }
509:                    return lprofiles;
510:                }
511:             */
512:
513:            /**
514:             * Compares two catalog entries for equality.
515:             *
516:             * @param entry is the entry to compare with
517:             * @return true if the entries match, false otherwise
518:             */
519:            public boolean equals(TransformationCatalogEntry entry) {
520:                return this.toTCString().equalsIgnoreCase(entry.toTCString());
521:            }
522:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.