Commit 9bb38b78 authored by Pietro Apollo's avatar Pietro Apollo
Browse files

Added javadocs and other comments

parent 90474848
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@ import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.model.IModel;

/**
 * AjaxCheckBox class extends CheckBox class to add an univocal ID (called idString) to it.
 * The onUpdate method of the OnChangeAjaxBehavior is never called, probably because
 * it is covered by other behaviors implemented in other files directly with the
 * AjaxCheckBox instances.
 * 
 * @author pietro
 */
@@ -17,6 +21,12 @@ public class AjaxCheckBox extends CheckBox {
    
    private String idString;
    
    /**
     * AjaxCheckBox constructor
     * 
     * @param id
     * @param model 
     */
    public AjaxCheckBox(String id, IModel model)
    {
        super(id, model);
+50 −22
Original line number Diff line number Diff line
@@ -23,6 +23,13 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 * AjaxTextField class extends TextField class to add an univocal ID (called idString) to it.
 * AjaxTextField class implements the onUpdate method of the OnChangeAjaxBehavior and
 * the onEvent method of the AjaxEventBehavior on the onfocusout event.
 * The onUpdate method of the OnChangeAjaxBehavior is needed to update the variables
 * of the data structure corresponding to every AjaxTextField.
 * The onEvent method of the AjaxEventBehavior on the onfocusout event is needed
 * to update the tooltip of the utype, ucd, unit and description AjaxTextFields.
 * 
 * @author pietro
 */
@@ -30,12 +37,26 @@ public class AjaxTextField extends TextField {
    
    private String idString;
    
    /**
     * AjaxTextField constructor
     * 
     * @param id
     * @param model 
     */
    public AjaxTextField(String id, IModel model)
    {
        super(id, model);
        
        OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior()
        {
            /**
             * The onUpdate method of the OnChangeAjaxBehavior updates the correct
             * variable of the data structure on the base of the idString path
             * when the user inserts a new character in the corresponding
             * AjaxTextField.
             * 
             * @param target
             */
            @Override
            protected void onUpdate(AjaxRequestTarget target)
            {
@@ -43,12 +64,12 @@ public class AjaxTextField extends TextField {
                String[] idSplit = getIdString().split("-");
                if (idSplit.length == 2) //if schema TextField
                {
                    //get current SchemaPanel
                    //gets current SchemaPanel
                    SchemaPanel schemaPanel =
                            (SchemaPanel)schemaPage.schemataTabbedPanel
                            .get("panel");
                    
                    //set selectSchemaCheckBox
                    //sets selectSchemaCheckBox
                    schemaPanel.selectSchemaCheckBox.setModelObject(true);
                    String[] idSplit2 = schemaPanel.selectSchemaCheckBox.getIdString().split("-");
                    if (idSplit2[1].equals("checked"))
@@ -60,7 +81,7 @@ public class AjaxTextField extends TextField {
                    target.add(schemaPanel.selectSchemaCheckBox);
                    //end setting selectSchemaCheckBox
                    
                    //set variable "checked" in the correct schema of tapschema structure
                    //sets variable "checked" in the correct schema of tapschema structure
                    for (Schema schema : schemaPage.tapschema.schemasMap.values())
                    {
                        if (schema.schema_name.equals(
@@ -71,7 +92,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting variable "checked"
                    
                    //set variables "utype" and "description" in the correct schema of tapschema structure 
                    //sets variables "utype" and "description" in the correct schema of tapschema structure 
                    if (idSplit[1].equals("utype"))
                    {
                        schemaPage.tapschema.schemasMap.get(idSplit[0])
@@ -88,7 +109,7 @@ public class AjaxTextField extends TextField {
                }
                else if (idSplit.length == 3) //if table TextField
                {
                    //get current SchemaPanel and TablePanel
                    //gets current SchemaPanel and TablePanel
                    SchemaPanel schemaPanel =
                            (SchemaPanel)schemaPage.schemataTabbedPanel
                            .get("panel");
@@ -96,7 +117,7 @@ public class AjaxTextField extends TextField {
                            (TablePanel)schemaPanel.tablesTabbedPanel
                            .get("panel");
                    
                    //set selectTableCheckBox
                    //sets selectTableCheckBox
                    tablePanel.selectTableCheckBox.setModelObject(true);
                    String[] idSplit2 = tablePanel.selectTableCheckBox.getIdString().split("-");
                    if (idSplit2[2].equals("checked"))
@@ -109,7 +130,7 @@ public class AjaxTextField extends TextField {
                    target.add(tablePanel.selectTableCheckBox);
                    //end setting selectTableCheckBox

                    //set selectSchemaCheckBox
                    //sets selectSchemaCheckBox
                    schemaPanel.selectSchemaCheckBox.setModelObject(true);
                    idSplit2 = schemaPanel.selectSchemaCheckBox.getIdString().split("-");
                    if (idSplit2[1].equals("checked"))
@@ -121,7 +142,7 @@ public class AjaxTextField extends TextField {
                    target.add(schemaPanel.selectSchemaCheckBox);
                    //end setting selectSchemaCheckBox
                    
                    //set variable "checked" in the correct schema of tapschema structure
                    //sets variable "checked" in the correct schema of tapschema structure
                    for (Schema schema : schemaPage.tapschema.schemasMap.values())
                    {
                        if (schema.schema_name.equals(
@@ -132,7 +153,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting variable "checked"
                    
                    //set variable "checked" in the correct table of tapschema structure
                    //sets variable "checked" in the correct table of tapschema structure
                    for (Table table : schemaPage.tapschema.schemasMap.get(idSplit[0])
                            .tablesMap.values())
                    {
@@ -145,7 +166,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting variable "checked"
                    
                    //set variables "utype" and "description" in the correct table of tapschema structure
                    //sets variables "utype" and "description" in the correct table of tapschema structure
                    if (idSplit[2].equals("utype"))
                    {
                        schemaPage.tapschema.schemasMap.get(idSplit[0])
@@ -165,7 +186,7 @@ public class AjaxTextField extends TextField {
                }
                else if (idSplit.length == 4) //if DataGridView TextField
                {
                    //set row CheckBox
                    //sets row CheckBox
                    List<Column> columnsList = new ArrayList<Column>();
                    for (Column column : schemaPage.tapschema.schemasMap.get(idSplit[0])
                                .tablesMap.get(idSplit[1])
@@ -186,7 +207,7 @@ public class AjaxTextField extends TextField {
                        }
                    }
                    
                    //get current SchemaPanel, TablePanel, DataGridView
                    //gets current SchemaPanel, TablePanel, DataGridView
                    SchemaPanel schemaPanel =
                            (SchemaPanel)schemaPage.schemataTabbedPanel
                            .get("panel");
@@ -213,7 +234,7 @@ public class AjaxTextField extends TextField {
                            cell2.setModelObject(true);
                            target.add(cell2);
                            
                            //set selectTableCheckBox
                            //sets selectTableCheckBox
                            tablePanel.selectTableCheckBox.setModelObject(true);
                            String[] idSplit2 = tablePanel.selectTableCheckBox.getIdString().split("-");
                            if (idSplit2[2].equals("checked"))
@@ -226,7 +247,7 @@ public class AjaxTextField extends TextField {
                            target.add(tablePanel.selectTableCheckBox);
                            //end set selectTableCheckBox
                            
                            //set selectSchemaCheckBox
                            //sets selectSchemaCheckBox
                            schemaPanel.selectSchemaCheckBox.setModelObject(true);
                            idSplit2 = schemaPanel.selectSchemaCheckBox.getIdString().split("-");
                            if (idSplit2[1].equals("checked"))
@@ -243,7 +264,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting row CheckBox
                    
                    //set variable "checked" in the correct schema of tapschema structure
                    //sets variable "checked" in the correct schema of tapschema structure
                    for (Schema schema : schemaPage.tapschema.schemasMap.values())
                    {
                        if (schema.schema_name.equals(
@@ -254,7 +275,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting variable "checked"
                    
                    //set variable "checked" in the correct table of tapschema structure
                    //sets variable "checked" in the correct table of tapschema structure
                    for (Table table : schemaPage.tapschema.schemasMap.get(idSplit[0])
                            .tablesMap.values())
                    {
@@ -267,7 +288,7 @@ public class AjaxTextField extends TextField {
                    }
                    //end setting variable "checked"
                    
                    //set variable "checked" in the correct column of tapschema structure
                    //sets variable "checked" in the correct column of tapschema structure
                    for (Column column : schemaPage.tapschema.schemasMap.get(idSplit[0])
                            .tablesMap.get(idSplit[1])
                            .columnsMap.values())
@@ -293,7 +314,7 @@ public class AjaxTextField extends TextField {
                        }
                    }
                    */
                    //set variables in the correct column of tapschema structure
                    //sets variables in the correct column of tapschema structure
                    if (idSplit[3].equals("table_name"))
                    {
                        schemaPage.tapschema.schemasMap.get(idSplit[0])
@@ -431,6 +452,13 @@ public class AjaxTextField extends TextField {
        
        AjaxEventBehavior ajaxEventBehavior = new AjaxEventBehavior("onfocusout")
        {
            /**
             * The onEvent method of the AjaxEventBehavior on the onfocusout event
             * updates the tooltip of the correct AjaxTextField on the base of the
             * idString path when this AjaxTextField loses focus.
             * 
             * @param target
             */
            @Override
            protected void onEvent(AjaxRequestTarget target)
            {
@@ -439,7 +467,7 @@ public class AjaxTextField extends TextField {
                    
                if (idSplit.length == 4) //if DataGridView TextField
                {
                    //set row CheckBox
                    //sets row CheckBox
                    List<Column> columnsList = new ArrayList<Column>();
                    for (Column column : schemaPage.tapschema.schemasMap.get(idSplit[0])
                                .tablesMap.get(idSplit[1])
@@ -460,7 +488,7 @@ public class AjaxTextField extends TextField {
                        }
                    }
                    
                    //get current SchemaPanel, TablePanel, DataGridView
                    //gets current SchemaPanel, TablePanel, DataGridView
                    SchemaPanel schemaPanel =
                            (SchemaPanel)schemaPage.schemataTabbedPanel
                            .get("panel");
@@ -480,7 +508,7 @@ public class AjaxTextField extends TextField {
                    {
                        if (item.getIndex() == columnIndex)
                        {
                            //get cells of index item, needed to set tooltips
                            //gets cells of index item, needed to set tooltips
                            RepeatingView cells = (RepeatingView)item.get("cells");
                   
                            if (idSplit[3].equals("utype"))
+17 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;

/**
 * CredentialPage class extends the default BasePage class and is the home page.
 * It obtains the MySQL credentials from the user and pass them to the SelectSchemataPage
 * with the onSubmit method of the credentialSubmit AjaxSubmitLink.
 * 
 * @author pietro
 */
@@ -38,6 +41,9 @@ public class CredentialPage extends BasePage {
    AjaxSubmitLink credentialSubmit;
    TextArea infoTextArea;
    
    /**
     * CredentialPage constructor
     */
    public CredentialPage()
    {
        //credential form
@@ -95,9 +101,17 @@ public class CredentialPage extends BasePage {
                
            }
            
            /**
             * onSubmit method of credentialSubmit AjaxSubmitLink get the credentials
             * from the TextFields and passes the credentials to SelectSchemataPage
             * 
             * @param target
             * @param form
             */
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
                // gets credentials from TextFields
                hostname = (String)hostnameTextField.getModelObject();
                port = (String)portTextField.getModelObject();
                username = (String)usernameTextField.getModelObject();
@@ -107,6 +121,7 @@ public class CredentialPage extends BasePage {
                Connection connection = null;
                try
                {
                    // opens the connection to MySQL on hostname
                    Class.forName("com.mysql.jdbc.Driver");
                    connection = DriverManager.getConnection(
                            url,
@@ -114,6 +129,7 @@ public class CredentialPage extends BasePage {
                            password
                    );
                    
                    // passes the credentials to SelectSchemataPage
                    SelectSchemataPage selectSchemataPage = new SelectSchemataPage(
                            target,
                            form,
+21 −1
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ package it.inaf.oats.ia2.tap.utils;
import java.io.Serializable;

/**
 * Row class represent a row model of the "rows" DataGridView in TablePanel class.
 * Row class must implement Serializable.
 * 
 * @author pietro
 */
@@ -29,6 +31,24 @@ public class Row implements Serializable {
    public int indexed;
    public int std;

    /**
     * Row constructor
     * 
     * @param select
     * @param primary_key
     * @param foreign_key
     * @param table_name
     * @param column_name
     * @param utype
     * @param ucd
     * @param unit
     * @param description
     * @param datatype
     * @param size
     * @param principal
     * @param indexed
     * @param std 
     */
    public Row(
            boolean select,
            String primary_key,
+61 −4
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@ import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.model.Model;

/**
 * SchemaPage class extends the default BasePage class.
 * SchemaPage class has an AjaxTabbedPanel to show the SchemaTabs dinamically,
 * and has the AjaxSubmitLink to submit all the tapschema structure to the
 * tapschema database.
 * 
 * @author pietro
 */
@@ -33,6 +37,18 @@ public class SchemaPage extends BasePage{
    
    public TapSchema tapschema;
    
    /**
     * SchemaPage constructor
     * 
     * @param target
     * @param form
     * @param hostname
     * @param port
     * @param username
     * @param password
     * @param tapschemaName
     * @param tapschema tapschema structure
     */
    public SchemaPage(
            AjaxRequestTarget target,
            Form<?> form,
@@ -70,6 +86,12 @@ public class SchemaPage extends BasePage{
                
            }
            
            /**
             * onSubmit method of updateSubmit AjaxSubmitLink updates the tapschema database.
             * 
             * @param target
             * @param form
             */
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
@@ -88,12 +110,16 @@ public class SchemaPage extends BasePage{
                                password,
                                tapschemaName);
                                */
                        // delete tables in tapschema database
                        updateTapSchema.resetTapSchemaDatabase(
                                hostname,
                                port,
                                username,
                                password,
                                tapschemaName);
                        
                        // inserts the metadata from the variables of
                        //tapschema structure to the tapschema database
                        updateTapSchema.updateTapSchemaDatabase(
                                hostname,
                                port,
@@ -127,6 +153,12 @@ public class SchemaPage extends BasePage{
                
            }
            
            /**
             * onSubmit method of backSubmit AjaxSubmitLink sends back to SelectSchemataPage.
             * 
             * @param target
             * @param form
             */
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
@@ -158,6 +190,18 @@ public class SchemaPage extends BasePage{
        schemaForm.add(infoTextArea);
    }
    
    /**
     * populateSchemaTabs method creates and populates SchemaTabs dinamically.
     * 
     * @param target
     * @param form
     * @param hostname
     * @param port
     * @param username
     * @param password
     * @param tapschemaName
     * @param tapschema tapschema structure
     */
    public void populateSchemaTabs(
            final AjaxRequestTarget target,
            final Form<?> form,
@@ -198,6 +242,19 @@ public class SchemaPage extends BasePage{
        }
    }
    
    /**
     * populateTableTabs method creates and populates TableTabs dinamically.
     * 
     * @param target
     * @param form
     * @param hostname
     * @param port
     * @param username
     * @param password
     * @param tapschemaName
     * @param schema current schema structure
     * @param schemaPanel 
     */
    public void populateTableTabs(
            AjaxRequestTarget target,
            Form<?> form,
@@ -211,14 +268,14 @@ public class SchemaPage extends BasePage{
    {
        try
        {
            //populate tablesTabs
            //populates tablesTabs
            List<ITab> tablesTabs = schemaPanel.tablesTabs;
            tablesTabs.removeAll(tablesTabs);
            for (Table table : schema.tablesMap.values())
            {
                final String table_name = table.table_name;

                //populate rowsList
                //populates rowsList
                List<Row> rowsList = new ArrayList<Row>();
                rowsList.removeAll(rowsList);
                for (Column column : table.columnsMap.values())
@@ -266,7 +323,7 @@ public class SchemaPage extends BasePage{
                            column.std));
                }

                //create tablesTabs dynamically
                //creates tablesTabs dynamically
                TableTab tableTab = new TableTab(
                        rowsList,
                        hostname,
Loading