Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r3871 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model

Subject: perfsonar development work

List archive

perfsonar: r3871 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r3871 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model
  • Date: Fri, 23 May 2008 05:53:42 -0400

Author: melis
Date: 2008-05-23 05:53:42 -0400 (Fri, 23 May 2008)
New Revision: 3871

Modified:

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
Log:
Updated SVN with basic working version of LG plugin (sending multiple
requests to multiple MPs/devices and displaying the result).

Will start adding new extra features now.

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -53,14 +53,14 @@
public org.w3c.dom.Document createRequest(IUserData uData, String
messageType)
throws Exception {

- System.out.println("*** createRequest(" + uData + ", " + messageType
+ ") called");
+ //System.out.println("[LGRequest] createRequest(" + uData + ", " +
messageType + ") called");
org.w3c.dom.Document doc = null;

org.jdom.Document jdoc = null;

if (IPerfsonarRequest.MA_MetadataKeyRequest.equals(messageType)) {

- //System.out.println("MetadataKeyRequest is being made...");
+ //System.out.println("[LGRequest] MetadataKeyRequest is being
made...");

jdoc = new Document();

@@ -99,7 +99,7 @@

} else if (IPerfsonarRequest.MA_SetupDataRequest.equals(messageType))
{

- System.out.println("SetupDataRequest is being made...");
+ //System.out.println("[LGRequest] SetupDataRequest is being
made...");

jdoc = new Document();

@@ -179,25 +179,21 @@
// IUserData entries
// This is if you need to send several simultaneous request for each
// entries in query - not sure if relevant for LG
- System.out.println("createRequest (" + endpoint + ", " + query + ", "
+ messageType + ") called");
return null;
}

@Override
public String getMessageNamespace() {
// TODO Auto-generated method stub
- System.out.println("getMessageNamespace() called");
return null;
}

public String[] getNamespaces() {
// TODO Auto-generated method stub
- System.out.println("getNamespace() called");
return null;
}

public String getRequestType() {
- System.out.println("getRequestType(() called");
return "lg";
}

@@ -208,7 +204,7 @@
IPerfsonarResponse listener) throws Exception {
// TODO Auto-generated method stub

- System.out.println("The response is:");
+ System.out.print("[LGRequest] The response is:");

StringWriter sw = new StringWriter();
XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(response));
@@ -232,7 +228,7 @@
// call on the end point
Object resultObject = null;
try {
- //logger.debug("Sending request to\t" + query.getEndpoint());
+ logger.debug("Sending request to\t" + query.getEndpoint());
//logger.debug(requestMessage);
//call.setTimeout(new Integer(1800000)); //30 min

@@ -241,7 +237,7 @@

SOAPEnvelope envelope = prepareEnvelope(requestMessage);

- System.out.println("**** requestMessage: " + requestMessage);
+ //System.out.println("[LGRequest] requestMessage: " +
requestMessage);

if (envelope != null) {
resultObject = call.invoke(new Message(envelope));

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -101,14 +101,18 @@
boolean ok = false;
//For each endpoint

- System.out.println("\n\nThere are " + endpoints.size() + " MPs to
be contacted.");
+ //System.out.println("\n\nThere are " + endpoints.size() + " MPs
to be contacted.");

+ parent.clearResults();
+
for (int i = 0; i < endpoints.size(); i++) {
if (isInterrupted()) {
break;
}
LGEndpoint mae = (LGEndpoint) endpoints.get(i);

+ final LGEndpoint mp = mae;
+
//if (mae.isEnabled()){
ok = true;
dataList.setNotificationEnabled(false);
@@ -117,7 +121,7 @@
// --> no longer supported, because it is possible for
another MP to be added to the list this way
//parent.addCurrentDeviceToDevicesList();
userData.setEndpoint(mae);
- System.out.println("Sending request " + (i+1) + " to " +
userData.getEndpoint());
+ //System.out.println("Sending request " + (i+1) + " to " +
userData.getEndpoint());
request.fireStatusMessage("Sending request to " +
userData.getEndpoint());

try {
@@ -150,7 +154,7 @@
super.process(request, uData, response);
//getDataList().setSelectedItem(null);

//parent.webserviceComboboxActionperformedHandler(response);
- parent.setResponse(response);
+ parent.setResponse(mp, response);
}

@Override

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -20,9 +20,9 @@
package org.perfsonar.perfsonarui.lookingglass;

import java.awt.Component;
+import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -34,6 +34,7 @@
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.event.ChangeEvent;
@@ -48,7 +49,6 @@
import org.perfsonar.perfsonarui.lookingglass.model.LGEndpoint;
import org.perfsonar.perfsonarui.lookingglass.model.LatestResultListModel;
import org.perfsonar.perfsonarui.lookingglass.model.LookingGlassClientModel;
-import
org.perfsonar.perfsonarui.lookingglass.model.QueriedDeviceComboboxModel;
import org.perfsonar.perfsonarui.lookingglass.model.WebserviceComboboxModel;
import org.perfsonar.perfsonarui.lookingglass.model.WebservicesModel;
import org.perfsonar.perfsonarui.lookingglass.support.TextHighlighter;
@@ -117,10 +117,14 @@
//private ParameterListModel parameterListModel;
private DeviceListModel deviceListModel;
private LatestResultListModel latestResultListModel;
- private QueriedDeviceComboboxModel queriedDeviceComboboxModel1;
- private QueriedDeviceComboboxModel queriedDeviceComboboxModel2;
private IPerfsonarTab iperftab;

+ private boolean and = true;
+
+ private boolean importExportEnabled = false;
+ private boolean searchEnabled = false;
+ private boolean andOrEnabled = false;
+ private boolean appendEnabled = false;

public LookingGlassMainPanel(Component parentFrame, IPerfsonarTab
iperftab) {
super(parentFrame, iperftab);
@@ -148,9 +152,6 @@

latestResultListModel = new LatestResultListModel(model);

- queriedDeviceComboboxModel1 = new QueriedDeviceComboboxModel();
- queriedDeviceComboboxModel2 = new QueriedDeviceComboboxModel();
-
addChangeListener(webserviceComboboxModel);

JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
addTopPane(), addBottomPane());
@@ -232,6 +233,8 @@

exportButton.setText("Export");
exportButton.setEnabled(false);
+ if (!importExportEnabled)
+ exportButton.setToolTipText("This feature hasn't been implemented
yet.");
exportButton.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -240,6 +243,10 @@
});

importButton.setText("Import");
+ if (!importExportEnabled){
+ importButton.setEnabled(false);
+ importButton.setToolTipText("This feature hasn't been implemented
yet.");
+ }
importButton.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -328,11 +335,24 @@

buttonGroup1.add(jRadioButton1);
jRadioButton1.setSelected(true);
+ jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ radiobuttonClicked();
+ }
+ });
jRadioButton1.setText("AND");

buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("OR");

+ if (!andOrEnabled){
+ jRadioButton1.setEnabled(false);
+ jRadioButton2.setEnabled(false);
+ jRadioButton1.setToolTipText("This feature hasn't been
implemented yet.");
+ jRadioButton2.setToolTipText("This feature hasn't been
implemented yet.");
+ }
+
org.jdesktop.layout.GroupLayout jPanel5Layout = new
org.jdesktop.layout.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
@@ -357,8 +377,15 @@

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Response"));

searchTextField.setText("");
-
+ if (!searchEnabled){
+ searchTextField.setEnabled(false);
+ searchTextField.setToolTipText("This feature hasn't been
implemented yet.");
+ }
highlightButton.setText("Search");
+ if (!searchEnabled){
+ highlightButton.setEnabled(false);
+ highlightButton.setToolTipText("This feature hasn't been
implemented yet.");
+ }
highlightButton.addActionListener(new java.awt.event.ActionListener()
{

public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -367,6 +394,10 @@
});

jCheckBox1.setText("Append Output");
+ if (!appendEnabled){
+ jCheckBox1.setEnabled(false);
+ jCheckBox1.setToolTipText("This feature hasn't been implemented
yet.");
+ }
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -429,76 +460,70 @@
}

public void valueChanged(ListSelectionEvent e) {
-
- /*String command = model.getCommand((String)
functionCombobox.getSelectedItem(),
- (MPDevicePair) deviceList.getSelectedValue());
-
- String syntax = model.getSyntax((String)
functionCombobox.getSelectedItem(),
- (MPDevicePair) deviceList.getSelectedValue());
-
- String description = model.getDescription((String)
functionCombobox.getSelectedItem(),
- (MPDevicePair) deviceList.getSelectedValue());
-
- this.commandTextField.setText(command);
- this.syntaxTextField.setText(syntax);
- this.descriptionTextField.setText(description);
- */
- try {
+ /*jTabbedPane1.removeAll();
+
+ for (int i = 0; i < model.getSelectedEndpoints().size(); i++){
+ resultTextArea = new JTextArea();
+ JScrollPane scroll = new JScrollPane(resultTextArea);
+
String result = model.getResult((MPDevicePair)
deviceList.getSelectedValue());
- resultTextArea.setText(result.replaceAll("@@@", "\n"));
+ if (result != null)
+ resultTextArea.setText(result.replaceAll("@@@", "\n"));

resultTextArea.setCaretPosition(0);

- //String status = model.getStatus((String)deviceList.
- // getSelectedValue());
- //statusTextField.setText(status);
- } catch (Exception ex) {
- ex.printStackTrace();
+ jTabbedPane1.add(scroll);
+ jTabbedPane1.setTitleAt(i, ((MPDevicePair)
deviceList.getSelectedValue()).toString());
}
-
+ jTabbedPane1.setSelectedIndex(0);*/
}

public void stateChanged(ChangeEvent event) {

- //System.out.println(System.currentTimeMillis());
- busy = false;
- if (deviceList.getSelectedIndex() > -1) {
+ jTabbedPane1.removeAll();
+
+ for (int i = 0; i < model.getSelectedEndpoints().size(); i++){
+ resultTextArea = new JTextArea();
+ resultTextArea.setEditable(false);
+ JScrollPane scroll = new JScrollPane(resultTextArea);
+
+ String result = model.getResult((MPDevicePair)
model.getSelectedEndpoints().get(i));
+ String status = model.getStatus((MPDevicePair)
model.getSelectedEndpoints().get(i));
+ if(status != null && status.contains("Successfully executed
request")){
+ if (result != null){
+ resultTextArea.setText(result.replaceAll("@@@", "\n"));

- String result = model.getResult((MPDevicePair)
deviceList.getSelectedValue());
- resultTextArea.setText(result.replaceAll("@@@", "\n"));
+ resultTextArea.setCaretPosition(0);

- //String status = model.getStatus((String)deviceList.
- // getSelectedValue());
- //statusTextField.setText(status);
+ jTabbedPane1.add(scroll);
+ jTabbedPane1.setTitleAt(i, ((MPDevicePair)
model.getSelectedEndpoints().get(i)).toString());
+ }
+ } else {
+ if (status != null){
+ resultTextArea.setText(status);

- //parameterListModel.removeAllElements();
+ resultTextArea.setCaretPosition(0);

+ jTabbedPane1.add(scroll);
+ jTabbedPane1.setTitleAt(i, ((MPDevicePair)
model.getSelectedEndpoints().get(i)).toString());
+ }
+ }
+ }
+ if (jTabbedPane1.getTabCount() > 0){
+ jTabbedPane1.setSelectedIndex(0);

-
+ if (searchEnabled){
+ searchTextField.setEnabled(true);
+ highlightButton.setEnabled(true);
+ }
} else {
- String result = "Please select the device in the list above " +
- "for which the result has to be displayed.";
- resultTextArea.setText(result.replaceAll("@@@", "\n"));
-
- //parameterListModel.removeAllElements();
-
-
- commandTextField.setText(model.getCommand(
- (String) functionCombobox.getSelectedItem(),
- (String) deviceCombobox.getSelectedItem()));
-
- //Iterator it = parameterListModel.getAllElements().iterator();
- //while (it.hasNext())
- // commandTextField.setText(commandTextField.getText()
- // + " " + (String)it.next());
+ jTabbedPane1.addTab("", null);
+ if (searchEnabled){
+ searchTextField.setEnabled(false);
+ highlightButton.setEnabled(false);
+ }
}

- searchTextField.setEnabled(true);
- highlightButton.setEnabled(true);
-
-
queriedDeviceComboboxModel1.initComboBox(deviceListModel.getAllElements());
-
-
queriedDeviceComboboxModel2.initComboBox(deviceListModel.getAllElements());
}

public JComboBox getWebserviceComboBox() {
@@ -510,7 +535,11 @@
* Combobox
**/
public void webserviceComboboxActionperformedHandler(Document response) {
-
+
+ //System.out.println("[LookingGlassMainPanel] Response caught,
updating model...");
+
+ busy = true;
+
parameterStringTextField.setText("");
this.parameterStringTextField.setEnabled(false);

@@ -537,6 +566,10 @@
if (deviceCombobox.getItemCount() != 0) {
addAllDevicesButton.setEnabled(true);
}
+
+ busy = false;
+
+ //System.out.println("[LookingGlassMainPanel] Model updated.");
}

public void disableComboboxes() {
@@ -615,14 +648,13 @@
deviceListModel.addElement(endpoint);
//model.addSelectedEndpoint(endpoint);

- resultTextArea.setText(null);
- //statusTextField.setText(null);

}
}

if (deviceListModel.getSize() > 0) {
- exportButton.setEnabled(true);
+ if (importExportEnabled)
+ exportButton.setEnabled(true);
removeDeviceButton.setEnabled(true);

}
@@ -637,7 +669,8 @@
}

if (deviceListModel.getSize() <= 0) {
- exportButton.setEnabled(false);
+ if (importExportEnabled)
+ exportButton.setEnabled(false);
removeDeviceButton.setEnabled(false);
resultTextArea.setText(null);
//statusTextField.setText(null);
@@ -729,9 +762,9 @@

}

- public void setResponse(Document response) {
+ public void setResponse(LGEndpoint mp, Document response) {
try {
- model.setQueryResult(response);
+ model.setQueryResult(mp, response);
} catch (Exception e) {
e.printStackTrace();
}
@@ -760,10 +793,17 @@
parameterStringTextField.setEnabled(false);
parameterStringTextField.setText("");

- searchTextField.setEnabled(false);
- highlightButton.setEnabled(false);
+ if (searchEnabled){
+ searchTextField.setEnabled(false);
+ highlightButton.setEnabled(false);
+ }
+ model.clearResults();
}

+ public void clearResults(){
+ model.clearResults();
+ }
+
public void exportDeviceListActionPerformed(java.awt.event.ActionEvent
evt) {
System.out.println("Exporting devicelist");

@@ -837,11 +877,52 @@
}

removeDeviceButton.setEnabled(true);
- exportButton.setEnabled(true);
+ if (importExportEnabled)
+ exportButton.setEnabled(true);
}

- public void
addAllDevicesAndMPsActionPerformed(java.awt.event.ActionEvent evt) {
-
+ public void
addAllDevicesAndMPsActionPerformed(java.awt.event.ActionEvent evt){
+ //System.out.println("[LookingGlassMainPanel] Number of MPs to
contact: " + webserviceCombobox.getItemCount());
+ for (int j = 0; j < webserviceCombobox.getItemCount(); j++) {
+ busy = true;
+ //System.out.println("[LookingGlassMainPanel] Selecting next
MP...");
+
+ webserviceCombobox.setSelectedItem(null); //if this isn't there,
it
+ // will not trigger a new MetadataKeyRequest for an but the first
MP
+ webserviceCombobox.setSelectedIndex(j);
+ /*try {
+ Thread.sleep(1000);
+ } catch (InterruptedException interruptedException) {
+ }*/
+
+ //System.out.println("[LookingGlassMainPanel] Next MP Selected.
MP: " + webserviceCombobox.getSelectedItem());
+
+ while (busy) {
+ try {
+ //System.out.println("[LookingGlassMainPanel] Still busy
updating the metadata for this MP");
+ Thread.sleep(1000);
+ } catch (InterruptedException interruptedException) {
+ }
+ }
+
+ //System.out.println("[LookingGlassMainPanel] Number of devices
for this MP: " + deviceCombobox.getItemCount());
+
+ for (int i = 0; i < deviceCombobox.getItemCount(); i++) {
+ if (!deviceListModel.contains(new MPDevicePair((LGEndpoint)
webserviceCombobox.getSelectedItem(), (String) deviceCombobox.getItemAt(i))))
{
+ MPDevicePair endpoint = new MPDevicePair((LGEndpoint)
webserviceCombobox.getSelectedItem(), (String) deviceCombobox.getItemAt(i));
+ deviceListModel.addElement(endpoint);
+ //model.addSelectedEndpoint(endpoint);
+ }
+ }
+
+ //System.out.println("[LookingGlassMainPanel] Device Added.");
+
+ }
+
+ deviceCombobox.setSelectedIndex(0);
+ removeDeviceButton.setEnabled(true);
+ if (importExportEnabled)
+ exportButton.setEnabled(true);
}

public void addAllDevicesActionPerformed(java.awt.event.ActionEvent evt)
{
@@ -854,9 +935,14 @@
}
deviceCombobox.setSelectedIndex(0);
removeDeviceButton.setEnabled(true);
- exportButton.setEnabled(true);
+ if (importExportEnabled)
+ exportButton.setEnabled(true);
}

+ public void radiobuttonClicked() {
+
+ }
+
public void appendOutputActionPerformed(java.awt.event.ActionEvent evt) {

}
@@ -866,9 +952,14 @@
//model.clearSelectedEndpoints();

removeDeviceButton.setEnabled(false);
- exportButton.setEnabled(false);
+ if (importExportEnabled)
+ exportButton.setEnabled(false);
}

+ public void setBusy(boolean busy){
+ this.busy = busy;
+ }
+
/**
* Housekeeping code for ChangeListeners
**/

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -43,13 +43,23 @@

if (obj == null || !(obj instanceof MPDevicePair))
return false;
+
if (!((MPDevicePair) obj).getMp().equals(mp))
return false;
+
if (!((MPDevicePair) obj).getDevice().equals(device))
return false;

return true;
}
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 23 * hash + (this.mp != null ? this.mp.hashCode() : 0);
+ hash = 23 * hash + (this.device != null ? this.device.hashCode() : 0);
+ return hash;
+ }

@Override
public String toString(){

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -59,10 +59,11 @@

@Override
public Object run(ActionEvent arg0) {
+
if (parent.getWebserviceComboBox().getSelectedItem() != null) {
- //System.out.println("Selected item: " +
parent.getWebserviceComboBox().getSelectedItem());
+ //System.out.println("[MetadataKeyRequestAction] Selected item: "
+ parent.getWebserviceComboBox().getSelectedItem());
+ //parent.setBusy(true);

-
if (request == null) {
return null;
} //TODO check if this should silently fail
@@ -154,6 +155,7 @@
logger.error(x);
}
}
+ //parent.setBusy(false);
return null;
}


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -60,7 +60,7 @@
//list.add((MPDevicePair)obj);
model.addSelectedEndpoint((MPDevicePair) obj);

- System.out.println("Element added: " + obj);
+ //System.out.println("[DeviceListModel] Element added: " + obj);

fireIntervalAdded(this, index, index);
}
@@ -71,7 +71,7 @@
int index = model.getSelectedEndpoints().size();
success = model.getSelectedEndpoints().remove(obj);

- System.out.println("Element removed: " + obj);
+ //System.out.println("[DeviceListModel] Element removed: " + obj);

fireIntervalRemoved(this, 0, index);


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2008-05-22 12:13:09 UTC (rev 3870)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2008-05-23 09:53:42 UTC (rev 3871)
@@ -7,13 +7,14 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.perfsonar.perfsonarui.lookingglass.model;

import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent;
@@ -23,12 +24,9 @@
import org.apache.xml.serialize.XMLSerializer;
import org.jdom.Namespace;
import org.jdom.input.DOMBuilder;
-import org.perfsonar.perfsonarui.AbstractMARequest;
import org.perfsonar.perfsonarui.lookingglass.MPDevicePair;
import org.w3c.dom.Document;

-
-
/**
* Main model class for the application
*
@@ -36,168 +34,166 @@
* @author smelis (Stijn Melis): Migration to perfsonarUI
*/
public class LookingGlassClientModel {
-
- private String[] resultStringTable = null;
- private String[] resultTimeValueTable = null;
- private String[] resultTimeTypeTable = null;
- private String[] resultValueUnitsTable = null;
- private String[] statusStringTable = null;
- private String[] devicesTable = null;
-
+
protected EventListenerList listenerList = new EventListenerList();
protected final ChangeEvent changeEvent =
new ChangeEvent("LookingGlassClientModel");
-
private List metadata = null;
private List devices = null;
private List functions = null;
private List urls = null;
-
private List<MPDevicePair> selectedEndpoints = null;
-
+ private Map<MPDevicePair, String> results = null;
+ private Map<MPDevicePair, String> stati = null;
private String selectedCommand = null;
-
/* feature ids */
public static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";;
public static final String NAMESPACE_PREFIXES_FEATURE_ID =
"http://xml.org/sax/features/namespace-prefixes";;
-
/* settings */
public static final String DEFAULT_PARSER_NAME =
"org.apache.xerces.parsers.SAXParser";
public static final boolean DEFAULT_NAMESPACES = true;
public static final boolean DEFAULT_NAMESPACE_PREFIXES = true;
-
-
+
/** Creates a new instance of LookingGlassClientModel */
public LookingGlassClientModel() {
-
+
metadata = new ArrayList();
devices = new ArrayList();
functions = new ArrayList();
urls = new ArrayList();
-
+
selectedEndpoints = new ArrayList<MPDevicePair>();
+ results = new HashMap<MPDevicePair, String>();
+ stati = new HashMap<MPDevicePair, String>();
}
-
+
/**
* Housekeeping code
**/
public void addChangeListener(ChangeListener l) {
-
+
listenerList.add(ChangeListener.class, l);
-
+
}
-
+
public void removeChangeListener(ChangeListener l) {
-
+
listenerList.remove(ChangeListener.class, l);
-
+
}
-
+
public void fireStateChanged() {
-
+
Object[] listeners = listenerList.getListenerList();
- for (int i=listeners.length-2; i >= 0; i-=2) {
-
- if (listeners[i] == ChangeListener.class)
- ((ChangeListener)listeners[i+1])
- .stateChanged(changeEvent);
-
+ //System.out.println("[LookingGlassClientModel] number of listeners:
" + listeners.length);
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ //System.out.println("[LookingGlassClientModel] index for
notifying listener: " + i);
+ if (listeners[i] == ChangeListener.class) {
+ ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
+ }
+
}
-
+
}
-
+
public void clearMetadata() {
metadata.clear();
functions.clear();
devices.clear();
- urls.clear();
+ urls.clear();
}
-
+
+ public void clearResults() {
+ results.clear();
+ stati.clear();
+ fireStateChanged();
+ }
+
/**
* Transmits a request towards the selected MP
**/
public void addMetadataForCurrentMP(Document response)
- throws Exception {
+ throws Exception {
//System.out.println("***
LookingGlassClientModel.addMetadataForCurrentMP("+response+") called ***");
-
+
devices.clear();
metadata.clear();
-
+
try {
DOMBuilder dom = new DOMBuilder();
org.jdom.Document resp = dom.build(response);
-
+
org.jdom.Element root = resp.getRootElement();
-
+
List children = root.getChildren();
Iterator it = children.iterator();
-
+
while (it.hasNext()) {
- org.jdom.Element next = (org.jdom.Element)it.next();
+ org.jdom.Element next = (org.jdom.Element) it.next();
//System.out.println(next);
-
+
if (next.getName().equalsIgnoreCase("metadata")) {
//System.out.println(next.getAttribute("id"));
String metadataId = next.getAttributeValue("id");
- if (metadataId.contains("resultCode")) {} else {
+ if (metadataId.contains("resultCode")) {
+ } else {
metadata.add(metadataId);
-
+ //System.out.println("metadataId: " + metadataId);
Iterator it2 = next.getChildren().iterator();
while (it2.hasNext()) {
- org.jdom.Element device =
(org.jdom.Element)it2.next();
- if (device.getName().equalsIgnoreCase("subject"))
-
+ org.jdom.Element device = (org.jdom.Element)
it2.next();
+ if (device.getName().equalsIgnoreCase("subject"))
{
+ //System.out.println("device: " + device);
devices.add(metadata.indexOf(metadataId),
device.getValue());
-
- else {
-
+ } else {
+
Iterator urlpit =
device.getChildren().iterator();
while (urlpit.hasNext()) {
-
- org.jdom.Element ur =
(org.jdom.Element)urlpit.next();
+
+ org.jdom.Element ur = (org.jdom.Element)
urlpit.next();
urls.add(ur.getAttributeValue("value"));
-
+
}
}
}
functions.add(new Vector());
-
+
}
} else if (next.getName().equalsIgnoreCase("data")) {
String metadataId =
next.getAttributeValue("metadataIdRef");
-
+
Iterator it2 = next.getChildren().iterator();
while (it2.hasNext()) {
-
- org.jdom.Element datum = (org.jdom.Element)it2.next();
-
+
+ org.jdom.Element datum = (org.jdom.Element)
it2.next();
+
Iterator it3 = datum.getChildren().iterator();
-
+
String function = null;
String command = null;
String syntax = null;
String description = null;
-
+
while (it3.hasNext()) {
-
- org.jdom.Element element =
(org.jdom.Element)it3.next();
-
+
+ org.jdom.Element element = (org.jdom.Element)
it3.next();
+
//System.out.println("INTERN");
if
(element.getName().equalsIgnoreCase("eventType")) {
-
+
function = element.getText();
- //System.out.println("Function: " + function);
-
+ //System.out.println("Function: " + function);
+
} else if
(element.getName().equalsIgnoreCase("parameters")) {
-
+
Iterator it4 =
element.getChildren().iterator();
-
+
while (it4.hasNext()) {
-
- org.jdom.Element element2 =
(org.jdom.Element)it4.next();
+
+ org.jdom.Element element2 =
(org.jdom.Element) it4.next();
if
(element2.getAttributeValue("name").equalsIgnoreCase("command")) {
command =
element2.getAttributeValue("value");
} else if
(element2.getAttributeValue("name").equalsIgnoreCase("description")) {
@@ -208,319 +204,290 @@
}
}
}
-
-
+
+
Vector v;
-
+
//System.out.println(function + " " + command + " " +
description + " " + syntax);
-
+
if (function != null) {
- v =
(Vector)functions.get(metadata.indexOf(metadataId));
+ v = (Vector)
functions.get(metadata.indexOf(metadataId));
v.add(new Command(function, syntax, description,
command));
- //System.out.println("FUNCTION ADDED:" +
function);
+ //System.out.println("FUNCTION ADDED:" + function);
}
}
}
}
- } /*catch (URISyntaxException ex) {
-
+ } catch (Exception e) {
JOptionPane.showMessageDialog(null,
- "An error occured while executing your task!",
- "Configuration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (RemoteException ex) {
-
- JOptionPane.showMessageDialog(null,
- "An error occured while executing your task!",
- "Configuration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (MalformedURLException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The URL of the MP is not valid!",
- "Configuration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (IOException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The configuration request template could not be read!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (ParserConfigurationException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The XML-file is invalid!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (SAXException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The XML-file is invalid!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- } catch (ServiceException ex) {
-
- JOptionPane.showMessageDialog(null,
"An error occured while contacting the remote service!",
"Communication Error",
JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
- */
- catch (Exception e) {
- JOptionPane.showMessageDialog(null,
- "An error occured while contacting the remote service!",
- "Communication Error",
- JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
-
+
}
-
- public void setQueryResult(Document response)
- throws Exception{
- try {
- StringWriter sw = new StringWriter();
+
+ public void setQueryResult(LGEndpoint mp, Document response)
+ throws Exception {
+ try {
+ StringWriter sw = new StringWriter();
XMLSerializer ser = new XMLSerializer(sw, new
OutputFormat(response));
ser.serialize(response.getDocumentElement());
-
- String XMLStr = sw.toString();
-
- //System.out.println("SetupDataResult (DOM): " + XMLStr);
-
-
-
-
+
DOMBuilder dom = new DOMBuilder();
org.jdom.Document result = dom.build(response);
-
+
org.jdom.Element root = result.getRootElement();
-
+
List children = root.getChildren();
- Iterator it = children.iterator();
+ Iterator it = children.iterator();

- int size =
root.getChildren("metadata",Namespace.getNamespace("nmwg",AbstractMARequest.NMWG2)).size();
+ String device[] = new String[root.getChildren("metadata",
Namespace.getNamespace("nmwg", "http://ggf.org/ns/nmwg/base/2.0/";)).size()];
+ String ids[] = new String[root.getChildren("metadata",
Namespace.getNamespace("nmwg", "http://ggf.org/ns/nmwg/base/2.0/";)).size()];
+
+ int i = 0;
+ while (it.hasNext()) { // search which devices fit which ids
+ org.jdom.Element message = (org.jdom.Element) it.next();
+
+ if (message.getName().contains("meta")) {
+ //System.out.println("**** Metadata block");
+ if
(!(message.getAttributeValue("id").contains("resultCode"))) {
+ ids[i] = message.getAttributeValue("id");
+ //System.out.println("Metadatablock with id: " +
ids[i]);
+ Iterator itmeta = message.getChildren().iterator();
+ while (itmeta.hasNext()) {
+ org.jdom.Element subject = (org.jdom.Element)
itmeta.next();
+ //System.out.println("****** subject:
"+subject.getValue());
+ if (subject.getName().contains("subject")) {
+ Iterator itsubject =
subject.getChildren().iterator();
+ while (itsubject.hasNext()) {
+ org.jdom.Element hostname =
+ (org.jdom.Element)
itsubject.next();
+ //System.out.println("hostname: " +
hostname.getValue());
+ if
(hostname.getName().contains("endPoint")) {
+ device[i] = hostname.getValue();
+
//System.out.println("[LookingGlassClientModel] device: "+device);
+ }
+ }
+ }
+ }
+ }
+ }
+ i++;
+ }

- resultStringTable = new String[size];
- resultTimeTypeTable = new String[size];
- resultTimeValueTable = new String[size];
- resultValueUnitsTable = new String[size];
- statusStringTable = new String[size];
- devicesTable = new String[size];
+ i = 0;
+ it = children.iterator();
+ while (it.hasNext()){
+ org.jdom.Element message = (org.jdom.Element) it.next();
+
+ if (message.getName().contains("meta")) {
+ //System.out.println("**** Metadata block");
+ if
((message.getAttributeValue("id").contains("resultCode"))) {
+ ids[i] = message.getAttributeValue("id");
+ //System.out.println("Metadatablock with id: " +
ids[i]);
+ Iterator itmeta = message.getChildren().iterator();
+ while (itmeta.hasNext()) {
+ org.jdom.Element subject = (org.jdom.Element)
itmeta.next();
+ //System.out.println("****** subject:
"+subject.getValue());
+ if (subject.getName().contains("subject")) {
+ String metadataIdRef =
subject.getAttributeValue("metadataIdRef");
+ for (int j = 0; j < ids.length; j++){
+ if (ids[j] != null &&
ids[j].startsWith(metadataIdRef)){
+ device[i] = device[j];

+ }
+ }
+ }
+ }
+ }
+ }
+ i++;
+ }

- boolean ok = true;
- int place = 0;
- while (it.hasNext()) {
- org.jdom.Element message = (org.jdom.Element)it.next();
-
- if (message.getName().contains("meta")) {
-
- if
((message.getAttributeValue("id").contains("resultCode"))) {
- String name = message.getAttributeValue("id");
- //System.out.println("*** id: "+name);
- String nr = name.substring(name.length()-1);
- place = Integer.parseInt(nr);
- //System.out.println("*** place uit message:
"+place);
- place--;
- //System.out.println("*** place na place--: "+place);
- Iterator itmeta = message.getChildren().iterator();
- while (itmeta.hasNext()) {
- org.jdom.Element subject =
(org.jdom.Element)itmeta.next();
- //System.out.println("*** subject:
"+subject.getValue());
- if (subject.getName().contains("subject")) {
- Iterator itsubject =
subject.getChildren().iterator();
- while (itsubject.hasNext()) {
- org.jdom.Element hostname =
-
(org.jdom.Element)itsubject.next();
- //System.out.println("*** hostname:
"+hostname.getValue());
- if
(hostname.getName().contains("endPoint")) {
- //System.out.println("*** place:
"+place);
- devicesTable[place] =
- hostname.getValue();
- }
- }
- }
- }
- }
-
- } else {
-
- String name = message.getAttributeValue("id");
- //System.out.println("*** data id:" + name);
- String nr = name.substring(name.length()-1);
- place = Integer.parseInt(nr);
- place--;
-
- if
(message.getAttributeValue("id").contains("resultCode")) {
- Iterator it2 = message.getChildren().iterator();
- org.jdom.Element datum =
(org.jdom.Element)it2.next();
- //System.out.println("*** DATUM: " + datum);
- //System.out.println("*** RESULTSTRING: " +
datum.getValue());
- statusStringTable[place] = datum.getValue();
- //System.out.println("***
statusStringTable["+place+"]: "+statusStringTable[place]);
- } else {
- try {
- Iterator it2 = message.getChildren().iterator();
- org.jdom.Element datum =
(org.jdom.Element)it2.next();
- //System.out.println("*** DATUM: " + datum);
- //System.out.println("*** RESULTSTRING: " +
datum.getValue());
- if (place == -1)
- place = 0;
- resultStringTable[place] = datum.getValue();
- //System.out.println("***
resultStringTable["+place+"]: "+resultStringTable[place]);
- } catch (Exception e) {
- e.printStackTrace();
- resultStringTable[place] = "";
- ok = false;
- }
- }
- }
- }
-
- fireStateChanged();
-
- } catch (Exception ex) {
-
- JOptionPane.showMessageDialog(null,
- "An error occured while executing your task!",
- "Sending Error",
- JOptionPane.ERROR_MESSAGE);
-
- ex.printStackTrace();
- fireStateChanged();
- throw ex;
-
- }
+ //System.out.println("");
+ //for (i = 0; i < ids.length; i++) {
+ // System.out.println("id: " + ids[i] + " --> device: " +
device[i]);
+ //}
+ //System.out.println("");
+ it = children.iterator();
+ while (it.hasNext()) {
+ org.jdom.Element message = (org.jdom.Element) it.next();
+
+ if (!message.getName().contains("meta")) { //this will be a
datablock
+
+ String name = message.getAttributeValue("id");
+ String nr = name.substring(name.length() - 1);
+ String metadataIdRef =
message.getAttributeValue("metadataIdRef");
+ //System.out.println("data block with metadataIdRef:" +
metadataIdRef);
+
+ //Search the corresponding device in the list of metadata
ids
+ int place = -1;
+ for (int j = 0; j < ids.length; j++) {
+ if (metadataIdRef.equals(ids[j])) {
+ //System.out.println("metadataIdRef " +
metadataIdRef + " equals " + ids[j]);
+ place = j;
+ break;
+ }
+ }
+ if (place != -1) { // if place == -1, no useful
corresponding block has been found
+ //System.out.println("place for datablock " + name +
": " + place);
+ if
(message.getAttributeValue("id").contains("resultCode")) {
+ //System.out.println("Updating status for
device:" + device[place]);
+ Iterator it2 = message.getChildren().iterator();
+ org.jdom.Element datum = (org.jdom.Element)
it2.next();
+ //System.out.println("*** DATUM: " + datum);
+ //System.out.println("*** RESULTSTRING: " +
datum.getValue());
+
+ if (!device[place].equals("")) {
+ MPDevicePair pair = new MPDevicePair(mp,
device[place]);
+ if (!stati.containsKey(pair)) {
+ stati.put(pair, datum.getValue());
+
//System.out.println("[LookingGlassClientModel] status for " + pair + " is "
+ stati.get(pair));
+ }
+ }
+ } else {
+ //System.out.println("Updating result for
device:" + device[place]);
+ try {
+ Iterator it2 =
message.getChildren().iterator();
+
+ org.jdom.Element datum = (org.jdom.Element)
it2.next();
+ //System.out.println("*** DATUM: " + datum);
+ //System.out.println("*** RESULTSTRING: " +
datum.getValue());
+
+ if (!device[place].equals("")) {
+ MPDevicePair pair = new MPDevicePair(mp,
device[place]);
+ if (!results.containsKey(pair)) {
+ results.put(pair, datum.getValue());
+
//System.out.println("[LookingGlassClientModel] result for " + pair + " is "
+ results.get(pair));
+ }
+ }
+
+ } catch (Exception e) {
+ //e.printStackTrace();
+ if (!device[place].equals("")) {
+ MPDevicePair pair = new MPDevicePair(mp,
device[place]);
+ if (!results.containsKey(pair)) {
+ results.put(pair, "");
+
//System.out.println("[LookingGlassClientModel] result for " + pair + " is "
+ results.get(pair));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ fireStateChanged();
+
+ } catch (Exception ex) {
+
+ JOptionPane.showMessageDialog(null,
+ "An error occured while executing your task!",
+ "Sending Error",
+ JOptionPane.ERROR_MESSAGE);
+
+ ex.printStackTrace();
+ fireStateChanged();
+ throw ex;
+
+ }
}
-
+
/**
* Return the result from the MP to the requestor
**/
public String getResult(MPDevicePair device) {
-
- int place = getDevicePlace(device);
- String result = resultStringTable[place];
- //System.out.println("place to check: "+place);
- if (result == null || result.equalsIgnoreCase("")){
- if (place+1 < statusStringTable.length)
- result = statusStringTable[place+1];
- //resultcode has index 1 higher than corresponding data
- else result = statusStringTable[place];
- //resultcode has index 1 lower than
- //corresponding data when last device
- }
- //System.out.println("\n**** result to be displayed: "+result +
"******\n");
- return result;
-
+ //System.out.println("[LookingGlassClientModel] Requesting result
for: " + device);
+ //System.out.println("[LookingGlassClientModel] results map contains
the device: " + results.containsKey(device));
+ //System.out.println("[LookingGlassClientModel] results for the
device: " + results.get(device));
+ return results.get(device);
}
-
+
/**
* Return the status from the MP to the requestor
**/
public String getStatus(MPDevicePair device) {
-
- int place = getDevicePlace(device);
- return statusStringTable[place];
-
+ return stati.get(device);
+
}
-
- private int getDevicePlace(MPDevicePair device) {
-
-
- //for (int i = 0; i < devicesTable.length; i++) {
- //System.out.print("devices: " + devicesTable[i]);
- //System.out.print("results: " + resultStringTable[i]);
- //System.out.print("statusses: " + statusStringTable[i]);
- //System.out.println();
- //}
-
- for (int i = 0; i < selectedEndpoints.size(); i++) {
- //System.out.println("i:" + i);
- //System.out.println("devicesTable[" +i+ "] = " +
devicesTable[i]);
- if (selectedEndpoints.get(i) != null &&
selectedEndpoints.get(i).equals(device))
- return i;
- }
- return 0;
+
+ /*private int getDevicePlace(MPDevicePair device) {
+ //for (int i = 0; i < devicesTable.length; i++) {
+ //System.out.print("devices: " + devicesTable[i]);
+ //System.out.print("results: " + resultStringTable[i]);
+ //System.out.print("statusses: " + statusStringTable[i]);
+ //System.out.println();
+ //}
+ for (int i = 0; i < selectedEndpoints.size(); i++) {
+ //System.out.println("i:" + i);
+ //System.out.println("devicesTable[" +i+ "] = " + devicesTable[i]);
+ if (selectedEndpoints.get(i) != null &&
selectedEndpoints.get(i).equals(device))
+ return i;
}
-
+ return 0;
+ }*/
/**
* Returns a list with all supported devices by given MP
**/
/*public List getDevices(String webservice) {
-
-
- devices = new ArrayList();
- functions = new ArrayList();
-
- getConfiguration((String)webservice);
- return devices;
-
+ devices = new ArrayList();
+ functions = new ArrayList();
+ getConfiguration((String)webservice);
+ return devices;
}*/
-
/**
* Returns a list with all supported devices by given MP
*/
public List getDevices() {
return devices;
}
-
+
/**
* Returns a list with all functions supported by a given device
**/
public List getFunctions() {
return functions;
}
-
+
/**
* Returns a list with all functions supported by a given device
**/
public Vector getFunctions(String device) {
-
+
int index = devices.indexOf(device);
- return (Vector)functions.get(index);
-
+ return (Vector) functions.get(index);
+
}
-
+
/**
* Returns a list with all descriptions of the functions supported
* by a given device
**/
public Vector getDescriptions(String device) {
-
+
int index = devices.indexOf(device);
- return (Vector)functions.get(index);
-
+ return (Vector) functions.get(index);
+
}
-
-
+
public String getDescription(String function, String device) {
-
+
try {
int index = devices.indexOf(device);
- Vector v = (Vector)functions.get(index);
-
+ Vector v = (Vector) functions.get(index);
+
Iterator it = v.iterator();
while (it.hasNext()) {
- Command command = (Command)it.next();
- if (function.startsWith(command.getFunction()) || (
- command.getDescription() != null &&
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
command.getDescription().equalsIgnoreCase(function)))
{
if (command.getDescription().equalsIgnoreCase("") ||
- command.getDescription() == null)
+ command.getDescription() == null) {
return "N/A";
- else
+ } else {
return command.getDescription();
+ }
}
}
return "N/A";
@@ -528,24 +495,24 @@
return "N/A";
}
}
-
+
public String getSyntax(String function, String device) {
-
+
try {
int index = devices.indexOf(device);
- Vector v = (Vector)functions.get(index);
-
+ Vector v = (Vector) functions.get(index);
+
Iterator it = v.iterator();
while (it.hasNext()) {
- Command command = (Command)it.next();
- if (function.startsWith(command.getFunction()) || (
- command.getDescription() != null &&
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
command.getDescription().equalsIgnoreCase(function)))
{
if (command.getSyntax().equalsIgnoreCase("") ||
- command.getSyntax() == null)
+ command.getSyntax() == null) {
return "N/A";
- else
+ } else {
return command.getSyntax();
+ }
}
}
return "N/A";
@@ -553,27 +520,27 @@
return "N/A";
}
}
-
+
public String getCommand(String function, String device) {
-
+
try {
int index = devices.indexOf(device);
- if (index > -1){
- Vector v = (Vector)functions.get(index);
-
+ if (index > -1) {
+ Vector v = (Vector) functions.get(index);
+
Iterator it = v.iterator();
while (it.hasNext()) {
- Command command = (Command)it.next();
- if (function.startsWith(command.getFunction()) || (
- command.getDescription() != null &&
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&

command.getDescription().equalsIgnoreCase(function))) {
if (command.getCommand().equalsIgnoreCase("") ||
- command.getCommand() == null)
+ command.getCommand() == null) {
return "N/A";
- else
- return command.getCommand() +
- ((command.getSyntax() != null &&
- !command.getSyntax().equals(""))? " " +
command.getSyntax() : "");
+ } else {
+ return command.getCommand() +
+ ((command.getSyntax() != null &&
+ !command.getSyntax().equals("")) ? " " +
command.getSyntax() : "");
+ }
}
}
}
@@ -582,87 +549,74 @@
e.printStackTrace();
return "N/A";
}
-
-
+
+
}
-
- public String getURL(String device) {
-
- //System.out.println(device);
- int index = devices.indexOf(device);
- //System.out.println(index);
- //System.out.println((String)urls.get(index));
-
- Iterator it = urls.iterator();
- while (it.hasNext()) {
- //System.out.println((String)it.next());
- }
-
- return (String)urls.get(index);
-
+
+ /*public String getURL(String device) {
+ //System.out.println(device);
+ int index = devices.indexOf(device);
+ //System.out.println(index);
+ //System.out.println((String)urls.get(index));
+ Iterator it = urls.iterator();
+ while (it.hasNext()) {
+ //System.out.println((String)it.next());
}
-
- public String getValue(MPDevicePair device) {
-
- int index = this.getDevicePlace(device);
- return resultStringTable[index];
-
- }
-
- public String[] getAllValues() {
-
- return resultStringTable;
-
- }
-
- public String getSelectedCommand() {
-
- return selectedCommand;
-
- }
-
+ return (String)urls.get(index);
+ }*/
+ /*public String getValue(MPDevicePair device) {
+ return results.get(device);
+ }*/
+ /*public String[] getAllValues() {
+ return resultStringTable;
+ }*/
+ /*public String getSelectedCommand() {
+ return selectedCommand;
+ }*/
public void setSelectedCommand(String selectedCommand) {
this.selectedCommand = selectedCommand;
}
-
- public void addSelectedEndpoint(MPDevicePair endpoint){
+
+ public void addSelectedEndpoint(MPDevicePair endpoint) {
selectedEndpoints.add(endpoint);
}
-
- public void addSelectedEndpoints(List endpoints){
+
+ public void addSelectedEndpoints(List endpoints) {
selectedEndpoints.addAll(endpoints);
}
-
- public boolean removeSelectedEndpoint(MPDevicePair endpoint){
+
+ public boolean removeSelectedEndpoint(MPDevicePair endpoint) {
return selectedEndpoints.remove(endpoint);
}
-
- public boolean removeSelectedEndpoint(int index){
- if (index < selectedEndpoints.size()){
+
+ public boolean removeSelectedEndpoint(int index) {
+ if (index < selectedEndpoints.size()) {
selectedEndpoints.remove(index);
return true;
+ } else {
+ return false;
}
- else return false;
}
-
- public void clearSelectedEndpoints(){
+
+ public void clearSelectedEndpoints() {
selectedEndpoints.clear();
}
-
- public List<MPDevicePair> getSelectedEndpoints(){
+
+ public List<MPDevicePair> getSelectedEndpoints() {
return selectedEndpoints;
}
-
- public List<String> getAllDevicesForMp(LGEndpoint mp){
+
+ public List<String> getAllDevicesForMp(LGEndpoint mp) {
List<String> result = new ArrayList<String>();
-
+
Iterator<MPDevicePair> it = selectedEndpoints.iterator();
- while (it.hasNext()){
+ while (it.hasNext()) {
MPDevicePair pair = it.next();
- if (pair.getMp() == mp)
+ if (pair.getMp() == mp) {
result.add(pair.getDevice());
+ }
}
-
+
return result;
}
}



  • perfsonar: r3871 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model, svnlog, 05/23/2008

Archive powered by MHonArc 2.6.16.

Top of Page