http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/vagrant/radix/vagrant/provision.sh ---------------------------------------------------------------------- diff --git a/vagrant/radix/vagrant/provision.sh b/vagrant/radix/vagrant/provision.sh deleted file mode 100644 index ed90950..0000000 --- a/vagrant/radix/vagrant/provision.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# 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. - -################################################## -# # -# OODT RADiX Vagrant Provision Script # -# # -################################################## - -# Load config file -source /vagrant/vagrant/env.sh - -echo "Update Ubuntuâs package index" -sudo apt-get update - -# --------- GENERAL INSTALL/CONFIG --------------------------------------------------------- -sudo apt-get install -y vim -sudo apt-get install -y subversion -sudo apt-get install -y git -sudo apt-get install -y tree -sudo apt-get install -y curl -sudo apt-get install -y maven2 -sudo apt-get install -y default-jdk -sudo apt-get install -y ack - -# --------- General config/install ---------- -sudo cp /vagrant/vagrant/conf/terminal/bashrc /home/vagrant/.bashrc -source /home/vagrant/.bashrc -sudo mkdir ${OODT_DEPLOYMENT_HOME} -sudo chown -R vagrant:vagrant ${OODT_DEPLOYMENT_HOME} - - -# ---------- OODT Installation -------------- -# NOTE: Checking out and installing OODT is only necessary for the SNAPSHOT versions of OODT -# TO DO: Set up some logic for differentiating between SNAPSHOT (trunk) and tagged releases -echo "Checking out latest (trunk) OODT from SVN" -cd /usr/local/src -sudo svn export ${OODT_SRC_REPO} oodt-${OODT_VERSION} -sudo chown -R vagrant:vagrant oodt-${OODT_VERSION} -echo "Build OODT and RADiX archetype" -cd oodt-${OODT_VERSION} -mvn -Dmaven.test.skip=true clean install -cd mvn/archetypes/radix -sudo mvn install - -# ---------- Setup new RADiX project -------- -cd /usr/local/src -sudo mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=org.apache.oodt -DarchetypeArtifactId=radix-archetype -DarchetypeVersion=${OODT_VERSION} -Doodt=${OODT_VERSION} -DgroupId=${PROJECT_GROUP_ID} -DartifactId=${PROJECT_ARTIFACT_ID} -Dversion=0.1-SNAPSHOT -cd ${PROJECT_ARTIFACT_ID} -sudo mvn package ${BUILD_FLAGS} -tar zxf distribution/target/${PROJECT_ARTIFACT_ID}-distribution-*-bin.tar.gz -C ${OODT_DEPLOYMENT_HOME} - -# ---------- Start OODT ---------- -cd ${OODT_DEPLOYMENT_HOME}/bin -./oodt start -echo "" -echo "OODT started, please navigate to: http://localhost:8080/opsui"
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/.gitignore ---------------------------------------------------------------------- diff --git a/xmlps/.gitignore b/xmlps/.gitignore deleted file mode 100644 index b54523f..0000000 --- a/xmlps/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/maven-eclipse.xml http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/pom.xml ---------------------------------------------------------------------- diff --git a/xmlps/pom.xml b/xmlps/pom.xml deleted file mode 100644 index 01b49c3..0000000 --- a/xmlps/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-core</artifactId> - <version>1.1-SNAPSHOT</version> - <relativePath>../core/pom.xml</relativePath> - </parent> - <artifactId>oodt-xmlps</artifactId> - <version>1.1-SNAPSHOT</version> - <name>XML-configured, DBMS-based Product and Profile Server</name> - <description>An XML-configured DBMS-based Product and Profile meant to easily - sit on top of Web-Grid and other Product and Profile server contexts - for rapid deployment and integration.</description> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>commons-dbcp</groupId> - <artifactId>commons-dbcp</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>commons-pool</groupId> - <artifactId>commons-pool</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>cas-metadata</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-commons</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-product</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-profile</artifactId> - <optional /> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-xmlquery</artifactId> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory> - <resources> - <resource> - <targetPath>org/apache/oodt/xmlps</targetPath> - <directory>${basedir}/src/main/conf</directory> - </resource> - </resources> - <testResources> - <testResource> - <targetPath>org/apache/oodt/xmlps/mapping</targetPath> - <filtering /> - <directory>${basedir}/src/test/resources</directory> - <includes /> - <excludes /> - </testResource> - </testResources> - - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <forkMode>pertest</forkMode> - <systemProperties> - <property> - <name>java.util.logging.config.file</name> - <value>${basedir}/src/test/resources/logging.properties</value> - </property> - </systemProperties> - </configuration> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/conf/example-ps.xml ---------------------------------------------------------------------- diff --git a/xmlps/src/main/conf/example-ps.xml b/xmlps/src/main/conf/example-ps.xml deleted file mode 100644 index 82cb08c..0000000 --- a/xmlps/src/main/conf/example-ps.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -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. ---> -<!-- Example XML mapping configuration file --> -<oodt:xmlps xmlns:oodt="http://incubator.apache.org/oodt/0.1-incubating" - name="Example Query Handler" id="project:subproject:exampleps"> - <!-- - attribute: - default (required): This is the name of the master table part of the - from clause in the generated query. The default table *does not* - require a definition in the underlying <table.. tags below, though - post OODT-548 these will be silently ignored. - --> - <tables default="Table1"> - <table name="Table2" join="join_key" tofld="base_table_join_key" /> - <table name="Table3" join="join_key" tofld="base_table_join_key" /> - </tables> - <!-- - field: - - type (required): dynamic or constant. If you choose dynamic, then the field - value is read from the row in the ResultSet returned - from the database. If constant, then each returned row - from the ResultSet is annotated with the value specified - in the 'value' attribute. - - name (required): the name of the attribute that you want returned - in the product server. - - string (optional): whether or not the internal db representation at the local - site for this field is a STRING, or something else (e.g., a number, etc.). Possible - values for this attribute are "true", to indicate that the field is a string, or - "false", to indicate that it is something else. If this attribute is omitted, a value - of "false" is assumed, and the attribute will not be quoted in the where clause of - the underlying SQL statement generated. - - dbname (optional): the name of the field within the underlying db. If not - specified, then assumed to be name - - table (optional): if provided, then the attribute a is selected as - 'table'.'a',and then returned. If omitted, the attribute - is assumed to come from the default table returned from the - PS query. - - value (optional): is necessary to provide if type='constant' is selected. - - scope (optional): limits the scope of a field's existence: acceptable values - are "query", which signifies that the field is only applicable when - translating queries: and "return", which signifies the field is only - applicable as a return field when converting database results into CDEResults. - - --> - <field type="dynamic" name="CDE_NAME1" dbname="site_specific_name1" table="Table1" /> - <field type="dynamic" name="CDE_NAME2" dbname="site_specific_name2" table="Table2" /> - <field type="dynamic" name="CDE_NAME3" dbname="site_specific_name3" table="Table2" /> - <field type="constant" name="CDE_NAME4" value="constant_value" /> -</oodt:xmlps> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/conf/example.db.properties ---------------------------------------------------------------------- diff --git a/xmlps/src/main/conf/example.db.properties b/xmlps/src/main/conf/example.db.properties deleted file mode 100644 index ac31f6a..0000000 --- a/xmlps/src/main/conf/example.db.properties +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -# Example data source configuration file - -xmlps.datasource.jdbc.url=<driver>:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]] -xmlps.datasource.jdbc.user=USERNAME -xmlps.datasource.jdbc.pass=PASSWORD -xmlps.datasource.jdbc.driver=java.sql.Driver http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java b/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java deleted file mode 100644 index 9a4f765..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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. - */ -package org.apache.oodt.xmlps.exceptions; - -/** - * XmlpsException for internally thrown exceptions. - */ -public class XmlpsException extends Exception { - - public XmlpsException(String message){ - super(message); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTable.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTable.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTable.java deleted file mode 100644 index ae4bb8a..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTable.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -/** - * - * <p> - * Description of a local site's database table that will be used as a model to - * query against and select data from. - * </p>. - */ -public class DatabaseTable { - - private String name; - - private String joinFieldName; - - private String defaultTableJoinFieldName; - - private String defaultTableJoin; - - /** - * @param name - * @param joinFieldName - * @param defaultTableJoinFieldName - * @param defaultTableJoin - */ - public DatabaseTable(String name, String joinFieldName, - String defaultTableJoinFieldName, String defaultTableJoin) { - super(); - this.name = name; - this.joinFieldName = joinFieldName; - this.defaultTableJoinFieldName = defaultTableJoinFieldName; - this.defaultTableJoin = defaultTableJoin; - } - - /** - * - */ - public DatabaseTable() { - } - - /** - * @return the joinFieldName - */ - public String getJoinFieldName() { - return joinFieldName; - } - - /** - * @param joinFieldName - * the joinFieldName to set - */ - public void setJoinFieldName(String joinFieldName) { - this.joinFieldName = joinFieldName; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the defaultTableJoinFieldName - */ - public String getDefaultTableJoinFieldName() { - return defaultTableJoinFieldName; - } - - /** - * @param defaultTableJoinFieldName - * the defaultTableJoinFieldName to set - */ - public void setDefaultTableJoinFieldName(String defaultTableJoinFieldName) { - this.defaultTableJoinFieldName = defaultTableJoinFieldName; - } - - /** - * @return the defaultTableJoin - */ - public String getDefaultTableJoin() { - return defaultTableJoin; - } - - /** - * @param defaultTableJoin - * the defaultTableJoin to set - */ - public void setDefaultTableJoin(String defaultTableJoin) { - this.defaultTableJoin = defaultTableJoin; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTableGroup.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTableGroup.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTableGroup.java deleted file mode 100644 index 5f42558..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/DatabaseTableGroup.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -//JDK imports -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -/** - * - * <p> - * A collection of {@link DatabaseTable}s - * </p>. - */ -public class DatabaseTableGroup { - - private Map<String, DatabaseTable> group; - - private List<DatabaseTable> orderedGroup; - - private String defaultTable; - - public DatabaseTableGroup() { - this.group = new TreeMap<String, DatabaseTable>(); - this.orderedGroup = new Vector<DatabaseTable>(); - } - - public void addTable(String tblName, DatabaseTable tbl) { - this.group.put(tblName, tbl); - this.orderedGroup.add(tbl); - } - - public DatabaseTable getTableByName(String name) { - return this.group.get(name); - } - - public int getNumTables() { - return this.group.keySet().size(); - } - - public List<String> getTableNames() { - List<String> names = new Vector<String>(); - for (DatabaseTable tbl : this.orderedGroup) { - names.add(tbl.getName()); - } - - return names; - } - - /** - * @return the defaultTable - */ - public String getDefaultTable() { - return defaultTable; - } - - /** - * @param defaultTable - * the defaultTable to set - */ - public void setDefaultTable(String defaultTable) { - this.defaultTable = defaultTable; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldScope.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldScope.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldScope.java deleted file mode 100644 index 40e7273..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldScope.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -/** - * - * <p> - * Defines the scope of a {@link MappingField}. - * </p>. - */ -public enum FieldScope { - - QUERY, - RETURN; - - public String getType() { - return toString().toLowerCase(); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldType.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldType.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldType.java deleted file mode 100644 index a2751aa..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/FieldType.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -/** - * - * <p> - * Defines the type of a {@link MappingField} - * </p>. - */ -public enum FieldType { - - DYNAMIC, - CONSTANT; - - public String getType() { - return toString().toLowerCase(); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/Mapping.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/Mapping.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/Mapping.java deleted file mode 100644 index 18e2ca3..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/Mapping.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -//JDK imports -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * - * <p> - * An Mapping is a {@link List} of {@link MappingField}s that define the - * translation of common ontological queries into queries against a local site's - * DBMS - * </p> - * . - */ -public class Mapping { - - private final Map<String, MappingField> fields; - - private final DatabaseTableGroup tables; - - private String id; - - private String name; - - /** - * - */ - public Mapping() { - this.fields = new TreeMap<String, MappingField>(); - this.tables = new DatabaseTableGroup(); - } - - public Mapping(Map<String, MappingField> fields, DatabaseTableGroup tables, - String id, String name) { - super(); - this.fields = fields; - this.id = id; - this.name = name; - this.tables = tables; - } - - public void addField(String fldName, MappingField field) { - this.fields.put(fldName, field); - } - - public MappingField getFieldByLocalName(String localName) { - if (this.fields == null || (this.fields.keySet().size() == 0)) { - return null; - } - - for (MappingField fld : this.fields.values()) { - if (fld.getLocalName().equals(localName)) { - return fld; - } - } - - return null; - } - - public MappingField getFieldByName(String name) { - return this.fields.get(name); - } - - public boolean constantField(String localName) { - MappingField fld = getFieldByLocalName(localName); - - if (fld == null) { - return true; // leave it out - } - - return fld.getType() == FieldType.CONSTANT; - } - - public int getNumFields() { - return this.fields.keySet().size(); - } - - public void addTable(String tblName, DatabaseTable tbl) { - this.tables.addTable(tblName, tbl); - } - - public DatabaseTable getTableByName(String name) { - return this.tables.getTableByName(name); - } - - public int getNumTables() { - return this.tables.getNumTables(); - } - - public List<String> getTableNames() { - return this.tables.getTableNames(); - } - - public List<String> getFieldNames() { - return Arrays.asList(this.fields.keySet().toArray(new String[] { "" })); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the defaultTable - */ - public String getDefaultTable() { - return this.tables.getDefaultTable(); - } - - /** - * @param defaultTable - * the defaultTable to set - */ - public void setDefaultTable(String defaultTable) { - this.tables.setDefaultTable(defaultTable); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingField.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingField.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingField.java deleted file mode 100644 index 317950d..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingField.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -//OODT imports -import org.apache.oodt.xmlps.mapping.funcs.MappingFunc; - -import java.util.List; -import java.util.Vector; - -/** - * - * <p> - * A field within a mapping.xml file that defines the relationship between CDEs - * and the underlying attributes of a local site's DBMS. - * </p> - * . - */ -public class MappingField { - - private String name; - - private FieldType type; - - private String dbName; - - private String tableName; - - private String constantValue; - - private FieldScope scope; - - private List<MappingFunc> funcs; - - private boolean string; - - /** - * @param name - * @param type - * @param dbName - * @param tableName - * @param constantValue - * @param scope - * @param funcs - * @param string - */ - public MappingField(String name, FieldType type, String dbName, - String tableName, String constantValue, FieldScope scope, - List<MappingFunc> funcs, boolean string) { - super(); - this.name = name; - this.type = type; - this.dbName = dbName; - this.tableName = tableName; - this.constantValue = constantValue; - this.scope = scope; - this.funcs = funcs; - this.string = string; - } - - /** - * - */ - public MappingField() { - this.name = null; - this.dbName = null; - this.tableName = null; - this.constantValue = null; - this.scope = null; - this.string = false; - this.funcs = new Vector<MappingFunc>(); - } - - /** - * @return the constantValue - */ - public String getConstantValue() { - return constantValue; - } - - /** - * @param constantValue - * the constantValue to set - */ - public void setConstantValue(String constantValue) { - this.constantValue = constantValue; - } - - /** - * @return the dbName - */ - public String getDbName() { - return dbName; - } - - /** - * @param dbName - * the dbName to set - */ - public void setDbName(String dbName) { - this.dbName = dbName; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the scope - */ - public FieldScope getScope() { - return scope; - } - - /** - * @param scope - * the scope to set - */ - public void setScope(FieldScope scope) { - this.scope = scope; - } - - /** - * @return the tableName - */ - public String getTableName() { - return tableName; - } - - /** - * @param tableName - * the tableName to set - */ - public void setTableName(String tableName) { - this.tableName = tableName; - } - - /** - * @return the type - */ - public FieldType getType() { - return type; - } - - /** - * @param type - * the type to set - */ - public void setType(FieldType type) { - this.type = type; - } - - /** - * @return the funcs - */ - public List<MappingFunc> getFuncs() { - return funcs; - } - - /** - * @param funcs - * the funcs to set - */ - public void setFuncs(List<MappingFunc> funcs) { - this.funcs = funcs; - } - - @Override - public String toString() { - return "[name=" + this.name + ",dbname=" + this.dbName + ",constant_value=" + this.constantValue + ",table_name=" - + this.tableName + ",scope=" + (this.scope.equals(FieldScope.RETURN) ? "return" : "query") + ",type=" + ( - this.type.equals(FieldType.CONSTANT) ? "constant" : "dynamic") + ",funcs=" + printClassNames(this.funcs) - + ",string=" + String.valueOf(this.string) + "]"; - } - - private String printClassNames(List<MappingFunc> funcs) { - StringBuilder buf = new StringBuilder(); - - if (funcs == null || (funcs.size() == 0)) { - return ""; - } else { - for (MappingFunc func : funcs) { - buf.append(func.getClass().getName()); - buf.append(","); - } - - buf.deleteCharAt(buf.length() - 1); - - return buf.toString(); - } - } - - /** - * @return the string - */ - public boolean isString() { - return string; - } - - /** - * @param string - * the string to set - */ - public void setString(boolean string) { - this.string = string; - } - - /** - * If dbname exists and is not empty, it is used as the field name. - * If the table exists and is not empty, - * return tableName.fieldName, otherwise return fieldName. - * @return the column name understood by the local db - */ - public String getLocalName() { - String dbColName = getName(); - if (getDbName() != null && !getDbName().isEmpty()) { - dbColName = getDbName(); - } - if (getTableName() == null || getTableName().isEmpty()) { - return dbColName; - } - return getTableName() + "." + dbColName; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java deleted file mode 100644 index cf7ab3a..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping; - -//OODT imports - -import org.apache.oodt.commons.xml.XMLUtils; -import org.apache.oodt.xmlps.exceptions.XmlpsException; -import org.apache.oodt.xmlps.mapping.funcs.MappingFunc; -import org.apache.oodt.xmlps.util.GenericCDEObjectFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.List; -import java.util.Properties; -import java.util.Vector; - -/** - * - * <p> - * A static final reader class for reading {@link Mapping}s. - * </p> - * . - */ -public final class MappingReader implements MappingReaderMetKeys { - - private MappingReader() throws InstantiationException { - throw new InstantiationException("Don't construct reader objects!"); - } - - public static Mapping getMapping(InputStream is) throws XmlpsException { - Document mappingDoc = XMLUtils.getDocumentRoot(is); - Mapping map = new Mapping(); - - Element rootElem = mappingDoc.getDocumentElement(); - - map.setId(rootElem.getAttribute("id")); - map.setName(rootElem.getAttribute("name")); - readTables(rootElem, map); - readFields(rootElem, map); - - return map; - - } - - public static Mapping getMapping(URL mappingUrl) throws IOException, XmlpsException { - return getMapping(mappingUrl.openStream()); - } - - public static Mapping getMapping(String filePath) throws FileNotFoundException, XmlpsException { - return getMapping(new FileInputStream(filePath)); - - } - - private static void readTables(Element rootElem, Mapping map) - throws XmlpsException { - Element tblsElem = XMLUtils.getFirstElement(TABLES_OUTER_TAG, rootElem); - if (tblsElem == null) { - throw new XmlpsException("Unable to parse mapping XML file: [" + map.getName() - + "]: reason: no defined tables tag element!"); - - } - - String defaultTbl = tblsElem.getAttribute("default"); - // make sure that the default attribute is set - if (defaultTbl == null || (defaultTbl.equals(""))) { - throw new XmlpsException("Unable to parse mapping XML file: [" + map.getName() - + "]: reason: there needs to be a default table defined " - + "by the \"default\" attribute!"); - } - - map.setDefaultTable(defaultTbl); - - // get a list of all the tables, and process them one by one - NodeList tableNodes = tblsElem.getElementsByTagName(TABLE_TAG); - if (tableNodes != null && tableNodes.getLength() > 0) { - for (int i = 0; i < tableNodes.getLength(); i++) { - Element tableElem = (Element) tableNodes.item(i); - DatabaseTable tbl = readTable(tableElem); - if (tbl.getDefaultTableJoin() == null || tbl.getDefaultTableJoin().isEmpty()) { - tbl.setDefaultTableJoin(map.getDefaultTable()); - } - map.addTable(tbl.getName(), tbl); - } - } - } - - private static DatabaseTable readTable(Element tableElem) { - DatabaseTable tbl = new DatabaseTable(); - tbl.setJoinFieldName(tableElem.getAttribute(TABLE_ATTR_JOIN_FLD)); - tbl.setName(tableElem.getAttribute(TABLE_ATTR_NAME)); - tbl.setDefaultTableJoinFieldName(tableElem - .getAttribute(TABLE_ATTR_BASE_TBL_JOIN_FLD)); - tbl.setDefaultTableJoin(tableElem - .getAttribute(TABLE_ATTR_BASE_TBL_JOIN_TABLE)); - return tbl; - } - - private static void readFields(Element rootElem, Mapping map) { - NodeList fldNodes = rootElem.getElementsByTagName(FIELD_TAG); - - if (fldNodes != null && fldNodes.getLength() > 0) { - for (int i = 0; i < fldNodes.getLength(); i++) { - MappingField fld = readField((Element) fldNodes.item(i)); - if (fld.getTableName() == null || fld.getTableName().isEmpty()) { - fld.setTableName(map.getDefaultTable()); - } - map.addField(fld.getName(), fld); - } - } - - } - - private static MappingField readField(Element fldElem) { - MappingField field = new MappingField(); - field.setTableName(fldElem.getAttribute(FIELD_ATTR_TABLE)); - field.setName(fldElem.getAttribute(FIELD_ATTR_NAME)); - field - .setType(fldElem.getAttribute(FIELD_ATTR_TYPE).equals("dynamic") ? FieldType.DYNAMIC - : FieldType.CONSTANT); - field.setString(Boolean.valueOf(fldElem.getAttribute(FIELD_ATTR_STRING))); - field.setConstantValue(fldElem.getAttribute(FIELD_ATTR_VALUE)); - field.setDbName(fldElem.getAttribute(FIELD_ATTR_DBNAME)); - if (fldElem.getAttribute(FIELD_ATTR_SCOPE) != null - && !fldElem.getAttribute(FIELD_ATTR_SCOPE).equals("")) { - - field - .setScope(fldElem.getAttribute(FIELD_ATTR_SCOPE).equals("query") ? FieldScope.QUERY - : FieldScope.RETURN); - } - - field.setFuncs(getTranslateFuncs(fldElem)); - - return field; - - } - - private static List<MappingFunc> getTranslateFuncs(Element fldElem) { - Element translateElem = XMLUtils.getFirstElement(FIELD_TRANSLATE_TAG, - fldElem); - - List<MappingFunc> funcs = new Vector<MappingFunc>(); - - if (translateElem != null) { - // check for func tags - NodeList funcNodes = translateElem.getElementsByTagName(FUNC_TAG); - if (funcNodes != null && funcNodes.getLength() > 0) { - for (int i = 0; i < funcNodes.getLength(); i++) { - Element funcElem = (Element) funcNodes.item(i); - funcs.add(getFunc(funcElem)); - } - } - } - - return funcs; - } - - private static MappingFunc getFunc(Element funcElem) { - String funcClass = funcElem.getAttribute(FUNC_ATTR_CLASS); - MappingFunc func = GenericCDEObjectFactory - .getMappingFuncFromClassName(funcClass); - - if (func != null) { - func.configure(getPropsFromElementAttrs(funcElem.getAttributes())); - } - - return func; - } - - private static Properties getPropsFromElementAttrs(NamedNodeMap map) { - Properties props = new Properties(); - - if (map != null) { - for (int i = 0; i < map.getLength(); i++) { - Node mapNode = map.item(i); - props.setProperty(mapNode.getNodeName(), mapNode.getNodeValue()); - } - } - - return props; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReaderMetKeys.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReaderMetKeys.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReaderMetKeys.java deleted file mode 100644 index 09e617f..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReaderMetKeys.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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. - */ - - -package org.apache.oodt.xmlps.mapping; - -/** - * - * <p> - * Met Keys for the {@link MappingReader} - * </p>. - */ -public interface MappingReaderMetKeys { - - String FIELD_TAG = "field"; - - String TABLES_OUTER_TAG = "tables"; - - String TABLE_TAG = "table"; - - String TABLE_ATTR_JOIN_FLD = "join"; - - String TABLE_ATTR_BASE_TBL_JOIN_TABLE = "to"; - - String TABLE_ATTR_BASE_TBL_JOIN_FLD = "tofld"; - - String TABLE_ATTR_NAME = "name"; - - String FIELD_ATTR_TYPE = "type"; - - String FIELD_ATTR_NAME = "name"; - - String FIELD_ATTR_DBNAME = "dbname"; - - String FIELD_ATTR_SCOPE = "scope"; - - String FIELD_ATTR_VALUE = "value"; - - String FIELD_ATTR_TABLE = "table"; - - String FIELD_ATTR_STRING = "string"; - - String FIELD_TRANSLATE_TAG = "translate"; - - String FUNC_TAG = "func"; - - String FUNC_ATTR_CLASS = "class"; - - String FIELD_ATTR_APPEND_TABLE_NAME = "appendTableName"; - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/MappingFunc.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/MappingFunc.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/MappingFunc.java deleted file mode 100644 index 6849349..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/MappingFunc.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping.funcs; - -//JDK imports -import java.util.Properties; - -//OODT imports -import org.apache.oodt.xmlps.structs.CDEValue; - -/** - * - * <p> - * A function to convert {@link CDEValue}s from a CDE domain vocabulary into a - * SDE domain vocabulary - * </p>. - */ -public interface MappingFunc { - - /** - * Translates the original CDE {@link CDEValue} into a local site's SDE - * {@link CDEValue}. - * - * @param orig - * The original {@link CDEValue} to translate. - * @return The translated {@link CDEValue}. - */ - CDEValue translate(CDEValue orig); - - /** - * Translates the local site's SDE {@link CDEValue} back into its CDE - * {@link CDEValue}. - * - * @param orig - * The local site's SDE {@link CDEValue} to translate back into - * a CDE. - * @return The translated {@link CDEValue}. - */ - CDEValue inverseTranslate(CDEValue orig); - - /** - * Configures the MappingFunc with the appropriate {@link Properties}. - * - * @param props - * The {@link Properties} to use to configure the MappingFunc. - */ - void configure(Properties props); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/ReplaceFunc.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/ReplaceFunc.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/ReplaceFunc.java deleted file mode 100644 index 80fb41f..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/funcs/ReplaceFunc.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.mapping.funcs; - -//JDK imports -import java.util.Properties; - -//OODT imports -import org.apache.oodt.xmlps.structs.CDEValue; - -/** - * - * <p> - * Describe your class here - * </p>. - */ -public class ReplaceFunc implements MappingFunc { - - private String orig; - - private String with; - - public ReplaceFunc() { - - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.xmlps.mapping.funcs.MappingFunc#translate(org.apache.oodt.xmlps.structs.CDEValue) - */ - public CDEValue translate(CDEValue orig) { - CDEValue cdeVal = new CDEValue(orig.getCdeName(), orig.getVal()); - String newVal = orig.getVal().equals(this.orig) ? with : orig.getVal(); - cdeVal.setVal(newVal); - return cdeVal; - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.xmlps.mapping.funcs.MappingFunc#configure(java.util.Properties) - */ - public void configure(Properties props) { - orig = props.getProperty("orig"); - with = props.getProperty("with"); - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.xmlps.mapping.funcs.MappingFunc#inverseTranslate(org.apache.oodt.xmlps.structs.CDEValue) - */ - public CDEValue inverseTranslate(CDEValue orig) { - CDEValue cdeVal = new CDEValue(orig.getCdeName(), orig.getVal()); - String newVal = orig.getVal().equals(this.with) ? this.orig : orig - .getVal(); - cdeVal.setVal(newVal); - return cdeVal; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/product/DBMSExecutor.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/product/DBMSExecutor.java b/xmlps/src/main/java/org/apache/oodt/xmlps/product/DBMSExecutor.java deleted file mode 100644 index 8046479..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/product/DBMSExecutor.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.product; - -//OODT imports - -import org.apache.oodt.commons.database.DatabaseConnectionBuilder; -import org.apache.oodt.xmlps.structs.CDEResult; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.sql.DataSource; - -/** - * - * <p> - * Executes CDE Queries against an underlying JDBC database, backed by Apache - * commons-pool and commons-dbcp. - * </p> - * . - */ -public class DBMSExecutor { - private static Logger LOG = Logger.getLogger(DBMSExecutor.class.getName()); - private final DataSource dataSource; - - public DBMSExecutor() { - String jdbcUrl = System.getProperty("xmlps.datasource.jdbc.url"); - String user = System.getProperty("xmlps.datasource.jdbc.user"); - String pass = System.getProperty("xmlps.datasource.jdbc.pass"); - String driver = System.getProperty("xmlps.datasource.jdbc.driver"); - dataSource = DatabaseConnectionBuilder.buildDataSource(user, pass, driver, jdbcUrl); - } - - public CDEResult executeLocalQuery(String sql) throws SQLException { - try { - Connection conn = dataSource.getConnection(); - Statement statement = conn.createStatement(); - ResultSet rs = statement.executeQuery(sql); - return new CDEResult(rs, conn); - } catch (SQLException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw e; - } - // do not close the Statement or Connection here - // call CDEResult#close() to close ResultSet and Connection - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java b/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java deleted file mode 100644 index efd5e58..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java +++ /dev/null @@ -1,390 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.product; - -//OODT imports - -import org.apache.oodt.product.ProductException; -import org.apache.oodt.product.QueryHandler; -import org.apache.oodt.xmlps.exceptions.XmlpsException; -import org.apache.oodt.xmlps.mapping.DatabaseTable; -import org.apache.oodt.xmlps.mapping.FieldScope; -import org.apache.oodt.xmlps.mapping.Mapping; -import org.apache.oodt.xmlps.mapping.MappingField; -import org.apache.oodt.xmlps.mapping.MappingReader; -import org.apache.oodt.xmlps.mapping.funcs.MappingFunc; -import org.apache.oodt.xmlps.queryparser.Expression; -import org.apache.oodt.xmlps.queryparser.HandlerQueryParser; -import org.apache.oodt.xmlps.structs.CDEResult; -import org.apache.oodt.xmlps.structs.CDEValue; -import org.apache.oodt.xmlps.util.XMLQueryHelper; -import org.apache.oodt.xmlquery.QueryElement; -import org.apache.oodt.xmlquery.XMLQuery; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.Stack; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * <p> - * An XML configurable version of a Product Server that requires no code - * to be written to plug into a local site's relational backend DBMS. - * </p>. - */ -public class XMLPSProductHandler implements QueryHandler { - - /* our log stream */ - private static final Logger LOG = Logger - .getLogger(XMLPSProductHandler.class.getName()); - - protected Mapping mapping; - - private DBMSExecutor executor; - - protected XMLPSProductHandler(String phony) { - /* this is to get around invoking the default constructor in sub-classes */ - } - - public XMLPSProductHandler() throws InstantiationException { - String MappingFilePath = System - .getProperty("org.apache.oodt.xmlps.xml.mapFilePath"); - - if (MappingFilePath == null) { - throw new InstantiationException( - "Need to specify path to xml mapping file!"); - } - - try { - mapping = MappingReader.getMapping(MappingFilePath); - } catch (Exception e) { - throw new InstantiationException( - "Unable to parse mapping xml file: [" - + MappingFilePath + "]: reason: " - + e.getMessage()); - } - - /* load the db properties file */ - /* - * if one exists: otherwise, don't bother and just print out the SQL to - * the console. - */ - String dbPropFilePath = System - .getProperty("org.apache.oodt.xmlps.xml.dbPropFilePath"); - if (dbPropFilePath != null) { - try { - System.getProperties() - .load(new FileInputStream(dbPropFilePath)); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - LOG.log(Level.SEVERE, e.getMessage()); - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new InstantiationException(e.getMessage()); - } - - executor = new DBMSExecutor(); - } - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.product.QueryHandler#query(org.apache.oodt.xmlquery.XMLQuery) - */ - public XMLQuery query(XMLQuery query) throws ProductException { - List<QueryElement> whereSet = query.getWhereElementSet(); - List<QueryElement> selectSet = query.getSelectElementSet(); - try { - translateToDomain(selectSet, true); - translateToDomain(whereSet, false); - } catch (Exception e) { - LOG.severe(e.getMessage()); - throw new ProductException(e.getMessage()); - } - - queryAndPackageResults(query); - - return query; - } - - public static void main(String[] args) throws InstantiationException, ProductException { - String usage = "XMLPSProductHandler <query>\n"; - - if (args.length != 1) { - System.err.println(usage); - System.exit(1); - } - - XMLPSProductHandler handler = new XMLPSProductHandler(); - XMLQuery q = handler.query(XMLQueryHelper - .getDefaultQueryFromQueryString(args[0])); - System.out.println(q.getXMLDocString()); - } - - protected List<QueryElement> getElemNamesFromQueryElemSet( - List<QueryElement> origSet) { - if (origSet == null || (origSet.size() == 0)) { - return Collections.emptyList(); - } - - List<QueryElement> newSet = new Vector<QueryElement>(); - - for (QueryElement elem : origSet) { - if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME) - && !mapping.constantField(elem.getValue())) { - newSet.add(elem); - - } - - } - - return newSet; - - } - - protected List<QueryElement> getConstElemNamesFromQueryElemSet( - List<QueryElement> origSet) { - if (origSet == null || (origSet.size() == 0)) { - return Collections.emptyList(); - } - - List<QueryElement> newSet = new Vector<QueryElement>(); - - for (QueryElement elem : origSet) { - if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME) - && mapping.constantField(elem.getValue())) { - newSet.add(elem); - } - } - - return newSet; - } - - protected void queryAndPackageResults(XMLQuery query) { - Stack<QueryElement> queryStack = HandlerQueryParser - .createQueryStack(query.getWhereElementSet()); - Expression parsedQuery = HandlerQueryParser.parse(queryStack, - this.mapping); - List<QueryElement> selectNames = getElemNamesFromQueryElemSet(query - .getSelectElementSet()); - - String querySelectNames = toSQLSelectColumns(selectNames); - - StringBuilder sqlBuf = new StringBuilder("SELECT "); - sqlBuf.append(querySelectNames); - sqlBuf.append(" FROM "); - sqlBuf.append(mapping.getDefaultTable()); - sqlBuf.append(" "); - - if (mapping.getNumTables() > 0) { - List<QueryElement> whereNames = getElemNamesFromQueryElemSet(query.getWhereElementSet()); - Set<DatabaseTable> requiredTables = getRequiredTables(whereNames, selectNames); - for (DatabaseTable tbl : requiredTables) { - sqlBuf.append("INNER JOIN "); - sqlBuf.append(tbl.getName()); - sqlBuf.append(" ON "); - sqlBuf.append(tbl.getName()); - sqlBuf.append("."); - sqlBuf.append(tbl.getJoinFieldName()); - sqlBuf.append(" = "); - sqlBuf.append(tbl.getDefaultTableJoin()); - sqlBuf.append("."); - sqlBuf.append(tbl.getDefaultTableJoinFieldName()); - sqlBuf.append(" "); - } - } - - if(parsedQuery != null){ - sqlBuf.append(" WHERE "); - sqlBuf.append(parsedQuery.evaluate()); - } - - LOG.log(Level.INFO, sqlBuf.toString()); - - if (executor != null) { - try { - CDEResult res = executor.executeLocalQuery(sqlBuf.toString()); - res.setOrderedFields(query.getSelectElementSet()); - res.setMapping(mapping); - res.setConstValues(getConstValuesForQuery(query)); - query.getResults().add(res); - } catch (SQLException e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, "Error executing sql: [" - + sqlBuf.toString() + "]: Message: " + e.getMessage()); - } - } - - } - - private List<CDEValue> getConstValuesForQuery(XMLQuery query) { - List<QueryElement> select = query.getSelectElementSet(); - List<QueryElement> constNames = getConstElemNamesFromQueryElemSet(select); - List<CDEValue> constValues = new ArrayList<CDEValue>(); - if (constNames != null) { - for (QueryElement qe : constNames) { - MappingField fld = mapping.getFieldByLocalName(qe.getValue()); - if (fld != null) { - constValues.add(new CDEValue(fld.getName(), fld.getConstantValue())); - } - } - } - return constValues; - } - - private String toSQLSelectColumns(List<QueryElement> elems) { - if (elems == null || (elems.size() == 0)) { - return null; - } - - StringBuilder buf = new StringBuilder(); - for (QueryElement qe : elems) { - MappingField fld = this.mapping.getFieldByLocalName(qe.getValue()); - if (fld != null) { - buf.append(fld.getLocalName()); - buf.append(" as "); - buf.append(fld.getName()); - buf.append(","); - } - } - - buf.deleteCharAt(buf.length() - 1); - - return buf.toString(); - } - - protected void translateToDomain(List<QueryElement> elemSet, - boolean selectSet) throws XmlpsException { - // go through each query element: use the mapping fields - // to translate the names - - for (Iterator<QueryElement> i = elemSet.iterator(); i.hasNext();) { - QueryElement elem = i.next(); - if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)) { - // do the translation - String elemValue = elem.getValue(); - MappingField fld = this.mapping.getFieldByName(elemValue); - // make sure fld is not null - if (fld == null) { - continue; - } - - // make sure scope is null, or if it's not null, then it's - // FieldScope.QUERY - - if (fld.getScope() != null - && fld.getScope().equals(FieldScope.RETURN)) { - // skip - continue; - } - - // check to see if it has a dbname attr, if not, then the name - // stays - // the same - String newFldName = fld.getLocalName(); - - elem.setValue(newFldName); - - // now translate the domain vocab if there are translate funcs - // present and this isn't the select set - - if (!selectSet && fld.getFuncs() != null - && fld.getFuncs().size() > 0) { - // the next query element should be - // XMLQueryHelper.ROLE_LITERAL - if (!i.hasNext()) { - break; - } - QueryElement litElem = i.next(); - if (!litElem.getRole().equals(XMLQueryHelper.ROLE_LITERAL)) { - throw new XmlpsException("next query element not " - + XMLQueryHelper.ROLE_LITERAL + "! role is " - + litElem.getRole() + " instead!"); - } - - for (MappingFunc func : fld.getFuncs()) { - CDEValue origVal = new CDEValue(fld.getName(), - litElem.getValue()); - CDEValue newVal = func.inverseTranslate(origVal); - litElem.setValue(newVal.getVal()); - } - - } - - } - } - - } - - protected Set<DatabaseTable> getRequiredTables( - List<QueryElement> whereElemNames, List<QueryElement> selectElemNames) { - Set<DatabaseTable> tables = new HashSet<DatabaseTable>(); - // add tables from where element set - if (whereElemNames != null) { - for (QueryElement qe : whereElemNames) { - MappingField fld = mapping.getFieldByLocalName(qe.getValue()); - if (fld != null) { - DatabaseTable t = mapping.getTableByName(fld.getTableName()); - if (t != null && !tables.contains(t) && !t.getName().equals(mapping.getDefaultTable())) { - tables.add(t); - } - } - } - } - // add tables from select element set - if (selectElemNames != null) { - for (QueryElement qe : selectElemNames) { - MappingField fld = mapping.getFieldByLocalName(qe.getValue()); - if (fld != null) { - DatabaseTable t = mapping.getTableByName(fld.getTableName()); - if (t != null && !tables.contains(t) && !t.getName().equals(mapping.getDefaultTable())) { - tables.add(t); - } - } - } - } - // the tables found may be joined on columns from tables we haven't found - // yet - // add additional required join tables - Set<DatabaseTable> moreTables = new HashSet<DatabaseTable>(tables); - for (DatabaseTable t : tables) { - DatabaseTable join = mapping.getTableByName(t.getDefaultTableJoin()); - // recursively add all join tables until we get to either - // (a) the mapping default table (join == null) - // (b) or a table already found (moreTables.contains(join)) - while (join != null && !moreTables.contains(join) && !join.getName().equals(mapping.getDefaultTable())) { - moreTables.add(join); - join = mapping.getTableByName(join.getDefaultTableJoin()); - } - } - return moreTables; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/profile/DBMSExecutor.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/DBMSExecutor.java b/xmlps/src/main/java/org/apache/oodt/xmlps/profile/DBMSExecutor.java deleted file mode 100644 index bd9d70f..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/DBMSExecutor.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.profile; - -//OODT imports -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.metadata.util.PathUtils; -import org.apache.oodt.commons.database.DatabaseConnectionBuilder; -import org.apache.oodt.profile.EnumeratedProfileElement; -import org.apache.oodt.profile.Profile; -import org.apache.oodt.profile.ProfileAttributes; -import org.apache.oodt.profile.ProfileElement; -import org.apache.oodt.profile.ResourceAttributes; -import org.apache.oodt.xmlps.mapping.FieldType; -import org.apache.oodt.xmlps.mapping.Mapping; -import org.apache.oodt.xmlps.mapping.MappingField; -import org.apache.oodt.xmlps.mapping.funcs.MappingFunc; -import org.apache.oodt.xmlps.structs.CDEValue; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.List; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.sql.DataSource; - -/** - * - * <p> - * Executes Profile Queries against an underlying JDBC database, backed by - * Apache commons-pool and commons-dbcp. - * </p> - * . - */ -public class DBMSExecutor { - - private final DataSource dataSource; - - private static final Logger LOG = Logger.getLogger(DBMSExecutor.class - .getName()); - - public DBMSExecutor() { - String jdbcUrl = System.getProperty("xmlps.datasource.jdbc.url"); - String user = System.getProperty("xmlps.datasource.jdbc.user"); - String pass = System.getProperty("xmlps.datasource.jdbc.pass"); - String driver = System.getProperty("xmlps.datasource.jdbc.driver"); - try { - Class.forName(driver); - } catch (ClassNotFoundException ignore) { - } - - this.dataSource = DatabaseConnectionBuilder.buildDataSource(user, pass, - driver, jdbcUrl); - - } - - public List<Profile> executeLocalQuery(Mapping map, String sql, - String resLocationSpec) throws SQLException { - Connection conn = null; - Statement statement = null; - - List<Profile> profiles = null; - - try { - conn = dataSource.getConnection(); - statement = conn.createStatement(); - ResultSet rs = statement.executeQuery(sql); - - profiles = new Vector<Profile>(); - - while (rs.next()) { - Profile prof = toProfile(rs, map, resLocationSpec); - profiles.add(prof); - } - - } catch (SQLException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw e; - } finally { - if (statement != null) { - try { - statement.close(); - } catch (Exception ignore) { - } - - } - - if (conn != null) { - try { - conn.close(); - } catch (Exception ignore) { - } - - } - } - - return profiles; - - } - - @SuppressWarnings("unchecked") - private Profile toProfile(ResultSet rs, Mapping map, String resLocationSpec) { - Profile profile = new Profile(); - ResourceAttributes resAttr = profile.getResourceAttributes(); - ProfileAttributes profAttr = profile.getProfileAttributes(); - resAttr.setResClass("system.profile"); - profAttr.setStatusID("active"); - profAttr.setType("profile"); - - Metadata met = new Metadata(); - - for (String fldName : map.getFieldNames()) { - MappingField fld = map.getFieldByName(fldName); - ProfileElement elem = new EnumeratedProfileElement(profile); - elem.setName(fld.getName()); - - try { - if (fld.getType().equals(FieldType.CONSTANT)) { - elem.getValues().add(fld.getConstantValue()); - } else { - String elemDbVal = rs.getString(fld.getDbName()); - for (MappingFunc func : fld.getFuncs()) { - CDEValue origVal = new CDEValue(fld.getName(), elemDbVal); - CDEValue newVal = func.translate(origVal); - elemDbVal = newVal.getVal(); - } - - elem.getValues().add(elemDbVal); - } - } catch (SQLException e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, "Unable to obtain field: [" - + fld.getLocalName() + "] from result set: message: " - + e.getMessage()); - } - - met.addMetadata(elem.getName(), (String) elem.getValues().get(0)); - - profile.getProfileElements().put(fld.getName(), elem); - } - - if (resLocationSpec != null) { - resAttr.getResLocations().add( - PathUtils.replaceEnvVariables(resLocationSpec, met)); - } - - return profile; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java b/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java deleted file mode 100644 index fd7150a..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.profile; - -import org.apache.oodt.profile.Profile; -import org.apache.oodt.profile.ProfileException; -import org.apache.oodt.profile.handlers.ProfileHandler; -import org.apache.oodt.xmlps.exceptions.XmlpsException; -import org.apache.oodt.xmlps.mapping.DatabaseTable; -import org.apache.oodt.xmlps.mapping.MappingReader; -import org.apache.oodt.xmlps.product.XMLPSProductHandler; -import org.apache.oodt.xmlps.queryparser.Expression; -import org.apache.oodt.xmlps.queryparser.HandlerQueryParser; -import org.apache.oodt.xmlquery.QueryElement; -import org.apache.oodt.xmlquery.XMLQuery; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; - - -/** - * - * <p> - * An implementation of a {@link ProfileHandler} that extends the capabilities - * of the {@link XMLPSProductHandler}, and uses the XML Specification defined - * by the mapping file to represent its field mapping information. - * </p>. - */ -public class XMLPSProfileHandler extends XMLPSProductHandler implements - ProfileHandler { - - private DBMSExecutor executor; - - /* our log stream */ - private static final Logger LOG = Logger.getLogger(XMLPSProfileHandler.class - .getName()); - - private String resLocationSpec; - - public XMLPSProfileHandler() throws InstantiationException { - super(null); - String mappingFilePath = System - .getProperty("org.apache.oodt.xmlps.profile.xml.mapFilePath"); - - if (mappingFilePath == null) { - throw new InstantiationException( - "Need to specify path to xml mapping file!"); - } - - try { - mapping = MappingReader.getMapping(mappingFilePath); - } catch (Exception e) { - throw new InstantiationException( - "Unable to parse profile mapping xml file: [" - + mappingFilePath + "]: reason: " - + e.getMessage()); - } - - // load the db properties file - // if one exists: otherwise, don't bother and just print out the SQL to - // the console. - // - String dbPropFilePath = System - .getProperty("org.apache.oodt.xmlps.profile.xml.dbPropFilePath"); - if (dbPropFilePath != null) { - try { - System.getProperties() - .load(new FileInputStream(dbPropFilePath)); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - LOG.log(Level.SEVERE, e.getMessage()); - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new InstantiationException(e.getMessage()); - } - - executor = new DBMSExecutor(); - } - - this.resLocationSpec = System - .getProperty("org.apache.oodt.xmlps.profile.xml.resLocationSpec"); - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.profile.handlers.ProfileHandler#findProfiles(org.apache.oodt.xmlquery.XMLQuery) - */ - public List<Profile> findProfiles(XMLQuery query) throws ProfileException { - List<QueryElement> whereSet = query.getWhereElementSet(); - List<QueryElement> selectSet = query.getSelectElementSet(); - try { - translateToDomain(selectSet, true); - translateToDomain(whereSet, false); - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new ProfileException(e.getMessage()); - } - return queryAndPackageProfiles(query); - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.profile.handlers.ProfileHandler#get(java.lang.String) - */ - public Profile get(String id) throws ProfileException { - throw new ProfileException("Method not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.profile.handlers.ProfileHandler#getID() - */ - public String getID() { - return mapping.getId(); - } - - protected List<Profile> queryAndPackageProfiles(XMLQuery query) { - Stack<QueryElement> queryStack = HandlerQueryParser - .createQueryStack(query.getWhereElementSet()); - Expression parsedQuery = HandlerQueryParser.parse(queryStack, - this.mapping); - List<Profile> profs = null; - - StringBuilder sqlBuf = new StringBuilder("SELECT *"); - sqlBuf.append(" FROM "); - sqlBuf.append(mapping.getDefaultTable()); - sqlBuf.append(" "); - - if (mapping.getNumTables() > 0) { - for (String tableName : mapping.getTableNames()) { - if (tableName.equals(mapping.getDefaultTable())) { - continue; - } - DatabaseTable tbl = mapping.getTableByName(tableName); - sqlBuf.append("INNER JOIN "); - sqlBuf.append(tbl.getName()); - sqlBuf.append(" ON "); - sqlBuf.append(tbl.getName()); - sqlBuf.append("."); - sqlBuf.append(tbl.getJoinFieldName()); - sqlBuf.append(" = "); - sqlBuf.append(tbl.getDefaultTableJoin()); - sqlBuf.append("."); - sqlBuf.append(tbl.getDefaultTableJoinFieldName()); - sqlBuf.append(" "); - } - } - - if (parsedQuery != null) { - sqlBuf.append(" WHERE "); - sqlBuf.append(parsedQuery.evaluate()); - } - - LOG.log(Level.INFO, sqlBuf.toString()); - - if (executor != null) { - try { - profs = executor.executeLocalQuery(this.mapping, sqlBuf - .toString(), this.resLocationSpec); - - } catch (SQLException e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, "Error executing sql: [" - + sqlBuf.toString() + "]: Message: " + e.getMessage()); - } - } - - return profs; - } - - protected void translateToDomain(List<QueryElement> elemSet, - boolean selectSet) throws XmlpsException { - super.translateToDomain(elemSet, selectSet); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java deleted file mode 100644 index dc97b00..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.queryparser; - -/** - * - * <p>A logical and expression</p>. - */ -public class AndExpression extends LogOpExpression implements ParseConstants{ - - public AndExpression(Expression lhs, Expression rhs) { - super(SQL_AND, lhs, rhs); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java deleted file mode 100644 index b12ef63..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.queryparser; - -/** - * - * A logical contains expression. - */ -public class ContainsExpression extends RelOpExpression implements ParseConstants { - - public ContainsExpression(String lhs, Expression literal) { - super(SQL_LIKE, lhs, literal); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java deleted file mode 100644 index bfc3aaf..0000000 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.xmlps.queryparser; - -/** - * - * Operator equals expression. - */ -public class EqualsExpression extends RelOpExpression implements ParseConstants { - - public EqualsExpression(String lhs, Expression literal) { - super(SQL_EQUAL, lhs, literal); - } - -}
