Create new enumeration type using Java API
2 answers
It looks that I found way to create new enumeration type stored in database:
public class OperationParticipant extends AbstractService implements IOperationParticipant { private IProjectArea fProjectArea; private class enumDetails { public String id; public String name; public enumDetails(String identifier, String displayName) { id = identifier; name = displayName; } } @SuppressWarnings("restriction") @Override public void run(AdvisableOperation operation, IProcessConfigurationElement participantConfig, IParticipantInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException { // TODO Auto-generated method stub List<enumDetails> enumsToCreate = new ArrayList<OperationParticipant.enumDetails>(); enumsToCreate.add(new enumDetails("hwVersion", "Found In HW")); enumsToCreate.add(new enumDetails("mechanicVersion", "Mechanic Version")); IRepositoryItemService itemService = (IRepositoryItemService)getService(IRepositoryItemService.class); this.fProjectArea = ((IProjectArea)itemService.fetchItem(operation.getProcessArea(), IRepositoryItemService.COMPLETE)); IEnumerationService enumServ = (IEnumerationService) getService(IEnumerationService.class); for (enumDetails enumDetails : enumsToCreate) { Enumeration enumToCreate = EnumerationFactory.eINSTANCE.createEnumeration(); enumToCreate.initNew(); enumToCreate.setContextId(fProjectArea.getContextId()); enumToCreate.setName(enumDetails.name); enumToCreate.setIdentifier(enumDetails.id); enumToCreate.setProjectArea(fProjectArea); enumToCreate.setItemId(UUID.generate()); enumServ.save(enumToCreate); } }
As far as I know, you would have to directly modify the process XML and save it.
You can check how the Eclipse client does it, but I am almost certain that you will have to use internal API if you try to do that. I have been looking for some stuff with respect to make attributes read only long time ago and I gave up because it was so hard.
All in all this might not be part of the public API, some code might just be rich client code, and is likely not considered as supported.