It's all about the answers!

Ask a question

Trouble creating a custom profile (Work Item Profile)


Pat McCarthy (12152) | asked Sep 05 '08, 2:38 p.m.
JAZZ DEVELOPER
Goal is a custom profile, based on an existing profile as found in IWorkItem, so that the custom profile has an extra attribute - a custom attribute.

I've tried this - but it fails:
String ATTR_INTERNAL2EXTERNAL = "ATTR_AI1f";


if (!IWorkItem.SMALL_PROFILE.contains(ATTR_INTERNAL2EXTERNAL))
System.out.println("expected that");

ItemProfile<IWorkItem> custom = null;

ArrayList<String> attrs = new ArrayList<String>();
attrs.add(ATTR_INTERNAL2EXTERNAL);

custom = IWorkItem.SMALL_PROFILE.createExtension((String[]) attrs.toArray(new String[attrs.size()]));

if (custom.contains(ATTR_INTERNAL2EXTERNAL))
System.out.println("expected that");

The attribute id hardcoded in the logic is known to the project area, but that does not seem to be the issue.

The createExtension fails an assertion deep in the ItemProfile code:

private ItemProfile(IItemType itemType, Collection<String> properties, boolean containsReferences) {
Assert.isTrue(AuditablesHelper.allProperties(itemType).containsAll(properties));
fItemType= itemType;
if (AuditablesHelper.USE_CUSTOM_ACCESS_PROFILES)
fProperties= Collections.unmodifiableCollection(properties);
else
fProperties= AuditablesHelper.allProperties(itemType);
fContainsReferences= containsReferences;
}


The properties at this point are:

That seems to be IWorkItem.SMALL_PROFILE and my custom attribute id; why must all those known to the helper exist?

Given the goal - Is this the wrong approach or a bug?

Pat Mc.

2 answers



permanent link
Christof Marti (681) | answered Sep 08 '08, 3:10 a.m.
Hi,

ItemProfile is not aware of custom attributes, but only of the lower-level hard-coded properties of an item type. If you want to retrieve custom attributes you can extend an existing profile like:

ItemProfile<IWorkItem> customProfile= IWorkItem.SMALL_PROFILE.createExtension(IWorkItem.CUSTOM_ATTRIBUTE_PROPERTIES);

That will retrieve all custom attributes, but there is currently no finer grained way of doing this.

Christof
Jazz Work Item team

permanent link
Patrick Streule (4.9k21) | answered Sep 08 '08, 3:18 a.m.
JAZZ DEVELOPER
That seems to be IWorkItem.SMALL_PROFILE and my custom attribute id;
why must all those known to the helper exist?

Given the goal - Is this the wrong approach or a bug?

When including custom attributes in an ItemProfile, you must also
include the attributes from IWorkItem.CUSTOM_ATTRIBUTE_PROPERTIES.

HTH,
Patrick
Jazz Work Item Team

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.