I'm using the Cumulocity Java SDK and I'm trying to get access of the custom fragment in one of the ManagedObject. Something like that:
...
"type": "sap_CustomomerLocation",
"c8y_PropertyType":{
"Customer.Name":{
"name":"customerName",
"sap_field_name":{
"requestIdentifier":"SAP",
"adressIdentifier":"customerName"
}
},
"Customer.Address":{
"name":"customerAddress",
"sap_field_name":{
"requestIdentifier":"SAP",
"adressIdentifier":"customerAddress"
}
}
}
...
I can't change the format of the fragment. In Java application I fetch the Mo by:
InventoryFilter filter = new InventoryFilter();
filter.byType("sap_CustomomerLocation");
ManagedObjectCollection configuration = platform.getInventoryApi().getManagedObjectsByFilter(filter);
ManagedObjectRepresentation singleConfig = configuration.get().allPages().iterator().next();
Map<String, Object> attrs = singleConfig.getAttrs();
The problem is that I can't get to the "sap_field_name", attrs is a HashMap@Node. In debugger in IntelliJ, when I use "evaluateExpression" something like that is generated:
((HashMap.Node)((HashMap)((HashMap.Node)((HashMap)((HashMap.Node)((HashMap)((HashMap.Node)((HashMap)attrs).entrySet().toArray()[0]).getValue()).entrySet().toArray()[0]).getValue()).entrySet().toArray()[0]).getValue()).entrySet().toArray()[1]).getValue()
So, can you suggest something? Should I somehow cast it to the DTO? But then how to handle keys in the JSON ("Customer.Name", "Customer.Address") that can change because this is a list of fields.