Java Code Examples for org.apache.olingo.odata2.api.edm.provider.Association#setAnnotationAttributes()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.Association#setAnnotationAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JPAEdmAssociation.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void copyAssociation(final Association copyToAssociation, final Association copyFromAssociation) {
  copyToAssociation.setEnd1(copyFromAssociation.getEnd1());
  copyToAssociation.setEnd2(copyFromAssociation.getEnd2());
  copyToAssociation.setName(copyFromAssociation.getName());
  copyToAssociation.setAnnotationAttributes(copyFromAssociation.getAnnotationAttributes());
  copyToAssociation.setAnnotationElements(copyFromAssociation.getAnnotationElements());
  copyToAssociation.setDocumentation(copyFromAssociation.getDocumentation());

}
 
Example 2
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Association readAssociation(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
  reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION);

  Association association = new Association();
  association.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
  List<AssociationEnd> associationEnds = new ArrayList<AssociationEnd>();
  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  association.setAnnotationAttributes(readAnnotationAttribute(reader));
  while (reader.hasNext()
      && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
      && XmlMetadataConstants.EDM_ASSOCIATION.equals(reader.getLocalName()))) {
    reader.next();
    if (reader.isStartElement()) {
      extractNamespaces(reader);
      currentHandledStartTagName = reader.getLocalName();
      if (XmlMetadataConstants.EDM_ASSOCIATION_END.equals(currentHandledStartTagName)) {
        associationEnds.add(readAssociationEnd(reader));
      } else if (XmlMetadataConstants.EDM_ASSOCIATION_CONSTRAINT.equals(currentHandledStartTagName)) {
        association.setReferentialConstraint(readReferentialConstraint(reader));
      } else {
        annotationElements.add(readAnnotationElement(reader));
      }
    }
  }
  if (associationEnds.size() < 2 && associationEnds.size() > 2) {
    throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
        .addContent("Count of association ends should be 2"));
  }
  if (!annotationElements.isEmpty()) {
    association.setAnnotationElements(annotationElements);
  }
  association.setEnd1(associationEnds.get(0)).setEnd2(associationEnds.get(1));
  associationsMap.put(new FullQualifiedName(currentNamespace, association.getName()), association);
  return association;
}