chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfermig...@apache.org
Subject svn commit: r905314 - in /incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell: app/ChemistryApp.java app/Context.java cmds/cmis/Query.java
Date Mon, 01 Feb 2010 15:56:11 GMT
Author: sfermigier
Date: Mon Feb  1 15:56:10 2010
New Revision: 905314

URL: http://svn.apache.org/viewvc?rev=905314&view=rev
Log:
Add "query" command.


Added:
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
  (with props)
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/Context.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java?rev=905314&r1=905313&r2=905314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
Mon Feb  1 15:56:10 2010
@@ -33,6 +33,7 @@
 import org.apache.chemistry.shell.cmds.cmis.Get;
 import org.apache.chemistry.shell.cmds.cmis.PropGet;
 import org.apache.chemistry.shell.cmds.cmis.Put;
+import org.apache.chemistry.shell.cmds.cmis.Query;
 import org.apache.chemistry.shell.cmds.cmis.Remove;
 import org.apache.chemistry.shell.cmds.cmis.SetProp;
 import org.apache.chemistry.shell.cmds.cmis.SetStream;
@@ -57,6 +58,7 @@
         registry.registerCommand(new Remove());
         registry.registerCommand(new Cat());
         registry.registerCommand(new Put());
+        registry.registerCommand(new Query());        
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/Context.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/Context.java?rev=905314&r1=905313&r2=905314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/Context.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/Context.java
Mon Feb  1 15:56:10 2010
@@ -74,7 +74,8 @@
      * Lists the keys of the available sub contexts.
      * This is used by the command line completor.
      *
-     * @return an empty array if no sub contexts are available, otherwise return the array
of sub context names
+     * @return an empty array if no sub contexts are available,
+     *         otherwise return the array of sub context names
      */
     String[] entries();
 

Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java?rev=905314&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
Mon Feb  1 15:56:10 2010
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ *   Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ *   Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ *   Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+import java.util.Collection;
+
+@Cmd(syntax="query query", synopsis="Run a CMISQL query")
+public class Query extends ChemistryCommand {
+
+    @Override
+    protected void execute(ChemistryApp app, CommandLine cmdLine)
+            throws Exception {
+
+        String query = cmdLine.getParameterValue("query");
+        if (query == null) {
+            throw new CommandException("Please specify a query");
+        }
+
+        Context ctx = app.getContext();
+        CMISObject currentObj = ctx.as(CMISObject.class);
+        Collection<CMISObject> result = currentObj.getConnection().query(query, false);
+        for (CMISObject obj : result) {
+            println(obj.getName());
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Query.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message