Package org.odata4j.edm

Examples of org.odata4j.edm.EdmEntityType


  private OEntity toOEntity(EdmEntitySet ees, Entity entity, QueryInfo queryInfo, String parentPropName) {
    final List<OProperty<?>> properties = new ArrayList<OProperty<?>>();
    final List<OLink> links = new ArrayList<OLink>();

    EdmEntityType eet = ees.getType();
    String entityKeyName = eet.getKeys().get(0);
    OEntityKey entityKey = OEntityKey.create(OProperties.int64(entityKeyName, entity.getKey().getId()));
    if (queryInfo == null || queryInfo.select == null || queryInfo.select.size() == 0 || containsProperty(queryInfo.select, entityKeyName, parentPropName)) {
      properties.add(OProperties.int64(entityKeyName, entity.getKey().getId()));
    }

    for (String propName : entity.getProperties().keySet()) {
      Object propValue = entity.getProperty(propName);
      if (propValue == null)
        continue;

      if (queryInfo != null && queryInfo.select != null && queryInfo.select.size() > 0) {
        if (!containsProperty(queryInfo.select, propName, parentPropName)) {
          continue;
        }
      }

      EdmProperty prop = eet.findProperty(propName);
      if (prop != null) {
        if (propValue instanceof Text) {
          propValue = ((Text) propValue).getValue();
        } else if (propValue instanceof ShortBlob) {
          propValue = ((ShortBlob) propValue).getBytes();
        }
        properties.add(OProperties.simple(propName, (EdmSimpleType<?>) prop.getType(), propValue));
      } else {
        EdmNavigationProperty navProp = eet.findNavigationProperty(propName);
        if (navProp != null) {
          List<OEntity> expandedProps = new ArrayList<OEntity>();
          try {
            if (queryInfo != null && queryInfo.expand != null && queryInfo.expand.size() > 0) {
              for (EntitySimpleProperty esp : queryInfo.expand) {
View Full Code Here


      try {
        String uri = link.getHref();
        String entitySetName = e.getKind();
        String key = uri.substring(uri.lastIndexOf('('));
        EdmEntitySet ees = metadata.getEdmEntitySet(entitySetName);
        EdmEntityType eet = ees.getType();
        EdmNavigationProperty enp = eet.findNavigationProperty(link.getRelation());
        EdmMultiplicity em = enp.getRelationship().getEnd2().getMultiplicity();
        Entity entity = findEntity(enp.getToRole().getType().getName(), OEntityKey.parse(key));
        if (em == EdmMultiplicity.ZERO_TO_ONE) {
          e.setProperty(link.getRelation(), entity.getKey());
        } else {
View Full Code Here

    // Support for filtering navigation properties by key
    if (propName.contains("/")) {
      propName = propName.substring(0, propName.indexOf("/"));
      EdmEntitySet ees = metadata.getEdmEntitySet(q.getKind());
      EdmEntityType eet = ees.getType();
      EdmNavigationProperty enp = eet.findNavigationProperty(propName);
      long id = Long.parseLong(propValue.toString());
      propValue = KeyFactory.createKey(enp.getToRole().getRole(), id);
    }

    Filter filter = new FilterPredicate(propName, op, propValue);
View Full Code Here

  }

  @Override
  public BaseResponse getNavProperty(String entitySetName, OEntityKey entityKey, String navProp, QueryInfo queryInfo) {
    final EdmEntitySet ees = metadata.getEdmEntitySet(entitySetName);
    EdmEntityType eet = ees.getType();
    EdmNavigationProperty enp = eet.findNavigationProperty(navProp);
    if (enp == null) {
      throw new NotFoundException("EdmNavigationProperty " + navProp + " not found.");
    }
    final EdmEntitySet eesNavProp = metadata.getEdmEntitySet(enp.getToRole().getRole());
    EdmMultiplicity relMultiplicity = enp.getRelationship().getEnd2().getMultiplicity();
View Full Code Here

TOP

Related Classes of org.odata4j.edm.EdmEntityType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.