?
Solved

Please comment this code so I can understand it...

Posted on 2007-03-28
2
Medium Priority
?
198 Views
Last Modified: 2010-03-31
Would someone comment this code so I can understand it?
import org.muos.management.managementSupport.Attribute;
import org.muos.management.managementSupport.Lab;
import org.muos.management.managementSupport.ManagementSupport;
import org.muos.management.managementSupport.ManagementSupportException;
import org.muos.management.managementSupport.ManagementSupportFactory;
import org.muos.management.managementSupport.RequirementVerificationID;
import org.muos.management.managementSupport.Tree;


public class SampleCode {

      /**
       * @param args
       */
      public static void main(String[] args) {
            String serviceLocation = "http://localhost:8080/axis2/services/TEService";
            ManagementSupport supporter = null;
            try {
                  supporter = ManagementSupportFactory.getManagementSupport(serviceLocation);
            } catch (ManagementSupportException e) {
                  //If can not initialize the TEServiceStub, do something here
                  e.printStackTrace();
            }

            if(supporter == null) {
                  return;
            }

            /*
             * Sample of deleteLab,
             */
            try {
                  supporter.deleteLab(123L);
                  //delete success
            } catch (ManagementSupportException e) {
                  //delete fail
                  e.printStackTrace();
            }

            /*
             * GetLabAttribute()
             */
            try {
                  String attribute = supporter.getLabAttribute(123L, "lab_attribute_name");
                  //Successfully get the attribute
                  System.out.println(attribute);
            } catch (ManagementSupportException e) {
                  //Fail
                  e.printStackTrace();
            }

            try {
                  String attribute = supporter.getLabChangeAttribute(1234L, "attribute_name");
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] labIds = supporter.getLabChanges();
                  for(long id : labIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabChangesByLab(123L); //LabId
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabChangesByNode(1234L);//NodeId
                  for(long id :ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getLabs();
                  for(long id : ids)  {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getNodeAttribute(1234L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getNodeChildren(1234L);
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getProjectAttribute(1234L, "attriubte_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getProjects();
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getRequirementVerificationAttribute("requirementId", 123L, "attibute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  RequirementVerificationID[]  ids = supporter.getRequirementVerifications(1243L);
                  for(RequirementVerificationID id : ids) {
                        System.out.println(id.getRequirementId());
                        System.out.println(id.getTestLogId());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] nodeIds = supporter.getRootNodes(1244L);
                  for(long id : nodeIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getSessionAttribute(134L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] sessionIds = supporter.getSessions();
                  for(long id : sessionIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String xml = supporter.getSTDTree();
                  System.out.println(xml);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  String value = supporter.getTestLogAttribute(1234L, "attribute_name");
                  System.out.println(value);
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] testlogIds = supporter.getTestLogs();
                  for(long id : testlogIds) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  long[] ids = supporter.getTestLogsByNode(1345L);
                  for(long id : ids) {
                        System.out.println(id);
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Lab lab = new Lab();
            lab.setDescription("This is a lab");
            lab.setId(4564L);
            lab.setLocation("Where the lab is");
            lab.setOwner("who the owner is");
            try {
                  Attribute[] attributes = supporter.saveLab(lab);
                  for(Attribute attr : attributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] labChangeAttributes = new Attribute[2];
            Attribute attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            Attribute attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveLabChange("test log UID", labChangeAttributes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] requirementVerificationAttributes = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveRequirementVerification("RequirementId", "testLogUID", requirementVerificationAttributes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] sessionAttibutes = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveSession(123L, "sessionUID", sessionAttibutes);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            Attribute[] testLogSession = new Attribute[2];
            attr1 = new Attribute();
            attr1.setName("attributeName");
            attr1.setValue("attributeValue");
            attr2 = new Attribute();
            attr2.setName("attributeName");
            attr2.setValue("attributeValue");
            labChangeAttributes[0] = attr1;
            labChangeAttributes[1] = attr2;
            try {
                  Attribute[] returnedAttributes = supporter.saveTestLog("sessionUID", "testLogUID", testLogSession);
                  for(Attribute attr : returnedAttributes) {
                        System.out.println("name :" + attr.getName() + " ; value = " + attr.getValue());
                  }
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            try {
                  Tree tree = supporter.populateTree(1234L);
                  System.out.println(tree.getNode().getNodeId());
                  for(Attribute att : tree.getNode().getAttributes()) {
                        System.out.println(att.getName());
                        System.out.println(att.getValue());
                  }
                  System.out.println("has children : "  + tree.getChildren().size());
            } catch (ManagementSupportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
      }

}
0
Comment
Question by:yankeebushsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18814648
first we must know what is the
org.muos.management.managementSupport
since most of functions are from it and the rest is documented.
0
 
LVL 8

Accepted Solution

by:
reach2piyush earned 2000 total points
ID: 18814731
//Looks like you got a web service with the following address
String serviceLocation = "http://localhost:8080/axis2/services/TEService";

//ManagementSupportFactory class looks like a utility class to connect to that Web Service ^ returns you a stub to call methods on that Web service
supporter = ManagementSupportFactory.getManagementSupport(serviceLocation);

// The following piece of code  along with all other subsequent similar code demonstrate/test a business method call to the above mentioned web-service,
Each call is enclosed in a separate try-catch loop, this will ensure that the program will continue even if any of the calls fails.  
/*
* Sample of deleteLab,
*/
try {
supporter.deleteLab(123L);
//delete success
} catch (ManagementSupportException e) {
//delete fail
e.printStackTrace();
}
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question