It's all about the answers!

Ask a question

How to get custom attribute of type enumeration server side

Ratheesh Madathil (1371728) | asked Jul 31 '15, 5:17 a.m.
Hello All,
Can some one suggest how to get (read) the story point enumeration value to make use in a server side plug-in ?

Below code works for standard attribute like duration, but not for enumeration type.
private long getDuration(IWorkItem child, IAttribute attribute, IProgressMonitor monitor) throws TeamRepositoryException {
    long duration = 0;
    if(attribute!=null && child.hasAttribute(attribute)){
        Long tempDuration = (Long)child.getValue(attribute);
        if(tempDuration!=null&& tempDuration.longValue()>0)
            return tempDuration.longValue();
    return duration;

Thank you.

Accepted answer

permanent link
Ralph Schoon (63.1k33646) | answered Jul 31 '15, 6:08 a.m.
edited Jul 31 '15, 6:09 a.m.

More details:

    private String calculateEnumerationLiteralAsString(Object value,
            IAttribute attribute) throws TeamRepositoryException {
        if (value == null) {
            return CONSTANT_NO_VALUE;
        if (!(value instanceof Identifier<?>)) {
            return "Value not an enumeration literal";
        IEnumeration<? extends ILiteral> enumeration = getWorkItemCommon()
                .resolveEnumeration(attribute, getMonitor());

        Identifier<? extends ILiteral> currentIdentifier = (Identifier<? extends ILiteral>) value;
        ILiteral literal = enumeration
        return literal.getName();

Ratheesh Madathil selected this answer as the correct answer

Ratheesh Madathil commented Aug 04 '15, 3:19 a.m.

Thank you Ralph for your answer. In fact we had refereed already to the link you mentioned, but not successful.
The error while deploying is "bundle could not be resolved".
My colleague has given now the full code for your reference, can be followed up further in the following link:.

Ratheesh Madathil commented Aug 14 '15, 10:19 a.m.

Thank you Ralph, that hint worked..

One other answer

permanent link
Ralph Schoon (63.1k33646) | answered Aug 04 '15, 4:07 a.m.
Please carefully read

The error you show is not an error in the code. It is an error in setting up the plugin and deploying it.
Before you even get to this point, you should have already followed and debugged your code on Jetty. Once the debugging works, it is easy enough to very fy the code works and if it does, then you deploy on the server and know that the code works and your problems are due to deployment problems.

Why do you run two threads with the same question? Can't you coordinate with your colleague?

Ratheesh Madathil commented Aug 04 '15, 4:20 a.m.

ok, got it.
We will follow up with this question.
Configure Jetty for debugging- we are not successful yet (port error while launch). We will try using your blog entries from start again.

Ralph Schoon commented Aug 04 '15, 4:30 a.m.

What error do you get with Jetty?
If the port is already taken, run a command like netstat to find out what process sits on the port. You can also change the port by editing the jetty launch. The port is set as a variable. Also shut down the development repository when running the JUnit to create the test database and give it time to succeed.

Your answer

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