It's all about the answers!

Ask a question

Setting Value to Priority attribute programtically in DTC defect form using OSLC Java code


Sujith Babu Bandla (111) | asked Sep 05 '17, 7:27 a.m.

 Hi,


Kindly request to help me on setting the value for Priority attribute(default-enumeration type) programtically in DTC defect form using OSLC Java code.

As of now,if trying to set it by using below code,but i'm not able to achieve it. Please correct me.
Note : I was able to set the values for Customised enumeration attribute,but not able to fill for default enumeration attribute(Priority).


Property PriorityProperty = shape.getProperty(new URI("http://open-services.net/ns/cm#internalPriority"));
if (PriorityProperty != null) {
URI allowedValuesRef8 = PriorityProperty.getAllowedValuesRef();
ClientResponse allowedValuesResponse8 = client.getResource(allowedValuesRef8.toString(),OslcMediaType.APPLICATION_XML);
AllowedValues allowedValues8 = allowedValuesResponse8.getEntity(AllowedValues.class);
Object[] values8 = allowedValues8.getValues().toArray();
//If this fails, you might need to check that the value is not "Unassigned", which is an allowed value in some RTC project areas.
//Try the second value instead of the first, most project area processes create more than one category
defect1.getExtendedProperties().put(new QName("http://open-services.net/ns/cm#", "internalPriority"), (URI) values8[2]);
}

Thanks,
Sujith Babu

One answer



permanent link
Sujith Babu Bandla (111) | answered Sep 06 '17, 12:42 a.m.

 I'm able to set the value.Thanks


//Look at the allowed values for Priority. This is generally a required field for defects.
Property PriorityProperty = shape.getProperty(new URI("http://open-services.net/ns/cm-x#priority"));
if (PriorityProperty != null) {
System.out.println("Inside not null property");
URI allowedValuesRef8 = PriorityProperty.getAllowedValuesRef();
ClientResponse allowedValuesResponse8 = client.getResource(allowedValuesRef8.toString(),OslcMediaType.APPLICATION_XML);
AllowedValues allowedValues8 = allowedValuesResponse8.getEntity(AllowedValues.class);
Object[] values8 = allowedValues8.getValues().toArray();
for(Object val:values8) {
System.out.println("The values of Priority literal are "+val);
}
//If this fails, you might need to check that the value is not "Unassigned", which is an allowed value in some RTC project areas.
//Try the second value instead of the first, most project area processes create more than one category
defect1.getExtendedProperties().put(new QName("http://open-services.net/ns/cm-x#", "priority"), (URI) values8[2]);
}

Thanks,
Sujith

Your answer


Register or to post your answer.