http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTable.java deleted file mode 100644 index 9734c7a..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTable.java +++ /dev/null @@ -1,620 +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.oozie.tools.workflowgenerator.client.property; - -import java.util.ArrayList; -import java.util.List; -import org.apache.oozie.tools.workflowgenerator.client.OozieDiagramController; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.EmailActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.FSActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.JavaActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.MapReduceActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.PigActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.PipesActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.SSHActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.ShellActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.StreamingActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.SubWFActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.DecisionNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.EndNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.ForkNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.JoinNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.KillNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.StartNodeWidget; -import com.google.gwt.cell.client.ButtonCell; -import com.google.gwt.cell.client.FieldUpdater; -import com.google.gwt.cell.client.SelectionCell; -import com.google.gwt.cell.client.TextInputCell; -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.cellview.client.CellTable; -import com.google.gwt.user.cellview.client.Column; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HasHorizontalAlignment; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.ScrollPanel; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.view.client.ListDataProvider; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; -import com.google.gwt.xml.client.Text; - -/** - * Base abstract class for property table; - */ -public abstract class PropertyTable extends ScrollPanel { - - protected NodeWidget current; - protected TextBox name; - protected ListBox okVal; - protected ListBox errorVal; - protected TextBox jt; - protected TextBox nn; - protected List<NodeWidget> widgetDropDown; - protected HandlerRegistration handler; - protected Grid grid; - - /** - * Constructor which records node widget - * - * @param w node widget - */ - public PropertyTable(NodeWidget w) { - super(); - this.current = w; - } - - /** - * Update a list of other node widgets shown in "OK" drop-down, excluding - * start and kill nodes - */ - public void updateWidgetDropDown() { - - List<NodeWidget> widgetList = current.getGenerator().getWidgets(); - OozieDiagramController controller = current.getController(); - - if (widgetDropDown == null) { - widgetDropDown = new ArrayList<NodeWidget>(); - } - else { - widgetDropDown.clear(); - } - - if (widgetList != null) { - for (NodeWidget w : widgetList) { - if (!(w instanceof KillNodeWidget) && !(w instanceof StartNodeWidget) && w != current) { - widgetDropDown.add(w); - } - } - } - - // if okVal listbox doesn't exist, return - if (okVal != null) { - okVal.clear(); - } - else { - return; - } - // insert empty option on top - okVal.addItem(""); - - for (int i = 0; i < widgetDropDown.size(); i++) { - NodeWidget w = widgetDropDown.get(i); - okVal.addItem(prettyItemString(w)); - // option selected when this node widget is connected to the - // widget in a design panel - List<NodeWidget> neigh = controller.getCurrentNeighbor(current); - if (neigh != null && neigh.size() > 0 && w == neigh.get(0)) - okVal.setSelectedIndex(i + 1); - } - - // remove previous handler, otherwise, end up having multiple handlers - if (handler != null) { - handler.removeHandler(); - } - - handler = okVal.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - int selectedIndex = okVal.getSelectedIndex(); - if (selectedIndex > 0) { - NodeWidget target = widgetDropDown.get(selectedIndex - 1); - current.getController().addConnection(current, target); - } - - } - }); - } - - /** - * Update "Error" drop-down list, currently only includes default kill node - */ - public void updateErrorDropDown() { - - List<NodeWidget> widgetList = current.getGenerator().getWidgets(); - - if (errorVal == null) { - errorVal = new ListBox(); - } - else { - errorVal.clear(); - } - - for (NodeWidget w : widgetList) { - if (w instanceof KillNodeWidget) { - errorVal.addItem(prettyItemString(w)); - errorVal.setSelectedIndex(0); - } - } - } - - /** - * Return an instance of a kill node - * - * @return - */ - protected NodeWidget getKillNode() { - - List<NodeWidget> widgetList = current.getGenerator().getWidgets(); - NodeWidget node = null; - for (NodeWidget w : widgetList) { - if (w instanceof KillNodeWidget) - node = w; - } - return node; - } - - /** - * Abstract method to generate xml elements and attach them to xml doc - * - * @param doc xml document - * @param root xml element under which generated xml elements are added - * @param next next node widget to be executed after this in workflow - */ - public abstract void generateXML(Document doc, Element root, NodeWidget next); - - /** - * Append a type of the node widget to its name for readability - * - * @param w - * @return - */ - protected String prettyItemString(NodeWidget w) { - StringBuilder s = new StringBuilder(); - s.append(w.getName()); - s.append(" "); - if (w instanceof EndNodeWidget) { - s.append(" (End Node)"); - } - else if (w instanceof ForkNodeWidget) { - s.append(" (Fork Node)"); - } - else if (w instanceof JoinNodeWidget) { - s.append(" (Join Node)"); - } - else if (w instanceof MapReduceActionWidget) { - s.append(" (MR Action)"); - } - else if (w instanceof PigActionWidget) { - s.append(" (Pig Action)"); - } - else if (w instanceof StreamingActionWidget) { - s.append(" (MR Streaming Action)"); - } - else if (w instanceof PipesActionWidget) { - s.append(" (MR Pipes Action)"); - } - else if (w instanceof JavaActionWidget) { - s.append(" (Java Action)"); - } - else if (w instanceof FSActionWidget) { - s.append(" (FS Action)"); - } - else if (w instanceof DecisionNodeWidget) { - s.append(" (Decision Node)"); - } - else if (w instanceof KillNodeWidget) { - s.append(" (Kill Node)"); - } - else if (w instanceof SSHActionWidget) { - s.append(" (SSH Node)"); - } - else if (w instanceof SubWFActionWidget) { - s.append(" (SubWF Node)"); - } - else if (w instanceof EmailActionWidget) { - s.append(" (Email Node)"); - } - else if (w instanceof ShellActionWidget) { - s.append(" (Shell Node)"); - } - return s.toString(); - } - - /** - * Set the width of widget - * - * @param w widget - * @return - */ - protected Widget formatCell(Widget w) { - w.setWidth("300px"); - return w; - } - - /** - * Create an expandable sub table as a part of property table - * - * @param colname1 1st column name - * @param colname2 2nd column name - * @param data data list - * @param options listbox options, if null, text input cell used - * @return - */ - protected CellTable<Property> createSubTable(String colname1, String colname2, List<Property> data, - List<String> options) { - - final CellTable<Property> table = new CellTable<Property>(); - final ListDataProvider<Property> dataProvider = new ListDataProvider<Property>(); - dataProvider.setList(data); - dataProvider.addDataDisplay(table); - - // add Name column - Column<Property, String> nameCol = null; - - if (options == null) { - nameCol = new Column<Property, String>(new TextInputCell()) { - @Override - public String getValue(Property object) { - return object.getName(); - } - }; - } - else { - nameCol = new Column<Property, String>(new SelectionCell(options)) { - @Override - public String getValue(Property object) { - return object.getName(); - } - }; - } - - // set event for updating value - nameCol.setFieldUpdater(new FieldUpdater<Property, String>() { - @Override - public void update(int index, Property object, String value) { - object.setName(value); - } - }); - table.addColumn(nameCol, colname1); - - // Add Value column - Column<Property, String> valueCol = new Column<Property, String>(new TextInputCell()) { - @Override - public String getValue(Property object) { - return object.getValue(); - } - }; - - valueCol.setFieldUpdater(new FieldUpdater<Property, String>() { - @Override - public void update(int index, Property object, String value) { - object.setValue(value); - } - }); - table.addColumn(valueCol, colname2); - - // Button to add row - Column<Property, String> addCol = new Column<Property, String>(new ButtonCell()) { - @Override - public String getValue(Property object) { - return " + "; - } - }; - addCol.setFieldUpdater(new FieldUpdater<Property, String>() { - @Override - public void update(int index, Property object, String value) { - dataProvider.getList().add(index + 1, new Property("", "")); - } - }); - - table.addColumn(addCol, ""); - - // Button to delete row - Column<Property, String> delCol = new Column<Property, String>(new ButtonCell()) { - @Override - public String getValue(Property object) { - return " - "; - } - }; - - delCol.setFieldUpdater(new FieldUpdater<Property, String>() { - - @Override - public void update(int index, Property object, String value) { - List<Property> li = dataProvider.getList(); - if (li.size() == 1) { - Property p = li.get(0); - p.setName(""); - p.setValue(""); - table.redraw(); - } - else - dataProvider.getList().remove(index); - } - }); - - table.addColumn(delCol, ""); - - return table; - } - - /** - * Create an add button in a table - * - * @param table - * @return - */ - protected Button createAddButton(Grid table) { - Button btn = new Button("+"); - btn.getElement() - .setAttribute("style", - "font-size:20px;margin:0px;padding:0px;-webkit-border-radius:10px;-moz-border-radius:10px;-border-radius:10px;"); - return btn; - } - - /** - * create a delete button in a table - * - * @param table - * @return - */ - protected Button createDelButton(Grid table) { - Button btn = new Button("-"); - btn.getElement() - .setAttribute("style", - "font-size:20px;margin:0px;padding:0px;-webkit-border-radius:10px;-moz-border-radius:10px;-border-radius:10px;"); - return btn; - } - - /** - * Create a label with common format - * - * @param name - * @return - */ - protected Label createLabel(String name) { - Label label = new Label(name); - label.setWidth("100px"); - label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); - return label; - } - - /** - * Generate xml elements of configuration - * - * @param list List of properties - * @param root xml element under which configuration tag is added - * @param doc xml document - */ - protected void configToXML(List<Property> list, Element root, Document doc) { - - Element confEle = null; - - for (Property prop : list) { - if (prop.getName() != null && !prop.getName().matches("\\s*") && prop.getValue() != null - && !prop.getValue().matches("\\s*")) { - - if (confEle == null) { - confEle = doc.createElement("configuration"); - root.appendChild(confEle); - } - - // create <property> - Element propEle = doc.createElement("property"); - confEle.appendChild(propEle); - - // create <name> - Element nameEle = doc.createElement("name"); - propEle.appendChild(nameEle); - nameEle.appendChild(doc.createTextNode(prop.getName())); - - // create <value> - Element valEle = doc.createElement("value"); - propEle.appendChild(valEle); - valEle.appendChild(doc.createTextNode(prop.getValue())); - } - } - - } - - /** - * Generate xml elements of prepare tag - * - * @param list list of properties - * @param root xml element under which prepare tag is added - * @param doc xml document - */ - protected void prepareToXML(List<Property> list, Element root, Document doc) { - - Element prepareEle = null; - for (Property prop : list) { - if (prop.getName() != null && !prop.getName().matches("\\s*") && prop.getValue() != null - && !prop.getValue().matches("\\s*")) { - - if (prepareEle == null) { - prepareEle = doc.createElement("prepare"); - root.appendChild(prepareEle); - } - - // create <delete> or <mkdir> - Element ele = null; - if (prop.getName().equals("delete")) { - ele = doc.createElement("delete"); - } - else if (prop.getName().equals("mkdir")) { - ele = doc.createElement("mkdir"); - } - ele.setAttribute("path", prop.getValue()); - prepareEle.appendChild(ele); - } - } - } - - /** - * Generate xml elements of specified tag name - * - * @param list list of properties - * @param root xml element under which new elements are added - * @param doc xml document - * @param key tag name - */ - protected void filterListToXML(List<Property> list, Element root, Document doc, String key) { - - for (Property prop : list) { - if (prop.getName() != null && !prop.getName().matches("\\s*") && prop.getValue() != null - && !prop.getValue().matches("\\s*")) { - if (prop.getName().equals(key)) { - // create key element - Element nameEle = doc.createElement(key); - root.appendChild(nameEle); - - // create text node under created element - Text valEle = doc.createTextNode(prop.getValue()); - nameEle.appendChild(valEle); - } - } - } - } - - /** - * Generate xml element of specific tag using content of textbox - * - * @param doc xml document - * @param tag tag name - * @param box textbox - * @return - */ - protected Element generateElement(Document doc, String tag, TextBox box) { - Element ele = doc.createElement(tag); - Text t = doc.createTextNode(box.getText()); - ele.appendChild(t); - return ele; - } - - /** - * Generate xml element of ok - * - * @param doc xml document - * @param next next node widget to be executed after this in workflow - * @return - */ - protected Element generateOKElement(Document doc, NodeWidget next) { - Element okEle = doc.createElement("ok"); - okEle.setAttribute("to", next.getName()); - return okEle; - } - - /** - * Generate xml element of error - * - * @param doc xml document - * @return - */ - protected Element generateErrorElement(Document doc) { - Element errEle = doc.createElement("error"); - NodeWidget kill = getKillNode(); - errEle.setAttribute("to", kill == null ? "" : kill.getName()); - return errEle; - } - - /** - * Insert a row with textbox into a grid table - * - * @param grid grid table - * @param row row number - * @param label name of label - * @return - */ - protected TextBox insertTextRow(Grid grid, int row, String label) { - grid.setWidget(row, 0, createLabel(label)); - TextBox box = new TextBox(); - grid.setWidget(row, 1, formatCell(box)); - return box; - } - - /** - * Insert a row for ok into a grid table - * - * @param grid grid table - * @param row row number - */ - protected void insertOKRow(Grid grid, int row) { - grid.setWidget(row, 0, createLabel("OK")); - okVal = new ListBox(); - updateWidgetDropDown(); - grid.setWidget(row, 1, formatCell(okVal)); - } - - /** - * Insert a row for error into a grid table - * - * @param grid grid table - * @param row row number - */ - protected void insertErrorRow(Grid grid, int row) { - grid.setWidget(row, 0, createLabel("Error")); - errorVal = new ListBox(); - updateErrorDropDown(); - grid.setWidget(row, 1, formatCell(errorVal)); - } - - /** - * Return a name of the node widget - * - * @return - */ - public String getName() { - String n = null; - if (name != null) { - n = name.getText(); - } - else { - n = new String(""); - } - return n; - } - - /** - * Set a name of the node widget - * - * @param n - */ - public void setName(String n) { - if (name != null) { - name.setText(n); - } - } - -}
http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTableFactory.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTableFactory.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTableFactory.java deleted file mode 100644 index 1e2608b..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/PropertyTableFactory.java +++ /dev/null @@ -1,137 +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.oozie.tools.workflowgenerator.client.property; - -import org.apache.oozie.tools.workflowgenerator.client.property.action.EmailPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.FSPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.JavaPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.MapReducePropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.PigPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.PipesPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.SSHPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.ShellPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.StreamingPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.action.SubWFPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.DecisionPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.EndPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.ForkPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.JoinPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.KillPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.property.control.StartPropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.EmailActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.FSActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.JavaActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.MapReduceActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.PigActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.PipesActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.SSHActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.ShellActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.StreamingActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.action.SubWFActionWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.DecisionNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.EndNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.ForkNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.JoinNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.KillNodeWidget; -import org.apache.oozie.tools.workflowgenerator.client.widget.control.StartNodeWidget; - -/** - * Singleton class to instantiate property table corresponding to node widget. - */ -public class PropertyTableFactory { - - // Singleton - private static PropertyTableFactory factory = new PropertyTableFactory(); - - private PropertyTableFactory() { - } - - /** - * Return PropertyTableFactory instance - * - * @return PropertyTableFactory - */ - public static PropertyTableFactory getInstance() { - return factory; - } - - /** - * Return property table instance corresponding to node widget given in an - * argument - * - * @param w node widget - * @return PropertyTable - */ - public PropertyTable createPropertyTable(NodeWidget w) { - - PropertyTable table = null; - - if (w instanceof MapReduceActionWidget) { - table = new MapReducePropertyTable(w); - } - else if (w instanceof PigActionWidget) { - table = new PigPropertyTable(w); - } - else if (w instanceof JavaActionWidget) { - table = new JavaPropertyTable(w); - } - else if (w instanceof FSActionWidget) { - table = new FSPropertyTable(w); - } - else if (w instanceof PipesActionWidget) { - table = new PipesPropertyTable(w); - } - else if (w instanceof StreamingActionWidget) { - table = new StreamingPropertyTable(w); - } - else if (w instanceof ShellActionWidget) { - table = new ShellPropertyTable(w); - } - else if (w instanceof SSHActionWidget) { - table = new SSHPropertyTable(w); - } - else if (w instanceof EmailActionWidget) { - table = new EmailPropertyTable(w); - } - else if (w instanceof SubWFActionWidget) { - table = new SubWFPropertyTable(w); - } - else if (w instanceof StartNodeWidget) { - table = new StartPropertyTable(w); - } - else if (w instanceof EndNodeWidget) { - table = new EndPropertyTable(w); - } - else if (w instanceof KillNodeWidget) { - table = new KillPropertyTable(w); - } - else if (w instanceof ForkNodeWidget) { - table = new ForkPropertyTable(w); - } - else if (w instanceof JoinNodeWidget) { - table = new JoinPropertyTable(w); - } - else if (w instanceof DecisionNodeWidget) { - table = new DecisionPropertyTable(w); - } - - return table; - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/EmailPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/EmailPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/EmailPropertyTable.java deleted file mode 100644 index 2bcdc12..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/EmailPropertyTable.java +++ /dev/null @@ -1,114 +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.oozie.tools.workflowgenerator.client.property.action; - -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of email action - */ -public class EmailPropertyTable extends PropertyTable { - - private TextBox to; - private TextBox cc; - private TextBox subject; - private TextBox body; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public EmailPropertyTable(NodeWidget w) { - super(w); - initWidget(); - } - - /** - * Generate xml elements of email action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <email> - Element emailEle = doc.createElement("email"); - action.appendChild(emailEle); - - // create <to> - emailEle.appendChild(generateElement(doc, "to", to)); - - // create <cc> - emailEle.appendChild(generateElement(doc, "cc", cc)); - - // create <subject> - emailEle.appendChild(generateElement(doc, "subject", subject)); - - // create <body> - emailEle.appendChild(generateElement(doc, "body", body)); - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(7, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for TO - to = insertTextRow(grid, 3, "To"); - - // insert row for CC - cc = insertTextRow(grid, 4, "CC"); - - // insert row for Subject - subject = insertTextRow(grid, 5, "Subject"); - - // insert row for Body - body = insertTextRow(grid, 6, "Body"); - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/FSPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/FSPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/FSPropertyTable.java deleted file mode 100644 index a0b23a4..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/FSPropertyTable.java +++ /dev/null @@ -1,477 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.cell.client.ButtonCell; -import com.google.gwt.cell.client.FieldUpdater; -import com.google.gwt.cell.client.SelectionCell; -import com.google.gwt.cell.client.TextCell; -import com.google.gwt.cell.client.Cell.Context; -import com.google.gwt.cell.client.TextInputCell; -import com.google.gwt.safehtml.shared.SafeHtml; -import com.google.gwt.safehtml.shared.SafeHtmlBuilder; -import com.google.gwt.user.cellview.client.CellTable; -import com.google.gwt.user.cellview.client.Column; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.view.client.ListDataProvider; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of FS action - */ -public class FSPropertyTable extends PropertyTable { - - private List<FSActionData> fsdata; - - /** - * Constructor which records node widget and initializes - * - * @param w - */ - public FSPropertyTable(NodeWidget w) { - super(w); - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - private void initConf() { - fsdata = new ArrayList<FSActionData>(); - fsdata.add(new FSActionData()); - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - VerticalPanel vertical = new VerticalPanel(); - this.add(vertical); - grid = new Grid(3, 2); - vertical.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // create cell table for FS operation - vertical.add(createFSActionTable(fsdata)); - } - - /** - * Create a table showing fs operations - * - * @param data - * @return - */ - protected CellTable<FSActionData> createFSActionTable(List<FSActionData> data) { - - final CellTable<FSActionData> table = new CellTable<FSActionData>(); - final ListDataProvider<FSActionData> dataProvider = new ListDataProvider<FSActionData>(); - dataProvider.setList(data); - dataProvider.addDataDisplay(table); - - // Add Name column - Column<FSActionData, String> nameCol = null; - - nameCol = new Column<FSActionData, String>(new SelectionCell(Arrays.asList("", "delete", "mkdir", "move", - "chmod", "touchz"))) { - @Override - public String getValue(FSActionData object) { - return object.getOp(); - } - }; - - // set event for updating value - nameCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - @Override - public void update(int index, FSActionData object, String value) { - FSActionData d = dataProvider.getList().get(index); - d.setOp(value); - table.redraw(); - } - }); - table.addColumn(nameCol, "operation"); - - Column<FSActionData, String> label1Col = new Column<FSActionData, String>(new TextCell()) { - @Override - public String getValue(FSActionData object) { - String rel = "Path"; - String op = object.getOp(); - if (op.equals("move")) { - rel = "Source Path"; - } - return rel; - } - }; - - table.addColumn(label1Col); - - // Add Column for 1st parameter of delete/mkdir/chmod/move/touchz - Column<FSActionData, String> param1Col = new Column<FSActionData, String>(new TextInputCell()) { - @Override - public String getValue(FSActionData object) { - String op = object.getOp(); - if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { - if (object.getParams().containsKey("path") && object.getParams().get("path") != null) - return object.getParams().get("path"); - } - else if (op.equals("move")) { - if (object.getParams().containsKey("source") && object.getParams().get("source") != null) - return object.getParams().get("source"); - } - return ""; - } - }; - - param1Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - @Override - public void update(int index, FSActionData object, String value) { - FSActionData d = dataProvider.getList().get(index); - String op = d.getOp(); - if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { - d.getParams().put("path", value); - } - else if (op.equals("move")) { - d.getParams().put("source", value); - } - } - }); - table.addColumn(param1Col, ""); - - // Add Label for 2rd parameter of move and chmod - Column<FSActionData, String> label2Col = new Column<FSActionData, String>(new TextCell()) { - - public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { - if (value != null) { - FSActionData data = (FSActionData) context.getKey(); - if (data.getOp().equals("move") || data.getOp().equals("chmod")) - sb.append(value); - } - } - - @Override - public String getValue(FSActionData object) { - String rel = null; - String op = object.getOp(); - if (op.equals("move")) { - rel = "Target Path"; - } - else if (op.equals("chmod")) { - rel = "Permissions"; - } - return rel; - } - }; - - table.addColumn(label2Col); - - // Add Column for 2nd parameter of move and chmod - Column<FSActionData, String> param2Col = new Column<FSActionData, String>(new CustomEditTextCell()) { - @Override - public String getValue(FSActionData object) { - String op = object.getOp(); - if (op.equals("move")) { - if (object.getParams().containsKey("target") && object.getParams().get("target") != null) - return object.getParams().get("target"); - } - else if (op.equals("chmod")) { - if (object.getParams().containsKey("permissions") && object.getParams().get("permissions") != null) - return object.getParams().get("permissions"); - } - return ""; - } - }; - - param2Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - @Override - public void update(int index, FSActionData object, String value) { - FSActionData d = dataProvider.getList().get(index); - String op = d.getOp(); - if (op.equals("move")) { - d.getParams().put("target", value); - } - else if (op.equals("chmod")) { - d.getParams().put("permissions", value); - } - } - }); - table.addColumn(param2Col, ""); - - // Add Label for 3rd parameter of chmod - Column<FSActionData, String> label3Col = new Column<FSActionData, String>(new TextCell()) { - - public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { - if (value != null) { - FSActionData data = (FSActionData) context.getKey(); - if (data.getOp().equals("chmod")) - sb.append(value); - } - } - - @Override - public String getValue(FSActionData object) { - String rel = null; - String op = object.getOp(); - if (op.equals("chmod")) - rel = "Chmod files within directory?(dir-files)"; - return rel; - } - }; - - table.addColumn(label3Col); - - // Add Column for 3rd parameter of chmod - // ( Recursive option not implemented in this version. need to add - // another column for that. ) - Column<FSActionData, String> param3Col = new Column<FSActionData, String>(new CustomSelectionCell( - Arrays.asList("true", "false"))) { - @Override - public String getValue(FSActionData object) { - String rel = null; - String op = object.getOp(); - if (op.equals("chmod")) - rel = object.getParams().get("dir-files"); - return rel; - } - }; - - param3Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - @Override - public void update(int index, FSActionData object, String value) { - FSActionData d = dataProvider.getList().get(index); - String op = d.getOp(); - if (op.equals("chmod")) { - d.getParams().put("dir-files", value); - } - } - }); - table.addColumn(param3Col, ""); - - // Button to add row - Column<FSActionData, String> addCol = new Column<FSActionData, String>(new ButtonCell()) { - @Override - public String getValue(FSActionData object) { - return " + "; - } - }; - addCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - @Override - public void update(int index, FSActionData object, String value) { - dataProvider.getList().add(index + 1, new FSActionData()); - } - }); - - table.addColumn(addCol, ""); - - // Button to delete row - Column<FSActionData, String> delCol = new Column<FSActionData, String>(new ButtonCell()) { - @Override - public String getValue(FSActionData object) { - return " - "; - } - }; - - delCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { - - @Override - public void update(int index, FSActionData object, String value) { - List<FSActionData> li = dataProvider.getList(); - if (li.size() == 1) { - FSActionData p = li.get(0); - p.clear(); - table.redraw(); - } - else { - dataProvider.getList().remove(index); - } - } - }); - - table.addColumn(delCol, ""); - - return table; - } - - class CustomEditTextCell extends TextInputCell { - - @Override - public void render(Context context, String value, SafeHtmlBuilder sb) { - FSActionData fsdata = (FSActionData) context.getKey(); - String op = fsdata.getOp(); - if (op.equals("move") || op.equals("chmod")) - super.render(context, value, sb); - - } - } - - class CustomSelectionCell extends SelectionCell { - - public CustomSelectionCell(List<String> options) { - super(options); - } - - @Override - public void render(Context context, String value, SafeHtmlBuilder sb) { - FSActionData fsdata = (FSActionData) context.getKey(); - String op = fsdata.getOp(); - if (op.equals("chmod")) { - super.render(context, value, sb); - } - } - } - - /** - * Generate xml elements of fs action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - Element fsEle = doc.createElement("fs"); - action.appendChild(fsEle); - - // create <delete> - fsDataListToXML(fsdata, fsEle, doc, "delete"); - - // create <mkdir> - fsDataListToXML(fsdata, fsEle, doc, "mkdir"); - - // create <move> - fsDataListToXML(fsdata, fsEle, doc, "move"); - - // create <chmod> - fsDataListToXML(fsdata, fsEle, doc, "chmod"); - - // create <touchz> - fsDataListToXML(fsdata, fsEle, doc, "touchz"); - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - - } - - /** - * Generate xml elements of fs operations - * - * @param list list of FS operations - * @param root xml element under which fs action is added - * @param doc xml document - * @param key name of fs operation - */ - protected void fsDataListToXML(List<FSActionData> list, Element root, Document doc, String key) { - - for (FSActionData fsdata : list) { - String op = fsdata.getOp(); - - if (op != null && !op.matches("\\s*") && op.equals(key)) { - - Map<String, String> params = fsdata.getParams(); - - boolean flag = true; - if (op.equals("delete") && !params.containsKey("path")) { - flag = false; - } - else if (op.equals("mkdir") && !params.containsKey("path")) { - flag = false; - } - else if (op.equals("move") && (!params.containsKey("source") || !params.containsKey("target"))) { - flag = false; - } - else if (op.equals("chmod") && (!params.containsKey("path") || !params.containsKey("permissions"))) { - flag = false; - } - else if (op.equals("touchz") && (!params.containsKey("path"))) { - flag = false; - } - - if (flag) { - // create key element - Element nameele = doc.createElement(key); - root.appendChild(nameele); - - // set attribute for parameter(s) - for (Map.Entry<String, String> e : params.entrySet()) { - nameele.setAttribute(e.getKey(), e.getValue()); - } - } - } - } - - } - - /** - * class to store FS operation and relevant parameters - */ - public class FSActionData { - - private String op; - private Map<String, String> params; - - public FSActionData() { - params = new HashMap<String, String>(); - op = ""; - } - - public String getOp() { - return op; - } - - public void setOp(String s) { - this.op = s; - } - - public Map<String, String> getParams() { - return params; - } - - public void clear() { - op = ""; - params.clear(); - } - } - -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/JavaPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/JavaPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/JavaPropertyTable.java deleted file mode 100644 index cc38ddc..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/JavaPropertyTable.java +++ /dev/null @@ -1,189 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.oozie.tools.workflowgenerator.client.property.Property; -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HasVerticalAlignment; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.RadioButton; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of java action - */ -public class JavaPropertyTable extends PropertyTable { - - private List<Property> configs; - private List<Property> prepare; - private List<Property> others; - private RadioButton rby; - private RadioButton rbn; - private TextBox mainClass; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public JavaPropertyTable(NodeWidget w) { - - super(w); - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - private void initConf() { - configs = new ArrayList<Property>(); - configs.add(new Property("mapred.job.queue.name", "")); - - prepare = new ArrayList<Property>(); - prepare.add(new Property("", "")); - - others = new ArrayList<Property>(); - others.add(new Property("", "")); - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(10, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for JobTracker - jt = insertTextRow(grid, 3, "JobTracker"); - - // insert row for NameNode - nn = insertTextRow(grid, 4, "NameNode"); - - // insert row for Configuration - grid.setWidget(5, 0, createLabel("Configuration")); - grid.setWidget(5, 1, createSubTable("Property Name", "Value", configs, null)); - - // insert row for Main Class - mainClass = insertTextRow(grid, 6, "Main Class"); - - // insert row for prepare - grid.setWidget(7, 0, createLabel("Prepare")); - grid.setWidget(7, 1, createSubTable("Operation", "Path", prepare, Arrays.asList("", "delete", "mkdir"))); - - // insert row for others - grid.setWidget(8, 0, createLabel("Others")); - grid.setWidget( - 8, - 1, - createSubTable("Tag", "value", others, - Arrays.asList("", "job-xml", "java-opts", "arg", "file", "archive"))); - - // insert row for Capture Output - grid.setWidget(9, 0, createLabel("Capture Output")); - HorizontalPanel btnpanel = new HorizontalPanel(); - btnpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); - rbn = new RadioButton("outputGroup", "false"); - rby = new RadioButton("outputGroup", "true"); - rbn.setChecked(true); - btnpanel.add(rby); - btnpanel.add(rbn); - grid.setWidget(9, 1, btnpanel); - - } - - /** - * Generate xml elements of java action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <java> - Element javaEle = doc.createElement("java"); - action.appendChild(javaEle); - - // create <job-tracker> - javaEle.appendChild(generateElement(doc, "job-tracker", jt)); - - // create <name-node> - javaEle.appendChild(generateElement(doc, "name-node", nn)); - - // create <prepare> - prepareToXML(prepare, javaEle, doc); - - // create <job-xml> - filterListToXML(others, javaEle, doc, "job-xml"); - - // create <configuration> - configToXML(configs, javaEle, doc); - - // create <main-class> - javaEle.appendChild(generateElement(doc, "main-class", mainClass)); - - // create <java-opts> - filterListToXML(others, javaEle, doc, "java-opts"); - - // create <arg> - filterListToXML(others, javaEle, doc, "arg"); - - // create <file> - filterListToXML(others, javaEle, doc, "file"); - - // create <archive> - filterListToXML(others, javaEle, doc, "archive"); - - // create <capture-output> - if (rby.getValue()) { - Element outputele = doc.createElement("capture-output"); - javaEle.appendChild(outputele); - } - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/MapReducePropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/MapReducePropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/MapReducePropertyTable.java deleted file mode 100644 index 0fa3596..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/MapReducePropertyTable.java +++ /dev/null @@ -1,156 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.oozie.tools.workflowgenerator.client.property.Property; -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of MR action - */ -public class MapReducePropertyTable extends PropertyTable { - - protected List<Property> configs; - protected List<Property> prepare; - protected List<Property> others; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public MapReducePropertyTable(NodeWidget w) { - super(w); - init(); - } - - /** - * Initialize a property table - */ - protected void init() { - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - protected void initConf() { - configs = new ArrayList<Property>(); - configs.add(new Property("mapred.mapper.class", "")); - configs.add(new Property("mapred.reduce.class", "")); - configs.add(new Property("mapred.job.queue.name", "")); - - prepare = new ArrayList<Property>(); - prepare.add(new Property("", "")); - - others = new ArrayList<Property>(); - others.add(new Property("", "")); - } - - /** - * Generate xml elements of mr action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <map-reduce> - Element mrEle = doc.createElement("map-reduce"); - action.appendChild(mrEle); - - // create <job-tracker> - mrEle.appendChild(generateElement(doc, "job-tracker", jt)); - - // create <name-node> - mrEle.appendChild(generateElement(doc, "name-node", nn)); - - // create <prepare> - prepareToXML(prepare, mrEle, doc); - - // create <job-xml> - filterListToXML(others, mrEle, doc, "job-xml"); - - // create <configuration> - configToXML(configs, mrEle, doc); - - // create <file> - filterListToXML(others, mrEle, doc, "file"); - - // create <archive> - filterListToXML(others, mrEle, doc, "archive"); - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(8, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for JobTracker - jt = insertTextRow(grid, 3, "JobTracker"); - - // insert row for NameNode - nn = insertTextRow(grid, 4, "NameNode"); - - // insert row for prepare - grid.setWidget(5, 0, createLabel("Prepare")); - grid.setWidget(5, 1, createSubTable("Operation", "Path", prepare, Arrays.asList("", "delete", "mkdir"))); - - // insert row for Configuration - grid.setWidget(6, 0, createLabel("Configuration")); - grid.setWidget(6, 1, createSubTable("Property Name", "Value", configs, null)); - - // insert row for others - grid.setWidget(7, 0, createLabel("Others")); - grid.setWidget(7, 1, createSubTable("Tag", "value", others, Arrays.asList("", "job-xml", "file", "archive"))); - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PigPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PigPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PigPropertyTable.java deleted file mode 100644 index 55e5ae1..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PigPropertyTable.java +++ /dev/null @@ -1,168 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.oozie.tools.workflowgenerator.client.property.Property; -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of pig action - */ -public class PigPropertyTable extends PropertyTable { - - private List<Property> configs; - private List<Property> prepare; - private List<Property> others; - private TextBox script; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public PigPropertyTable(NodeWidget w) { - - super(w); - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - private void initConf() { - configs = new ArrayList<Property>(); - configs.add(new Property("mapred.job.queue.name", "")); - - prepare = new ArrayList<Property>(); - prepare.add(new Property("", "")); - - others = new ArrayList<Property>(); - others.add(new Property("", "")); - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(9, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for Script - script = insertTextRow(grid, 3, "Script"); - - // insert row for JobTracker - jt = insertTextRow(grid, 4, "JobTracker"); - - // insert row for NameNode - nn = insertTextRow(grid, 5, "NameNode"); - - // insert row for Configuration - grid.setWidget(6, 0, createLabel("Configuration")); - grid.setWidget(6, 1, createSubTable("Property Name", "Value", configs, null)); - - // insert row for prepare - grid.setWidget(7, 0, createLabel("Prepare")); - grid.setWidget(7, 1, createSubTable("Operation", "Path", prepare, Arrays.asList("", "delete", "mkdir"))); - - // insert row for others - grid.setWidget(8, 0, createLabel("Others")); - grid.setWidget( - 8, - 1, - createSubTable("Tag", "value", others, - Arrays.asList("", "job-xml", "argument", "param", "file", "archive"))); - - } - - /** - * Generate xml elements of pig action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <pig> - Element pigEle = doc.createElement("pig"); - action.appendChild(pigEle); - - // create <job-tracker> - pigEle.appendChild(generateElement(doc, "job-tracker", jt)); - - // create <name-node> - pigEle.appendChild(generateElement(doc, "name-node", nn)); - - // create <prepare> - prepareToXML(prepare, pigEle, doc); - - // create <job-xml> - filterListToXML(others, pigEle, doc, "job-xml"); - - // create <configuration> - configToXML(configs, pigEle, doc); - - // create <script> - pigEle.appendChild(generateElement(doc, "script", script)); - - // create <param> - filterListToXML(others, pigEle, doc, "param"); - - // create <argument> - filterListToXML(others, pigEle, doc, "argument"); - - // create <file> - filterListToXML(others, pigEle, doc, "file"); - - // create <archive> - filterListToXML(others, pigEle, doc, "archive"); - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PipesPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PipesPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PipesPropertyTable.java deleted file mode 100644 index d3b2ef5..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/PipesPropertyTable.java +++ /dev/null @@ -1,207 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.oozie.tools.workflowgenerator.client.property.Property; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.xml.client.Text; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of MR pipes action - */ -public class PipesPropertyTable extends MapReducePropertyTable { - - private List<Property> pipes; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public PipesPropertyTable(NodeWidget w) { - super(w); - } - - /** - * Initialize a property table - */ - @Override - protected void init() { - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - @Override - protected void initConf() { - configs = new ArrayList<Property>(); - configs.add(new Property("mapred.job.queue.name", "")); - - prepare = new ArrayList<Property>(); - prepare.add(new Property("", "")); - - others = new ArrayList<Property>(); - others.add(new Property("", "")); - - pipes = new ArrayList<Property>(); - pipes.add(new Property("", "")); - } - - /** - * Generate xml elements of pipes action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <map-reduce> - Element mrEle = doc.createElement("map-reduce"); - action.appendChild(mrEle); - - // create <job-tracker> - mrEle.appendChild(generateElement(doc, "job-tracker", jt)); - - // create <name-node> - mrEle.appendChild(generateElement(doc, "name-node", nn)); - - // create <prepare> - prepareToXML(prepare, mrEle, doc); - - // create <pipes> - Element pipesEle = null; - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "map"); - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "reduce"); - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "inputformat"); - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "partitioner"); - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "writer"); - pipesEle = filterListToXML(pipes, mrEle, pipesEle, doc, "program"); - - // create <job-xml> - filterListToXML(others, mrEle, doc, "job-xml"); - - // create <configuration> - configToXML(configs, mrEle, doc); - - // create <file> - filterListToXML(others, mrEle, doc, "file"); - - // create <archive> - filterListToXML(others, mrEle, doc, "archive"); - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - } - - /** - * Create xml element of specified tag name - * - * @param list list of properties - * @param root xml element under which new elements are added - * @param pipes pipes element - * @param doc xml doc - * @param key tag name - * @return - */ - protected Element filterListToXML(List<Property> list, Element root, Element pipes, Document doc, String key) { - - for (Property prop : list) { - if (prop.getName() != null && !prop.getName().matches("\\s*") && prop.getValue() != null - && !prop.getValue().matches("\\s*")) { - if (prop.getName().equals(key)) { - if (pipes == null) { - pipes = doc.createElement("pipes"); - root.appendChild(pipes); - } - // create key element - Element nameele = doc.createElement(key); - pipes.appendChild(nameele); - - // create text node under created element - Text valele = doc.createTextNode(prop.getValue()); - nameele.appendChild(valele); - } - } - } - return pipes; - } - - /** - * Initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(9, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for Pipes setting - grid.setWidget(3, 0, createLabel("Pipes Setting")); - grid.setWidget( - 3, - 1, - createSubTable("Tag", "value", pipes, - Arrays.asList("", "map", "reduce", "inputformat", "partitioner", "writer", "program"))); - - // insert row for JobTracker - jt = insertTextRow(grid, 4, "JobTracker"); - - // insert row for NameNode - nn = insertTextRow(grid, 5, "NameNode"); - - // insert row for prepare - grid.setWidget(6, 0, createLabel("Prepare")); - grid.setWidget(6, 1, createSubTable("Operation", "Path", prepare, Arrays.asList("", "delete", "mkdir"))); - - // insert row for Configuration - grid.setWidget(7, 0, createLabel("Configuration")); - grid.setWidget(7, 1, createSubTable("Property Name", "Value", configs, null)); - - // insert row for others - grid.setWidget(8, 0, createLabel("Others")); - grid.setWidget(8, 1, createSubTable("Tag", "value", others, Arrays.asList("", "job-xml", "file", "archive"))); - - } -} http://git-wip-us.apache.org/repos/asf/oozie/blob/aec39dd2/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/SSHPropertyTable.java ---------------------------------------------------------------------- diff --git a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/SSHPropertyTable.java b/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/SSHPropertyTable.java deleted file mode 100644 index 34d7662..0000000 --- a/workflowgenerator/src/main/java/org/apache/oozie/tools/workflowgenerator/client/property/action/SSHPropertyTable.java +++ /dev/null @@ -1,234 +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.oozie.tools.workflowgenerator.client.property.action; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable; -import org.apache.oozie.tools.workflowgenerator.client.widget.NodeWidget; - -import com.google.gwt.cell.client.ButtonCell; -import com.google.gwt.cell.client.FieldUpdater; -import com.google.gwt.cell.client.TextInputCell; -import com.google.gwt.xml.client.Text; -import com.google.gwt.user.cellview.client.CellTable; -import com.google.gwt.user.cellview.client.Column; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HasVerticalAlignment; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.RadioButton; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.view.client.ListDataProvider; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; - -/** - * Class for property table of SSH action - */ -public class SSHPropertyTable extends PropertyTable { - - private List<String> args; - private TextBox host; - private TextBox command; - private RadioButton rby; - private RadioButton rbn; - - /** - * Constructor which records node widget and initializes - * - * @param w node widget - */ - public SSHPropertyTable(NodeWidget w) { - super(w); - initConf(); - initWidget(); - } - - /** - * Initialize configuration - */ - protected void initConf() { - args = new ArrayList<String>(); - args.add(""); - } - - /** - * Generate xml elements of ssh action and attach them to xml doc - */ - public void generateXML(Document doc, Element root, NodeWidget next) { - - Element action = doc.createElement("action"); - action.setAttribute("name", current.getName()); - - // create <ssh> - Element sshEle = doc.createElement("ssh"); - action.appendChild(sshEle); - - // create <host> - sshEle.appendChild(generateElement(doc, "host", host)); - - // create <command> - sshEle.appendChild(generateElement(doc, "command", command)); - - // create <args> - for (String arg : args) { - Element argsEle = doc.createElement("args"); - Text n = doc.createTextNode(arg); - argsEle.appendChild(n); - sshEle.appendChild(argsEle); - - } - - // create <capture-output> - if (rby.getValue()) { - Element outputele = doc.createElement("capture-output"); - sshEle.appendChild(outputele); - } - - // create <ok> - action.appendChild(generateOKElement(doc, next)); - - // create <error> - action.appendChild(generateErrorElement(doc)); - - root.appendChild(action); - } - - /** - * initialize widgets shown in property table - */ - protected void initWidget() { - - grid = new Grid(7, 2); - this.add(grid); - - this.setAlwaysShowScrollBars(true); - this.setSize("100%", "80%"); - - // insert row for Name - name = insertTextRow(grid, 0, "Name"); - - // insert row for OK - insertOKRow(grid, 1); - - // insert row for ERROR - insertErrorRow(grid, 2); - - // insert row for Host - host = insertTextRow(grid, 3, "Host"); - - // insert row for Command - command = insertTextRow(grid, 4, "Command"); - - // insert row for Arguments - grid.setWidget(5, 0, createLabel("Args")); - grid.setWidget(5, 1, createArgsTable(args)); - - // insert row for Capture Output - grid.setWidget(6, 0, createLabel("Capture Output")); - HorizontalPanel btnpanel = new HorizontalPanel(); - btnpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); - rbn = new RadioButton("outputGroup", "false"); - rby = new RadioButton("outputGroup", "true"); - rbn.setChecked(true); - btnpanel.add(rby); - btnpanel.add(rbn); - grid.setWidget(6, 1, btnpanel); - - } - - /** - * Create a table showing list of arguments added by a user - * - * @param data - * @return - */ - protected CellTable<String> createArgsTable(List<String> data) { - final CellTable<String> table = new CellTable<String>(); - final ListDataProvider<String> dataProvider = new ListDataProvider<String>(); - dataProvider.setList(data); - dataProvider.addDataDisplay(table); - - // Add Name column - Column<String, String> argCol = null; - - // when editText is used for name column - - argCol = new Column<String, String>(new TextInputCell()) { - @Override - public String getValue(String object) { - return object; - } - }; - - // set event for updating value - argCol.setFieldUpdater(new FieldUpdater<String, String>() { - @Override - public void update(int index, String object, String value) { - List<String> li = dataProvider.getList(); - li.remove(index); - li.add(index, value); - } - }); - table.addColumn(argCol, ""); - - // Button to add row - Column<String, String> addCol = new Column<String, String>(new ButtonCell()) { - @Override - public String getValue(String object) { - return " + "; - } - }; - addCol.setFieldUpdater(new FieldUpdater<String, String>() { - @Override - public void update(int index, String object, String value) { - List<String> li = dataProvider.getList(); - li.add(index + 1, new String(" ")); - } - }); - - table.addColumn(addCol, ""); - - // Button to delete row - Column<String, String> delCol = new Column<String, String>(new ButtonCell()) { - @Override - public String getValue(String object) { - return " - "; - } - }; - - delCol.setFieldUpdater(new FieldUpdater<String, String>() { - @Override - public void update(int index, String object, String value) { - List<String> li = dataProvider.getList(); - li.remove(index); - if (li.size() == 0) { - li.add(" "); - table.redraw(); - } - } - }); - - table.addColumn(delCol, ""); - - return table; - - } -}