Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2926B200B5B for ; Thu, 30 Jun 2016 08:55:56 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 27A20160A52; Thu, 30 Jun 2016 06:55:56 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0C462160A73 for ; Thu, 30 Jun 2016 08:55:53 +0200 (CEST) Received: (qmail 15045 invoked by uid 500); 30 Jun 2016 06:55:53 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 14548 invoked by uid 99); 30 Jun 2016 06:55:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jun 2016 06:55:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2D41AEC22D; Thu, 30 Jun 2016 06:55:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dbhowmick@apache.org To: commits@ambari.apache.org Date: Thu, 30 Jun 2016 06:56:00 -0000 Message-Id: <92c409ea4fa542ffb28d7674e4d291a9@git.apache.org> In-Reply-To: <46e544db9494444f9ecc3dd4a6702253@git.apache.org> References: <46e544db9494444f9ecc3dd4a6702253@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/10] ambari git commit: AMBARI-17079. Moved Hue to Ambari migrator to standard view architecture (Pradarttana Panda via dipayanb) archived-at: Thu, 30 Jun 2016 06:55:56 -0000 http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..f3349c6 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/OracleQuerySetAmbariDB.java @@ -0,0 +1,44 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.historyqueryset; + +/** + * + * Overriding methods for Oracle specific queries + */ + +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_jobimpl_" + id + ""; + } + @Override + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl' and view_instance_name=?"; + } + @Override + protected String getSqlInsertHiveHistory(int id) { + return "INSERT INTO ds_jobimpl_" + id + " values (?,'','','','','default',?,0,'','',?,'admin',?,'','job','','','Unknown',?,'','Worksheet')"; + } + @Override + protected String getRevSql(int id,String maxcount){ + return "delete from ds_jobimpl_" + id + " where ds_id='" + maxcount + "'"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..5f4356b --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.historyqueryset; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/QuerySetAmbariDB.java new file mode 100644 index 0000000..5be8cc1 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/historyqueryset/QuerySetAmbariDB.java @@ -0,0 +1,79 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.historyqueryset; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * History Query Prepared statemets + */ + +public abstract class QuerySetAmbariDB { + + public PreparedStatement getTableIdFromInstanceName(Connection connection, String instance) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(getTableIdSqlFromInstanceName()); + prSt.setString(1, instance); + return prSt; + } + + public PreparedStatement getMaxDsIdFromTableId(Connection connection, int id) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlMaxDSidFromTableId(id)); + + return prSt; + } + + public PreparedStatement insertToHiveHistory(Connection connection, int id, String maxcount, long epochtime, String dirname) throws SQLException { + + String Logfile= dirname + "logs"; + String queryHqlFile= dirname + "query.hql"; + + PreparedStatement prSt = connection.prepareStatement(getSqlInsertHiveHistory(id)); + + prSt.setString(1, maxcount); + prSt.setLong(2, epochtime); + prSt.setString(3, Logfile); + prSt.setString(4, queryHqlFile); + prSt.setString(5, dirname); + + return prSt; + } + + public String RevertSql(int id,String maxcount) throws SQLException { + return getRevSql(id,maxcount); + } + + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_jobimpl_" + id + ";"; + } + + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl' and view_instance_name=?;"; + } + + protected String getSqlInsertHiveHistory(int id) { + return "INSERT INTO ds_jobimpl_" + id + " values (?,'','','','','default',?,0,'','',?,'admin',?,'','job','','','Unknown',?,'','Worksheet');"; + } + + protected String getRevSql(int id,String maxcount){ + return "delete from ds_jobimpl_" + id + " where ds_id='" + maxcount + "';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/MysqlQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/MysqlQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/MysqlQuerySetAmbariDB.java new file mode 100644 index 0000000..b3a0323 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/MysqlQuerySetAmbariDB.java @@ -0,0 +1,23 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.instancedetail; + + +public class MysqlQuerySetAmbariDB extends QuerySetAmbariDB { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..bc41bf7 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/OracleQuerySetAmbariDB.java @@ -0,0 +1,31 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.instancedetail; + + +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getHiveInstanceSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='HIVE{1.0.0}'"; + } + @Override + protected String getAllInstanceDetailSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='HIVE{1.0.0}' or view_name='PIG{1.0.0}';"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..3297f32 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.instancedetail; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/QuerySetAmbariDB.java new file mode 100644 index 0000000..da1c411 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/instancedetail/QuerySetAmbariDB.java @@ -0,0 +1,48 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.instancedetail; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Service class to get instance detail + */ + +public abstract class QuerySetAmbariDB { + + public PreparedStatement getHiveInstanceDeatil(Connection connection) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(getHiveInstanceSql()); + return prSt; + } + + public PreparedStatement getAllInstanceDeatil(Connection connection) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(getAllInstanceDetailSql()); + return prSt; + } + + protected String getHiveInstanceSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='HIVE{1.0.0}';"; + } + + protected String getAllInstanceDetailSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='HIVE{1.0.0}' or view_name='PIG{1.0.0}';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/MysqlQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/MysqlQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/MysqlQuerySetAmbariDB.java new file mode 100644 index 0000000..2b40491 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/MysqlQuerySetAmbariDB.java @@ -0,0 +1,65 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.savedqueryset; + +/** + * override methods specific to Mysql + */ + +public class MysqlQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableIdSavedQuery(int id) { + return "select max( cast(ds_id as unsigned) ) as max from DS_SAVEDQUERY_" + id + ";"; + } + + @Override + protected String getTableIdSqlFromInstanceNameSavedQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.savedQueries.SavedQuery' and view_instance_name=?;"; + } + + @Override + protected String getSqlMaxDSidFromTableIdHistoryQuery(int id) { + return "select MAX(cast(ds_id as integer)) as max from DS_JOBIMPL_" + id + ";"; + } + + @Override + protected String getTableIdSqlFromInstanceNameHistoryQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl' and view_instance_name=?;"; + } + + @Override + protected String getSqlInsertHiveHistory(int id) { + return "INSERT INTO DS_JOBIMPL_" + id + " values (?,'','','','','default',?,0,'','',?,'admin',?,'','job','','','Unknown',?,'','Worksheet');"; + } + + @Override + protected String getSqlInsertSavedQuery(int id) { + return "INSERT INTO DS_SAVEDQUERY_" + id + " values (?,?,'" + "admin" + "',?,?,?);"; + } + + @Override + protected String getRevSqlSavedQuery(int id, String maxcount) { + return "delete from DS_SAVEDQUERY_" + id + " where ds_id='" + maxcount + "';"; + } + + @Override + protected String getRevSqlHistoryQuery(int id, String maxcount) { + return "delete from DS_JOBIMPL_" + id + " where ds_id='" + maxcount + "';"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..11f9170 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/OracleQuerySetAmbariDB.java @@ -0,0 +1,58 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.savedqueryset; + +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableIdSavedQuery(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_savedquery_" + id + ""; + } + + @Override + protected String getTableIdSqlFromInstanceNameSavedQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.savedQueries.SavedQuery' and view_instance_name=?"; + } + + @Override + protected String getSqlMaxDSidFromTableIdHistoryQuery(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_jobimpl_" + id + ""; + } + @Override + protected String getTableIdSqlFromInstanceNameHistoryQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl' and view_instance_name=?"; + } + + @Override + protected String getSqlInsertHiveHistory(int id) { + return "INSERT INTO ds_jobimpl_" + id + " values (?,'','','','','default',?,0,'','',?,'admin',?,'','job','','','Unknown',?,'','Worksheet')"; + } + @Override + protected String getSqlInsertSavedQuery(int id) { + return "INSERT INTO ds_savedquery_" + id + " values (?,?,'" + "admin" + "',?,?,?)"; + } + + @Override + protected String getRevSqlSavedQuery(int id, String maxcount) { + return "delete from ds_savedquery_" + id + " where ds_id='" + maxcount + "'"; + } + @Override + protected String getRevSqlHistoryQuery(int id, String maxcount) { + return "delete from ds_jobimpl_" + id + " where ds_id='" + maxcount + "'"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..7c8eeab --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.savedqueryset; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/QuerySetAmbariDB.java new file mode 100644 index 0000000..8ab13b2 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/hive/savedqueryset/QuerySetAmbariDB.java @@ -0,0 +1,131 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.savedqueryset; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Prepared statement for Saved query + */ + +public abstract class QuerySetAmbariDB { + + public PreparedStatement getTableIdFromInstanceNameSavedquery(Connection connection, String instance) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getTableIdSqlFromInstanceNameSavedQuery()); + prSt.setString(1, instance); + return prSt; + } + + public PreparedStatement getTableIdFromInstanceNameHistoryquery(Connection connection, String instance) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getTableIdSqlFromInstanceNameHistoryQuery()); + prSt.setString(1, instance); + return prSt; + } + + public PreparedStatement getMaxDsIdFromTableIdHistoryquery(Connection connection, int id) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlMaxDSidFromTableIdHistoryQuery(id)); + return prSt; + } + + public PreparedStatement getMaxDsIdFromTableIdSavedquery(Connection connection, int id) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlMaxDSidFromTableIdSavedQuery(id)); + + return prSt; + } + + public PreparedStatement insertToHiveHistory(Connection connection, int id, String maxcount, long epochtime, String dirname) throws SQLException { + + String Logfile = dirname + "logs"; + String queryHqlFile = dirname + "query.hql"; + + PreparedStatement prSt = connection.prepareStatement(getSqlInsertHiveHistory(id)); + + prSt.setString(1, maxcount); + prSt.setLong(2, epochtime); + prSt.setString(3, Logfile); + prSt.setString(4, queryHqlFile); + prSt.setString(5, dirname); + + return prSt; + } + + public PreparedStatement insertToHiveSavedQuery(Connection connection, int id, String maxcount, String database, String dirname, String query, String name) throws SQLException { + + String Logfile = dirname + "logs"; + String queryHqlFile = dirname + "query.hql"; + + PreparedStatement prSt = connection.prepareStatement(getSqlInsertSavedQuery(id)); + + prSt.setString(1, maxcount); + prSt.setString(2, database); + prSt.setString(3, queryHqlFile); + prSt.setString(4, query); + prSt.setString(5, name); + + return prSt; + } + + public String revertSqlHistoryQuery(int id, String maxcount) throws SQLException { + + return getRevSqlHistoryQuery(id, maxcount); + } + + public String revertSqlSavedQuery(int id, String maxcount) throws SQLException { + + return getRevSqlSavedQuery(id, maxcount); + } + + protected String getSqlMaxDSidFromTableIdSavedQuery(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_savedquery_" + id + ";"; + } + + protected String getTableIdSqlFromInstanceNameSavedQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.savedQueries.SavedQuery' and view_instance_name=?;"; + } + + protected String getSqlMaxDSidFromTableIdHistoryQuery(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_jobimpl_" + id + ";"; + } + + protected String getTableIdSqlFromInstanceNameHistoryQuery() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl' and view_instance_name=?;"; + } + + protected String getSqlInsertHiveHistory(int id) { + return "INSERT INTO ds_jobimpl_" + id + " values (?,'','','','','default',?,0,'','',?,'admin',?,'','job','','','Unknown',?,'','Worksheet');"; + } + + protected String getSqlInsertSavedQuery(int id) { + return "INSERT INTO ds_savedquery_" + id + " values (?,?,'" + "admin" + "',?,?,?);"; + } + + protected String getRevSqlSavedQuery(int id, String maxcount) { + return "delete from ds_savedquery_" + id + " where ds_id='" + maxcount + "';"; + } + + protected String getRevSqlHistoryQuery(int id, String maxcount) { + return "delete from ds_jobimpl_" + id + " where ds_id='" + maxcount + "';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/MysqlQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/MysqlQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/MysqlQuerySetAmbariDB.java new file mode 100644 index 0000000..429a598 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/MysqlQuerySetAmbariDB.java @@ -0,0 +1,23 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.instancedetail; + + +public class MysqlQuerySetAmbariDB extends QuerySetAmbariDB { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..e8b4265 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/OracleQuerySetAmbariDB.java @@ -0,0 +1,30 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.instancedetail; + +/** + * override method specific to Query. + */ +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getPigInstanceSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='PIG{1.0.0}'"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..8b7f27b --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.instancedetail; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/QuerySetAmbariDB.java new file mode 100644 index 0000000..6d878fe --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/instancedetail/QuerySetAmbariDB.java @@ -0,0 +1,39 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.instancedetail; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Prepared statement for Pig Instance details + */ + +public abstract class QuerySetAmbariDB { + + public PreparedStatement getAllPigInstance(Connection connection) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(getPigInstanceSql()); + return prSt; + } + + protected String getPigInstanceSql(){ + return "select distinct(view_instance_name) as instancename from viewentity where view_name='PIG{1.0.0}';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/MysqlQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/MysqlQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/MysqlQuerySetAmbariDB.java new file mode 100644 index 0000000..fdc2484 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/MysqlQuerySetAmbariDB.java @@ -0,0 +1,43 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.jobqueryset; + +/** + * Override method specific to Mysql + */ + +public class MysqlQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableId(int id) { + return "select max( cast(ds_id as unsigned) ) as max from DS_PIGJOB_" + id + ";"; + } + + @Override + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.jobs.models.PigJob' and view_instance_name=?;"; + } + @Override + protected String getSqlinsertToPigJob(int id) { + return "INSERT INTO DS_PIGJOB_" + id + " values (?,?,0,'','f','','','admin',0,?,'',?,'','',?,?,'',?);"; + } + @Override + protected String getRevSql(int id, String maxcount) { + return "delete from DS_PIGJOB_" + id + " where ds_id='" + maxcount + "';"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..2c27409 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/OracleQuerySetAmbariDB.java @@ -0,0 +1,41 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.jobqueryset; + +/** + * Override methods for Oracle + */ +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_pigjob_" + id + ""; + } + @Override + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.jobs.models.PigJob' and view_instance_name=?"; + } + @Override + protected String getSqlinsertToPigJob(int id) { + return "INSERT INTO ds_pigjob_" + id + " values (?,?,0,'','f','','','admin',0,?,'',?,'','',?,?,'',?)"; + } + @Override + protected String getRevSql(int id, String maxcount) { + return "delete from ds_pigjob_" + id + " where ds_id='" + maxcount + "'"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..07a174c --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.jobqueryset; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/QuerySetAmbariDB.java new file mode 100644 index 0000000..ec70e45 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/jobqueryset/QuerySetAmbariDB.java @@ -0,0 +1,80 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.jobqueryset; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Pig Job Prepare statement + */ + +public abstract class QuerySetAmbariDB { + + public PreparedStatement getTableIdFromInstanceName(Connection connection, String instance) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getTableIdSqlFromInstanceName()); + prSt.setString(1, instance); + return prSt; + } + + public PreparedStatement getMaxDsIdFromTableId(Connection connection, int id) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlMaxDSidFromTableId(id)); + return prSt; + } + + public PreparedStatement insertToPigJob(String dirname, String maxcountforpigjob, long epochtime1, String title, Connection connection, int id, String status) throws SQLException { + + String pigScriptFile = dirname + "script.pig"; + + PreparedStatement prSt = connection.prepareStatement(getSqlinsertToPigJob(id)); + + prSt.setString(1, maxcountforpigjob); + prSt.setLong(2, epochtime1); + prSt.setString(3, pigScriptFile); + prSt.setString(4, maxcountforpigjob); + prSt.setString(5, status); + prSt.setString(6, dirname); + prSt.setString(7, title); + + return prSt; + } + + public String revertSql(int id, String maxcount) throws SQLException { + return getRevSql(id, maxcount); + } + + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_pigjob_" + id + ";"; + } + + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.jobs.models.PigJob' and view_instance_name=?;"; + } + + protected String getSqlinsertToPigJob(int id) { + return "INSERT INTO ds_pigjob_" + id + " values (?,?,0,'','f','','','admin',0,?,'',?,'','',?,?,'',?);"; + } + + protected String getRevSql(int id, String maxcount) { + return "delete from ds_pigjob_" + id + " where ds_id='" + maxcount + "';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/MysqlQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/MysqlQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/MysqlQuerySetAmbariDB.java new file mode 100644 index 0000000..a8c1c4d --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/MysqlQuerySetAmbariDB.java @@ -0,0 +1,43 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.savedscriptqueryset; + +/** + * over rides method for Mysql specific queries + */ + +public class MysqlQuerySetAmbariDB extends QuerySetAmbariDB { + + @Override + protected String getSqlMaxDSidFromTableId(int id) { + return "select max( cast(ds_id as unsigned) ) as max from DS_PIGSCRIPT_" + id + ";"; + } + @Override + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.scripts.models.PigScript' and view_instance_name=?;"; + } + @Override + protected String getSqlinsertToPigScript(int id) { + return "INSERT INTO DS_PIGSCRIPT_" + id + " values (?,'1970-01-17 20:28:55.586000 +00:00:00',0,'admin',?,'','',?);"; + } + @Override + protected String getRevSql(int id,String maxcount){ + return "delete from DS_PIGSCRIPT_" + id + " where ds_id='" + maxcount + "';"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/OracleQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/OracleQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/OracleQuerySetAmbariDB.java new file mode 100644 index 0000000..d7dfc0b --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/OracleQuerySetAmbariDB.java @@ -0,0 +1,41 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.savedscriptqueryset; + +public class OracleQuerySetAmbariDB extends QuerySetAmbariDB { + /* + * Overriding methods for Oracle specific queries + * */ + + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_pigscript_" + id + ""; + } + + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.scripts.models.PigScript' and view_instance_name=?"; + } + + protected String getSqlinsertToPigScript(int id) { + return "INSERT INTO ds_pigscript_" + id + " values (?,'1970-01-17 20:28:55.586000 +00:00:00','f','admin',?,'','',?)"; + } + + protected String getRevSql(int id, String maxcount) { + return "delete from ds_pigscript_" + id + " where ds_id='" + maxcount + "'"; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/PostgressQuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/PostgressQuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/PostgressQuerySetAmbariDB.java new file mode 100644 index 0000000..fc99751 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/PostgressQuerySetAmbariDB.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.savedscriptqueryset; + + +public class PostgressQuerySetAmbariDB extends QuerySetAmbariDB { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/QuerySetAmbariDB.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/QuerySetAmbariDB.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/QuerySetAmbariDB.java new file mode 100644 index 0000000..4fc61fe --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/ambariqueryset/pig/savedscriptqueryset/QuerySetAmbariDB.java @@ -0,0 +1,70 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.savedscriptqueryset; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Pig Script prepared statement + */ +public abstract class QuerySetAmbariDB { + + public PreparedStatement getTableIdFromInstanceName(Connection connection, String instance) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(getTableIdSqlFromInstanceName()); + prSt.setString(1, instance); + return prSt; + } + + public PreparedStatement getMaxDsIdFromTableId(Connection connection, int id) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlMaxDSidFromTableId(id)); + return prSt; + } + + public PreparedStatement insertToPigScript(Connection connection, int id, String maxcount1, String dirname, String title) throws SQLException { + + PreparedStatement prSt = connection.prepareStatement(getSqlinsertToPigScript(id)); + prSt.setString(1, maxcount1); + prSt.setString(2, dirname); + prSt.setString(3, title); + + return prSt; + } + + public String revertSql(int id, String maxcount) throws SQLException { + return getRevSql(id, maxcount); + } + + protected String getSqlMaxDSidFromTableId(int id) { + return "select MAX(cast(ds_id as integer)) as max from ds_pigscript_" + id + ";"; + } + + protected String getTableIdSqlFromInstanceName() { + return "select id from viewentity where class_name LIKE 'org.apache.ambari.view.pig.resources.scripts.models.PigScript' and view_instance_name=?;"; + } + + protected String getSqlinsertToPigScript(int id) { + return "INSERT INTO ds_pigscript_" + id + " values (?,'1970-01-17 20:28:55.586000 +00:00:00','f','admin',?,'','',?);"; + } + + protected String getRevSql(int id, String maxcount) { + return "delete from ds_pigscript_" + id + " where ds_id='" + maxcount + "';"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/MysqlQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/MysqlQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/MysqlQuerySet.java new file mode 100644 index 0000000..d379f88 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/MysqlQuerySet.java @@ -0,0 +1,23 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.historyqueryset; + + +public class MysqlQuerySet extends QuerySet { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/OracleQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/OracleQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/OracleQuerySet.java new file mode 100644 index 0000000..4afb222 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/OracleQuerySet.java @@ -0,0 +1,61 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.historyqueryset; + + +public class OracleQuerySet extends QuerySet { + + @Override + protected String fetchuserIdfromUsernameSql() { + return "select id from auth_user where username=?"; + } + @Override + protected String fetchHueQueriesNoStartdateNoEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =?"; + } + @Override + protected String fetchHueQueriesNoStartdateYesEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date <= date(?)"; + } + @Override + protected String fetchHueQueriesYesStartdateNoEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date >= date(?)"; + } + @Override + protected String fetchHueQueriesYesStartdateYesEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date >= date(?) AND submission_date <= date(?)"; + } + @Override + protected String fetchHueQueriesNoStartdateNoEnddateYesallUserSql() { + return "select query from beeswax_queryhistory"; + } + @Override + protected String fetchHueQueriesNoStartdateYesEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date <= date(?)"; + } + @Override + protected String fetchHueQueriesYesStartdateNoEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date >= date(?)"; + + } + @Override + protected String fetchHueQueriesYesStartdateYesEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date >= date(?) AND submission_date <= date(?)"; + + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/PostgressQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/PostgressQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/PostgressQuerySet.java new file mode 100644 index 0000000..829582a --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/PostgressQuerySet.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.historyqueryset; + + +public class PostgressQuerySet extends QuerySet { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/QuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/QuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/QuerySet.java new file mode 100644 index 0000000..8d2aad4 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/QuerySet.java @@ -0,0 +1,130 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.historyqueryset; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + + +public abstract class QuerySet { + + + public PreparedStatement getUseridfromUserName(Connection connection, String username) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchuserIdfromUsernameSql()); + prSt.setString(1, username); + return prSt; + } + + public PreparedStatement getQueriesNoStartDateNoEndDate(Connection connection, int id) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesNoStartdateNoEnddateSql()); + prSt.setInt(1, id); + return prSt; + } + + public PreparedStatement getQueriesNoStartDateYesEndDate(Connection connection, int id, String enddate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesNoStartdateYesEnddateSql()); + prSt.setInt(1, id); + prSt.setString(2, enddate); + return prSt; + } + + public PreparedStatement getQueriesYesStartDateNoEndDate(Connection connection, int id, String startdate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesYesStartdateNoEnddateSql()); + prSt.setInt(1, id); + prSt.setString(2, startdate); + return prSt; + } + + public PreparedStatement getQueriesYesStartDateYesEndDate(Connection connection, int id, String startdate, String endate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesYesStartdateYesEnddateSql()); + prSt.setInt(1, id); + prSt.setString(2, startdate); + prSt.setString(3, endate); + return prSt; + } + + /** + * for all user + */ + public PreparedStatement getQueriesNoStartDateNoEndDateAllUser(Connection connection) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesNoStartdateNoEnddateYesallUserSql()); + return prSt; + } + + public PreparedStatement getQueriesNoStartDateYesEndDateAllUser(Connection connection, String enddate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesNoStartdateYesEnddateYesallUserSql()); + prSt.setString(1, enddate); + return prSt; + } + + public PreparedStatement getQueriesYesStartDateNoEndDateAllUser(Connection connection, String startdate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesYesStartdateNoEnddateYesallUserSql()); + prSt.setString(1, startdate); + return prSt; + } + + public PreparedStatement getQueriesYesStartDateYesEndDateAllUser(Connection connection, String startdate, String endate) throws SQLException { + PreparedStatement prSt = connection.prepareStatement(fetchHueQueriesYesStartdateYesEnddateYesallUserSql()); + prSt.setString(1, startdate); + prSt.setString(2, endate); + return prSt; + } + + + protected String fetchuserIdfromUsernameSql() { + return "select id from auth_user where username=?;"; + + } + + protected String fetchHueQueriesNoStartdateNoEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =?;"; + } + + protected String fetchHueQueriesNoStartdateYesEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date <= date(?);"; + } + + protected String fetchHueQueriesYesStartdateNoEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date >= date(?);"; + } + + protected String fetchHueQueriesYesStartdateYesEnddateSql() { + return "select query from beeswax_queryhistory where owner_id =? AND submission_date >= date(?) AND submission_date <= date(?);"; + } + + protected String fetchHueQueriesNoStartdateNoEnddateYesallUserSql() { + return "select query from beeswax_queryhistory;"; + } + + protected String fetchHueQueriesNoStartdateYesEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date <= date(?);"; + } + + protected String fetchHueQueriesYesStartdateNoEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date >= date(?);"; + + } + + protected String fetchHueQueriesYesStartdateYesEnddateYesallUserSql() { + return "select query from beeswax_queryhistory where submission_date >= date(?) AND submission_date <= date(?);"; + + } + + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/SqliteQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/SqliteQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/SqliteQuerySet.java new file mode 100644 index 0000000..417df3a --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/historyqueryset/SqliteQuerySet.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.historyqueryset; + + +public class SqliteQuerySet extends QuerySet { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/MysqlQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/MysqlQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/MysqlQuerySet.java new file mode 100644 index 0000000..d91633d --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/MysqlQuerySet.java @@ -0,0 +1,23 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.savedqueryset; + + +public class MysqlQuerySet extends QuerySet { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/OracleQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/OracleQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/OracleQuerySet.java new file mode 100644 index 0000000..3190885 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/OracleQuerySet.java @@ -0,0 +1,65 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.savedqueryset; + + +public class OracleQuerySet extends QuerySet { + + @Override + protected String fetchuserIdfromUsernameSql() { + return "select id from auth_user where username=?"; + + } + @Override + protected String fetchHueQueriesNoStartdateNoEnddateSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query'and owner_id =?"; + } + @Override + protected String fetchHueQueriesNoStartdateYesEnddateSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query'and owner_id =? AND mtime <= date(?)"; + } + @Override + protected String fetchHueQueriesYesStartdateNoEnddateSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query'and owner_id =? AND mtime >= date(?)"; + + } + @Override + protected String fetchHueQueriesYesStartdateYesEnddateSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query'and owner_id =? AND mtime >= date(?) AND mtime <= date(?)"; + + } + @Override + protected String fetchHueQueriesNoStartdateNoEnddateYesallUserSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query'"; + } + @Override + protected String fetchHueQueriesNoStartdateYesEnddateYesallUserSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query' AND mtime <= date(?)"; + + } + @Override + protected String fetchHueQueriesYesStartdateNoEnddateYesallUserSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query' AND mtime >= date(?)"; + + } + @Override + protected String fetchHueQueriesYesStartdateYesEnddateYesallUserSql() { + return "select data,name,owner_id from beeswax_savedquery where name!='My saved query' AND mtime >= date(?) AND mtime <= date(?)"; + + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/c86672cb/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/PostgressQuerySet.java ---------------------------------------------------------------------- diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/PostgressQuerySet.java b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/PostgressQuerySet.java new file mode 100644 index 0000000..83d32c7 --- /dev/null +++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/datasource/queryset/huequeryset/hive/savedqueryset/PostgressQuerySet.java @@ -0,0 +1,22 @@ +/** + * 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.ambari.view.huetoambarimigration.datasource.queryset.huequeryset.hive.savedqueryset; + + +public class PostgressQuerySet extends QuerySet { +}