Skip to main content

alphaWorks  >  Forums  >  IBM Rational Team API  >  developerWorks

How do I set multiple values on a RESOURCE_LIST type CqRecord field?    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is not answered.

Permlink Replies: 1 - Pages: 1 - Last Post: Oct 28, 2009 2:00 PM Last Post By: wild_instigator Threads: [ Previous | Next ]
wild_instigator

Posts: 2
Registered: Oct 28, 2009 12:41:50 PM
How do I set multiple values on a RESOURCE_LIST type CqRecord field?
Posted: Oct 28, 2009 01:50:43 PM
 
Click to report abuse...   Click to reply to this thread Reply
I'm attempting to set a CqRecord RESOURCE_LIST field with multiple values. I'm using the field format "cq.record:Build/<value>@<DB Name>/<DB Target>", per value that I want to be set/include.

Code example/
CqRecord record;
CqFieldValue buildField;
...
// get all field meta data
Property.List fieldsFinal = record.getAllFieldValues();
// find CQ Fields for updating CQ record later
CqFieldValue cqField = null;
for (Object field : fieldsFinal) {
	cqField = (CqFieldValue) field;
	String fieldName = cqField.getName();
	...
	if (fieldName.equals("Builds")) {
		buildField = cqField;
		List<String> initChoices = new ArrayList<String>(cqField.getChoiceList());
		initChoices.remove(0);
		buildChoices = initChoices;
	}
	...
}
...
// update builds
List<String> buildTableValues = ((TableModel) buildTable.getModel()).getRows();
String buildString = "";
for (String build : buildTableValues) {
	String buildValue = "cq.record:Build/" + build + CQIntegration.DB_NAME + "/" + CQIntegration.DB_TARGET;
	if (buildString.isEmpty()) {
		buildString = buildString + buildValue;
	} else {
		buildString = buildString + "\n" + buildValue;
	}
}
 
// CqFieldValue.initialize() works if I only have one build to set in this field
// buildField.initialize(buildValue);
 
// CqFieldValue.setMultilineStringValue() doesn't work (or maybe it does?) if I form a multi-line String
// Is this even the correct logic/method to use for setting multiple values in a RESOURCE_LIST type field?
buildField.setMultilineStringValue(buildString);
record.setProperty(buildField.getPropertyName(), buildField);
...
record.doDeliver(null, StpChangeContext.UNORDERED);
...


When there's only one value to set, this works fine by using relatedBuild.initialize();

However, I need to be able to account for multiple values, so I tried using relatedBuild.setMultilineStringValue() after creating a multi-line String with "\n". This produces the exception:

'Property error: The Field "Builds" has multiple entries which do not identify existing entities of type Build:
cq.record:Build/<value>@<DB Name>/<DB Target>
cq.record:Build/<value>@<DB Name>/<DB Target>'

What am I doing wrong? A single value and I'm good. Multiple values, I'm not sure what String format it's expecting or what's exactly going wrong.

I'm open to other tips/criticisms of my approach as well...
wild_instigator

Posts: 2
Registered: Oct 28, 2009 12:41:50 PM
Re: How do I set multiple values on a RESOURCE_LIST type CqRecord field?
Posted: Oct 28, 2009 02:00:57 PM   in response to: wild_instigator in response to: wild_instigator's post
 
Click to report abuse...   Click to reply to this thread Reply
Correction to post typos:

When there's only one value to set, this works fine by using buildField.initialize();

However, I need to be able to account for multiple values, so I tried using buildField.setMultilineStringValue() after creating a multi-line...

Point your RSS reader here for a feed of the latest messages in all forums