[Mulgara-svn] r403 - in branches/nw-interface/src/jar/query/java/org/mulgara/query: . operation
pag at mulgara.org
pag at mulgara.org
Thu Sep 6 20:13:41 UTC 2007
Author: pag
Date: 2007-09-06 15:13:41 -0500 (Thu, 06 Sep 2007)
New Revision: 403
Added:
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Deletion.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DropGraph.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Help.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Insertion.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Load.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Modification.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/NullOp.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Quit.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Restore.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Rollback.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetTime.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetUser.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
Log:
Renamed from ast to operation
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,109 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.rmi.RemoteException;
+
+import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+import org.mulgara.rules.InitializerException;
+import org.mulgara.rules.RulesException;
+import org.mulgara.rules.RulesRef;
+
+/**
+ * Represents a command to apply rules to a set of data.
+ *
+ * @created Aug 10, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class ApplyRules extends ServerCommand {
+
+ /** The graph containing the rules to be run. */
+ private URI ruleGraph;
+
+ /** The graph containing the data to apply the rules to. */
+ private URI baseGraph;
+
+ /** The graph to put the rule productions into. */
+ private URI destGraph;
+
+ /**
+ * Create a new rules command.
+ * @param ruleGraph The graph containing the rules to be run.
+ * @param baseGraph The graph containing the data to apply the rules to.
+ * @param destGraph The graph to put the rule productions into.
+ */
+ public ApplyRules(URI ruleGraph, URI baseGraph, URI destGraph) {
+ super(destGraph);
+ this.ruleGraph = ruleGraph;
+ this.baseGraph = baseGraph;
+ this.destGraph = destGraph;
+ }
+
+ /**
+ * @return the ruleGraph
+ */
+ public URI getRuleGraph() {
+ return ruleGraph;
+ }
+
+ /**
+ * @return the baseGraph
+ */
+ public URI getBaseGraph() {
+ return baseGraph;
+ }
+
+ /**
+ * @return the destGraph
+ */
+ public URI getDestGraph() {
+ return destGraph;
+ }
+
+ /**
+ * Apply rules using the given connection.
+ * @param conn The connection to make the rule application on.
+ * @return A string containing the result message.
+ * @throws InitializerException The rules were not structured correctly.
+ * @throws QueryException Unable to read the rules.
+ * @throws RemoteException There was a connectivity problem with the server.
+ * @throws RulesException There was an error with the application of the rules.
+ */
+ public Object execute(Connection conn) throws RemoteException, RulesException, QueryException, InitializerException {
+ return execute(conn, conn);
+ }
+
+ /**
+ * Apply rules using separate connections for getting rules and applying them.
+ * @param conn The connection to apply the rules with.
+ * @param ruleConn The connection to retrieve rules over.
+ * @return A string containing the result message.
+ * @throws InitializerException The rules were not structured correctly.
+ * @throws QueryException Unable to read the rules.
+ * @throws RemoteException There was a connectivity problem with the server.
+ * @throws RulesException There was an error with the application of the rules.
+ */
+ public Object execute(Connection conn, Connection ruleConn) throws RemoteException, RulesException, QueryException, InitializerException {
+ if (conn == null) throw new IllegalArgumentException("Connection may not be null");
+ // get the structure from the rule model
+ RulesRef rules = ruleConn.getSession().buildRules(ruleGraph, baseGraph, destGraph);
+ // create apply the rules to the model
+ conn.getSession().applyRules(rules);
+ resultMessage = "Successfully applied " + ruleGraph + " to " + baseGraph + (destGraph == baseGraph ? "" : " => " + destGraph);
+ return resultMessage;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,154 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import org.apache.log4j.Logger;
+import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+
+import edu.emory.mathcs.util.remote.io.RemoteOutputStream;
+import edu.emory.mathcs.util.remote.io.server.impl.RemoteOutputStreamSrvImpl;
+
+/**
+ * Represents a command to back data up from a model.
+ *
+ * @created Aug 19, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Backup extends DataTx {
+
+ private static final String FILE = "file";
+
+ /** The logger */
+ static final Logger logger = Logger.getLogger(Backup.class.getName());
+
+ /** The URI for the server. */
+ private URI serverUri;
+
+ /**
+ * Creates a new Backup command.
+ * @param source The data to back up. May be a server or just a single graph.
+ * @param destination The location where to back the data up.
+ * Only file URLs supported at the moment.
+ */
+ public Backup(URI source, URI destination) {
+ super(source, destination);
+ if (!destination.getScheme().equals(FILE)) throw new IllegalArgumentException("Backups must be sent to a file");
+ calcServerUri(source);
+ }
+
+ /**
+ * @return The URI of the destination graph.
+ */
+ public URI getServerURI() throws UnsupportedOperationException {
+ return serverUri;
+ }
+
+
+ /**
+ * Perform a backup on a server.
+ * @param conn The connection to talk to the server on.
+ * @return Nothing.
+ * @throws QueryException There was an error asking the server to perform the backup.
+ * @throws MalformedURLException The destination is not a valid file.
+ */
+ public Object execute(Connection conn) throws QueryException, MalformedURLException {
+ FileOutputStream fileOutputStream = null;
+ String destinationFile = this.getDestination().toURL().getPath();
+ try {
+ fileOutputStream = new FileOutputStream(destinationFile);
+ } catch (FileNotFoundException ex) {
+ throw new QueryException("File " + destinationFile + " cannot be created for backup. ", ex);
+ }
+
+ backup(conn, serverUri, fileOutputStream);
+
+ return null;
+ }
+
+
+ /**
+ * Public interface to perform a backup into an output stream.
+ * This is callable directly, without an AST interface.
+ * @param conn The connection to a server to be backed up.
+ * @param source The URI describing the graph on the server to back up.
+ * @param outputStream The output which will receive the data to be backed up.
+ * @throws QueryException There was an error asking the server to perform the backup.
+ */
+ public static void backup(Connection conn, URI source, OutputStream outputStream) throws QueryException {
+ // open and wrap the outputstream
+ RemoteOutputStreamSrvImpl srv = new RemoteOutputStreamSrvImpl(outputStream);
+
+ // prepare it for exporting
+ try {
+ UnicastRemoteObject.exportObject(srv);
+ } catch (RemoteException rex) {
+ throw new QueryException("Unable to backup "+ source + " to an output stream", rex);
+ }
+
+ outputStream = new RemoteOutputStream(srv);
+
+ // perform the backup
+ try {
+ conn.getSession().backup(source, outputStream);
+ } finally {
+ // cleanup the output
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException ioe ) {};
+ }
+ // cleanup the RMI for the output stream
+ if (srv != null) {
+ try {
+ UnicastRemoteObject.unexportObject(srv, false);
+ } catch (NoSuchObjectException ex) {};
+ }
+ }
+ }
+
+
+ /**
+ * Sets the server URI for this server operation.
+ * @param uri The URI to determine the server URI from.
+ */
+ private URI calcServerUri(URI uri) {
+ assert serverUri != null;
+ // check if backing up a graph or a server
+ String fragment = uri.getFragment();
+ if (fragment == null) {
+ if (logger.isDebugEnabled()) logger.debug("Backup for server: " + uri);
+ serverUri = uri;
+ } else {
+ String serverUriString = uri.toString().replaceAll("#" + fragment, "");
+ try {
+ serverUri = new URI(serverUriString);
+ } catch (URISyntaxException e) {
+ throw new Error("Unable to truncate a fragment from a valid URI");
+ }
+ }
+ return serverUri;
+ }
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,40 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+/**
+ * This class indicates a command for the UI to set a local boolean property.
+ * @created Aug 17, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class BooleanSetCommand extends SetCommand {
+
+ /** Indicates that option has been set on or off. */
+ private boolean on;
+
+ /**
+ * Create a command to set and option on or off.
+ * @param on <code>true</code> if the option is on.
+ */
+ public BooleanSetCommand(boolean on) {
+ this.on = on;
+ }
+
+ /**
+ * @return the set option
+ */
+ public boolean isOn() {
+ return on;
+ }
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,62 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * A general Abstract Syntax Tree for TQL commands.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public interface Command {
+
+ /**
+ * Indicates if an AST element is an operation for a local client.
+ * @return <code>true</code> if the operation is only relevant to a client.
+ */
+ boolean isLocalOperation();
+
+ /**
+ * Indicates if an AST represents a command for a user interface.
+ * @return <code>true</code> if the operation is only relevant to a user interface
+ */
+ boolean isUICommand();
+
+ /**
+ * Gets the associated server for a non-local operation.
+ * @return the server URI if one can be determined,
+ * or <code>null</code> if not a valid operation.
+ * @throws UnsupportedOperationException If this command is local only.
+ */
+ URI getServerURI() throws UnsupportedOperationException;
+
+ /**
+ * Executes the operation. This is highly specific to each operation.
+ * @return Data specific to the operation.
+ * @throws Exception specific to the operation.
+ */
+ Object execute(Connection conn) throws Exception;
+
+ /**
+ * Gets a message text relevant to the operation. Useful for the UI.
+ * @return A text message associated with the result of this
+ * operation.
+ */
+ String getResultMessage();
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,41 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+
+import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+
+
+/**
+ * An AST element for the COMMIT command.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Commit extends TransactionCommand implements Command {
+
+ /**
+ * Commits the transaction on a connection.
+ * @param conn Contains the session to commit.
+ * @throws QueryException There was a server error commiting the transaction.
+ */
+ public Object execute(Connection conn) throws QueryException {
+ conn.getSession().commit();
+ resultMessage = "Successfully committed transaction";
+ return resultMessage;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,60 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Represents a command to create a new graph.
+ * @created Aug 10, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class CreateGraph extends ServerCommand {
+
+ /** The URI for the graph. */
+ private URI graphUri;
+
+ /** The URI for the type of the graph. */
+ private URI type;
+
+ public CreateGraph(URI graphUri, URI type) {
+ super(graphUri);
+ this.graphUri = graphUri;
+ this.type = type;
+ }
+
+ /**
+ * Get the URI of the graph to create.
+ * @return the URI of the graph to create.
+ */
+ public URI getGraphUri() {
+ return graphUri;
+ }
+
+ /**
+ * Get the type of the graph to create.
+ * @return the type of the graph.
+ */
+ public URI getType() {
+ return type;
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,66 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+/**
+ * Represents a command to move data in or out of a model.
+ *
+ * @created Aug 13, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class DataTx extends ServerCommand {
+
+ /** The source of data to insert. */
+ private URI source;
+
+ /** The graph to load data into. */
+ private URI destination;
+
+ /**
+ * Create a new load command.
+ * @param source The source of data to insert.
+ * @param destination The graph to load data into.
+ */
+ public DataTx(URI source, URI destination) {
+ super(destination);
+ if (source == null) throw new IllegalArgumentException("Need a valid source of data");
+ if (destination == null) throw new IllegalArgumentException("Need a valid destination for data");
+ this.source = source;
+ this.destination = destination;
+ }
+
+ /**
+ * @return The URI of the destination graph.
+ */
+ public URI getServerURI() throws UnsupportedOperationException {
+ return destination;
+ }
+
+ /**
+ * @return the URI of the source data.
+ */
+ public URI getSource() {
+ return source;
+ }
+
+ /**
+ * @return the destination URI for the data.
+ */
+ public URI getDestination() {
+ return destination;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Deletion.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Deletion.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Deletion.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,54 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jrdf.graph.Triple;
+import org.mulgara.connection.Connection;
+import org.mulgara.query.Query;
+
+/**
+ * An AST element for deleting from a graph.
+ * @created Aug 15, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Deletion extends Modification {
+
+ /**
+ * Create a deletion command for deleting a set of statements from a graph.
+ * @param graph The graph to delete from.
+ * @param statements The data to be deleted.
+ */
+ public Deletion(URI graph, Set<Triple> statements){
+ super(graph, statements);
+ }
+
+ /**
+ * Create an deletion command for deleting the results of a query from a graph.
+ * @param graph The graph to delete from.
+ * @param selectQuery The query to get data from for deletion.
+ */
+ public Deletion(URI graph, Query selectQuery){
+ super(graph, selectQuery);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ if (isSelectBased()) conn.getSession().delete(graph, getSelectQuery());
+ else conn.getSession().delete(graph, getStatements());
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DropGraph.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DropGraph.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DropGraph.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,48 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Represents a command to drop a graph.
+ * @created Aug 10, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class DropGraph extends ServerCommand {
+
+ /** The URI for the graph. */
+ private URI graphUri;
+
+ public DropGraph(URI graphUri) {
+ super(graphUri);
+ this.graphUri = graphUri;
+ }
+
+ /**
+ * Get the URI of the graph to drop.
+ * @return the URI of the graph to drop.
+ */
+ public URI getGraphUri() {
+ return graphUri;
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,58 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URL;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * An AST element for running an external script.
+ * @created Aug 14, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class ExecuteScript extends LocalCommand {
+
+ /** The script to be executed. */
+ private URL script;
+
+ /**
+ * Creates a script execution command.
+ * @param script The script to execute.
+ */
+ public ExecuteScript(URL script) {
+ this.script = script;
+ }
+
+ /**
+ * Indicates that this is a command for the UI.
+ * @return <code>true</code> to indicated that script execution is a UI feature.
+ */
+ public boolean isUICommand() {
+ return true;
+ }
+
+ /**
+ * @return the script URL
+ */
+ public URL getScript() {
+ return script;
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Help.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Help.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Help.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,52 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+
+/**
+ * An AST element for the HELP command.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Help extends LocalCommand {
+
+ private String helpText;
+
+ public Help(String helpText) {
+ this.helpText = helpText;
+ }
+
+ /**
+ * Indicates that this operation is for a UI.
+ * @return <code>true</code> as operation is for UI output only.
+ */
+ public boolean isUICommand() {
+ return true;
+ }
+
+ public String getOutput() {
+ // let the user know the help for the selected command
+ return helpText;
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Insertion.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Insertion.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Insertion.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,54 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jrdf.graph.Triple;
+import org.mulgara.connection.Connection;
+import org.mulgara.query.Query;
+
+/**
+ * An AST element for inserting into a graph.
+ * @created Aug 14, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Insertion extends Modification {
+
+ /**
+ * Create an insertion command for inserting a set of statements into a graph.
+ * @param graph The graph to insert into.
+ * @param statements The data to be inserted.
+ */
+ public Insertion(URI graph, Set<Triple> statements){
+ super(graph, statements);
+ }
+
+ /**
+ * Create an insertion command for inserting the results of a query into a graph.
+ * @param graph The graph to insert into.
+ * @param selectQuery The query to get data from for insertion.
+ */
+ public Insertion(URI graph, Query selectQuery){
+ super(graph, selectQuery);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ if (isSelectBased()) conn.getSession().insert(graph, getSelectQuery());
+ else conn.getSession().insert(graph, getStatements());
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Load.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Load.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Load.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,37 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Represents a command to load data into a model.
+ *
+ * @created Aug 19, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Load extends DataTx {
+
+ public Load(URI source, URI destination) {
+ super(source, destination);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,64 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+/**
+ * An AST element for non-server commands.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class LocalCommand implements Command {
+
+ /** The message set by the result of this command. */
+ protected String resultMessage = "";
+
+ /**
+ * Indicates that this operation is local.
+ * @return Always <code>true</code> to indicate this command is local.
+ */
+ public final boolean isLocalOperation() {
+ return true;
+ }
+
+ /**
+ * Gets the associated server for a non-local operation.
+ * @throws UnsupportedOperationException Always thrown for local commands.
+ */
+ public URI getServerURI() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Server URI not available for local commands.");
+ }
+
+ /**
+ * Executes the operation. This is highly specific to each operation.
+ * @return Data specific to the operation.
+ * @throws Exception specific to the operation.
+ */
+ public Object execute() throws Exception {
+ return execute(null);
+ }
+
+ /**
+ * Gets a message text relevant to the operation. Useful for the UI.
+ * @return A text message associated with the result of this
+ * operation.
+ */
+ public String getResultMessage() {
+ return resultMessage;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Modification.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Modification.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Modification.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,83 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jrdf.graph.Triple;
+import org.mulgara.query.Query;
+
+public abstract class Modification extends ServerCommand {
+
+ /** The graph to insert into. */
+ protected URI graph;
+ /** A SELECT query where the results are to be inserted into the graph. */
+ protected Query selectQuery;
+ /** A set of statements to be inserted into the graph. */
+ protected Set<Triple> statements;
+
+ /**
+ * Create a modification command for modifying a set of statements in a graph.
+ * @param graph The graph to modify.
+ * @param statements The data to be modified.
+ */
+ public Modification(URI graph, Set<Triple> statements){
+ super(graph);
+ this.graph = graph;
+ this.statements = statements;
+ }
+
+ /**
+ * Create a modification command for modifying the results of a query in a graph.
+ * @param graph The graph to modify.
+ * @param selectQuery The query to get data for modification.
+ */
+ public Modification(URI graph, Query selectQuery){
+ super(graph);
+ this.graph = graph;
+ this.selectQuery = selectQuery;
+ }
+
+ /**
+ * Test is this insertion is based on a SELECT query.
+ * @return <code>true</code> if the data to be inserted comes from a SELECT query.
+ * <code>false</code> otherwise.
+ */
+ public boolean isSelectBased() {
+ assert selectQuery == null ^ statements == null;
+ return selectQuery != null;
+ }
+
+ /**
+ * @return the graph
+ */
+ public URI getGraph() {
+ return graph;
+ }
+
+ /**
+ * @return the selectQuery
+ */
+ public Query getSelectQuery() {
+ return selectQuery;
+ }
+
+ /**
+ * @return the statements
+ */
+ public Set<Triple> getStatements() {
+ return statements;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/NullOp.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/NullOp.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/NullOp.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,40 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * An AST element for commands that do not require processing.
+ *
+ * @created 2007-08-21
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class NullOp extends LocalCommand {
+
+ /**
+ * @see org.mulgara.operation.Command#isUICommand()
+ */
+ public boolean isUICommand() {
+ return false;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public Object execute(Connection conn) throws Exception {
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Quit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Quit.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Quit.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,41 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+
+/**
+ * An AST element for the QUIT command.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Quit extends LocalCommand {
+
+ /**
+ * Indicates that this operation is for a UI.
+ * @return <code>true</code> as operation is for UI output only.
+ */
+ public boolean isUICommand() {
+ return true;
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Restore.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Restore.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Restore.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,37 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Represents a command to reload backup data.
+ *
+ * @created Aug 19, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Restore extends DataTx {
+
+ public Restore(URI source, URI destination) {
+ super(source, destination);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Rollback.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Rollback.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Rollback.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,41 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+
+import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+
+
+/**
+ * An AST element for the ROLLBACK command.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Rollback extends TransactionCommand implements Command {
+
+ /**
+ * Commits the transaction on a connection.
+ * @param conn Contains the session to commit.
+ * @throws QueryException There was a server error commiting the transaction.
+ */
+ public Object execute(Connection conn) throws QueryException {
+ conn.getSession().rollback();
+ resultMessage = "Successfully committed transaction";
+ return resultMessage;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,83 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.mulgara.query.ModelResource;
+
+/**
+ * An AST element for server-based commands.
+ *
+ * @created 2007-08-22
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class ServerCommand implements Command {
+
+ /** The graph being referred to on the server. */
+ private ModelResource serverGraph;
+
+ /** The message set by the result of this command. */
+ protected String resultMessage;
+
+ /**
+ * Creates a new command, with a principle graph URI.
+ * @param serverGraphUri The URI of the graph.
+ */
+ public ServerCommand(URI serverGraphUri) {
+ serverGraph = new ModelResource(serverGraphUri);
+ resultMessage = "";
+ }
+
+
+ /**
+ * Finds the server URI for the graph.
+ * @return The URI used to find the server.
+ */
+ public URI getServerURI() {
+ Set<URI> gs = serverGraph.getDatabaseURIs();
+ assert gs.size() == 1;
+ return gs.iterator().next();
+ }
+
+
+ /**
+ * Indicates that this operation is not local.
+ * @return Always <code>false</code> to indicate this command is not local.
+ */
+ public final boolean isLocalOperation() {
+ return false;
+ }
+
+
+ /**
+ * Indicates that this operation is not a UI command by default.
+ * @return By default this will be <code>false</code> as a server side operation should not
+ * affect the local UI.
+ */
+ public boolean isUICommand() {
+ return false;
+ }
+
+
+ /**
+ * Gets a message text relevant to the operation. Useful for the UI.
+ * @return A text message associated with the result of this
+ * operation.
+ */
+ public String getResultMessage() {
+ return resultMessage;
+ }
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,38 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Indicates a UI request to automatically commit after executing a write operation.
+ * @created Aug 17, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class SetAutoCommit extends BooleanSetCommand {
+
+ /**
+ * Create a command to set autocommit on or off.
+ * @param option The value to set the time recording to.
+ */
+ public SetAutoCommit(boolean option) {
+ super(option);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetCommand.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetCommand.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,31 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+/**
+ * This class indicates a command for the UI to set a local property.
+ * @created Aug 17, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class SetCommand extends LocalCommand {
+
+ /**
+ * Check if this command is for the local UI.
+ * @return <code>true</code> to indicate that this command is for the UI only.
+ */
+ public boolean isUICommand() {
+ return true;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetTime.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetTime.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetTime.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,37 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+/**
+ * Indicates a UI request to record timing information for executing an operation.
+ * @created Aug 17, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class SetTime extends BooleanSetCommand {
+
+ /**
+ * Create a command to set timing on or off.
+ * @param option The value to set the time recording to.
+ */
+ public SetTime(boolean option) {
+ super(option);
+ }
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetUser.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetUser.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetUser.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,93 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+import org.mulgara.connection.Connection;
+
+
+/**
+ * An AST element for the COMMIT command.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class SetUser extends LocalCommand {
+
+ /** The user logging in. */
+ private String user;
+
+ /** The password for the user, as provided in the UI. */
+ private String password;
+
+ /** The security domain to log in to. */
+ private URI securityDomain;
+
+ /**
+ * Create a new SetUser command.
+ * @param user The user logging in.
+ * @param password The password for the user.
+ * @param securityDomain The domain to log in to.
+ */
+ public SetUser(String user, String password, URI securityDomain) {
+ this.user = user;
+ this.password = password;
+ this.securityDomain = securityDomain;
+ }
+
+
+ /**
+ * Indicates that this operation is not specific to a UI.
+ * @return <code>false</code> as operation is not specific to UIs.
+ */
+ public boolean isUICommand() {
+ return false;
+ }
+
+
+ /**
+ * Retrieves the user name.
+ * @return the user
+ */
+ public String getUser() {
+ return user;
+ }
+
+
+ /**
+ * Retrieves the user password.
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+
+ /**
+ * Retrieves the URI of the security domain.
+ * @return the securityDomain
+ */
+ public URI getSecurityDomain() {
+ return securityDomain;
+ }
+
+
+ public Object execute(Connection conn) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java 2007-09-06 20:11:22 UTC (rev 402)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java 2007-09-06 20:13:41 UTC (rev 403)
@@ -0,0 +1,64 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+
+/**
+ * An AST element for controlling transactions.
+ *
+ * @created 2007-08-09
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class TransactionCommand {
+
+ /** An optional message that can be returned to a UI after execution. */
+ protected String resultMessage = "";
+
+ /**
+ * Indicates that this operation may require network access.
+ * @return <code>false</code> as network access may be needed.
+ */
+ public boolean isLocalOperation() {
+ return false;
+ }
+
+ /**
+ * Indicates that this operation is not specific to a UI.
+ * @return <code>false</code> as operation is not specific to UIs.
+ */
+ public boolean isUICommand() {
+ return false;
+ }
+
+ /**
+ * Requests a server URI for this operation. None available, as it
+ * operates on the local connection.
+ * @return <code>null</code>
+ */
+ public URI getServerURI() {
+ return null;
+ }
+
+ /**
+ * Gets a message text relevant to the operation. Useful for the UI.
+ * @return A text message associated with the result of this
+ * operation.
+ */
+ public String getResultMessage() {
+ return resultMessage;
+ }
+
+}
More information about the Mulgara-svn
mailing list