It's all about the answers!

Ask a question

workItem.hasAttribute( attribute)= false after I add the attribute into the configuration xml and i execute Synchronize Attributes.


0
2
Stefania Axo (12621513) | asked Feb 20 '13, 11:00 p.m.
edited Feb 20 '13, 11:10 p.m.
my system:
- RTC 4.0.1 - Jazz Server and RTC Eclipse Client 4.0.1
precondition:
- client plugin on RTC Eclipse Client.
- The plugin performs an update of the xml configuration  and then a synchronize Attributes

Here is the scenario from the Client Plugin code:
- update of the xml configuration is successful. The update does some adding of attributes in the work items.
- run synchronize attributes with com.ibm.team.workitem.client.WorkItemOperation execute
workItemClient.updateWorkItemType( workItem, type, type, monitor );
 ...with success
- other code will look for the new attributes and the com.ibm.team.workitem.common.model.IWorkItem.hasAttribute(IAttribute) will return false for the new added attribute....this is my FAILURE because the attribute should be there.


Consideration:
1. it does not happen all the times.
2. It can happen for some work item and not all.
3. usually a double execution of the synchronize attribute via my plugin code will fix the issue and the attribute will be found the second time around.
4. i run a query on my work item to execute the Synchronize Attributes and to do the other com.ibm.team.workitem.common.model.IWorkItem.hasAttribute(IAttribute) on specific work item

Question:
is it possible that Synchronize Attributes did not work?
is there a way to make sure that i get the right work item working copy's connection? some call to make sure that the work item is updated?
is there another way to make sure that the attribute changes are picked up?
My only guess is that something did not get trough.

thank you
Stefania

Comments
Ralph Schoon commented Feb 21 '13, 2:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Stefania,

as far as I know modifying the process XML is not a suggested scenario. In fact in all discussions I attended with the process team it was strongly discouraged.

Since the Eclipse client does add new attributes, I have to assume there is an API that allows to do it. I had looked into it because of a forum question, but was not able to find the API, unfortunately. Well, I found an entry point, but couldn't drill deep enough.

Another though: There is some caching going on behind the scenes. Maybe you have to force reload your process changes before running a synchronize attributes. I would assume the process components refreshes when it adds attributes.

9 answers



permanent link
Stefania Axo (12621513) | answered Feb 21 '13, 12:21 p.m.
we do need to modify the Process Configuration and add the new attributes.
It is a total replacement of the process configuration xml.
The attributes are added fine in the Process Configuration with success.
////////////////////////////////////////////////////////////
IProjectAreaWorkingCopy projectAreaWorkingCopy = (IProjectAreaWorkingCopy)itemWorkingCopy;
 IDocument spec = projectAreaWorkingCopy.getProcessSpecification();
.....
spec.set( newSpecSource );
itemWorkingCopy.save( monitor );
////////////////////////////////////////////////////////////

The problem is that the Synchronize Attributes after does not seem to pick up the change soon enough.
If i rerun the Synchronize Attributes it works.
You said 'Maybe you have to force reload your process changes before running a synchronize attributes'
How can i force a reload of the process changes?

I guess that is the same thing that happen when i do:
- work item perspective
- Team Artifact tab
- select of my connected project area
- right click
- select of Open.

thanks again.
Stefania

Comments
Ralph Schoon commented Feb 21 '13, 12:41 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Stefania,

i don't know the API in that section good enough and I would suspect it is an internal call anyway. The client would probably call it on save. You could use plugin SPY (Sift+ALT+F1) on the editor tab to look what happens on save. It could also be done by the process API if it changes things.

In general if you load items in the client API you specify to use the cash or to refresh. See: http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/ for an example.

Get The Latest Data

The API caches Data. If you want to make sure that the data is refreshed, use IItemManager.REFRESH instead of IItemManager.DEFAULT in the code above.



Stefania Axo commented Feb 22 '13, 8:44 p.m.

thanks so much
i will try and let you know


Stefania Axo commented Mar 04 '13, 8:16 p.m.

hi Ralph
i am having problem with this.
I used the ItemManager.REFRESH and i think i loaded correctly the project area.
I don't think i am saving it correctly i mean making sure that the process configuration is not cached someplace.

I will like to look at the code that does the 'Save' button on the Project Area Editor (Work Item perspective - Team Artifact tab - select on connected project area - right click and Open - do a configuration change like a change on a name of presentation - click 'Save')
I want to see if i load the project area correctly and if i Save it right.

thanks a lot
Stefania


Stefania Axo commented Mar 04 '13, 8:32 p.m.

I just want to let you know that my code overall works.
The new process is saved correctly and most of the times i don't hit this problem the new attributes are found.

But when i do lot of changes in the process adding new attributes and stuffs that things seems to be out of synch with the server where i can have the 'workItem.hasAttribute( attribute)= false '

The work around for that is to re-run the synchronization and to do a dummy open and save of the project area from the Eclipse client with the process configuration source tab...i will just enter a space and then click on the save button....that is why i would like to understand what is trigged with the save button.


permanent link
Simon Fisher (1631710) | answered Mar 05 '13, 11:17 a.m.
JAZZ DEVELOPER
Hi,

From your comments it seems like the sync only fails when there are a lot of changes - could it be that the sync call is a non-blocking method, e.g. that when you run it it returns immediately; however the sync could still be running in the background / a separate thread?

Simon

Comments
Stefania Axo commented Mar 05 '13, 12:01 p.m.

hi
i believe it is run sequentially.
I do use WorkItemOperation.execute to do the "Synchronize Attributes" on each single work item returned by a query i created. I am not sure what happen with the code of WorkItemOperation.execute though.

From the selection of the Repository i run my menu that select the new process xml file and then replace it with the current process xml file that is in the project area.
After the replacement the synchronize attribute is done with the query of my new work item types to automatically get the changes done on the process.

thanks again


permanent link
Stefania Axo (12621513) | answered Mar 05 '13, 12:04 p.m.
it is a client plugin that has this extensions:
**************************************************
   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="com.ibm.team.repository.client.ITeamRepository"
            id="com.ibm.sport.rtc.process.deployment.ui.contribution1">
         <menu
               label="Process Specification"
               path="additions"
               id="com.ibm.sport.rtc.process.deployment.ui.menu1">
            <separator
                  name="group1">
            </separator>
         </menu>
         <action
               label="Deploy Process Change..."
               class="com.ibm.sport.rtc.process.deployment.ui.popup.actions.DeployProcessChangeAction"
               menubarPath="com.ibm.sport.rtc.process.deployment.ui.menu1/group1"
               enablesFor="1"
               id="com.ibm.sport.rtc.process.deployment.ui.deployProcessChange">
         </action>
      </objectContribution>
   </extension>
********************************************************************
here is a piece of code that get the project areas related to the selected repository.
*********************************************************************
private Object[] projectSelection(ITeamRepository repository)
            throws TeamRepositoryException {
        IAuditableClient auditableClient = (IAuditableClient) repository
                .getClientLibrary(IAuditableClient.class);
        ItemProfile<IProjectArea> profile = ItemProfile
                .createFullProfile(IProjectArea.ITEM_TYPE);
        List<IProjectArea> projectAreas = auditableClient.findAuditables(
                profile, monitor);
        filteredProjects = new ArrayList<IProjectArea>(projectAreas.size());
        for (IProjectArea project : projectAreas) {
            if (!project.isArchived())
                filteredProjects.add(project);
        }
        projectNames = null;
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                setShell(Display.getDefault().getActiveShell());
                ListSelectionDialog dialog = new ListSelectionDialog(shell,
                        filteredProjects, new ListContentProvider(),
                        new ProjectAreaLabelProvider(),
                        "Select Target Projects");
                dialog.setTitle("Select Projects");
                if (dialog.open() == ListSelectionDialog.OK) {
                    projectNames = dialog.getResult();
                }
            }
        });
        return (projectNames);
**************************************************************************************

After the selection of the project area is done i will run the deployment on it in a sequential way.
is it something i can do in the way i load those project areas?

Also this is what i added to the code:
***************************************
         // START
         // Make sure we have the project area/ repository refreshed from the server
         IItemManager itemManager = repository.itemManager();
         projectArea = (IProjectArea)itemManager.fetchCompleteItem(
               projectArea.getItemHandle(), IItemManager.REFRESH, monitor );       
         repository = (ITeamRepository) projectArea.getOrigin();
         // END
         workingCopyManager.connect( projectArea );       
         IProcessItemWorkingCopy itemWorkingCopy = workingCopyManager
               .getWorkingCopy( projectArea );
.........

         IProjectAreaWorkingCopy projectAreaWorkingCopy = (IProjectAreaWorkingCopy)itemWorkingCopy;
         IDocument spec = projectAreaWorkingCopy.getProcessSpecification();
         spec.set( newSpecSource );
........
            // save project area
            // START
            // Make sure we have the project area/ repository refreshed from the server
            itemWorkingCopy.asyncInitialize( null );
            itemWorkingCopy.requestUpdateContext();
            // END
            itemWorkingCopy.save( monitor );


*******************************************




permanent link
Stefania Axo (12621513) | answered Mar 20 '13, 2:13 p.m.
After trying different tries with com.ibm.team.repository.client.IItemManager and com.ibm.team.process.client.workingcopies.IProjectAreaWorkingCopy methods like :

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
(IProjectArea)itemManager.fetchCompleteItem(
               projectArea.getItemHandle(), IItemManager.REFRESH, monitor );
..........

            projectAreaWorkingCopy.asyncInitialize( null );
            projectAreaWorkingCopy.requestUpdateContext();
            projectAreaWorkingCopy.asyncRefresh();
            if (projectAreaWorkingCopy.isDirty())

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
the code that seems to workaround the problem does the following steps:
- Save the new specification with the new attributes and stuff
- get the specification back and append a space (+" ") then Save
- get the specification back and remove the space then Save

The re-editing of the the process specification seems to do the trick!! That is true even if i do from the Eclipse client with the project area editor.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            spec = projectAreaWorkingCopy.getProcessSpecification();
            s = spec.get();
            spec.set( s + " " );
            projectAreaWorkingCopy.save( monitor );
            s = spec.get();
            s = s.substring( 0, s.length() - 1 );
            spec.set( s );
            projectAreaWorkingCopy.save( monitor );

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

permanent link
SEC Servizi (97123559) | answered Oct 25 '13, 10:40 a.m.
edited Oct 25 '13, 10:41 a.m.
We've got the same behaviour: if we programmamtically update the Process Configuration Source the new attributes then are not showed in work-items.
Stefania's trick seems does not work for us... :(  At the moment our code is:
IProcessItemService processClient = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IWorkingCopyManager workingCopyManager = processClient.getWorkingCopyManager();
IProjectArea prjArea = (IProjectArea) repo.itemManager().fetchCompleteItem(prjAreaH, IItemManager.REFRESH, null);
workingCopyManager.connect(prjArea);
IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.getWorkingCopy(prjArea);
IDocument document = prjAreaFreshCopy.getProcessSpecification();
String xml = document.get();
document.set(template);
prjAreaFreshCopy.asyncInitialize(IProcessClientService.ALL_PROPERTIES);
prjAreaFreshCopy.requestUpdateContext();
prjAreaFreshCopy.save(null);
final String trick = "\n<!-- Updated from " + templateName + " -->";
document = prjAreaFreshCopy.getProcessSpecification();
final String raw = document.get() + trick;
final int n = raw.length() - trick.length();
document.set(raw);
prjAreaFreshCopy.save(null);
document = prjAreaFreshCopy.getProcessSpecification();
document.set(raw.substring(0, n));
prjAreaFreshCopy.save(null);
Any advice?
Thanks in advance.

permanent link
SEC Servizi (97123559) | answered Oct 25 '13, 11:05 a.m.
edited Oct 25 '13, 11:07 a.m.
We found that the org.eclipse.ui.part.EditorPart#doSave is overrided by com.ibm.team.process.internal.ide.ui.editors.AbstractProcessItemEditor#doSave.
We found that in our IWorkingCopyManager the IUpdateContext was null when instead with a ProjectAreaEditorInput the IUpdateContext is never null:
if (manager.getUpdateContext() == null) {
manager.setUpdateContext(new UIUpdateContext());
}

Comments
Stefania Axo commented Oct 25 '13, 12:35 p.m.

did it work?


SEC Servizi commented Oct 28 '13, 4:10 a.m. | edited Oct 28 '13, 4:11 a.m.

The code above comes from  com.ibm.team.process.internal.ide.ui.editors.ProcessItemEditorInput#getWorkingCopy.

If we would try to set a IUpdateContext in our manager, we have to implement method "execute(Runnable runnable)" from that interface. (We had not try it yet.)


permanent link
SEC Servizi (97123559) | answered Oct 28 '13, 6:56 a.m.
edited Oct 28 '13, 6:58 a.m.
Further investigation... Inside com.ibm.team.process.internal.client.tests.AbstractTeamProcessTest class we found the method syncInitializeWorkingCopy which performs the working copy asyncInitialize inside a separate thread because:
// We make this call inside a separate thread so that the initialization
// will be performed synchronously.  This is due to the fact that the
// working copy framework performs initialization synchronously if the
// calling thread supports long ops.
Could our initialization be missing because of this? Any advice from Jazz devs would be great .:D
Cheers.

permanent link
Stefania Axo (12621513) | answered Oct 28 '13, 11:54 a.m.
i am not a jazz developer.
i may not be the best to answer this.
the workaround i put for RTC 4.0 seems to hold so far.
between the connection and the empty space
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
(IProjectArea)itemManager.fetchCompleteItem(
               projectArea.getItemHandle(), IItemManager.REFRESH, monitor );
..........

            projectAreaWorkingCopy.asyncInitialize( null );
            projectAreaWorkingCopy.requestUpdateContext();
            projectAreaWorkingCopy.asyncRefresh();
            if (projectAreaWorkingCopy.isDirty())

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



permanent link
KB 20 (123) | answered May 01 '14, 1:33 p.m.
Hey guys, I am also trying to post the process config source xml file back to the project and following your examples and some others, I have been getting this error: "com.ibm.team.process.common.service.ProcessDataValidationException: content is not allowed in prolog".

I have edited the file on my local machine and now want to post it back to the project and save it. Any ideas, why I could be getting this error?

Comments
Stefania Axo commented May 01 '14, 3:26 p.m.

i will suggest this:
- open one of the RTC default template like Scrum template. (from Work Item perspective
Do Windows-> Show View -> Other -> team -> Process template)
- Look at the Process Configuration Source tab with the xml and try to understand what is different there in the beginning part of the xml.


KB 20 commented May 01 '14, 4:21 p.m.

are you able to post content back to your projects? I just checked the scrum template and everything seems to be the same at the beginning. Could it be an encoding issue? Do you keep "<?xml version="1.0" encoding="UTF-8"?>" at the top of your xml file? If it is working for you then, my next question is if you are using a windows machine to post the content back? 


Stefania Axo commented May 15 '14, 5:05 p.m.

this is what is on my process configuration source
<?xml version="1.0" encoding="UTF-8"?>

Yes i use windows.

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.