[OLINGO-786] Fix alias usage in metadata for annotations

This commit is contained in:
Christian Amend 2015-10-20 15:51:40 +02:00
parent d00e3881dc
commit 15164da8f1
3 changed files with 8 additions and 20 deletions

View File

@ -244,8 +244,8 @@ public class MetadataDocumentXmlSerializer {
for (EdmAnnotation annotation : annotations) {
writer.writeStartElement(XML_ANNOTATION);
if (annotation.getTerm() != null) {
writer.writeAttribute(XML_TERM_ATT, annotation.getTerm().getFullQualifiedName()
.getFullQualifiedNameAsString());
writer.writeAttribute(XML_TERM_ATT, getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName(),
false));
}
if (annotation.getQualifier() != null) {
writer.writeAttribute(XML_QUALIFIER_ATT, annotation.getQualifier());
@ -315,7 +315,7 @@ public class MetadataDocumentXmlSerializer {
break;
case Cast:
EdmCast asCast = dynExp.asCast();
writer.writeAttribute(XML_TYPE, asCast.getType().getFullQualifiedName().getFullQualifiedNameAsString());
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asCast.getType(), false));
if (asCast.getMaxLength() != null) {
writer.writeAttribute(XML_MAX_LENGTH, "" + asCast.getMaxLength());
@ -345,7 +345,7 @@ public class MetadataDocumentXmlSerializer {
break;
case IsOf:
EdmIsOf asIsOf = dynExp.asIsOf();
writer.writeAttribute(XML_TYPE, asIsOf.getType().getFullQualifiedName().getFullQualifiedNameAsString());
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asIsOf.getType(), false));
if (asIsOf.getMaxLength() != null) {
writer.writeAttribute(XML_MAX_LENGTH, "" + asIsOf.getMaxLength());
@ -388,7 +388,7 @@ public class MetadataDocumentXmlSerializer {
break;
case Record:
EdmRecord asRecord = dynExp.asRecord();
writer.writeAttribute(XML_TYPE, asRecord.getType().getFullQualifiedName().getFullQualifiedNameAsString());
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asRecord.getType(), false));
for (EdmPropertyValue propValue : asRecord.getPropertyValues()) {
writer.writeStartElement(XML_PROPERTY_Value);
writer.writeAttribute(XML_PROPERTY, propValue.getProperty());

View File

@ -333,7 +333,7 @@ public class MetadataDocumentXmlSerializerTest {
assertTrue(metadata.contains("<Path>PathValue</Path>"));
assertTrue(metadata.contains("<PropertyPath>PropertyPathValue</PropertyPath>"));
assertTrue(metadata
.contains("<Record Type=\"namespace.ETAbstract\"><PropertyValue Property=\"PropName\"><String>value</String>"
.contains("<Record Type=\"Alias.ETAbstract\"><PropertyValue Property=\"PropName\"><String>value</String>"
+ "<Annotation Term=\"ns.term\"/></PropertyValue><Annotation Term=\"ns.term\"/></Record>"));
assertTrue(metadata.contains("<UrlRef><String>URLRefValue</String><Annotation Term=\"ns.term\"/></UrlRef>"));

View File

@ -50,6 +50,7 @@ public class MetadataDocumentTest {
final String metadata = IOUtils.toString(
odata.createSerializer(ContentType.APPLICATION_XML).metadataDocument(serviceMetadata).getContent());
System.out.println(metadata);
assertNotNull(metadata);
assertThat(metadata, containsString("<edmx:Reference Uri=\"" + CORE_VOCABULARY + "\">"
+ "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" + "</edmx:Reference>"));
@ -76,23 +77,10 @@ public class MetadataDocumentTest {
+ "<Property Name=\"AdditionalPropertyString_5\" Type=\"Edm.String\"/>"
+ "</EntityType>"));
// assertThat(metadata, containsString("<EntitySet Name=\"ESAllPrim\" EntityType=\"Namespace1_Alias.ETAllPrim\">"
// + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimOne\" Target=\"ESTwoPrim\"/>"
// + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimMany\" Target=\"ESTwoPrim\"/>"
// + "</EntitySet>"));
assertThat(metadata, containsString("<EntitySet Name=\"ESAllPrim\" EntityType=\"Namespace1_Alias.ETAllPrim\">"
+ "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimOne\" Target=\"ESTwoPrim\"/>"
+ "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimMany\" Target=\"ESTwoPrim\"/>"
+ "<Annotation Term=\"Core.Description\" String=\"Contains entities with all primitive types\"/>"
+ "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledForEntitySet\" String=\"System Query Options:"
+ " $filter, $count, $orderby, $skip, $top, $expand, $select, $format; Operations: Create, Create with Deep "
+ "Insert, Create with Bind Operation, Read\"/>"
+ "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledForEntity\" String=\"System Query Options: "
+ "$expand, $select, $format; Operations: Read, Update, Update with Bind Operation, Delete\"/>"
+ "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledNavigationProperties\" "
+ "String=\"NavPropertyETTwoPrimOne, NavPropertyETTwoPrimMany\"/>"
+ "</EntitySet>"));
+ "<Annotation Term=\"Core.Description\""));
assertThat(metadata,
containsString("<ComplexType Name=\"CTPrim\">"