Olingo - OData: How to define complex types in Olingo OData

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Olingo - OData: How to define complex types in Olingo OData



I need to define below JSON in OData entity.


"d" : {
"__metadata" : {
"type" : "ServiceCloudAssetModel.HBServicesInfo",
"uri" : "http://sdf.com/notimplemented/Entity(0)"
},
"SPVersion" : "0",
"Status" : "Informational",
"ResponseCode" : "100",
"Description" : "High Memory Usage; Hardware Failure detected",
"LastBootUpDate" : "2017-04-07T20:48:13.486816",
"SchemaVersion" : null,
"AgentVersion" : "2.0.0.0",
"WindowsUpdatedRunDate" : "2017-04-05T08:13:42",
"UTCDate" : "2018-06-20T18:22:32.3388283Z",
"ResponseMessage" : "Success",
"uuid" : "bada16db-2b2f-46de-a366-545ea9774d2c",
"LocalDate" : "2018-06-10T23:52:32.3970051+05:30",
"URL" : "https://uat.sdf.com/#/xyz/devices/heartbeat/XYZ$$9223370507383975807",
"SystemDriveFreeSpace" : "110.29 GB",
"HighCPUUsage" : "60",
"Model" : "ABCE7440",
"ApplicationCrashesLast24hrs" : null,
"OSVersion" : "6.3.9600",
"BIOSVersion" : "A08",
"ServiceTagId" : "XYZ",
"Registered" : "false",
"HighMemUsage" : "87.5"
}



I have written the below getEntityType function for Simple types...Rest I need is help on defining __metadata and d complex type..


@Override
public CsdlEntityType getEntityType() {
// create CsdlPropertyRef for Key element
CsdlEntityType entityType = new CsdlEntityType();
entityType.setName(ET_HeartBeatData);
CsdlPropertyRef propertyRef = new CsdlPropertyRef();
propertyRef.setName(ETF_SERVICETAGID);
List<CsdlPropertyRef> csdlPropertyRefList = new ArrayList<CsdlPropertyRef>();
csdlPropertyRefList.add(propertyRef);
entityType.setKey(csdlPropertyRefList);


// create EntityType properties


CsdlProperty SPVersion = new CsdlProperty().setName(ETF_SPVERSION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty Status = new CsdlProperty().setName(ETF_STATUS)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty ResponseCode = new CsdlProperty().setName(ETF_RESPONSECODE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty Description = new CsdlProperty().setName(ETF_DESCRIPTION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty LastBootUpDate = new CsdlProperty().setName(ETF_LASTBOOTUPDATE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty SchemaVersion = new CsdlProperty().setName(ETF_SCHEMAVERSION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty AgentVersion = new CsdlProperty().setName(ETF_AGENTVERSION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty WindowsUpdatedRunDate = new CsdlProperty().setName(ETF_WINDOWSUPDATEDRUNDATE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty UTCDate = new CsdlProperty().setName(ETF_UTCDATE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty ResponseMessage = new CsdlProperty().setName(ETF_RESPONSEMESSAGE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty uuid = new CsdlProperty().setName(ETF_UUID)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty LocalDate = new CsdlProperty().setName(ETF_LOCALDATE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty URL = new CsdlProperty().setName(ETF_URL)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty SystemDriveFreeSpace = new CsdlProperty().setName(ETF_SYSTEMDRIVEFREESPACE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty HighCPUUsage = new CsdlProperty().setName(ETF_HIGHCPUUSAGE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty Model = new CsdlProperty().setName(ETF_MODEL)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty ApplicationCrashesLast24hrs = new CsdlProperty().setName(ETF_APPLICATIONCRASHESLAST24HRS)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty OSVersion = new CsdlProperty().setName(ETF_OSVERSION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty BIOSVersion = new CsdlProperty().setName(ETF_BIOSVERSION)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty ServiceTagId = new CsdlProperty().setName(ETF_SERVICETAGID)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty Registered = new CsdlProperty().setName(ETF_REGISTERED)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
CsdlProperty HighMemUsage = new CsdlProperty().setName(ETF_HIGHMEMUSAGE)
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());

// configure EntityType
entityType.setProperties(Arrays.asList(SPVersion,Status,ResponseCode,Description,LastBootUpDate,SchemaVersion,AgentVersion,WindowsUpdatedRunDate,UTCDate,ResponseMessage,uuid,LocalDate,URL,SystemDriveFreeSpace,HighCPUUsage,Model,ApplicationCrashesLast24hrs,OSVersion,BIOSVersion,ServiceTagId,Registered,HighMemUsage));
return entityType;
}



Please ignore the below text.
Please ignore the below text.
Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.Please ignore the below text.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

gonPpAMGvEF
ttsUY l7LDJ6CNXYSZ NlI8v7cZQPLCx4q,cL0NROg,j,n9qA22nU 498,eFoAPKikr3

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results