[OLINGO-1191] Code Improvements
This commit is contained in:
parent
dd992163b7
commit
a3a84c9e86
|
@ -125,12 +125,14 @@ public class CsdlTypeValidator {
|
|||
baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName);
|
||||
}
|
||||
baseEntityType = csdlEntityTypesMap.get(baseTypeFQName);
|
||||
if (baseEntityType.getKey() != null) {
|
||||
break;
|
||||
} else if (baseEntityType != null && baseEntityType.getBaseType() != null) {
|
||||
baseTypeFQName = baseEntityType.getBaseTypeFQN();
|
||||
} else if (baseEntityType.getBaseType() == null) {
|
||||
break;
|
||||
if (baseEntityType != null) {
|
||||
if (baseEntityType.getKey() != null) {
|
||||
break;
|
||||
} else if (baseEntityType.getBaseType() != null) {
|
||||
baseTypeFQName = baseEntityType.getBaseTypeFQN();
|
||||
} else if (baseEntityType.getBaseType() == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseEntityType;
|
||||
|
@ -149,16 +151,18 @@ public class CsdlTypeValidator {
|
|||
baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName);
|
||||
}
|
||||
baseEntityType = csdlEntityTypesMap.get(baseTypeFQName);
|
||||
if (baseEntityType.getNavigationProperty(navBindingProperty) != null) {
|
||||
break;
|
||||
} else if (baseEntityType != null && baseEntityType.getBaseType() != null) {
|
||||
baseTypeFQName = baseEntityType.getBaseTypeFQN();
|
||||
} else if (baseEntityType.getBaseType() == null) {
|
||||
break;
|
||||
if (baseEntityType != null) {
|
||||
if (baseEntityType.getNavigationProperty(navBindingProperty) != null) {
|
||||
break;
|
||||
} else if (baseEntityType.getBaseType() != null) {
|
||||
baseTypeFQName = baseEntityType.getBaseTypeFQN();
|
||||
} else if (baseEntityType.getBaseType() == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (baseEntityType == null) {
|
||||
throw new RuntimeException("Entity TYpe is null with fully qualified name:" + baseTypeFQName);
|
||||
throw new RuntimeException("Entity Type is null with fully qualified name:" + baseTypeFQName);
|
||||
}
|
||||
return baseEntityType.getNavigationProperty(navBindingProperty);
|
||||
}
|
||||
|
|
|
@ -404,17 +404,4 @@ public class EntityTest extends AbstractTest {
|
|||
assertTrue(property.isPrimitive());
|
||||
assertEquals(property.getValueType(), ValueType.PRIMITIVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindTypeInEdmEnabledClient() throws Exception {
|
||||
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("metadata_TripInService.xml"));
|
||||
assertNotNull(edm);
|
||||
final InputStream input = getClass().getResourceAsStream("tripinServEntity.json");
|
||||
EdmEnabledODataClient edmClient = ODataClientFactory.getEdmEnabledClient(SERVICE_URI, ContentType.APPLICATION_JSON);
|
||||
ClientEntity entity = edmClient.getBinder().getODataEntity(
|
||||
edmClient.getDeserializer(ContentType.APPLICATION_JSON).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
assertEquals(entity.getTypeName().getFullQualifiedNameAsString(),
|
||||
"Microsoft.OData.SampleService.Models.TripPin.Person");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -350,8 +350,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
* @return ascii representation of the entity id
|
||||
*/
|
||||
private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException {
|
||||
if(entity.getId() == null) {
|
||||
if(entity == null || entityType == null || entityType.getKeyPredicateNames() == null
|
||||
if(entity != null && entity.getId() == null) {
|
||||
if(entityType == null || entityType.getKeyPredicateNames() == null
|
||||
|| name == null) {
|
||||
throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID);
|
||||
}else{
|
||||
|
|
Loading…
Reference in New Issue