[Ds-java-dev] svn commit r17215 - in trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide: dialog wizard

svn at wso2.org svn at wso2.org
Wed May 21 02:00:17 PDT 2008


Author: samindaw
Date: Wed May 21 02:00:17 2008
New Revision: 17215

Log:
refactoring the variable names operator symbols and putting decriptions for function names

Modified:
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java	Wed May 21 02:00:17 2008
@@ -45,17 +45,20 @@
 	private Text sqlColumnNameText;
 	private Text outputFieldNameText;
 
-	private boolean isEditMode=false;
+	private boolean isEditMode = false;
 	private List tmpData;
 	
 	public AddOutputMappingDialog(Shell parentShell, List data) {
 		super(parentShell);
-		isEditMode=(data!=null);
-		tmpData=data;	
-		mappingData=new ArrayList();
+		isEditMode = (data !=  null);
+		tmpData = data;	
+		mappingData = new ArrayList();
 		resetMappingData();
 	}
 
+	/**
+	 * clear the values in the list which keeps the mapping data
+	 */
 	private void resetMappingData(){
 		mappingData.clear();
 		mappingData.add("");
@@ -147,7 +150,7 @@
 		comboChanged();
 		if (isEditMode){
 			updateMappingData(tmpData);
-			mappingData=tmpData;
+			mappingData = tmpData;
 		}
 		return super.createDialogArea(parent);
 	}
@@ -161,6 +164,9 @@
 		mappingTypeCombo.add("ATTRIBUTE");
 	}
 
+	/**
+	 * when the text box values change
+	 */
 	private void pathChanged() {
 		mappingData.set(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL,
 				sqlColumnNameText.getText().trim());
@@ -170,10 +176,10 @@
 	}
 	
 	/**
-	 * Ensures that both text fields are set.
+	 * Ensures that both combobox fields are set.
 	 */
 	private void comboChanged() {
-		if (mappingTypeCombo.getSelectionIndex()>-1) 
+		if (mappingTypeCombo.getSelectionIndex() > -1) 
 			mappingData.set(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_TYPE, 
 					mappingTypeCombo.getItem(mappingTypeCombo.getSelectionIndex()).trim());
 	}
@@ -182,10 +188,14 @@
 		return mappingData;
 	}
 	
+	/**
+	 * update the UI components with the values in a list which contains mapping data
+	 * @param data: list which contains mapping data
+	 */
 	private void updateMappingData(List data){
-		int i=mappingTypeCombo.indexOf(
+		int i = mappingTypeCombo.indexOf(
 				data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_TYPE).toString());
-		if (i>=0) mappingTypeCombo.select(i);
+		if (i >= 0) mappingTypeCombo.select(i);
 		
 		sqlColumnNameText.setText(data.get(
 				WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString());
@@ -199,9 +209,13 @@
 		}
 	}
 	
+	/**
+	 * validate the entered data
+	 * @return true if the entered data are all valid
+	 */
 	private boolean isAllDataValid(){
 		String validateString;
-		validateString=mappingData.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString();
+		validateString = mappingData.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString();
 		if (validateString.equals("")){
 			showMsg("Output field name cannot be empty.");
 			return false;
@@ -212,7 +226,7 @@
 			}
 		}
 		
-		validateString=mappingData.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString();
+		validateString = mappingData.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString();
 		if (validateString.equals("")){
 			showMsg("SQL column name cannot be empty.");
 			return false;
@@ -221,9 +235,13 @@
 		return true;
 	}
 	
-	private void showMsg(String msg){
-		MessageBox messageBox =new MessageBox(getShell(),SWT.OK);
-		 messageBox.setMessage(msg);
+	/**
+	 * show a message box
+	 * @param message
+	 */
+	private void showMsg(String message){
+		MessageBox messageBox  = new MessageBox(getShell(),SWT.OK);
+		 messageBox.setMessage(message);
 		 messageBox.open();
 	}
 	

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java	Wed May 21 02:00:17 2008
@@ -72,22 +72,25 @@
 	private List outputMapList;
 	private List tmpQIDList;
 	
-	private boolean isEditMode=false;
+	private boolean isEditMode = false;
 	
 	public AddQueryDialog(Shell parentShell, String headingPrefix,
 			WSO2DataserviceWizardStepTwo page) {
 		super(parentShell);
 		configList = new ArrayList();
-		inputMapList=new ArrayList();
-		outputMapList=new ArrayList();
+		inputMapList = new ArrayList();
+		outputMapList = new ArrayList();
 		resetConfigData();
 		dialogHeadingPrefix = headingPrefix;
-		isEditMode=headingPrefix.equals(WSO2DataserviceWizardConstant.editTag);
+		isEditMode = headingPrefix.equals(WSO2DataserviceWizardConstant.editTag);
 		//Obtain the current context from eclipse preferences.
 
 		parentPage = page;
 	}
 
+	/**
+	 * clear the query data
+	 */
 	private void resetConfigData(){
 		configList.clear();
 		configList.add("");
@@ -236,7 +239,7 @@
 		gd.horizontalSpan = 1;
 		editButtonInputMap.setLayoutData(gd);
 
-		deleteButtonInputMap= new Button(container, SWT.PUSH);
+		deleteButtonInputMap =  new Button(container, SWT.PUSH);
 		deleteButtonInputMap.setText("Delete Selected Mapping");
 		deleteButtonInputMap.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
@@ -364,7 +367,7 @@
 		gd.horizontalSpan = 1;
 		editButtonOutputMap.setLayoutData(gd);
 
-		deleteButtonOutputMap= new Button(container, SWT.PUSH);
+		deleteButtonOutputMap =  new Button(container, SWT.PUSH);
 		deleteButtonOutputMap.setText("Delete Selected Mapping");
 		deleteButtonOutputMap.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
@@ -390,24 +393,28 @@
 		 * setup the environment for edit mode
 		 */
 		if (isEditMode){
-			String qId=parentPage.getSelectedQueryId();
-			List tmpConfigList=parentPage.getQueryData(qId);
+			String qId = parentPage.getSelectedQueryId();
+			List tmpConfigList = parentPage.getQueryData(qId);
 			resetQueryData(tmpConfigList);
-			configList=tmpConfigList;
+			configList = tmpConfigList;
 			queryIDText.setEditable(false);
 		}
       return super.createDialogArea(parent);
 	}
 
+	/**
+	 * sets the UI component values to the values in a List which has query information  
+	 * @param tmpConfigList: List containing the query information 
+	 */
 	private void resetQueryData(List tmpConfigList){
-		if (tmpConfigList!=null){
+		if (tmpConfigList!= null){
 			queryIDText.setText((String)tmpConfigList.get(0));
 			sqlStatementText.setText((String)tmpConfigList.get(1));
 			rowNamespaceText.setText((String)tmpConfigList.get(2));
 			groupByElementText.setText((String)tmpConfigList.get(3));
 			rowNameText.setText((String)tmpConfigList.get(4));
-			inputMapList=(List)tmpConfigList.get(5);
-			outputMapList=(List)tmpConfigList.get(6);
+			inputMapList = (List)tmpConfigList.get(5);
+			outputMapList = (List)tmpConfigList.get(6);
 			updateTable(tableInputMaps, inputMapList);
 			updateTable(tableOutputMaps, outputMapList);
 		} 	
@@ -421,7 +428,7 @@
 		addOutputMappingDialog.create();
 		addOutputMappingDialog.getShell().setSize(500, 350);
 		addOutputMappingDialog.open();
-		if (addOutputMappingDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+		if (addOutputMappingDialog.getReturnCode() == org.eclipse.jface.window.Window.OK){
 			setMappingData(outputMapList, -1, addOutputMappingDialog.getMappingData());
 			updateTable(tableOutputMaps,outputMapList);
 		}
@@ -436,7 +443,7 @@
 		addInputParamDialog.create();
 		addInputParamDialog.getShell().setSize(500, 350);
 		addInputParamDialog.open();
-		if (addInputParamDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+		if (addInputParamDialog.getReturnCode() == org.eclipse.jface.window.Window.OK){
 			setMappingData(inputMapList, -1, addInputParamDialog.getMappingData());
 			updateTable(tableInputMaps,inputMapList);
 		}
@@ -462,7 +469,7 @@
 	}
 	
 	private void showMsg(String msg){
-		MessageBox messageBox =new MessageBox(getShell(),SWT.OK);
+		MessageBox messageBox  = new MessageBox(getShell(),SWT.OK);
 		 messageBox.setMessage(msg);
 		 messageBox.open();
 	}
@@ -495,7 +502,8 @@
 		if (isQueryIDAlreadyPresent(
 				configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString())){
 			inputMappingButton.setEnabled(isEditMode);
-			if (isEditMode) labelMessage.setText(""); else labelMessage.setText("Query ID already exists.");
+			if (isEditMode) labelMessage.setText(""); 
+			else labelMessage.setText("Query ID already exists.");
 			outMappingButton.setEnabled(isEditMode && (!configList.get
 					(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT).toString().equals("")));
 		}else{
@@ -513,10 +521,15 @@
 		
 	}
 	
-	private boolean isQueryIDAlreadyPresent(String qid){
-		if (qid.equals("")) return false;
-		if (tmpQIDList==null) tmpQIDList=parentPage.getQueryIdList();
-		return (tmpQIDList.indexOf(qid)>=0);
+	/**
+	 * checks whether the given query id is already present in the query list 
+	 * @param qid: query id tested
+	 * @return true if the id is already present
+	 */
+	private boolean isQueryIDAlreadyPresent(String queryId){
+		if (queryId.equals("")) return false;
+		if (tmpQIDList == null) tmpQIDList = parentPage.getQueryIdList();
+		return (tmpQIDList.indexOf(queryId) >= 0);
 	}
 	/**
 	 * Return the current Config List
@@ -526,24 +539,28 @@
 		return configList;
 	}
 
+	/**
+	 * validate the data entered
+	 * @return true if all the data are valid
+	 */
 	private boolean isAllDataValid(){
 		String validateString;
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString();
-		if ((!isEditMode)&&(parentPage.getQueryData(validateString)!=null)){
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString();
+		if ((!isEditMode)&& (parentPage.getQueryData(validateString)!= null)){
 			showMsg("Query Id '"+validateString+"' already present.");
 			return false;
 		}
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString().trim();
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString().trim();
 		if (validateString.equals("")){
 			showMsg("Query id is required.");
 			return false;
 		}
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERY).toString();
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERY).toString();
 		if (validateString.trim().equals("")){
 			showMsg("Sql statement is required.");
 			return false;
 		}
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT).toString();
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT).toString();
 		if (validateString.trim().equals("")){
 			showMsg("Group by element is required.");
 			return false;
@@ -553,7 +570,7 @@
 				return false;
 			}
 		}
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_ROW_NAME).toString();
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_ROW_NAME).toString();
 		if (validateString.trim().equals("")){
 			showMsg("Row name is required.");
 			return false;
@@ -564,7 +581,7 @@
 			}
 		}
 		
-		validateString=configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_NAME_SPACE).toString();
+		validateString = configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_NAME_SPACE).toString();
 		if (!validateString.trim().equals("")){
 			if (!WSO2DataserviceWizardStepTwo.isStringValidXmlTag(validateString)){
 				showMsg("Row namespace string '"+validateString+"' is not a valid xml tag string.");
@@ -584,22 +601,27 @@
 	 * Handle when an item in the query table is selected 
 	 */
 	private void handleInputMapTableItemSelected(){
-		editButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!=-1);
-		deleteButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!=-1);
+		editButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!= -1);
+		deleteButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!= -1);
 	}
 	
 	/**
 	 * Handle when an item in the query table is selected 
 	 */
 	private void handleOutputMapTableItemSelected(){
-		editButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex()!=-1);
-		deleteButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex()!=-1);
+		editButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex() != -1);
+		deleteButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex() != -1);
 	}
 	
+	/**
+	 * updates the input/output mapping tables with the mapping list data 
+	 * @param tbl: table to update
+	 * @param fillItems: the list mapping data to be updated from 
+	 */
 	private void updateTable(Table tbl,List fillItems) {
-		if (fillItems != null) {
+		if (fillItems !=  null) {
 			int queryCount = fillItems.size();
-			int indexSelected=tbl.getSelectionIndex();
+			int indexSelected = tbl.getSelectionIndex();
 			tbl.removeAll();
 			if (queryCount > 0) {
 				TableItem[] items = new TableItem[queryCount]; // An item for each field
@@ -607,7 +629,7 @@
 					items[i] = new TableItem(tbl, SWT.NONE);
 					//Get the Query ID
 					List iMapItem = (List)fillItems.get(i);
-					if (tbl==tableInputMaps){
+					if (tbl == tableInputMaps){
 						items[i].setText(new String[]{
 							iMapItem.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME).toString()
 							,iMapItem.get(
@@ -624,28 +646,28 @@
 						
 					}
 				}
-				if (indexSelected>(queryCount-1)){
-					indexSelected=queryCount-1;
+				if (indexSelected > (queryCount-1)){
+					indexSelected = queryCount-1;
 				}
 				tbl.setSelection(indexSelected);
 				//updateStatus(null);
 			}
 			tbl.redraw();
 		}
-		setTableVisibleStatus(tbl, fillItems.size()>0);
+		setTableVisibleStatus(tbl, fillItems.size() > 0);
 	}
 	
 	/**
 	 * Handle edit Query
 	 */
 	private void handleInputMapEditQuery() {
-		if (tableInputMaps.getSelectionIndex()>=0){
+		if (tableInputMaps.getSelectionIndex() >= 0){
 			AddInputParamDialog addInputParamDialog = new AddInputParamDialog(getShell(),
 					(List)inputMapList.get(tableInputMaps.getSelectionIndex()));
 			addInputParamDialog.create();
 			addInputParamDialog.getShell().setSize(500, 350);
 			addInputParamDialog.open();
-			if (addInputParamDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+			if (addInputParamDialog.getReturnCode() == org.eclipse.jface.window.Window.OK){
 				updateTable(tableInputMaps,inputMapList);
 			}
 		}
@@ -655,13 +677,13 @@
 	 * Handle edit Query
 	 */
 	private void handleOutputMapEditQuery() {
-		if (tableOutputMaps.getSelectionIndex()>=0){
+		if (tableOutputMaps.getSelectionIndex() >= 0){
 			AddOutputMappingDialog addOutputMappingDialog = new AddOutputMappingDialog(getShell(),
 					(List)outputMapList.get(tableOutputMaps.getSelectionIndex()));
 			addOutputMappingDialog.create();
 			addOutputMappingDialog.getShell().setSize(500, 350);
 			addOutputMappingDialog.open();
-			if (addOutputMappingDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+			if (addOutputMappingDialog.getReturnCode() == org.eclipse.jface.window.Window.OK){
 				updateTable(tableOutputMaps,outputMapList);
 			}
 		}
@@ -671,10 +693,10 @@
 	 * Handle delete Query
 	 */
 	private void handleInputMapDeleteQuery() {
-		if (tableInputMaps.getSelectionIndex()>=0){
-			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+		if (tableInputMaps.getSelectionIndex() >= 0){
+			MessageBox messageBox  = new MessageBox(getShell(),SWT.YES|SWT.NO);
 			messageBox.setMessage("Are you sure you want to remove the selected input mapping?");
-			if (messageBox.open()==SWT.YES){
+			if (messageBox.open() == SWT.YES){
 				removeQueryData(inputMapList, tableInputMaps.getSelectionIndex());
 				updateTable(tableInputMaps,inputMapList);
 				handleInputMapTableItemSelected();
@@ -686,10 +708,10 @@
 	 * Handle delete Query
 	 */
 	private void handleOutputMapDeleteQuery() {
-		if (tableOutputMaps.getSelectionIndex()>=0){
-			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+		if (tableOutputMaps.getSelectionIndex() >= 0){
+			MessageBox messageBox  = new MessageBox(getShell(),SWT.YES|SWT.NO);
 			messageBox.setMessage("Are you sure you want to remove the selected output mapping?");
-			if (messageBox.open()==SWT.YES){
+			if (messageBox.open() == SWT.YES){
 				removeQueryData(outputMapList, tableOutputMaps.getSelectionIndex());
 				updateTable(tableOutputMaps,outputMapList);
 				handleOutputMapTableItemSelected();
@@ -697,28 +719,45 @@
 		}
 	}
 	
+	/**
+	 * change the visibility of a table
+	 * @param tbl: table object
+	 * @param visible
+	 */
 	private void setTableVisibleStatus(Table tbl,boolean visible){
-		visible=true;
+		visible = true;
 		tbl.setVisible(visible);
 		if (visible){
-			((GridData)tbl.getLayoutData()).heightHint=80;
+			((GridData)tbl.getLayoutData()).heightHint = 80;
 		}else{
-			((GridData)tbl.getLayoutData()).heightHint=0;
+			((GridData)tbl.getLayoutData()).heightHint = 0;
 		}
 	}
 	
+	/**
+	 * update the input/output mapping data to the input/output mapping list
+	 * @param mapList: input/output maplist to update
+	 * @param index: the index of the existing input/output mapping. -1 for a new mapping
+	 * @param data: the data to be updated for the mapping
+	 * @return the index of mapping data updated in the list.
+	 */
 	public int setMappingData(List mapList,int index, List data){
-		if ((index<0) ||(index>(mapList.size()-1))){
+		if ((index < 0) || (index > (mapList.size()-1))){
 			mapList.add(data);
-			index=mapList.size()-1;
+			index = mapList.size()-1;
 		}else{
 			mapList.set(index, data);
 		}
 		return index;
 	}
 	
+	/**
+	 * remove the mapping data from the input/output list
+	 * @param mapList
+	 * @param index: index of the mapping in the list to remove
+	 */
 	public void removeQueryData(List mapList,int index){
-		if ((index>=0) &&(index<mapList.size())){
+		if ((index >= 0) && (index < mapList.size())){
 			mapList.remove(index);
 		}
 	}

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java	Wed May 21 02:00:17 2008
@@ -61,22 +61,22 @@
 	private Table table;
 	private PersistentDSContext dsContext;
 
-	public static final int SQLQUERY_QUERYID=0;
-	public static final int SQLQUERY_QUERY=1;
-	public static final int SQLQUERY_NAME_SPACE=2;
-	public static final int SQLQUERY_ELEMENT=3;
-	public static final int SQLQUERY_ROW_NAME=4;
-	public static final int SQLQUERY_INPUT_MAPS=5;
-	public static final int SQLQUERY_OUTPUT_MAPS=6;
-	
-	public static final int SQLQUERY_IMAP_NAME=0;
-	public static final int SQLQUERY_IMAP_SQL_TYPE=1;
-	public static final int SQLQUERY_IMAP_INOUT_TYPE=2;
-	public static final int SQLQUERY_IMAP_ORDINAL=3;
-	
-	public static final int SQLQUERY_OMAP_TYPE=0;
-	public static final int SQLQUERY_OMAP_OUT_FIELD=1;
-	public static final int SQLQUERY_OMAP_SQL_COL=2;
+	public static final int SQLQUERY_QUERYID = 0;
+	public static final int SQLQUERY_QUERY = 1;
+	public static final int SQLQUERY_NAME_SPACE = 2;
+	public static final int SQLQUERY_ELEMENT = 3;
+	public static final int SQLQUERY_ROW_NAME = 4;
+	public static final int SQLQUERY_INPUT_MAPS = 5;
+	public static final int SQLQUERY_OUTPUT_MAPS = 6;
+	
+	public static final int SQLQUERY_IMAP_NAME = 0;
+	public static final int SQLQUERY_IMAP_SQL_TYPE = 1;
+	public static final int SQLQUERY_IMAP_INOUT_TYPE = 2;
+	public static final int SQLQUERY_IMAP_ORDINAL = 3;
+	
+	public static final int SQLQUERY_OMAP_TYPE = 0;
+	public static final int SQLQUERY_OMAP_OUT_FIELD = 1;
+	public static final int SQLQUERY_OMAP_SQL_COL = 2;
 	/**
 	 * Constructor for WSO2DataserviceWizardStepTwo.
 	 * @param pageName
@@ -157,7 +157,7 @@
 		gd.horizontalSpan = 2;
 		editButton.setLayoutData(gd);
 
-		deleteButton= new Button(container, SWT.PUSH);
+		deleteButton =  new Button(container, SWT.PUSH);
 		deleteButton.setText("Delete Selected Query");
 		deleteButton.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
@@ -212,12 +212,12 @@
 	 * @param fillItems : query list to load to the table
 	 */
 	private void updateTable(List fillItems) {
-		if (fillItems != null) {
+		if (fillItems !=  null) {
 			int queryCount = fillItems.size();
-			String selectedId=null;
-			int indexSelected=table.getSelectionIndex();
-			if (table.getSelectionIndex()>-1){
-				selectedId=table.getItem(table.getSelectionIndex()).getText();
+			String selectedId = null;
+			int indexSelected = table.getSelectionIndex();
+			if (table.getSelectionIndex() > -1){
+				selectedId = table.getItem(table.getSelectionIndex()).getText();
 			}
 			table.removeAll();
 			if (queryCount > 0) {
@@ -228,15 +228,15 @@
 					List iQueryItem = (List)fillItems.get(i);
 					items[i].setText(iQueryItem.get(SQLQUERY_QUERYID).toString());
 					items[i].setChecked(true);//check them all by default
-					if (selectedId!=null){
+					if (selectedId != null){
 						if (iQueryItem.get(SQLQUERY_QUERYID).toString().equals(selectedId)){
-							indexSelected=i;
+							indexSelected = i;
 						}						
 					}
 					
 				}
-				if (indexSelected>(queryCount-1)){
-					indexSelected=queryCount-1;
+				if (indexSelected > (queryCount-1)){
+					indexSelected = queryCount-1;
 				}
 				table.setSelection(indexSelected);
 				updateStatus(null);
@@ -247,7 +247,7 @@
 	}
 
 	/**
-	 * Get the query information related to given query id
+	 * Get the query data related to given query id
 	 * @param queryId
 	 * @return
 	 */
@@ -262,6 +262,11 @@
 		return null;
 	}
 	
+	/**
+	 * Update the query data in the query list for the relevant query id 
+	 * @param queryId
+	 * @param data
+	 */
 	public void setQueryData(String queryId, List data){
 		int queryCount = queryToUIMapping.size();
 		for (int i = 0; i < queryCount; i++) {
@@ -274,6 +279,10 @@
 		queryToUIMapping.add(data);
 	}
 	
+	/**
+	 * Remove a query specified by query id
+	 * @param queryId
+	 */
 	public void removeQueryData(String queryId){
 		int queryCount = queryToUIMapping.size();
 		for (int i = 0; i < queryCount; i++) {
@@ -285,9 +294,12 @@
 		}
 	}
 	
-	
+	/**
+	 * Retrieve a list of query ids currently present
+	 * @return
+	 */
 	public List getQueryIdList(){
-		List IdList=new ArrayList();
+		List IdList = new ArrayList();
 		int queryCount = queryToUIMapping.size();
 		for (int i = 0; i < queryCount; i++) {
 			List iQueryItem = (List)queryToUIMapping.get(i);
@@ -301,7 +313,7 @@
 	 * @return
 	 */
 	public String getSelectedQueryId(){
-		if (table.getSelectionIndex()>-1){
+		if (table.getSelectionIndex() > -1){
 			return table.getItem(table.getSelectionIndex()).getText();
 		}
 		return null;
@@ -325,8 +337,8 @@
 	 * Handle when an item in the query table is selected 
 	 */
 	private void handleTableItemSelected(){
-		editButton.setEnabled(table.getSelectionIndex()!=-1);
-		deleteButton.setEnabled(table.getSelectionIndex()!=-1);
+		editButton.setEnabled(table.getSelectionIndex() != -1);
+		deleteButton.setEnabled(table.getSelectionIndex() != -1);
 	}
 	/**
 	 * Handle add new Query
@@ -338,7 +350,7 @@
 		addQueryDialog.create();
 		addQueryDialog.getShell().setSize(500, 800);
 		addQueryDialog.open();
-		if (addQueryDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+		if (addQueryDialog.getReturnCode() == org.eclipse.jface.window.Window.OK){
 			noOfLoadedQuery++;
 			updateTable(queryToUIMapping);			
 		}
@@ -349,7 +361,7 @@
 	 */
 	private void handleEditQuery() {
 		//Add Query Selection
-		if (table.getSelectionIndex()>=0){
+		if (table.getSelectionIndex() >= 0){
 			AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(), 
 				WSO2DataserviceWizardConstant.editTag, this);
 			addQueryDialog.create();
@@ -362,10 +374,10 @@
 	 * Handle delete Query
 	 */
 	private void handleDeleteQuery() {
-		if (table.getSelectionIndex()>=0){
-			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+		if (table.getSelectionIndex() >= 0){
+			MessageBox messageBox  = new MessageBox(getShell(),SWT.YES|SWT.NO);
 			messageBox.setMessage("Are you sure you want to remove the selected query?");
-			if (messageBox.open()==SWT.YES){
+			if (messageBox.open() == SWT.YES){
 				removeQueryData(getSelectedQueryId());
 				noOfLoadedQuery--;
 				updateTable(queryToUIMapping);
@@ -377,7 +389,7 @@
 
 	private void updateStatus(String message) {
 		setErrorMessage(message);
-		setPageComplete(message == null);
+		setPageComplete(message  ==  null);
 	}
 	
 	public String loadPreviousConfig(){
@@ -414,9 +426,9 @@
 						node.detach();
 					}
 			}
-			List qIdList=getQueryIdList();
+			List qIdList = getQueryIdList();
 			OMElement element;
-			for(int i=0;i<qIdList.size();i++){
+			for(int i = 0;i < qIdList.size();i++){
 				element = createQueryElement(getQueryData((String)qIdList.get(i)));
 				root.addChild(element);	
 			}
@@ -447,8 +459,8 @@
 		currentElement.setText(configData.get(SQLQUERY_QUERY).toString());
 		root.addChild(currentElement);
 		
-		for(int i=0;i<((List)configData.get(SQLQUERY_INPUT_MAPS)).size();i++){
-			List mapData=(List)((List)configData.get(SQLQUERY_INPUT_MAPS)).get(i);
+		for(int i = 0;i < ((List)configData.get(SQLQUERY_INPUT_MAPS)).size();i++){
+			List mapData = (List)((List)configData.get(SQLQUERY_INPUT_MAPS)).get(i);
 			currentElement = factory.createOMElement("param",null);
 			currentElement.addAttribute(
 					"name",mapData.get(SQLQUERY_IMAP_NAME).toString(), null);
@@ -466,8 +478,8 @@
 				configData.get(SQLQUERY_NAME_SPACE).toString(), null);
 		currentElement.addAttribute("element",configData.get(SQLQUERY_ELEMENT).toString(), null);
 		currentElement.addAttribute("rowName",configData.get(SQLQUERY_ROW_NAME).toString(), null);
-		for(int i=0;i<((List)configData.get(SQLQUERY_OUTPUT_MAPS)).size();i++){
-			List mapData=(List)((List)configData.get(SQLQUERY_OUTPUT_MAPS)).get(i);
+		for(int i = 0;i < ((List)configData.get(SQLQUERY_OUTPUT_MAPS)).size();i++){
+			List mapData = (List)((List)configData.get(SQLQUERY_OUTPUT_MAPS)).get(i);
 			OMElement tcurrentElement = 
 				factory.createOMElement(
 						mapData.get(SQLQUERY_OMAP_TYPE).toString().toLowerCase(),null);
@@ -481,8 +493,13 @@
 		return root;
 	}
 	
-	public static boolean isStringValidXmlTag(String s){
-		java.util.regex.Pattern p= java.util.regex.Pattern.compile("[A-Za-z]([A-Za-z0-9._]|-)*");
-		return p.matcher(s).matches();
+	/**
+	 * validates whether the string passed can be used as a valid string for a xml tag
+	 * @param xmlTagString: the string that needs to be validated 
+	 * @return true if the string is a valid xml tag string
+	 */
+	public static boolean isStringValidXmlTag(String xmlTagString){
+		java.util.regex.Pattern p = java.util.regex.Pattern.compile("[A-Za-z]([A-Za-z0-9._]|-)*");
+		return p.matcher(xmlTagString).matches();
 	}
 }
\ No newline at end of file



More information about the Ds-java-dev mailing list