Source Code Cross Referenced for ShowMeta.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » toolkit » 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.vdl.toolkit 
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.vdl.toolkit;
017:
018:        import java.io.*;
019:        import java.util.*;
020:        import gnu.getopt.*;
021:
022:        import org.griphyn.vdl.util.Logging;
023:        import org.griphyn.vdl.util.ChimeraProperties;
024:        import org.griphyn.vdl.dbschema.*;
025:        import org.griphyn.vdl.directive.*;
026:        import org.griphyn.vdl.annotation.*;
027:        import org.griphyn.common.util.Separator;
028:        import org.griphyn.common.util.Version;
029:
030:        /**
031:         * This class deletes annotations for definition's and lfn's
032:         *
033:         * @author Jens-S. Vöckler
034:         * @author Yong Zhao
035:         * @version $Revision: 50 $
036:         *
037:         */
038:        public class ShowMeta extends Toolkit {
039:            /**
040:             * Constructor
041:             */
042:            public ShowMeta(String appName) {
043:                super (appName);
044:            }
045:
046:            /**
047:             * Print the usage string 
048:             */
049:            public void showUsage() {
050:                String linefeed = System.getProperty("line.separator", "\r\n");
051:
052:                System.out
053:                        .println("$Id: ShowMeta.java 50 2007-05-19 00:48:32Z gmehta $"
054:                                + linefeed
055:                                + "VDS version "
056:                                + Version.instance().toString() + linefeed);
057:
058:                System.out
059:                        .println("Usage: "
060:                                + this .m_application
061:                                + " [general] [-n ns] [-i id] [-v vs] [-a arg] [key [..]]"
062:                                + linefeed + "Or   : " + this .m_application
063:                                + " [general] [-f lfn] [key [..]]" + linefeed);
064:
065:                System.out
066:                        .println("General options: "
067:                                + linefeed
068:                                + " -V|--version    print version information and exit."
069:                                + linefeed
070:                                + " -d|--dbase db   associates the dbname with the database, unused."
071:                                + linefeed
072:                                + "    --verbose    increases the verbosity level."
073:                                + linefeed
074:                                + " -t|--type tr|dv limits candidates to either TR or DV, default is both."
075:                                + linefeed
076:                                + linefeed
077:                                + "Option group 1: Arguments dealing with VDL definitions "
078:                                + linefeed
079:                                + " -n|--vdlns ns   limits candidates to definition namespace matches."
080:                                + linefeed
081:                                + " -i|--vdlid id   limits candidates to definition name matches."
082:                                + linefeed
083:                                + " -v|--vdlvs vs   limits candidates to definition version matches."
084:                                + linefeed
085:                                + " -a|--arg  arg   limits to formal arguments, requires -t tr."
086:                                + linefeed
087:                                + linefeed
088:                                + "Option group 2: Arguments dealing with VDL logical filenames"
089:                                + linefeed
090:                                + " -f|--file lfn   limits candidates to logical filename matches."
091:                                + linefeed
092:                                + linefeed
093:                                + "Option groups 1 and 2 are mutually exclusive."
094:                                + linefeed);
095:            }
096:
097:            /**
098:             * Creates a set of options.
099:             * @return the assembled long option list
100:             */
101:            protected LongOpt[] generateValidOptions() {
102:                LongOpt[] lo = new LongOpt[17];
103:
104:                lo[0] = new LongOpt("dbase", LongOpt.REQUIRED_ARGUMENT, null,
105:                        'd');
106:                lo[1] = new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V');
107:                lo[2] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
108:                lo[3] = new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 1);
109:
110:                lo[4] = new LongOpt("vdlns", LongOpt.REQUIRED_ARGUMENT, null,
111:                        'n');
112:                lo[5] = new LongOpt("namespace", LongOpt.REQUIRED_ARGUMENT,
113:                        null, 'n');
114:                lo[6] = new LongOpt("ns", LongOpt.REQUIRED_ARGUMENT, null, 'n');
115:
116:                lo[7] = new LongOpt("vdlid", LongOpt.REQUIRED_ARGUMENT, null,
117:                        'i');
118:                lo[8] = new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null,
119:                        'i');
120:                lo[9] = new LongOpt("identifier", LongOpt.REQUIRED_ARGUMENT,
121:                        null, 'i');
122:                lo[10] = new LongOpt("id", LongOpt.REQUIRED_ARGUMENT, null, 'i');
123:
124:                lo[11] = new LongOpt("vdlvs", LongOpt.REQUIRED_ARGUMENT, null,
125:                        'v');
126:                lo[12] = new LongOpt("vs", LongOpt.REQUIRED_ARGUMENT, null, 'v');
127:
128:                lo[13] = new LongOpt("arg", LongOpt.REQUIRED_ARGUMENT, null,
129:                        'a');
130:                lo[14] = new LongOpt("args", LongOpt.REQUIRED_ARGUMENT, null,
131:                        'a');
132:                lo[15] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null,
133:                        't');
134:
135:                lo[16] = new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null,
136:                        'f');
137:
138:                return lo;
139:            }
140:
141:            /**
142:             * Searches the database for specific TR's or DV's
143:             */
144:            public static void main(String[] args) {
145:                int result = 0;
146:                try {
147:                    ShowMeta me = new ShowMeta("showmeta");
148:
149:                    // no arguments -- yikes
150:                    if (args.length == 0) {
151:                        me.showUsage();
152:                        return;
153:                    }
154:
155:                    // obtain commandline options first -- we may need the database stuff
156:                    Getopt opts = new Getopt(me.m_application, args,
157:                            "hd:t:n:i:v:a:f:V", me.generateValidOptions());
158:
159:                    opts.setOpterr(false);
160:                    String secondary = null;
161:                    String primary = new String();
162:                    String type = null;
163:                    String vdlns = null;
164:                    String vdlid = null;
165:                    String vdlvs = null;
166:                    String lfn = null;
167:                    String arg = null;
168:
169:                    int option = 0;
170:                    while ((option = opts.getopt()) != -1) {
171:                        switch (option) {
172:                        case 1:
173:                            me.increaseVerbosity();
174:                            break;
175:
176:                        case 'V':
177:                            System.out
178:                                    .println("$Id: ShowMeta.java 50 2007-05-19 00:48:32Z gmehta $");
179:                            System.out.println("VDS version "
180:                                    + Version.instance().toString());
181:                            return;
182:
183:                        case 'a':
184:                            arg = opts.getOptarg();
185:                            break;
186:
187:                        case 'd':
188:                            // currently inactive option
189:                            opts.getOptarg();
190:                            break;
191:
192:                        case 'f':
193:                            lfn = opts.getOptarg();
194:                            break;
195:
196:                        case 'i':
197:                            vdlid = opts.getOptarg();
198:                            break;
199:
200:                        case 'n':
201:                            vdlns = opts.getOptarg();
202:                            break;
203:
204:                        case 't':
205:                            type = opts.getOptarg();
206:                            break;
207:
208:                        case 'v':
209:                            vdlvs = opts.getOptarg();
210:                            break;
211:
212:                        case 'h':
213:                        default:
214:                            me.showUsage();
215:                            return;
216:                        }
217:                    }
218:
219:                    boolean condition1 = (lfn != null);
220:                    boolean condition2 = (vdlns != null || vdlid != null || vdlvs != null);
221:                    //  (a XOR b) <=> (a AND !b) OR (!a AND b)
222:                    // !(a XOR b) <=> (a OR !b) AND (!a OR b)
223:                    if ((condition1 || !condition2)
224:                            && (!condition1 || condition2)) {
225:                        me.showUsage();
226:                        throw new RuntimeException(
227:                                "You must either specify the -n -i -v options, or\n"
228:                                        + "\tuse the -f option!");
229:                    }
230:
231:                    int classType = -1;
232:                    if (condition2) {
233:                        // metadata for TR or DV?
234:                        switch (Character.toUpperCase(type.charAt(0))) {
235:                        case 'D': // DV
236:                            classType = Annotation.CLASS_DERIVATION;
237:                            break;
238:
239:                        case 'T': // TR
240:                            classType = Annotation.CLASS_TRANSFORMATION;
241:                            if (arg != null) {
242:                                classType = Annotation.CLASS_DECLARE;
243:                                secondary = arg;
244:                            }
245:                            break;
246:
247:                        default:
248:                            me.showUsage();
249:                            throw new RuntimeException("invalid argument \""
250:                                    + type + "\" for option t");
251:                        }
252:
253:                        // will be used for 'D' and 'T' only
254:                        primary = Separator.combine(vdlns, vdlid, vdlvs);
255:                    } else {
256:                        // must be condition1
257:                        classType = Annotation.CLASS_FILENAME;
258:                        primary = lfn;
259:                    }
260:                    // postcondition: variable "type" can be recycled now
261:
262:                    // Connect the database.
263:                    String schemaName = ChimeraProperties.instance()
264:                            .getVDCSchemaName();
265:                    Connect connect = new Connect();
266:                    DatabaseSchema dbschema = connect
267:                            .connectDatabase(schemaName);
268:
269:                    if (!(dbschema instanceof  Annotation)) {
270:                        dbschema.close();
271:                        throw new RuntimeException(
272:                                "The database does not support metadata!");
273:                    } else {
274:                        Annotation annotation = (Annotation) dbschema;
275:
276:                        // check metadata file first
277:                        if (opts.getOptind() == args.length - 1) {
278:                            // no keys on CLI
279:                            java.util.List list = annotation.loadAnnotation(
280:                                    primary, secondary, classType);
281:                            for (Iterator i = list.iterator(); i.hasNext();) {
282:                                Tuple tuple = (Tuple) i.next();
283:                                System.out.println(tuple);
284:                            }
285:                        } else {
286:                            // there were keys on the CLI
287:                            for (int i = opts.getOptind(); i < args.length; ++i) {
288:                                Logging.instance().log("app", 2,
289:                                        "get key [" + i + "] = " + args[i]);
290:                                Tuple tuple = annotation.loadAnnotation(
291:                                        primary, secondary, classType, args[i]);
292:                                if (tuple != null)
293:                                    System.out.println(tuple);
294:                            }
295:                        }
296:                    }
297:                    if (dbschema != null)
298:                        dbschema.close();
299:                } catch (RuntimeException rte) {
300:                    Logging.instance().log("default", 0,
301:                            "runtime error: " + rte.getMessage());
302:                    System.err.println("ERROR: " + rte.getMessage());
303:                    result = 1;
304:
305:                } catch (Exception e) {
306:                    Logging.instance().log("default", 0,
307:                            "FATAL: " + e.getMessage());
308:                    e.printStackTrace();
309:                    System.err.println("FATAL: " + e.getMessage());
310:                    result = 2;
311:                }
312:
313:                if (result != 0)
314:                    System.exit(result);
315:            }
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.