It's all about the answers!

Ask a question

Making an attribute internal


Pat McCarthy (12152) | asked Aug 05 '08, 7:36 a.m.
JAZZ DEVELOPER
I'm not sure if what I want to do is supported and I'm doing it wrong, or if its just not permitted.

Goal - add a custom attribute to a work item such that it does not get added to the custom tab by default. I want it to be hidden, but available to my logic at runtime.

I've created the attribute, and can set its value, but it shows in the work item UI.

I've read the Javadoc for IAttribute.setInternal and IAttribute.isInternal - it seems like what I want.

I've used this code to try and set the attribute as internal:

	ITeamRepository repo = getUtility().getRepo(true);

IProjectArea projectArea = getUtility().getProjectArea();

IWorkItemClient workItemClient = ((IWorkItemClient)
repo.getClientLibrary(IWorkItemClient.class));
IAttribute attr = workItemClient.findAttribute(projectArea, "testNewCustomAttr", null);

if (attr != null) {
IItemManager itemManager = repo.itemManager();
attr = (IAttribute) itemManager.fetchCompleteItem(attr, IItemManager.DEFAULT, null);

IAttribute workAttr = (IAttribute) attr.getWorkingCopy();
workAttr.setInternal(true);
attr = workItemClient.saveAttribute(workAttr, null);
}


But the result is an exception with this message:
    com.ibm.team.repository.common.TeamRepositoryException: Cannot change attribute 'testNewCustomAttr' to internal

Is the use of internal for a custom attribute not permitted or is my approach wrong?

Thanks for any insight
Pat Mc.

8 answers



permanent link
Marcel Bihr, Jazz Work Item team (1.4k) | answered Aug 06 '08, 2:49 a.m.
JAZZ DEVELOPER
Hi Pat
To hide an attribute from the editor, you have to configure the editor presentations accordingly. The easiest way is to add the attribute to an arbitrary section and use the 'doNotShow' kind for it. Unfortunately the process configuration editor does not propose this kind, you have to set it manually in the process configuration source xml. Its id is 'com.ibm.team.workitem.kind.special.doNotShow'. (I have filed defect 59557: "The 'doNotShow' kind does not appear in the list of available kinds in the aspect editor" for that).

Doing this, the custom tab will not recognize it as unconfigured (wrt presentations) and will not show it.

Having an internal attribute would also do the trick but afaik it is not possible to create internal custom attributes.

Regards

Marcel
Jazz Work Item team

permanent link
Christof Marti (681) | answered Aug 06 '08, 4:15 a.m.
You can make the attribute internal only when creating it:

IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
IAttribute attribute= workItemClient.findAttribute(projectArea, identifier, monitor);
if (attribute == null) {
attribute= workItemClient.createNewAttribute(projectArea, identifier, attributeType, IAttribute.FULL_TEXT_KIND_DEFAULT, monitor);
attribute.setDisplayName(displayName);
attribute.setInternal(internal);
attribute= workItemClient.saveAttribute(attribute, monitor);
}

It is currently not possible to set this flag in the process configuration.

Christof
Jazz Work Item team

permanent link
Pat McCarthy (12152) | answered Aug 06 '08, 12:09 p.m.
JAZZ DEVELOPER
Thanks for the hints; I'll try them to create my own internal custom attribute.

Given I can't make it internal after it has been created, can I assume that it can't be changed from internal to public (setInternal(false)) either? I'm guessing yes; this is a creation time choice.

I guess given the two approaches - and with the assumption above:
    If I know it will always be internal I should create it as internal.

    If I may change my mind, I should add a custom attribute and the doNotShow custom presentation control, with the implied ability of the process administrator to show this attribute if they want to see it.

Thanks again - Pat Mc.

permanent link
Pat McCarthy (12152) | answered Aug 07 '08, 3:36 a.m.
JAZZ DEVELOPER
Well; maybe not. (the options I thought I had).

I create a new attribute - internal-false, then I create a WI with that attribute set to a value, shows in UI on custom tab.

I create a new attribute - internal-true, then I create a WI with that attribute set to a value, does not show in the UI.

I create a new attribute - internal-true, then I create a WI with that attribute set to a value, does not show in the UI; I continue and change the attribute from internal-true to internal-false, then I create a WI with that attribute set to a value, still does not show in the UI.

Three things seem odd:
    I can change an attribute from internal-true to internal-false, but I couldn't change from false to true? (this was the problem in the initial post, I'd guessed wrong in that I thought I could not change it - but the API tells me I have).

    Once an attribute is internal-true the value is never in the UI. Even when changed to internal-false, new WIs with that attribute/value don't get the custom tab. (is this the expected behavior?)

    I've done my testing with the RTC Client UI; custom tab shows there, but the Web UI does not show this tab. I'd assumed it would, but now need to check into that difference a bit more. (Does the Web UI for WIs differ here? I'd have thought the custom tab would become visible in the Web UI too.)

The option to use presentation to control display visibility may be the only option.

Comments?

permanent link
Patrick Streule (4.9k21) | answered Aug 08 '08, 4:11 a.m.
JAZZ DEVELOPER
I've done my testing with the RTC Client UI; custom tab shows there,
but the Web UI does not show this tab. I'd assumed it would, but now
need to check into that difference a bit more. (Does the Web UI for
WIs differ here? I'd have thought the custom tab would become visible
in the Web UI too.)

The Web UI does not yet have the 'collector' type Custom tab that lists
all custom attributes that do not have an explicit editor presentation
configured.

Regards,
Patrick
Jazz Work Item Team

permanent link
Christof Marti (681) | answered Aug 08 '08, 4:13 a.m.
You can change it from internal to public, but not back, that's subtle but expected.

Having changed it from internal to public I would have expected it to show up in the RCP UI as well. May be a caching issue, did you try restarting the client?

The Web UI does currently not add custom attributes automatically to its presentation, but you can add them to the editor layout explicitly. This is tracked as work item 11619 (https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/11619).

Christof
Jazz Work Item team


patmc wrote:
Well; maybe not. (the options I thought I had).

I create a new attribute - internal-false, then I create a WI with
that attribute set to a value, shows in UI on custom tab.

I create a new attribute - internal-true, then I create a WI with that
attribute set to a value, does not show in the UI.

I create a new attribute - internal-true, then I create a WI with that
attribute set to a value, does not show in the UI; I continue and
change the attribute from internal-true to internal-false, then I
create a WI with that attribute set to a value, still does not show
in the UI.

Three things seem odd:
I can change an attribute from internal-true to
internal-false, but I couldn't change from false to true? (this was
the problem in the initial post, I'd guessed wrong in that I thought
I could not change it - but the API tells me I have).

Once an attribute is internal-true the value is never in the UI. Even
when changed to internal-false, new WIs with that attribute/value
don't get the custom tab. (is this the expected behavior?)

I've done my testing with the RTC Client UI; custom tab shows there,
but the Web UI does not show this tab. I'd assumed it would, but now
need to check into that difference a bit more. (Does the Web UI for
WIs differ here? I'd have thought the custom tab would become visible
in the Web UI too.)

The option to use presentation to control display visibility may be
the only option.

Comments?

permanent link
Pat McCarthy (12152) | answered Aug 08 '08, 12:48 p.m.
JAZZ DEVELOPER
Three comments.
1) re Web UI; I added my attribute to the process config but I think I added it to the custom tab and maybe that is why I did not see it in the Web UI yet; will try again by adding the attribute to a tab visible in the Web UI. Agree that I should be able to do this and understand that the Web UI may offer the dynamic custom tab in the future.

2) Re making an internal attribute external (internal-false); yes, when I recycled the client the attribute marked as internal-false did start showing. This seems repeatable (I can add new attributes, internal-true, create WI, change to internal-false, and they don't show until I cycle the RTC client).
Want a bug on this? Or, is there something I can do to force the cache after such an update to an attribute? I've tried using a 2nd client and I get the same issue; restart clears it up there too. Not sure a direct cache recycle would help given it crosses clients.

3)Error fyi; many times (not 100%) I get an error opening the WI editor when a new attribute has been added and a WI created with a ref to that attribute.
Simple dialog msg says:
Error running operation 'Loading Work Item'

CRJAZ0244I Internal error.
CRJAZ0244I Internal error.

Error log entry:
java.lang.NullPointerException
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.hasBuiltInAttribute(WorkItemImpl.java:2780)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.isAttributeSet(WorkItemImpl.java:2747)
at com.ibm.team.workitem.client.internal.util.ResolvedWorkItem.collect(ResolvedWorkItem.java:257)
at com.ibm.team.workitem.client.internal.util.ResolvedWorkItem.resolve(ResolvedWorkItem.java:226)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemUIWorkingCopy.resolve(WorkItemUIWorkingCopy.java:231)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.resolveAuxiliaryItems(WorkItemEditorInput.java:205)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.access$4(WorkItemEditorInput.java:196)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput$1.run(WorkItemEditorInput.java:149)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.fetchAll(WorkItemEditorInput.java:122)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.getWorkingCopy(WorkItemEditorInput.java:107)
at com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInputFuture$1.runProtected(WorkItemEditorInputFuture.java:86)
at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Looking during debug of the RTC client - the attribute is null, the null seems to be from an entry in the attributes field which looks to be constructed from the builtin and custom attributes. Did not chase farther.

If I close the empty editor (its there but no data), and try again, then it opens.
I get the same bug from another client; WI and attribute implementation runs as a native java program, the 2nd client sees the WIs in the query results view, but the open fails as shown above.

Want a bug report on this?

permanent link
Christof Marti (681) | answered Aug 11 '08, 4:21 a.m.
1) my understanding is that the custom tab should work in the Web UI like in the RCP except that it does not collect custom attributes automatically, it should show those that are explicitly configured in the editor presentation, please open a defect report if that's not the case (ideally including your process configuration xml)
2) the cache should update automatically on the client the attribute was saved from, for other clients we would have to find a better invalidation strategy, please open a bug report
3) should work too, the NPE might indicate that the attribute was not saved in the repository yet, otherwise please open a bug report

Thanks,

Christof
Jazz Work Item team


patmc wrote:
Three comments.
1) re Web UI; I added my attribute to the process config but I think I
added it to the custom tab and maybe that is why I did not see it in
the Web UI yet; will try again by adding the attribute to a tab
visible in the Web UI. Agree that I should be able to do this and
understand that the Web UI may offer the dynamic custom tab in the
future.

2) Re making an internal attribute external (internal-false); yes,
when I recycled the client the attribute marked as internal-false did
start showing. This seems repeatable (I can add new attributes,
internal-true, create WI, change to internal-false, and they don't
show until I cycle the RTC client).
Want a bug on this? Or, is there something I can do to force the
cache after such an update to an attribute? I've tried using a 2nd
client and I get the same issue; restart clears it up there too. Not
sure a direct cache recycle would help given it crosses clients.

3)Error fyi; many times (not 100%) I get an error opening the WI
editor when a new attribute has been added and a WI created with a
ref to that attribute.
Simple dialog msg says:
Error running operation 'Loading Work Item'

CRJAZ0244I Internal error.
CRJAZ0244I Internal error.

Error log entry:
java.lang.NullPointerException
at
com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.hasBuiltInAttribute(WorkItemImpl.java:2780)
at
com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.isAttributeSet(WorkItemImpl.java:2747)
at
com.ibm.team.workitem.client.internal.util.ResolvedWorkItem.collect(ResolvedWorkItem.java:257)
at
com.ibm.team.workitem.client.internal.util.ResolvedWorkItem.resolve(ResolvedWorkItem.java:226)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemUIWorkingCopy.resolve(WorkItemUIWorkingCopy.java:231)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.resolveAuxiliaryItems(WorkItemEditorInput.java:205)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.access$4(WorkItemEditorInput.java:196)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput$1.run(WorkItemEditorInput.java:149)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.fetchAll(WorkItemEditorInput.java:122)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInput.getWorkingCopy(WorkItemEditorInput.java:107)
at
com.ibm.team.workitem.ide.ui.internal.editor.WorkItemEditorInputFuture$1.runProtected(WorkItemEditorInputFuture.java:86)
at
com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Looking during debug of the RTC client - the attribute is null, the
null seems to be from an entry in the attributes field which looks to
be constructed from the builtin and custom attributes. Did not chase
farther.

If I close the empty editor (its there but no data), and try again,
then it opens.
I get the same bug from another client; WI and attribute
implementation runs as a native java program, the 2nd client sees the
WIs in the query results view, but the open fails as shown above.

Want a bug report on this?

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.