当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationAttribute类代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute的典型用法代码示例。如果您正苦于以下问题:Java AnnotationAttribute类的具体用法?Java AnnotationAttribute怎么用?Java AnnotationAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnnotationAttribute类属于org.apache.olingo.odata2.api.edm.provider包,在下文中一共展示了AnnotationAttribute类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extendJPAEdmSchema

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Override
public void extendJPAEdmSchema(JPAEdmSchemaView view) {
	ResourceBundle i18n = ODataContextUtil.getResourceBundle("i18n");
	final Schema edmSchema = view.getEdmSchema();
	
	for (EntityType entityType : edmSchema.getEntityTypes()) {
		for (Property property : entityType.getProperties()) {
			String label = null;
			if (i18n != null) { try { label = i18n.getString(entityType.getName() + "." + property.getName()); } catch (Exception e) {} }
			List<AnnotationAttribute> annotationAttributeList = new ArrayList<AnnotationAttribute>();
			if (label != null) {
				annotationAttributeList.add(new AnnotationAttribute()
						.setNamespace(SAP_NAMESPACE)
						.setPrefix(SAP_PREFIX)
						.setName(LABEL).setText(label));
			}
			annotationAttributeList.addAll(getSapPropertyAnnotations(entityType, property));
			property.setAnnotationAttributes(annotationAttributeList); 
		}
	}
	
	addSmartAnnotations(edmSchema);
}
 
开发者ID:jpenninkhof,项目名称:odata-boilerplate,代码行数:24,代码来源:JPAEdmExtension.java

示例2: writeAnnotationAttributes

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private static void writeAnnotationAttributes(final Collection<AnnotationAttribute> annotationAttributes,
    final Map<String, String> predefinedNamespaces, ArrayList<String> setNamespaces,
    final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
  if (annotationAttributes != null) {
    if (setNamespaces == null) {
      setNamespaces = new ArrayList<String>();
    }
    for (AnnotationAttribute annotationAttribute : annotationAttributes) {
      if (annotationAttribute.getNamespace() != null) {
        xmlStreamWriter.writeAttribute(annotationAttribute.getPrefix(), annotationAttribute.getNamespace(),
            annotationAttribute.getName(), annotationAttribute.getText());
        if (setNamespaces.contains(annotationAttribute.getNamespace()) == false
            && predefinedNamespaces.containsValue(annotationAttribute.getNamespace()) == false) {
          xmlStreamWriter.writeNamespace(annotationAttribute.getPrefix(), annotationAttribute.getNamespace());
          setNamespaces.add(annotationAttribute.getNamespace());
        }
      } else {
        xmlStreamWriter.writeAttribute(annotationAttribute.getName(), annotationAttribute.getText());
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:XmlMetadataProducer.java

示例3: readEntityTypeKey

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private Key readEntityTypeKey(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
  reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ENTITY_TYPE_KEY);
  List<PropertyRef> keys = new ArrayList<PropertyRef>();
  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  List<AnnotationAttribute> annotationAttributes = readAnnotationAttribute(reader);
  while (reader.hasNext()
      && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
      && XmlMetadataConstants.EDM_ENTITY_TYPE_KEY.equals(reader.getLocalName()))) {
    reader.next();
    if (reader.isStartElement()) {
      extractNamespaces(reader);
      currentHandledStartTagName = reader.getLocalName();
      if (XmlMetadataConstants.EDM_PROPERTY_REF.equals(currentHandledStartTagName)) {
        reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_PROPERTY_REF);
        keys.add(readPropertyRef(reader));
      } else {
        annotationElements.add(readAnnotationElement(reader));
      }
    }
  }
  Key key = new Key().setKeys(keys).setAnnotationAttributes(annotationAttributes);
  if (!annotationElements.isEmpty()) {
    key.setAnnotationElements(annotationElements);
  }
  return key;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:XmlMetadataConsumer.java

示例4: readAnnotationAttribute

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private List<AnnotationAttribute> readAnnotationAttribute(final XMLStreamReader reader) {
  List<AnnotationAttribute> annotationAttributes = new ArrayList<AnnotationAttribute>();
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    String attributeNamespace = reader.getAttributeNamespace(i);
    if (attributeNamespace != null && !isDefaultNamespace(attributeNamespace)
        && !mandatoryNamespaces.containsValue(attributeNamespace)
        && !edmNamespaces.contains(attributeNamespace)) {
      annotationAttributes.add(new AnnotationAttribute().setName(reader.getAttributeLocalName(i)).
          setPrefix(reader.getAttributePrefix(i)).setNamespace(attributeNamespace).setText(
              reader.getAttributeValue(i)));
    }
  }
  if (annotationAttributes.isEmpty()) {
    return null;
  }
  return annotationAttributes;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:18,代码来源:XmlMetadataConsumer.java

示例5: getEdmEntityContainerImpl

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Before
public void getEdmEntityContainerImpl() throws Exception {

  List<AnnotationAttribute> annotationAttributes = new ArrayList<AnnotationAttribute>();
  AnnotationAttribute attribute =
      new AnnotationAttribute().setName("attributeName").setNamespace("namespace").setPrefix("prefix")
          .setText("Text");
  annotationAttributes.add(attribute);

  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  AnnotationElement element =
      new AnnotationElement().setName("elementName").setNamespace("namespace").setPrefix("prefix").setText("xmlData");
  annotationElements.add(element);

  annotationsProvider = new EdmAnnotationsImplProv(annotationAttributes, annotationElements);

  annotationsProviderWithNullEementAndAttributes = new EdmAnnotationsImplProv(null, null);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:EdmAnnotationsImplProvTest.java

示例6: EdmAnnotationsImplProv

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
public EdmAnnotationsImplProv(final List<AnnotationAttribute> annotationAttributes,
    final List<AnnotationElement> annotationElements) {
  if (annotationAttributes != null) {
    this.annotationAttributes = new ArrayList<EdmAnnotationAttribute>();
    this.annotationAttributes.addAll(annotationAttributes);
  }
  if (annotationElements != null) {
    this.annotationElements = new ArrayList<EdmAnnotationElement>();
    for (AnnotationElement element : annotationElements) {
      EdmAnnotationElement edmElement = new EdmAnnotationElementImplProv(element);
      this.annotationElements.add(edmElement);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:15,代码来源:EdmAnnotationsImplProv.java

示例7: writeValidMetadata4

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Test
public void writeValidMetadata4() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:39,代码来源:XmlMetadataProducerTest.java

示例8: writeValidMetadata5

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Test
public void writeValidMetadata5() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:41,代码来源:XmlMetadataProducerTest.java

示例9: createElementWithInclude

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private AnnotationElement createElementWithInclude() {
  List<AnnotationAttribute> childAttributes = new ArrayList<AnnotationAttribute>();
  childAttributes.add(new AnnotationAttribute().setName("Namespace").setText("Org.OData.Core.V1"));
  childAttributes.add(new AnnotationAttribute().setName("Alias").setText("UI"));
  List<AnnotationElement> childElements = new ArrayList<AnnotationElement>();
  childElements.add(new AnnotationElement().setName("Include").setNamespace(
      "http://docs.oasis-open.org/odata/ns/edmx").setPrefix("edmx").setAttributes(childAttributes));
  List<AnnotationAttribute> referenceAttributes = new ArrayList<AnnotationAttribute>();
  referenceAttributes.add(new AnnotationAttribute().setName("Uri").setText("http://someurl2.com"));
  return new AnnotationElement().setName("Reference").setPrefix("edmx").setNamespace(
      "http://docs.oasis-open.org/odata/ns/edmx").setAttributes(referenceAttributes).setChildElements(childElements);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:13,代码来源:XmlMetadataConsumerTest.java

示例10: readAnnotationElement

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private AnnotationElement readAnnotationElement(final XMLStreamReader reader) throws XMLStreamException {
  AnnotationElement aElement = new AnnotationElement();
  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  List<AnnotationAttribute> annotationAttributes = new ArrayList<AnnotationAttribute>();
  aElement.setName(reader.getLocalName());
  String elementNamespace = reader.getNamespaceURI();
  if (!edmNamespaces.contains(elementNamespace)) {
    aElement.setPrefix(reader.getPrefix());
    aElement.setNamespace(elementNamespace);
  }
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    AnnotationAttribute annotationAttribute = new AnnotationAttribute();
    annotationAttribute.setText(reader.getAttributeValue(i));
    annotationAttribute.setName(reader.getAttributeLocalName(i));
    annotationAttribute.setPrefix(reader.getAttributePrefix(i));
    String namespace = reader.getAttributeNamespace(i);
    if (namespace != null && !isDefaultNamespace(namespace)) {
      annotationAttribute.setNamespace(namespace);
    }
    annotationAttributes.add(annotationAttribute);
  }
  if (!annotationAttributes.isEmpty()) {
    aElement.setAttributes(annotationAttributes);
  }

  boolean justRead = false;
  if (reader.hasNext()) {
    reader.next();
    justRead = true;
  }

  while (justRead && !(reader.isEndElement() && aElement.getName() != null
      && aElement.getName().equals(reader.getLocalName()))) {
    justRead = false;
    if (reader.isStartElement()) {
      annotationElements.add(readAnnotationElement(reader));
      if (reader.hasNext()) {
        reader.next();
        justRead = true;
      }
    } else if (reader.isCharacters()) {
      String elementText = "";
      do {
        justRead = false;
        elementText = elementText + reader.getText();
        if (reader.hasNext()) {
          reader.next();
          justRead = true;
        }
      } while (justRead && reader.isCharacters());
      aElement.setText(elementText);
    }
  }
  if (!annotationElements.isEmpty()) {
    aElement.setChildElements(annotationElements);
  }
  return aElement;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:59,代码来源:XmlMetadataConsumer.java

示例11: writeValidMetadata2

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Test
public void writeValidMetadata2() throws Exception {
  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationElement> childElements = new ArrayList<AnnotationElement>();
  childElements
      .add(new AnnotationElement().setName("schemaElementTest2").setText("text2").setNamespace("namespace1"));

  List<AnnotationAttribute> elementAttributes = new ArrayList<AnnotationAttribute>();
  elementAttributes.add(new AnnotationAttribute().setName("rel").setText("self"));
  elementAttributes.add(new AnnotationAttribute().setName("href").setText("http://google.com").setPrefix("pre")
      .setNamespace("namespaceForAnno"));

  List<AnnotationElement> element3List = new ArrayList<AnnotationElement>();
  element3List.add(new AnnotationElement().setName("schemaElementTest4").setText("text4").setAttributes(
      elementAttributes));
  childElements.add(new AnnotationElement().setName("schemaElementTest3").setText("text3").setPrefix("prefix")
      .setNamespace("namespace2").setChildElements(element3List));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setText("text1").setChildElements(
      childElements));

  schemaElements.add(new AnnotationElement().setName("test"));
  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("b", "namespace1");
  prefixMap.put("prefix", "namespace2");
  prefixMap.put("pre", "namespaceForAnno");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  String metadata = StringHelper.inputStreamToString(csb.getInputStream());
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/b:schemaElementTest2", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/prefix:schemaElementTest3", metadata);
  assertXpathExists(
      "/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/prefix:schemaElementTest3/" +
          "a:schemaElementTest4[@rel=\"self\" and @pre:href=\"http://google.com\"]",
      metadata);

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:57,代码来源:XmlMetadataProducerTest.java

示例12: writeValidMetadata6

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Test
public void writeValidMetadata6() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));

  List<AnnotationElement> elementElements = new ArrayList<AnnotationElement>();
  elementElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  elementElements.add(new AnnotationElement().setName("schemaElementTest3").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1).setChildElements(elementElements));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1/atom:schemaElementTest2",
      metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1/atom:schemaElementTest3",
      metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:48,代码来源:XmlMetadataProducerTest.java

示例13: writeWithPredefinedNamespaces

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
@Test
public void writeWithPredefinedNamespaces() throws Exception {
  // prepare
  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("foo").setNamespace(
      "http://www.foo.bar/Protocols/Data"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("foo").setNamespace(
      "http://www.foo.bar/Protocols/Data"));

  List<AnnotationElement> elementElements = new ArrayList<AnnotationElement>();
  elementElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("foo").setNamespace(
      "http://www.foo.bar/Protocols/Data").setAttributes(attributesElement1));
  elementElements.add(new AnnotationElement().setName("schemaElementTest3").setPrefix("foo").setNamespace(
      "http://www.foo.bar/Protocols/Data").setAttributes(attributesElement1));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("foo").setNamespace(
      "http://www.foo.bar/Protocols/Data").setAttributes(attributesElement1).setChildElements(elementElements));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  // Execute
  Map<String, String> predefinedNamespaces = new HashMap<String, String>();
  predefinedNamespaces.put("foo", "http://www.foo.bar/Protocols/Data");
  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, predefinedNamespaces);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  // Verify
  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("foo", "http://www.foo.bar/Protocols/Data");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/foo:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/foo:schemaElementTest1/foo:schemaElementTest2", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/foo:schemaElementTest1/foo:schemaElementTest3", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:50,代码来源:XmlMetadataProducerTest.java

示例14: createElementWithoutInclude

import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute; //导入依赖的package包/类
private AnnotationElement createElementWithoutInclude() {
  List<AnnotationAttribute> referenceAttributes = new ArrayList<AnnotationAttribute>();
  referenceAttributes.add(new AnnotationAttribute().setName("Uri").setText("http://someurl.com"));
  return new AnnotationElement().setName("Reference").setPrefix("edmx").setNamespace(
      "http://docs.oasis-open.org/odata/ns/edmx").setAttributes(referenceAttributes);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:7,代码来源:XmlMetadataConsumerTest.java


注:本文中的org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。