Java Code Examples for org.apache.olingo.commons.api.edm.EdmEntityType#getKeyPropertyRefs()

The following examples show how to use org.apache.olingo.commons.api.edm.EdmEntityType#getKeyPropertyRefs() . 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: MetadataDocumentJsonSerializer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void appendKey(final JsonGenerator json, 
    final EdmEntityType entityType) throws SerializerException, IOException {
  List<EdmKeyPropertyRef> keyPropertyRefs = entityType.getKeyPropertyRefs();
  if (keyPropertyRefs != null && !keyPropertyRefs.isEmpty()) {
    // Resolve Base Type key as it is shown in derived type
    EdmEntityType baseType = entityType.getBaseType();
    if (baseType != null && baseType.getKeyPropertyRefs() != null && !(baseType.getKeyPropertyRefs().isEmpty())) {
      return;
    }
    json.writeArrayFieldStart(KEY);
    for (EdmKeyPropertyRef keyRef : keyPropertyRefs) {
      
      if (keyRef.getAlias() != null) {
        json.writeStartObject();
        json.writeStringField(keyRef.getAlias(), keyRef.getName());
        json.writeEndObject();
      } else {
        json.writeString(keyRef.getName());
      }
    }
    json.writeEndArray();
  }
}
 
Example 2
Source File: MetadataDocumentXmlSerializer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void appendKey(final XMLStreamWriter writer, final EdmEntityType entityType) throws XMLStreamException {
  List<EdmKeyPropertyRef> keyPropertyRefs = entityType.getKeyPropertyRefs();
  if (keyPropertyRefs != null && !keyPropertyRefs.isEmpty()) {
    // Resolve Base Type key as it is shown in derived type
    EdmEntityType baseType = entityType.getBaseType();
    if (baseType != null && baseType.getKeyPropertyRefs() != null && !(baseType.getKeyPropertyRefs().isEmpty())) {
      return;
    }

    writer.writeStartElement(XML_KEY);
    for (EdmKeyPropertyRef keyRef : keyPropertyRefs) {
      writer.writeEmptyElement(XML_PROPERTY_REF);

      writer.writeAttribute(XML_NAME, keyRef.getName());

      if (keyRef.getAlias() != null) {
        writer.writeAttribute(XML_ALIAS, keyRef.getAlias());
      }
    }
    writer.writeEndElement();
  }
}
 
Example 3
Source File: ODataAdapter.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method check whether propertyName is a keyProperty or not.
 *
 * @param edmEntityType EdmEntityType
 * @param propertyName  PropertyName
 * @return isKey
 */
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
    List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
    for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
        if (propRef.getName().equals(propertyName)) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: Storage.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static boolean isKey(EdmEntityType edmEntityType, String propertyName) {
    List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
    for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
        String keyPropertyName = propRef.getName();
        if (keyPropertyName.equals(propertyName)) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 6
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 7
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 8
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 9
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 10
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 11
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 12
Source File: Storage.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
  List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
  for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
    String keyPropertyName = propRef.getName();
    if (keyPropertyName.equals(propertyName)) {
      return true;
    }
  }
  return false;
}
 
Example 13
Source File: AbstractUtility.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
public Map<String, String> getEntityKeyType(final EdmEntityType entityType) {
  EdmEntityType baseType = entityType;
  while (CollectionUtils.isEmpty(baseType.getKeyPredicateNames()) && baseType.getBaseType() != null) {
    baseType = getEdmTypeInfo(baseType.getBaseType().getFullQualifiedName().toString()).getEntityType();
  }

  final Map<String, String> res = new LinkedHashMap<String, String>();
  for (EdmKeyPropertyRef pref : baseType.getKeyPropertyRefs()) {
    res.put(pref.getName(),
            getJavaType(pref.getProperty().getType().getFullQualifiedName().toString()));
  }

  return res;
}