Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Moving assets into approved state using Java API

The requirement is to bulk upload assets and transition them into approved state.

Asset Lifecycle is set to Draft -> Review -> Approved
Review to Approved transition requires at least one approval from the asset reviewers user group.

I am the community admin and belong to asset reviewers user group. I am using the following code to transition the lifecycle of assets. The program executes fine but the assets are set to Review state instead of approved state.

Would be helpful if someone can point out the error?
public void setApproveState(RAMAsset anAsset) {
	//move the asset into review state
RAMAction[] actions = anAsset.getAvailableActions();
for (int i = 0; i < actions.length; i++) {
if (actions[i].getName().equals("Submit for Approval")) {
anAsset.setAction(actions[i]);
break;
}
}
session.put(anAsset, new NullProgressMonitor());

//provide one approval for the asset in review state
RAMStateHistory stateHistory = anAsset.getCurrentStateHistory();
RAMVote review = new RAMVote();
review.setVoteChoice(RAMVote.APPROVE);
review.setComment("comment");
stateHistory.castVote(review);
session.put(anAsset, new NullProgressMonitor());

// move the asset to approved state
actions = anAsset.getAvailableActions();
for (int i = 0; i < actions.length; i++) {
if (actions[i].getName().equals("Approve")) {
anAsset.setAction(actions[i]);
break;
}
}
session.put(anAsset, new NullProgressMonitor());
}

0 votes

Comments

Are you saying that the first transition, and the vote are recorded fine, but that the last action ("Approve") did not take place?  ... i.e., if you look at the asset on the web, you it is in the 2nd state, and the vote is recorded?


btw, there is no indication in your code if any action was found .... are you sure that the setAction was executed?

Gili, when I look the asset on the web, the first transition and vote are recorded fine but the last approve action didn't take place.
I removed logging statements here but the log confirms that setAction(...) was executed.

Is there something missing in the code to satisfy the policy constraint of having one approval by asset reviewer?

My transition condition from Review -> Approve is
- Manual action is Approve
- Number of approvals from Asset reviewers is 1

Where does this code run? Perhaps the RAMVote needs to be associated with a user from the Asset reviewers group (while you say the vote is recorded, does it show as recorded by you)? Does logging also confirm that closing put() is called? A stretch, I know...


Be the first one to answer this question!

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,079

Question asked: Sep 23 '13, 6:56 a.m.

Question was seen: 6,790 times

Last updated: Sep 27 '13, 7:15 p.m.

Confirmation Cancel Confirm