http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/parsers/xml/XMLParser.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/parsers/xml/XMLParser.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/parsers/xml/XMLParser.java deleted file mode 100644 index 4edc82c..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/parsers/xml/XMLParser.java +++ /dev/null @@ -1,100 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.parsers.xml; - -import org.apache.ambari.view.hive.client.Row; -import org.apache.ambari.view.hive.resources.uploads.parsers.ParseOptions; -import org.apache.ambari.view.hive.resources.uploads.parsers.Parser; -import org.apache.ambari.view.hive.resources.uploads.parsers.RowIterator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import java.io.IOException; -import java.io.Reader; -import java.util.Collection; -import java.util.Iterator; - -/** - * assumes XML of following format - * <table> - * <row> - * <col name="col1Name">row1-col1-Data</col> - * <col name="col2Name">row1-col2-Data</col> - * <col name="col3Name">row1-col3-Data</col> - * <col name="col4Name">row1-col4-Data</col> - * </row> - * <row> - * <col name="col1Name">row2-col1-Data</col> - * <col name="col2Name">row2-col2-Data</col> - * <col name="col3Name">row2-col3-Data</col> - * <col name="col4Name">row2-col4-Data</col> - * </row> - * </table> - */ -public class XMLParser extends Parser { - - protected final static Logger LOG = - LoggerFactory.getLogger(XMLParser.class); - - private RowIterator iterator; - private XMLEventReader xmlReader; - private XMLIterator xmlIterator; - - public XMLParser(Reader reader, ParseOptions parseOptions) throws IOException { - super(reader, parseOptions); - XMLInputFactory factory = XMLInputFactory.newInstance(); - try { - this.xmlReader = factory.createXMLEventReader(reader); - } catch (XMLStreamException e) { - LOG.error("error occurred while creating xml reader : ", e); - throw new IOException("error occurred while creating xml reader : ", e); - } - xmlIterator = new XMLIterator(this.xmlReader); - iterator = new RowIterator(xmlIterator); - } - - @Override - public Row extractHeader() { - Collection<String> headers = this.iterator.extractHeaders(); - Object[] objs = new Object[headers.size()]; - Iterator<String> iterator = headers.iterator(); - for (int i = 0; i < headers.size(); i++) { - objs[i] = iterator.next(); - } - - return new Row(objs); - } - - @Override - public void close() throws Exception { - try { - this.xmlReader.close(); - } catch (XMLStreamException e) { - throw new IOException(e); - } - } - - @Override - public Iterator<Row> iterator() { - return iterator; - } -}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/DeleteQueryInput.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/DeleteQueryInput.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/DeleteQueryInput.java deleted file mode 100644 index 1fe30fd..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/DeleteQueryInput.java +++ /dev/null @@ -1,48 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -public class DeleteQueryInput { - private String database; - private String table; - - public DeleteQueryInput() { - } - - public DeleteQueryInput(String database, String table) { - this.database = database; - this.table = table; - } - - public String getDatabase() { - return database; - } - - public void setDatabase(String database) { - this.database = database; - } - - public String getTable() { - return table; - } - - public void setTable(String table) { - this.table = table; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/InsertFromQueryInput.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/InsertFromQueryInput.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/InsertFromQueryInput.java deleted file mode 100644 index c568e0b..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/InsertFromQueryInput.java +++ /dev/null @@ -1,92 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -import org.apache.ambari.view.hive.resources.uploads.ColumnDescriptionImpl; - -import java.util.List; - -public class InsertFromQueryInput { - private String fromDatabase; - private String fromTable; - private String toDatabase; - private String toTable; - private List<ColumnDescriptionImpl> header; - private Boolean unhexInsert = Boolean.FALSE; - - public InsertFromQueryInput() { - } - - public InsertFromQueryInput(String fromDatabase, String fromTable, String toDatabase, String toTable, List<ColumnDescriptionImpl> header, Boolean unhexInsert) { - this.fromDatabase = fromDatabase; - this.fromTable = fromTable; - this.toDatabase = toDatabase; - this.toTable = toTable; - this.header = header; - this.unhexInsert = unhexInsert; - } - - public List<ColumnDescriptionImpl> getHeader() { - return header; - } - - public void setHeader(List<ColumnDescriptionImpl> header) { - this.header = header; - } - - public Boolean getUnhexInsert() { - return unhexInsert; - } - - public void setUnhexInsert(Boolean unhexInsert) { - this.unhexInsert = unhexInsert; - } - - public String getFromDatabase() { - return fromDatabase; - } - - public void setFromDatabase(String fromDatabase) { - this.fromDatabase = fromDatabase; - } - - public String getFromTable() { - return fromTable; - } - - public void setFromTable(String fromTable) { - this.fromTable = fromTable; - } - - public String getToDatabase() { - return toDatabase; - } - - public void setToDatabase(String toDatabase) { - this.toDatabase = toDatabase; - } - - public String getToTable() { - return toTable; - } - - public void setToTable(String toTable) { - this.toTable = toTable; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/LoadQueryInput.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/LoadQueryInput.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/LoadQueryInput.java deleted file mode 100644 index 122b754..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/LoadQueryInput.java +++ /dev/null @@ -1,67 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -/** - * input for QueryGenerator for generating Load From Query - */ -public class LoadQueryInput { - private String hdfsFilePath; - private String databaseName; - private String tableName; - - public LoadQueryInput(String hdfsFilePath, String databaseName, String tableName) { - this.hdfsFilePath = hdfsFilePath; - this.databaseName = databaseName; - this.tableName = tableName; - } - - public String getHdfsFilePath() { - return hdfsFilePath; - } - - public void setHdfsFilePath(String hdfsFilePath) { - this.hdfsFilePath = hdfsFilePath; - } - - public String getDatabaseName() { - return databaseName; - } - - public void setDatabaseName(String databaseName) { - this.databaseName = databaseName; - } - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - @Override - public String toString() { - return "LoadQueryInput{" + - "hdfsFilePath='" + hdfsFilePath + '\'' + - ", databaseName='" + databaseName + '\'' + - ", tableName='" + tableName + '\'' + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/QueryGenerator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/QueryGenerator.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/QueryGenerator.java deleted file mode 100644 index 6db89e0..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/QueryGenerator.java +++ /dev/null @@ -1,142 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -import org.apache.ambari.view.hive.client.ColumnDescription; -import org.apache.ambari.view.hive.resources.uploads.ColumnDescriptionImpl; -import org.apache.ambari.view.hive.resources.uploads.HiveFileType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * generates the sql query from given data - */ -public class QueryGenerator { - protected final static Logger LOG = - LoggerFactory.getLogger(QueryGenerator.class); - - public String generateCreateQuery(TableInfo tableInfo) { - String tableName = tableInfo.getTableName(); - List<ColumnDescriptionImpl> cdList = tableInfo.getHeader(); - - StringBuilder query = new StringBuilder(); - query.append("CREATE TABLE ").append(tableName).append(" ("); - Collections.sort(cdList, new Comparator<ColumnDescription>() { - @Override - public int compare(ColumnDescription o1, ColumnDescription o2) { - return o1.getPosition() - o2.getPosition(); - } - }); - - boolean first = true; - for (ColumnDescriptionImpl cd : cdList) { - if (first) { - first = false; - } else { - query.append(", "); - } - - query.append(cd.getName()).append(" ").append(cd.getType()); - if (cd.getPrecision() != null) { - query.append("(").append(cd.getPrecision()); - if (cd.getScale() != null) { - query.append(",").append(cd.getScale()); - } - query.append(")"); - } - - } - - query.append(")"); - - if(tableInfo.getHiveFileType().equals(HiveFileType.TEXTFILE)) { - query.append(getRowFormatQuery(tableInfo.getRowFormat())); - } - query.append(" STORED AS ").append(tableInfo.getHiveFileType().toString()); - String queryString = query.append(";").toString(); - LOG.info("Query : {}", queryString); - return queryString; - } - - private String getRowFormatQuery(RowFormat rowFormat) { - StringBuilder sb = new StringBuilder(); - if(rowFormat != null) { - sb.append(" ROW FORMAT DELIMITED"); - if(rowFormat.getFieldsTerminatedBy() != null ){ - sb.append(" FIELDS TERMINATED BY '").append(rowFormat.getFieldsTerminatedBy()).append('\''); - } - if(rowFormat.getEscapedBy() != null){ - String escape = String.valueOf(rowFormat.getEscapedBy()); - if(rowFormat.getEscapedBy() == '\\'){ - escape = escape + '\\'; // special handling of slash as its escape char for strings in hive as well. - } - sb.append(" ESCAPED BY '").append(escape).append('\''); - } - } - - return sb.toString(); - } - - public String generateInsertFromQuery(InsertFromQueryInput ifqi) { - StringBuilder insertQuery = new StringBuilder("INSERT INTO TABLE ").append(ifqi.getToDatabase()).append(".") - .append(ifqi.getToTable()).append(" SELECT "); - - boolean first = true; - for(ColumnDescriptionImpl column : ifqi.getHeader()){ - String type = column.getType(); - boolean unhex = ifqi.getUnhexInsert() && ( - ColumnDescription.DataTypes.STRING.toString().equals(type) - || ColumnDescription.DataTypes.VARCHAR.toString().equals(type) - || ColumnDescription.DataTypes.CHAR.toString().equals(type) - ); - - if(!first){ - insertQuery.append(", "); - } - - if(unhex) { - insertQuery.append("UNHEX("); - } - - insertQuery.append(column.getName()); - - if(unhex) { - insertQuery.append(")"); - } - - first = false; - } - - insertQuery.append(" FROM ").append(ifqi.getFromDatabase()).append(".").append(ifqi.getFromTable()).append(";"); - String query = insertQuery.toString(); - LOG.info("Insert Query : {}", query); - return query; - } - - public String generateDropTableQuery(DeleteQueryInput deleteQueryInput) { - String dropQuery = new StringBuilder("DROP TABLE ").append(deleteQueryInput.getDatabase()) - .append(".").append(deleteQueryInput.getTable()).append(";").toString(); - LOG.info("Drop Query : {}", dropQuery); - return dropQuery; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/RowFormat.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/RowFormat.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/RowFormat.java deleted file mode 100644 index 4c1cb2b..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/RowFormat.java +++ /dev/null @@ -1,57 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -public class RowFormat { - private Character fieldsTerminatedBy; - private Character escapedBy; - - private RowFormat() { - } - - public RowFormat(Character fieldsTerminatedBy, Character escapedBy) { - this.fieldsTerminatedBy = fieldsTerminatedBy; - this.escapedBy = escapedBy; - } - - public Character getFieldsTerminatedBy() { - return fieldsTerminatedBy; - } - - public void setFieldsTerminatedBy(Character fieldsTerminatedBy) { - this.fieldsTerminatedBy = fieldsTerminatedBy; - } - - public Character getEscapedBy() { - return escapedBy; - } - - public void setEscapedBy(Character escapedBy) { - this.escapedBy = escapedBy; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("RowFormat{ fieldsTerminatedBy='"); - sb.append(fieldsTerminatedBy).append( '\'').append(", escapedBy='") - .append(escapedBy).append("\'}"); - - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/TableInfo.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/TableInfo.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/TableInfo.java deleted file mode 100644 index 76f448c..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/query/TableInfo.java +++ /dev/null @@ -1,96 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.hive.resources.uploads.query; - -import org.apache.ambari.view.hive.resources.uploads.ColumnDescriptionImpl; -import org.apache.ambari.view.hive.resources.uploads.HiveFileType; - -import java.io.Serializable; -import java.util.List; - -/** - * used as input in Query generation - */ -public class TableInfo implements Serializable{ - private String tableName; - private String databaseName; - private List<ColumnDescriptionImpl> header; - private HiveFileType hiveFileType; - - private RowFormat rowFormat; - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public String getDatabaseName() { - return databaseName; - } - - public void setDatabaseName(String databaseName) { - this.databaseName = databaseName; - } - - public List<ColumnDescriptionImpl> getHeader() { - return header; - } - - public void setHeader(List<ColumnDescriptionImpl> header) { - this.header = header; - } - - public HiveFileType getHiveFileType() { - return hiveFileType; - } - - public void setHiveFileType(HiveFileType hiveFileType) { - this.hiveFileType = hiveFileType; - } - - public RowFormat getRowFormat() { - return rowFormat; - } - - public void setRowFormat(RowFormat rowFormat) { - this.rowFormat = rowFormat; - } - - public TableInfo(String databaseName, String tableName, List<ColumnDescriptionImpl> header, HiveFileType hiveFileType, RowFormat rowFormat) { - this.databaseName = databaseName; - this.tableName = tableName; - this.header = header; - this.hiveFileType = hiveFileType; - this.rowFormat = rowFormat; - } - - public TableInfo(TableInfo tableInfo) { - this.tableName = tableInfo.tableName; - this.databaseName = tableInfo.databaseName; - this.header = tableInfo.header; - this.hiveFileType = tableInfo.hiveFileType; - this.rowFormat = tableInfo.rowFormat; - } - - public TableInfo() { - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/BadRequestFormattedException.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/BadRequestFormattedException.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/BadRequestFormattedException.java deleted file mode 100644 index 0641af1..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/BadRequestFormattedException.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.ambari.view.hive.utils; - -public class BadRequestFormattedException extends ServiceFormattedException { - private final static int STATUS = 400; - - public BadRequestFormattedException(String message, Throwable exception) { - super(message, exception, STATUS); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/FilePaginator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/FilePaginator.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/FilePaginator.java deleted file mode 100644 index eb1a401..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/FilePaginator.java +++ /dev/null @@ -1,127 +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.ambari.view.hive.utils; - -import org.apache.ambari.view.utils.hdfs.HdfsApi; -import org.apache.hadoop.fs.FSDataInputStream; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Arrays; - -import static java.lang.Math.ceil; - -/** - * Pagination for HDFS file implementation - */ -public class FilePaginator { - public static int MB = 1024*1024; - public static int PAGE_SIZE = 1*MB; - - private String filePath; - private HdfsApi hdfsApi; - - /** - * Constructor - * @param filePath Path to file on HDFS - * @param hdfsApi hdfs api - */ - public FilePaginator(String filePath, HdfsApi hdfsApi) { - this.filePath = filePath; - this.hdfsApi = hdfsApi; - } - - /** - * Set page size - * @param PAGE_SIZE size - */ - public static void setPageSize(int PAGE_SIZE) { - FilePaginator.PAGE_SIZE = PAGE_SIZE; - } - - /** - * Get page count - * @return page count - * @throws java.io.IOException - * @throws InterruptedException - */ - public long pageCount() throws IOException, InterruptedException { - return (long) - ceil( hdfsApi.getFileStatus(filePath).getLen() / ((double)PAGE_SIZE) ); - } - - /** - * Read one page of size PAGE_SIZE - * @param page page index - * @return data in UTF-8 - * @throws java.io.IOException - * @throws InterruptedException - */ - public String readPage(long page) throws IOException, InterruptedException { - FSDataInputStream stream = hdfsApi.open(filePath); - try { - stream.seek(page * PAGE_SIZE); - } catch (IOException e) { - throw new IllegalArgumentException("Page " + page + " does not exists"); - } - - byte[] buffer = new byte[PAGE_SIZE]; - int readCount = 0; - int read = 0; - while(read < PAGE_SIZE) { - try { - readCount = stream.read(buffer, read, PAGE_SIZE-read); - } catch (IOException e) { - stream.close(); - throw e; - } - if (readCount == -1) - break; - read += readCount; - } - if (read != 0) { - byte[] readData = Arrays.copyOfRange(buffer, 0, read); - return new String(readData, Charset.forName("UTF-8")); - } else { - if (page == 0) { - return ""; - } - throw new IllegalArgumentException("Page " + page + " does not exists"); - } - } - - public String readFull(long sizeLimit) throws IOException, InterruptedException { - StringBuilder builder = new StringBuilder(); - int i = 0; - while (true) { - try { - builder.append(readPage(i++)); - } catch (IllegalArgumentException ex) { - break; - } - if (sizeLimit != -1 && (i+1)*PAGE_SIZE > sizeLimit) - break; - } - return builder.toString(); - } - - public String readFull() throws IOException, InterruptedException { - return readFull(-1); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/HiveClientFormattedException.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/HiveClientFormattedException.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/HiveClientFormattedException.java deleted file mode 100644 index a602d22..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/HiveClientFormattedException.java +++ /dev/null @@ -1,26 +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.ambari.view.hive.utils; - -public class HiveClientFormattedException extends ServiceFormattedException { - - public HiveClientFormattedException(Throwable exception) { - super(exception.getMessage(), exception); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/MisconfigurationFormattedException.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/MisconfigurationFormattedException.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/MisconfigurationFormattedException.java deleted file mode 100644 index 314b00b..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/MisconfigurationFormattedException.java +++ /dev/null @@ -1,47 +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.ambari.view.hive.utils; - -import org.json.simple.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.HashMap; - -public class MisconfigurationFormattedException extends WebApplicationException { - private final static int STATUS = 500; - private final static String message = "Parameter \"%s\" is set to null"; - private final static Logger LOG = - LoggerFactory.getLogger(MisconfigurationFormattedException.class); - - public MisconfigurationFormattedException(String name) { - super(errorEntity(name)); - } - - protected static Response errorEntity(String name) { - HashMap<String, Object> response = new HashMap<String, Object>(); - response.put("message", String.format(message, name)); - response.put("trace", null); - response.put("status", STATUS); - return Response.status(STATUS).entity(new JSONObject(response)).type(MediaType.APPLICATION_JSON).build(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/NotFoundFormattedException.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/NotFoundFormattedException.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/NotFoundFormattedException.java deleted file mode 100644 index 91b11cf..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/NotFoundFormattedException.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.ambari.view.hive.utils; - -public class NotFoundFormattedException extends ServiceFormattedException { - private final static int STATUS = 404; - - public NotFoundFormattedException(String message, Throwable exception) { - super(message, exception, STATUS); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/ServiceFormattedException.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/ServiceFormattedException.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/ServiceFormattedException.java deleted file mode 100644 index d057cdb..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/ServiceFormattedException.java +++ /dev/null @@ -1,107 +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.ambari.view.hive.utils; - -import org.apache.ambari.view.hive.client.HiveInvalidQueryException; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.json.simple.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.security.AccessControlException; -import java.util.HashMap; - -public class ServiceFormattedException extends WebApplicationException { - private final static Logger LOG = - LoggerFactory.getLogger(ServiceFormattedException.class); - - public ServiceFormattedException(String message) { - super(errorEntity(message, null, suggestStatus(null), null)); - } - - public ServiceFormattedException(Throwable exception) { - super(errorEntity(null, exception, suggestStatus(exception), null)); - } - - public ServiceFormattedException(String message, Throwable exception) { - super(errorEntity(message, exception, suggestStatus(exception), null)); - } - - public ServiceFormattedException(String message, Throwable exception, int status) { - super(errorEntity(message, exception, status, null)); - } - - public ServiceFormattedException(String message, Exception ex, String curl) { - super(errorEntity(message, ex, suggestStatus(ex), curl)); - } - - private static int suggestStatus(Throwable exception) { - int status = 500; - if (exception == null) { - return status; - } - if (exception instanceof AccessControlException) { - status = 403; - } - if (exception instanceof HiveInvalidQueryException) { - status = 400; - } - return status; - } - - protected static Response errorEntity(String message, Throwable e, int status, String header) { - HashMap<String, Object> response = new HashMap<String, Object>(); - - String trace = null; - - response.put("message", message); - if (e != null) { - trace = e.toString() + "\n\n"; - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - trace += sw.toString(); - - if (message == null) { - String innerMessage = e.getMessage(); - String autoMessage; - - if (innerMessage != null) - autoMessage = String.format("E090 %s [%s]", innerMessage, e.getClass().getSimpleName()); - else - autoMessage = "E090 " + e.getClass().getSimpleName(); - response.put("message", autoMessage); - } - } - response.put("trace", trace); - response.put("status", status); - - if(message != null && status != 400) LOG.error(message); - if(trace != null && status != 400) LOG.error(trace); - - Response.ResponseBuilder responseBuilder = Response.status(status).entity(new JSONObject(response)).type(MediaType.APPLICATION_JSON); - if (header != null) - responseBuilder.header("X-INFO", header); - return responseBuilder.build(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/SharedObjectsFactory.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/SharedObjectsFactory.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/SharedObjectsFactory.java deleted file mode 100644 index 45f2fbf..0000000 --- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/utils/SharedObjectsFactory.java +++ /dev/null @@ -1,187 +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.ambari.view.hive.utils; - -import org.apache.ambari.view.ViewContext; -import org.apache.ambari.view.hive.client.Connection; -import org.apache.ambari.view.hive.persistence.IStorageFactory; -import org.apache.ambari.view.hive.persistence.Storage; -import org.apache.ambari.view.hive.persistence.utils.StorageFactory; -import org.apache.ambari.view.hive.resources.jobs.OperationHandleControllerFactory; -import org.apache.ambari.view.hive.resources.jobs.atsJobs.ATSParser; -import org.apache.ambari.view.hive.resources.jobs.atsJobs.ATSParserFactory; -import org.apache.ambari.view.hive.resources.jobs.rm.RMParser; -import org.apache.ambari.view.hive.resources.jobs.rm.RMParserFactory; -import org.apache.ambari.view.hive.resources.jobs.viewJobs.IJobControllerFactory; -import org.apache.ambari.view.hive.resources.jobs.viewJobs.JobControllerFactory; -import org.apache.ambari.view.hive.resources.savedQueries.SavedQueryResourceManager; -import org.apache.ambari.view.utils.hdfs.HdfsApi; -import org.apache.ambari.view.utils.hdfs.HdfsApiException; -import org.apache.ambari.view.utils.hdfs.HdfsUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Generates shared connections. Clients with same tag will get the same connection. - * e.g. user 'admin' using view instance 'HIVE1' will use one connection, another user - * will use different connection. - */ -public class SharedObjectsFactory implements IStorageFactory { - protected final static Logger LOG = - LoggerFactory.getLogger(SharedObjectsFactory.class); - - private ViewContext context; - private final IStorageFactory storageFactory; - private final ATSParserFactory atsParserFactory; - private final RMParserFactory rmParserFactory; - - private static final Map<Class, Map<String, Object>> localObjects = new ConcurrentHashMap<Class, Map<String, Object>>(); - - public SharedObjectsFactory(ViewContext context) { - this.context = context; - this.storageFactory = new StorageFactory(context); - this.atsParserFactory = new ATSParserFactory(context); - this.rmParserFactory = new RMParserFactory(context); - - synchronized (localObjects) { - if (localObjects.size() == 0) { - localObjects.put(OperationHandleControllerFactory.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(Storage.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(IJobControllerFactory.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(ATSParser.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(SavedQueryResourceManager.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(HdfsApi.class, new ConcurrentHashMap<String, Object>()); - localObjects.put(RMParser.class, new ConcurrentHashMap<String, Object>()); - } - } - } - - // ============================= - - public OperationHandleControllerFactory getOperationHandleControllerFactory() { - if (!localObjects.get(OperationHandleControllerFactory.class).containsKey(getTagName())) - localObjects.get(OperationHandleControllerFactory.class).put(getTagName(), new OperationHandleControllerFactory(context, this)); - return (OperationHandleControllerFactory) localObjects.get(OperationHandleControllerFactory.class).get(getTagName()); - } - - // ============================= - @Override - public Storage getStorage() { - if (!localObjects.get(Storage.class).containsKey(getTagName())) - localObjects.get(Storage.class).put(getTagName(), storageFactory.getStorage()); - return (Storage) localObjects.get(Storage.class).get(getTagName()); - } - - // ============================= - public IJobControllerFactory getJobControllerFactory() { - if (!localObjects.get(IJobControllerFactory.class).containsKey(getTagName())) - localObjects.get(IJobControllerFactory.class).put(getTagName(), new JobControllerFactory(context, this)); - return (IJobControllerFactory) localObjects.get(IJobControllerFactory.class).get(getTagName()); - } - - // ============================= - - public SavedQueryResourceManager getSavedQueryResourceManager() { - if (!localObjects.get(SavedQueryResourceManager.class).containsKey(getTagName())) - localObjects.get(SavedQueryResourceManager.class).put(getTagName(), new SavedQueryResourceManager(context, this)); - return (SavedQueryResourceManager) localObjects.get(SavedQueryResourceManager.class).get(getTagName()); - } - - // ============================= - public ATSParser getATSParser() { - if (!localObjects.get(ATSParser.class).containsKey(getTagName())) - localObjects.get(ATSParser.class).put(getTagName(), atsParserFactory.getATSParser()); - return (ATSParser) localObjects.get(ATSParser.class).get(getTagName()); - } - - // ============================= - public RMParser getRMParser() { - if (!localObjects.get(RMParser.class).containsKey(getTagName())) - localObjects.get(RMParser.class).put(getTagName(), rmParserFactory.getRMParser()); - return (RMParser) localObjects.get(RMParser.class).get(getTagName()); - } - - // ============================= - public HdfsApi getHdfsApi() { - if (!localObjects.get(HdfsApi.class).containsKey(getTagName())) { - try { - localObjects.get(HdfsApi.class).put(getTagName(), HdfsUtil.connectToHDFSApi(context)); - } catch (HdfsApiException e) { - String message = "F060 Couldn't open connection to HDFS"; - LOG.error(message); - throw new ServiceFormattedException(message, e); - } - } - return (HdfsApi) localObjects.get(HdfsApi.class).get(getTagName()); - } - - /** - * Generates tag name. Clients with same tag will share one connection. - * @return tag name - */ - public String getTagName() { - if (context == null) - return "<null>"; - return String.format("%s:%s", context.getInstanceName(), context.getUsername()); - } - - /** - * For testing purposes, ability to substitute some local object - */ - public void setInstance(Class clazz, Object object) { - localObjects.get(clazz).put(getTagName(), object); - } - - /** - * For testing purposes, ability to clear all local objects of particular class - */ - public void clear(Class clazz) { - localObjects.get(clazz).clear(); - } - - /** - * For testing purposes, ability to clear all connections - */ - public void clear() { - for(Map<String, Object> map : localObjects.values()) { - map.clear(); - } - } - - /** - * - * Drops all objects for give instance name. - * - * @param instanceName - */ - public static void dropInstanceCache(String instanceName){ - for(Map<String,Object> cache : localObjects.values()){ - for(Iterator<Map.Entry<String, Object>> it = cache.entrySet().iterator(); it.hasNext();){ - Map.Entry<String, Object> entry = it.next(); - if(entry.getKey().startsWith(instanceName+":")){ - it.remove(); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.bowerrc ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.bowerrc b/contrib/views/hive/src/main/resources/ui/hive-web/.bowerrc deleted file mode 100644 index 959e169..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.bowerrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "directory": "bower_components", - "analytics": false -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.editorconfig ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.editorconfig b/contrib/views/hive/src/main/resources/ui/hive-web/.editorconfig deleted file mode 100644 index 47c5438..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.editorconfig +++ /dev/null @@ -1,34 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -root = true - - -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -indent_style = space -indent_size = 2 - -[*.js] -indent_style = space -indent_size = 2 - -[*.hbs] -insert_final_newline = false -indent_style = space -indent_size = 2 - -[*.css] -indent_style = space -indent_size = 2 - -[*.html] -indent_style = space -indent_size = 2 - -[*.{diff,md}] -trim_trailing_whitespace = false http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.ember-cli ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.ember-cli b/contrib/views/hive/src/main/resources/ui/hive-web/.ember-cli deleted file mode 100644 index 3da2738..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.ember-cli +++ /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. - */ - -{ - /** - Ember CLI sends analytics information by default. The data is completely - anonymous, but there are times when you might want to disable this behavior. - - Setting `disableAnalytics` to true will prevent any data from being sent. - */ - "disableAnalytics": true -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.gitignore ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.gitignore b/contrib/views/hive/src/main/resources/ui/hive-web/.gitignore deleted file mode 100644 index e1b6b28..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -# Numerous always-ignore extensions -*.diff -*.err -*.orig -*.log -*.rej -*.swo -*.swp -*.vi -*~ -*.sass-cache - -# OS or Editor folders -.DS_Store -.cache -.project -.settings -.tmproj -dist -nbproject -Thumbs.db - -# NPM packages folder. -node_modules/ - -bower_components/ - -node/ - -# Brunch folder for temporary files. -tmp/ - -public/ - -_generators/ - -coverage.json http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.jshintrc ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.jshintrc b/contrib/views/hive/src/main/resources/ui/hive-web/.jshintrc deleted file mode 100644 index 0195538..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.jshintrc +++ /dev/null @@ -1,33 +0,0 @@ -{ - "predef": [ - "document", - "window", - "-Promise", - "d3" - ], - "browser" : true, - "boss" : true, - "curly": true, - "debug": false, - "devel": true, - "eqeqeq": false, - "evil": true, - "forin": false, - "immed": false, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": false, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": false, - "eqnull": true, - "esnext": true, - "unused": true -} http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/.travis.yml ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/.travis.yml b/contrib/views/hive/src/main/resources/ui/hive-web/.travis.yml deleted file mode 100644 index 5d96e28..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/.travis.yml +++ /dev/null @@ -1,38 +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. - ---- -language: node_js -node_js: - - "0.12" - -sudo: false - -cache: - directories: - - node_modules - -before_install: - - "npm config set spin false" - - "npm install -g npm@^2" - -install: - - npm install -g bower - - npm install - - bower install - -script: - - npm test http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/Brocfile.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/Brocfile.js b/contrib/views/hive/src/main/resources/ui/hive-web/Brocfile.js deleted file mode 100644 index 318d1f8..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/Brocfile.js +++ /dev/null @@ -1,54 +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. - */ - -/* global require, module */ - -var EmberApp = require('ember-cli/lib/broccoli/ember-app'); - -var app = new EmberApp({ - autoprefixer: { - browsers: ['last 3 version'] - }, - 'ember-cli-selectize': { - //valid values are `default`, `bootstrap2`, `bootstrap3` or false - 'theme': 'bootstrap3' - }, - vendorFiles: { - 'handlebars.js': null - }, - hinting: false -}); - -app.import('bower_components/ember/ember-template-compiler.js'); -app.import('bower_components/bootstrap/dist/js/bootstrap.js'); -app.import('bower_components/bootstrap/dist/css/bootstrap.css'); -app.import('bower_components/bootstrap/dist/css/bootstrap.css.map', { - destDir: 'assets' -}); - -app.import('bower_components/ember-i18n/lib/i18n.js'); -app.import('bower_components/ember-i18n/lib/i18n-plurals.js'); - -app.import('vendor/codemirror/codemirror-min.js'); -app.import('vendor/codemirror/sql-hint.js'); -app.import('vendor/codemirror/show-hint.js'); -app.import('vendor/codemirror/codemirror.css'); -app.import('vendor/codemirror/show-hint.css'); -app.import('vendor/dagre.min.js'); - -module.exports = app.toTree(); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/README.md ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/README.md b/contrib/views/hive/src/main/resources/ui/hive-web/README.md deleted file mode 100644 index 2237863..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/README.md +++ /dev/null @@ -1,14 +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](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. ---> http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/application.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/application.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/application.js deleted file mode 100644 index 2c68b89..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/application.js +++ /dev/null @@ -1,54 +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. - */ - -import DS from 'ember-data'; -import Ember from 'ember'; -import constants from 'hive/utils/constants'; - -export default DS.RESTAdapter.extend({ - - init: function() { - Ember.$.ajaxSetup({ - cache: false - }) - }, - - headers: { - 'X-Requested-By': 'ambari', - 'Content-Type': 'application/json' - //,'Authorization': 'Basic YWRtaW46YWRtaW4=' - }, - - buildURL: function () { - var version = constants.adapter.version, - instanceName = constants.adapter.instance; - - var params = window.location.pathname.split('/').filter(function (param) { - return !!param; - }); - - if (params[params.length - 3] === 'HIVE') { - version = params[params.length - 2]; - instanceName = params[params.length - 1]; - } - - var prefix = constants.adapter.apiPrefix + version + constants.adapter.instancePrefix + instanceName; - var url = this._super.apply(this, arguments); - return prefix + url; - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/database.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/database.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/database.js deleted file mode 100644 index cdbd43b..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/database.js +++ /dev/null @@ -1,25 +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. - */ - -import application from './application'; - -export default application.extend({ - pathForType: function (type) { - return 'resources/ddl/' + type; - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file-upload.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file-upload.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file-upload.js deleted file mode 100644 index 7bb6e0b..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file-upload.js +++ /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. - */ - -import EmberUploader from 'ember-uploader'; -import Ember from 'ember'; - -export default EmberUploader.Uploader.extend({ - headers: {}, - - // Override - _ajax: function(settings) { - settings = Ember.merge(settings, this.getProperties('headers')); - return this._super(settings); - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file.js deleted file mode 100644 index 47894c1..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/file.js +++ /dev/null @@ -1,26 +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. - */ - -import application from './application'; -import constants from 'hive/utils/constants'; - -export default application.extend({ - pathForType: function (type) { - return constants.adapter.resourcePrefix + type; - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/upload-table.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/upload-table.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/upload-table.js deleted file mode 100644 index 76fce50..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/adapters/upload-table.js +++ /dev/null @@ -1,89 +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. - */ - -import EmberUploader from 'ember-uploader'; -import Ember from 'ember'; -import application from './application'; -import FileUploader from './file-upload'; - -export default application.extend({ - - buildUploadURL: function (path) { - return this.buildURL() + "/resources/upload/" + path; - }, - - uploadFiles: function (path, files, extras) { - var uploadUrl = this.buildUploadURL(path); - - console.log("uplaoder : uploadURL : ", uploadUrl, " extras : ", extras , "files : ", files); - - var hdrs = Ember.$.extend(true, {},this.get('headers')); - delete hdrs['Content-Type']; - var uploader = FileUploader.create({ - headers: hdrs, - url: uploadUrl - }); - - if (!Ember.isEmpty(files)) { - var promise = uploader.upload(files[0], extras); - return promise; - } - }, - - createTable: function (tableData) { - console.log("creating table with data :", tableData); - return this.doPost("createTable",tableData); - }, - - insertIntoTable: function(insertData){ - console.log("inserting into table with data : ", insertData); - return this.doPost("insertIntoTable",insertData); - }, - - deleteTable: function(deleteData){ - console.log("delete table with info : ", deleteData); - return this.doPost("deleteTable",deleteData); - }, - - doPost : function(path,inputData){ - var self = this; - return new Ember.RSVP.Promise(function(resolve,reject){ - Ember.$.ajax({ - url : self.buildUploadURL(path), - type : 'post', - data: JSON.stringify(inputData), - headers: self.get('headers'), - dataType : 'json' - }).done(function(data) { - resolve(data); - }).fail(function(error) { - reject(error); - }); - }); - }, - - previewFromHDFS : function(previewFromHdfsData){ - console.log("preview from hdfs with info : ", previewFromHdfsData); - return this.doPost("previewFromHdfs",previewFromHdfsData) - }, - - uploadFromHDFS : function(uploadFromHdfsData){ - console.log("upload from hdfs with info : ", uploadFromHdfsData); - return this.doPost("uploadFromHDFS",uploadFromHdfsData) - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/app.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/app.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/app.js deleted file mode 100644 index f35a5a3..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/app.js +++ /dev/null @@ -1,34 +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. - */ - -import Ember from 'ember'; -import Resolver from 'ember/resolver'; -import loadInitializers from 'ember/load-initializers'; -import config from './config/environment'; - -Ember.MODEL_FACTORY_INJECTIONS = true; - -var App = Ember.Application.extend({ - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix, - Resolver: Resolver -}); - -loadInitializers(App, config.modulePrefix); - -export default App; http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/.gitkeep ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/.gitkeep b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/.gitkeep deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/alert-message-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/alert-message-widget.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/alert-message-widget.js deleted file mode 100644 index 565d93d..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/alert-message-widget.js +++ /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. - */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - actions: { - remove: function () { - this.sendAction('removeMessage', this.get('message')); - }, - - toggleMessage: function () { - this.toggleProperty('message.isExpanded'); - - if (!this.get('message.isExpanded')) { - this.sendAction('removeLater', this.get('message')); - } - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/collapsible-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/collapsible-widget.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/collapsible-widget.js deleted file mode 100644 index eb174ab..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/collapsible-widget.js +++ /dev/null @@ -1,38 +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. - */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'collapsible', - - actions: { - toggle: function () { - this.toggleProperty('isExpanded'); - - if (this.get('isExpanded')) { - this.sendAction('expanded', this.get('heading'), this.get('toggledParam')); - } - }, - - sendControlAction: function (action) { - this.set('controlAction', action); - this.sendAction('controlAction', this.get('heading'), this.get('toggledParam')); - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/column-filter-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/column-filter-widget.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/column-filter-widget.js deleted file mode 100644 index 461dabe..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/column-filter-widget.js +++ /dev/null @@ -1,56 +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. - */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'column-filter', - - didInsertElement: function () { - if (this.get('filterValue')) { - this.send('sendFilter'); - } - }, - - isSorted: (function () { - var sortProperties = this.get('sortProperties'); - - if (sortProperties) { - return sortProperties[0] === this.get('column.property'); - } else { - return false; - } - }).property('sortProperties'), - - actions: { - sendSort: function () { - this.sendAction('columnSorted', this.get('column.property')); - }, - - sendFilter: function (params) { - if (params && (params.from || params.from === 0) && (params.to || params.to === 0)) { - this.set('filterValue', Ember.Object.create({ - min: params.from, - max: params.to - })); - } - - this.sendAction('columnFiltered', this.get('column.property'), this.get('filterValue')); - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/date-range-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/date-range-widget.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/date-range-widget.js deleted file mode 100644 index 8e9c074..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/date-range-widget.js +++ /dev/null @@ -1,98 +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. - */ - - /* globals moment */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - displayFromDate: function () { - return moment(this.get('dateRange.from')).format('MM/DD/YYYY'); - }.property('dateRange.from'), - - displayToDate: function () { - return moment(this.get('dateRange.to')).format('MM/DD/YYYY'); - }.property('dateRange.to'), - - updateMinDate: function () { - if (this.get('rendered')) { - this.$('.toDate').datepicker("option", "minDate", new Date(this.get('dateRange.from'))); - } - }.observes('dateRange.from'), - - updateMaxDate: function () { - if (this.get('rendered')) { - this.$('.fromDate').datepicker("option", "maxDate", new Date(this.get('dateRange.to'))); - } - }.observes('dateRange.to'), - - didInsertElement: function () { - var self = this; - var dateRange = this.get('dateRange'); - - if (!dateRange.get('min') && !dateRange.get('max')) { - dateRange.set('max', new Date()); - } - - if (!dateRange.get('from') && !dateRange.get('to')) { - dateRange.set('from', dateRange.get('min')); - dateRange.set('to', dateRange.get('max')); - } - - this.$(".fromDate").datepicker({ - defaultDate: new Date(dateRange.get("from")), - maxDate: new Date(dateRange.get('to')), - - onSelect: function (selectedDate) { - self.$(".toDate").datepicker("option", "minDate", selectedDate); - - dateRange.set('from', new Date(selectedDate).getTime()); - self.sendAction('rangeChanged', dateRange); - } - }); - - this.$(".toDate").datepicker({ - defaultDate: new Date(dateRange.get('to')), - - minDate: new Date(dateRange.get('from')), - - onSelect: function (selectedDate) { - selectedDate += ' 23:59'; - - self.$(".fromDate").datepicker("option", "maxDate", selectedDate); - - dateRange.set('to', new Date(selectedDate).getTime()); - self.sendAction('rangeChanged', dateRange); - } - }); - - this.$(".fromDate").on('blur', function() { - if(moment(self.$(".fromDate").val(), 'MM/DD/YYYY', true).format() === 'Invalid date'){ - self.$(".fromDate").val('') - } - }); - - this.$(".toDate").on('blur', function() { - if(moment(self.$(".toDate").val(), 'MM/DD/YYYY', true).format() === 'Invalid date'){ - self.$(".toDate").val('') - } - }); - - this.set('rendered', true); - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/expander-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/expander-widget.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/expander-widget.js deleted file mode 100644 index 12da9ea..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/expander-widget.js +++ /dev/null @@ -1,36 +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. - */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'expander', - - didInsertElement: function () { - if (this.get('isExpanded')) { - this.$('.accordion-body').toggle(); - } - }, - - actions: { - toggle: function () { - this.toggleProperty('isExpanded'); - this.$('.accordion-body').toggle(200); - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/extended-input.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/extended-input.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/extended-input.js deleted file mode 100644 index 9b30201..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/extended-input.js +++ /dev/null @@ -1,50 +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. - */ - -import Ember from 'ember'; - -export default Ember.TextField.extend(Ember.I18n.TranslateableProperties, { - didInsertElement: function () { - var dynamicValue = this.get('dynamicValue'); - var dynamicContext = this.get('dynamicContext'); - - if (dynamicValue && dynamicContext) { - this.set('value', dynamicContext.get(dynamicValue)); - } - }, - - sendValueChanged: function () { - var dynamicValue = this.get('dynamicValue'); - var dynamicContext = this.get('dynamicContext'); - - if (dynamicValue && dynamicContext) { - dynamicContext.set(dynamicValue, this.get('value')); - } - - this.sendAction('valueChanged', this.get('value')); - }, - - keyUp: function (e) { - //if user has pressed enter - if (e.keyCode === 13) { - this.sendAction('valueSearched', this.get('value')); - } else { - Ember.run.debounce(this, this.get('sendValueChanged'), 300); - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/e423a65e/contrib/views/hive/src/main/resources/ui/hive-web/app/components/file-upload.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/file-upload.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/file-upload.js deleted file mode 100644 index 5dc7746..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/file-upload.js +++ /dev/null @@ -1,34 +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. - */ - -import EmberUploader from 'ember-uploader'; - -export default EmberUploader.FileField.extend({ - onChangeUploadFiles : function(){ - if(!this.get("uploadFiles")){ - // files were cleared by the controller so clear here as well. - this.set("files"); - this.set("value"); - } - }.observes("uploadFiles"), - filesDidChange: function(files) { - if( files ) { - this.sendAction('filesUploaded', files); // sends this action to controller. - } - } -});
