Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can I set multiple values for an attribute of type set using web services?

How can I set multiple values for an attribute of type set using web services?

Problem:

How can I set multiple values for an attribute of type set using web services?

Resolution:

Using Web Services you can set multiple values for an attribute of type set.

Please see example below that logs in as admin | admin and adds 3 values (Windows 2000, Windows 2003 and Windows XP) to the attribute "Platform".

Please note - attributes and their options must be defined by using the GUI before they can be used via web services.

..............................................

package com.borland.testmanager.democlient.samples;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.borland.testmanager.stubs.sccsystem.SystemService;
import com.borland.testmanager.stubs.sccsystem.SystemServiceServiceLocator;
import com.borland.testmanager.stubs.tmplanning.PlanningService;
import com.borland.testmanager.stubs.tmplanning.PlanningServiceServiceLocator;
import com.borland.testmanager.stubs.tmplanning.tm.PropertyValue;
import com.borland.testmanager.stubs.tmplanning.tm.TestPlanningNode;

/**
* Assigns options of attribute "Platform" (type SET) to a node.
*
* @author gehmayer
*
*/
public class SetPlatformAttributeSetOptions {

String host = "localhost";
int port = 19120;
String user = "admin";
String pwd = "admin";
int nodeId = 12; // see demo project: test definition "Attach File to Requirement" (ID=12)

/**
* @param args
*/
public static void main(String[] args) {

SetPlatformAttributeSetOptions optionsSetter = new SetPlatformAttributeSetOptions();

optionsSetter.processArguments(args);

try {
long sessionId = optionsSetter.login();

optionsSetter.setPlatformAttributeOptions(sessionId);

TestPlanningNode node = optionsSetter.retrieveNode(sessionId);

boolean noAttributesFound = ReadAttributeOptions.printAttributes(node);

if (noAttributesFound) {
System.out.printf("no attributes found for node "%s" (ID=%d)%n", node.getName(), node.getId());
}

} catch (Exception e) {
e.printStackTrace();
}
}

private void setPlatformAttributeOptions(long sessionId) throws MalformedURLException, ServiceException, RemoteException {
PlanningService planningService = new PlanningServiceServiceLocator().gettmplanning(new URL("http", host, port, "/services/tmplanning"));
planningService.updateProperties(sessionId, makePlatformOptions());
}

private PropertyValue[] makePlatformOptions() {
return new PropertyValue[] {
new PropertyValue() {
{
setPropertyTypeID("_attribute_option_");
setPropertyID ("_attribute_option_Platform");
setName ("Platform");
setValue ("Platform");
setNodeID (Integer.toString(nodeId));
setType (12); // attribute type SET (see javadoc of PropertyMetaInfo)
setChildren(new PropertyValue[] {
new PropertyValue() {
{
setPropertyTypeID("_attribute_option_");
setPropertyID ("_attribute_option_Platform");
setName ("Platform");
setValue ("Windows 2000");
setNodeID (Integer.toString(nodeId));
setType (12);
}
},
new PropertyValue() {
{
setPropertyTypeID("_attribute_option_");
setPropertyID ("_attribute_option_Platform");
setName ("Platform");
setValue ("Windows 2003");
setNodeID (Integer.toString(nodeId));
setType (12); // attribute type SET (see javadoc of PropertyMetaInfo)
}
},
new PropertyValue() {
{
setPropertyTypeID("_attribute_option_");
setPropertyID ("_attribute_option_Platform");
setName ("Platform");
setValue ("Windows XP");
setNodeID (Integer.toString(nodeId));
setType (12); // attribute type SET (see javadoc of PropertyMetaInfo)
}
},
});
}
}
};
}

private TestPlanningNode retrieveNode(long sessionId) throws ServiceException, MalformedURLException, RemoteException {
PlanningService planningService = new PlanningServiceServiceLocator().gettmplanning(new URL("http", host, port, "/services/tmplanning"));
TestPlanningNode node = planningService.getNode(sessionId, Integer.toString(nodeId));
return node;
}

private long login() throws ServiceException, MalformedURLException, RemoteException {
SystemService sccService = new SystemServiceServiceLocator().getsccsystem(new URL("http", host, port, "/services/sccsystem"));
long sessionId = sccService.logonUser(user, pwd);
return sessionId;
}

private void processArguments(String[] args) {
for (int i = 0; i
switch (i) {
case 0:
if ("help".equals(args)) {
System.out.println("valid arguments: host port user password nodeID");
System.exit(0);
} else {
host = args;
}
break;
case 1:
port = Integer.parseInt(args);
break;
case 2:
user = args;
break;
case 3:
pwd = args;
case 4:
nodeId = Integer.parseInt(args);
break;
}
}
}

}

SetPlatformAttributeSetOptions.java
Old KB# 30287

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 20:45
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.