Trouble creating a custom profile (Work Item Profile)
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:
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:
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.
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
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
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
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