workItem.hasAttribute( attribute)= false after I add the attribute into the configuration xml and i execute Synchronize Attributes.
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
- 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
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
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
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
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
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 );
*******************************************
**************************************************
<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 );
*******************************************
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 );
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
(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 );
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
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.
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());
}
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.
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())
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
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())
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
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
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 21 '13, 2:35 a.m.