View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2020.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss about it
6    * every time possible with every body.
7    * 
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   ******************************************************************************/
11  package com.jsql.view.terminal.interaction;
12  
13  import com.jsql.model.bean.database.Column;
14  import com.jsql.util.AnsiColorUtil;
15  import com.jsql.view.interaction.InteractionCommand;
16  import org.apache.logging.log4j.LogManager;
17  import org.apache.logging.log4j.Logger;
18  
19  import java.util.List;
20  
21  /**
22   * Add the columns to corresponding table.
23   */
24  public class AddColumns implements InteractionCommand {
25      
26      private static final Logger LOGGER = LogManager.getRootLogger();
27  
28      /**
29       * Columns retrieved by the view.
30       */
31      private final List<Column> columns;
32  
33      /**
34       * @param interactionParams List of columns retrieved by the Model
35       */
36      @SuppressWarnings("unchecked")
37      public AddColumns(Object[] interactionParams) {
38          this.columns = (List<Column>) interactionParams[0];  // Get list of columns from the model
39      }
40  
41      @Override
42      public void execute() {
43          
44          LOGGER.info(() -> AnsiColorUtil.addGreenColor(this.getClass().getSimpleName()));
45          
46          // Loop into the list of columns
47          for (Column column: this.columns) {
48              LOGGER.debug(column);
49          }
50      }
51  }