ChangeSetManagementService
ChangeSetManagementService
The ChangeSetManagementService provides methods for persisting Change Sets objects (add, get, remove, update).
Adding a Change Set
Use the ChangeSetManagementService to create new Change Sets.
ChangeSetManagementService changeSetMgmtService = beanFactory.getBean(ContextIdNames.CHANGESET_MANAGEMENT_SERVICE); ChangeSet changeSet = beanFactory.getBean(ContextIdNames.CHANGE_SET); changeSet.setName("CS01"); changeSet.setDescription("My first change set"); ChangeSet updatedChangeSet = changeSetManagementService.add(changeSet);
The service will assign a new unique guid to the change set, set the created date and persist it to the database.
Retrieving Change Sets
Use the ChangeSetManagementService to retrieve Change Sets.
ChangeSetManagementService changeSetMgmtService = beanFactory.getBean(ContextIdNames.CHANGESET_MANAGEMENT_SERVICE); Collection<ChangeSet> changeSets = changeSetMgmtService.findAllChangeSets(null);
The findAllChangeSets method takes an argument that can be null or it can be a ChangeSetLoadTuner that specifies whether information about the Change Set members is loaded. If null, all Change Set member information is loaded.
You can also search for Change Set by specifying criteria. The following example returns all open Change Sets whose name contains ChangeSet. (The noMembersLoadTuner is configured to load Change Sets without any member information.)
ChangeSetSearchCriteria criteria = new ChangeSetSearchCriteria(); criteria.setChangeSetStateCode(ChangeSetStateCode.OPEN); criteria.setChangeSetName("CS01"); criteria.setStrictName(false); ChangeSetLoadTuner noMembersLoadTuner = beanFactory.getBean(ContextIdNames.CHANGESET_LOAD_TUNER); Collection<ChangeSet> changeSets = changeSetMgmtService.findByCriteria(criteria, noMembersLoadTuner);
If strictName is set to false, the search matches all Change Sets whose names contains CS01 (for example, CS01 and abcCS01def). If set to true, then the results will only contain the Change Sets whose names match CS01 exactly.
Updating the Change Set State
Use the updateState method to change the state of a Change Set.
changeSetMgmtService.updateState(changeSetGuid, ChangeSetStateCode.LOCK, null);
The ChangeSetStateCode enum defines the possible Change Set states:
OPEN | The Change Set is open. Objects can be added to and removed from the Change Set. |
---|---|
LOCKED | The Change Set is locked. Objects cannot be added to or removed from the Change Set. Objects in the Change Set cannot be modified. |
FINALIZED | The Change Set has been finalized. This means that changes made to objects in the Change Set have been synchronized to the target system and the objects have been released (i.e., unlocked). Once the objects are released, they can once again be edited and added to other Change Sets. |
Moving Objects From One Change Set to Another
Use the updateAndMoveObjects to move objects from one Change Set to another.
ChangeSetLoadTuner allMembersLoadTuner = beanFactory.getBean(ContextIdNames.CHANGESET_LOAD_TUNER); allMembersLoadTuner.setLoadingMemberObjects(true); allMembersLoadTuner.setLoadingMemberObjectsMetadata(true); Collection<BusinessObjectDescriptor> objectsToMove = new HashSet<BusinessObjectDescriptor>(); Pair<ChangeSet, ChangeSet> sourceAndTargetChangeSet = changeSetMgmtService.updateAndMoveObjects(sourceChangeSetGuid, targetChangeSetGuid, objectsToMove, allMembersLoadTuner); ChangeSet sourceChangeSet = sourceAndTargetChangeSet.getFirst(); ChangeSet targetChangeSet = sourceAndTargetChangeSet.getSecond();
updateAndMoveObjects returns a Pair containing the source and destination Change Sets after the business objects have been moved.