# How to get a custom attribute enumerated value using OSLC Java API in DNG

**URL:** <https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325>\
**Category:** OSLC implementations\
**Created:** [November 11, 2019, 8:18pm UTC](https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325 "2019-11-11T20:18:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbarreno](https://forum.open-services.net/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@fbarreno](https://forum.open-services.net/u/fbarreno)\
**Post date:** [November 11, 2019, 8:18pm UTC](https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325/1 "2019-11-11T20:18:19Z")

</div>

I have a custom attribute enumerated value. This attribute contains two labels called True and False with two values 1 and 0, respectively.  
I think, the problem is that the client’s response and subsequent treatment to take the entity as a requirement class does not return the correct structure of this requirement. But i´m mot sure.

My code is:

```java
private static boolean getAttributeLinks(String url, JazzRootServicesHelper helper, JazzFormAuthClient client, String projectArea) {
 boolean isValid = false;

 try {

  /* Get the URL of the OSLC QualityManagement catalog */
  String catalogUrl = helper.getCatalogUrl();

  /* Find the OSLC Service Provider for the project area we want to work with */
  String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, projectArea);

  //STEP 6: Get the Query Capabilities URL so that we can run some OSLC queries
  String queryCapability = client.lookupQueryCapability(serviceProviderUrl,
   OSLCConstants.OSLC_RM_V2,
   OSLCConstants.RM_REQUIREMENT_TYPE);

  //Get Feature Requirement Type URL
  ResourceShape featureInstanceShape = RmUtil.lookupRequirementsInstanceShapes(
   serviceProviderUrl, OSLCConstants.OSLC_RM_V2,
   OSLCConstants.RM_REQUIREMENT_TYPE, client, "Requirement");

  // We need to use Resource shapes to properly handle date attributes,
  // so they aren't interpreted as dateTime.
  // The following 4 lines will enable the logic to properly handle date attributes
  List < ResourceShape > shapes = new ArrayList < ResourceShape > ();
  shapes.add(featureInstanceShape);
  OSLC4JUtils.setShapes(shapes);
  OSLC4JUtils.setInferTypeFromShape("true");

  ClientResponse getResponse = client.getResource(url, OslcMediaType.APPLICATION_RDF_XML);
  Requirement requirement = getResponse.getEntity(Requirement.class);
  // Display attributes based on the Resource shape
  Map < QName, Object > requestExtProperties = requirement.getExtendedProperties();

  for (QName qname: requestExtProperties.keySet()) {
   Property attr = featureInstanceShape.getProperty(new URI(qname.getNamespaceURI() + qname.getLocalPart()));
   String name = null;
   if (attr != null) {
    name = attr.getTitle();

    if (name != null) {
     if (name.equals("CUSTOM_ATTR")) {

      if (requirement.getExtendedProperties().get(qname).toString().equals("True"))
       return true;
     }
    }
   }
  }

 } catch (Exception e) {
  logger.log(Level.SEVERE, e.getMessage(), e);
 }

 return isValid;

}

```

This code works fine if CUSTOM\_ATTR is boolen type, but it do not work whether it´s enumerated value attribute.

Any suggestions on how to get the value from this enumerated attribute?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [November 11, 2019, 8:29pm UTC](https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325/2 "2019-11-11T20:29:23Z")

</div>

Hello Felipe and welcome!

I don’t have hands-on experience with DNG’s OSLC interface, unfortunately. But I think it’s not the first time the handling of enums came up w.r.t. to their handling in IBM products with OSLC 1 and OSLC 2 I/Fs. Let me CC @jamsden for help.

Cheers,  
Andrew

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [November 11, 2019, 8:44pm UTC](https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325/3 "2019-11-11T20:44:06Z")

</div>

Heads up @fbarreno, Nick replied with a clue [on Slack](https://app.slack.com/client/T58686F7F/CKS5U1MKN), you can freely join via [this link](https://join.slack.com/t/oslc-op/shared_invite/enQtNjY2MjI4ODMzNDkzLTBmNzY3NDI3NDNmZWNlZjk1MmZkODUwMTA2YmNjYzllN2M0ZTkyMzJiMjNhY2ZlYTE0MWE4NjM4NjEwNDM1NGY):

![image](https://forum.open-services.net/uploads/default/original/1X/86f88ef285e045a0e374960b738e0148c9655db7.png)

---

<div class="post-metadata">

**Author:** ![fbarreno](https://forum.open-services.net/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@fbarreno](https://forum.open-services.net/u/fbarreno)\
**Post date:** [November 12, 2019, 9:38am UTC](https://forum.open-services.net/t/how-to-get-a-custom-attribute-enumerated-value-using-oslc-java-api-in-dng/325/4 "2019-11-12T09:38:25Z")

</div>

Thank you very much for the answer!

If I previously set the URI value associated with each of the attribute tags listed. Later  
I can make a comparison of the URI that returns the attribute listed and I could already know the value of the  
attribute listed. This seems to be going well.  
My next question is: How can I change this value to the attribute?

Thanks in advance.
