workItem.hasAttribute( attribute)= false after I add the attribute into the configuration xml and i execute Synchronize Attributes.
- 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
9 answers
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
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 DataThe API caches Data. If you want to make sure that the data is refreshed, use
IItemManager.REFRESH
instead ofIItemManager.DEFAULT
in the code above.
thanks so much
i will try and let you know
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
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.
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
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
**************************************************
<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 );
*******************************************
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
(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 );
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
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);
if (manager.getUpdateContext() == null) {
manager.setUpdateContext(new UIUpdateContext());
}
// 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.
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())
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Comments
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.
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?
this is what is on my process configuration source
<?xml version="1.0" encoding="UTF-8"?>
Yes i use windows.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 21 '13, 2:35 a.m.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.