Package org.apache.olingo.odata2.api.edm.provider

Examples of org.apache.olingo.odata2.api.edm.provider.Association


    return associationEnd;
  }

  @Override
  public Association getEdmAssociation() {
    Association association = new Association();
    association
        .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));

    return association;
  }
View Full Code Here


        return associationEnd;
      }

      @Override
      public Association getEdmAssociation() {
        Association association = new Association();
        association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing",
            "SalesOrderHeader")));
        association.setEnd2(new AssociationEnd()
            .setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem")));

        return association;
      }
    }
View Full Code Here

   * EDM Association Name - RULES
   * ************************************************************************
   */

  public static void build(final JPAEdmAssociationView view, final int count) {
    Association association = view.getEdmAssociation();
    String associationName = null;
    String end1Name = association.getEnd1().getType().getName();
    String end2Name = association.getEnd2().getType().getName();

    if (end1Name.compareToIgnoreCase(end2Name) > 0) {
      associationName = end2Name + UNDERSCORE + end1Name;
    } else {
      associationName = end1Name + UNDERSCORE + end2Name;
    }
    if (count > 1) {
      associationName = associationName + Integer.toString(count - 1);
    }
    association.setName(associationName);

  }
View Full Code Here

    String fromName = null;
    String navPropName = null;
    NavigationProperty navProp = navPropertyView.getEdmNavigationProperty();
    String namespace = buildNamespace(associationView);

    Association association = associationView.getEdmAssociation();
    navProp.setRelationship(new FullQualifiedName(namespace, association
        .getName()));

    FullQualifiedName associationEndTypeOne = association.getEnd1()
        .getType();
    FullQualifiedName associationEndTypeTwo = association.getEnd2()
        .getType();

    Attribute<?, ?> jpaAttribute = propertyView.getJPAAttribute();
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    ((Mapping) mapping).setInternalName(jpaAttribute.getName());
    mapping.setJPAType(jpaAttribute.getJavaType());
    navProp.setMapping((Mapping) mapping);

    String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView()
        .getJPAEntityType().getName();
    JPAEdmMappingModelAccess mappingModelAccess = navPropertyView
        .getJPAEdmMappingModelAccess();

    String targetEntityTypeName = null;
    if (jpaAttribute.isCollection()) {
      targetEntityTypeName = ((PluralAttribute<?, ?, ?>) jpaAttribute).getElementType().getJavaType().getSimpleName();
    } else {
      targetEntityTypeName = jpaAttribute.getJavaType().getSimpleName();
    }

    if (mappingModelAccess != null
        && mappingModelAccess.isMappingModelExists()) {
      navPropName = mappingModelAccess.mapJPARelationship(
          jpaEntityTypeName, jpaAttribute.getName());
      toName = mappingModelAccess.mapJPAEntityType(targetEntityTypeName);
      fromName = mappingModelAccess
          .mapJPAEntityType(jpaEntityTypeName);
    }
    if (toName == null) {
      toName = targetEntityTypeName;
    }

    if (fromName == null) {
      fromName = jpaEntityTypeName;
    }

    if (skipDefaultNaming == false) {
      if (navPropName == null) {
        navPropName = toName.concat(NAVIGATION_NAME);
      }
      if (count > 1) {
        navPropName = navPropName + Integer.toString(count - 1);
      }
    } else if (navPropName == null) {
      navPropName = jpaAttribute.getName();
    }

    navProp.setName(navPropName);

    if (toName.equals(associationEndTypeOne.getName())) {
      navProp.setFromRole(association.getEnd2().getRole());
      navProp.setToRole(association.getEnd1().getRole());
    } else if (toName.equals(associationEndTypeTwo.getName())) {

      navProp.setToRole(association.getEnd2().getRole());
      navProp.setFromRole(association.getEnd1().getRole());
    }
  }
View Full Code Here

        return associationEnd;
      }

      @Override
      public Association getEdmAssociation() {
        Association association = new Association();
        association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing",
            "SalesOrderHeader")));
        association.setEnd2(new AssociationEnd()
            .setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem")));

        return association;
      }
View Full Code Here

    return joinColumnNames;
  }

  @Override
  public Association getEdmAssociation() {
    Association association = new Association();
    association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
    association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
        "SalesOrderHeader"));
    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
        .setRole("SalesOrderItem"));
    return association;
  }
View Full Code Here

    assertEquals("Assoc_SalesOrderHeader_SalesOrderItem", objJPAEdmReferentialConstraint.getEdmRelationShipName());
  }

  @Override
  public Association getEdmAssociation() {
    Association association = new Association();
    association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
    association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
        "SalesOrderHeader"));
    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
        .setRole("SalesOrderItem"));
    return association;
  }
View Full Code Here

  @Override
  public Association searchAssociation(final JPAEdmAssociationEndView view) {
    if (view != null) {
      for (String key : associationMap.keySet()) {
        Association association = associationMap.get(key);
        if (association != null) {
          if (view.compare(association.getEnd1(), association.getEnd2())) {
            JPAEdmAssociationEndView associationEnd = associationEndMap.get(association.getName());
            if (associationEnd.getJoinColumnNames() != null
                && associationEnd.getJoinColumnReferenceColumnNames() != null
                && view.getJoinColumnNames() != null && view.getJoinColumnReferenceColumnNames() != null) {
              if (Arrays.equals(view.getJoinColumnNames(), associationEnd.getJoinColumnNames())
                  &&
View Full Code Here

    AssociationEnd currentAssociationEnd1 = view.getEdmAssociationEnd1();
    AssociationEnd currentAssociationEnd2 = view.getEdmAssociationEnd2();
    AssociationEnd end1 = null;
    AssociationEnd end2 = null;
    for (String key : associationMap.keySet()) {
      Association association = associationMap.get(key);
      if (association != null) {
        end1 = association.getEnd1();
        end2 = association.getEnd2();
        if ((end1.getType().equals(currentAssociationEnd1.getType()) && end2.getType().equals(
            currentAssociationEnd2.getType()))
            || (end1.getType().equals(currentAssociationEnd2.getType()) && end2.getType().equals(
                currentAssociationEnd1.getType()))) {
          count++;
View Full Code Here

    @Override
    public void build() throws ODataJPAModelException, ODataJPARuntimeException {

      if (associationEndView != null && searchAssociation(associationEndView) == null) {
        currentAssociation = new Association();
        currentAssociation.setEnd1(associationEndView.getEdmAssociationEnd1());
        currentAssociation.setEnd2(associationEndView.getEdmAssociationEnd2());

        JPAEdmNameBuilder.build(JPAEdmAssociation.this, numberOfSimilarEndPoints);

        associationMap.put(currentAssociation.getName(), currentAssociation);

      } else if (!inconsistentRefConstraintViewList.isEmpty()) {
        int inconsistentRefConstraintViewSize = inconsistentRefConstraintViewList.size();
        int index = 0;
        for (int i = 0; i < inconsistentRefConstraintViewSize; i++) {
          JPAEdmReferentialConstraintView view = inconsistentRefConstraintViewList.get(index);

          if (view.isExists() && !view.isConsistent()) {
            view.getBuilder().build();
          }
          if (view.isConsistent()) {
            Association newAssociation = new Association();
            copyAssociation(newAssociation, associationMap.get(view.getEdmRelationShipName()));
            newAssociation.setReferentialConstraint(view.getEdmReferentialConstraint());
            consistentAssociatonList.add(newAssociation);
            associationMap.put(view.getEdmRelationShipName(), newAssociation);
            inconsistentRefConstraintViewList.remove(index);
          } else {
            associationMap.remove(view.getEdmRelationShipName());
            index++;
          }
        }
      }

      if (associationMap.size() == consistentAssociatonList.size()) {
        isConsistent = true;
      } else {
        for (String key : associationMap.keySet()) {
          Association association = associationMap.get(key);
          if (!consistentAssociatonList.contains(association)) {
            consistentAssociatonList.add(association);
          }
        }
        isConsistent = true;
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.provider.Association

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.