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

Create new enumeration type using Java API

I've searched, but I only find how to add enumeration value to existing enum. But did anyone created new enumeration type?
We wan't to use database stored enums in projects, but they can't be specified in process template, and I'm trying to write custom follow up action to handle this.

1 vote



2 answers

Permanent link

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);
        }
        
    }

1 vote


Permanent link

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.

0 votes

Comments

I've tried to search in process XML, but database stored enumerations are not saved there, everything is stored in database only.

They are created in the Eclipse Rich client, so you can try to search the RTC Client SDK, what the code does. It is likely still unsupported internal API.

Your answer

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
× 10,937

Question asked: Mar 13 '18, 7:18 a.m.

Question was seen: 2,009 times

Last updated: Mar 13 '18, 10:30 a.m.

Confirmation Cancel Confirm