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

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


  @Override
  public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
      final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException {
    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (ASSOCIATION_1_1.equals(association)) {
        return new AssociationSet().setName(ASSOCIATION_1_1.getName())
            .setAssociation(ASSOCIATION_1_1)
            .setEnd1(new AssociationSetEnd().setRole(ROLE_1_4).setEntitySet(ENTITY_SET_1_4))
            .setEnd2(new AssociationSetEnd().setRole(ROLE_1_1).setEntitySet(ENTITY_SET_1_1));
      } else if (ASSOCIATION_1_2.equals(association)) {
        return new AssociationSet().setName(ASSOCIATION_1_2.getName())
            .setAssociation(ASSOCIATION_1_2)
            .setEnd1(new AssociationSetEnd().setRole(ROLE_1_2).setEntitySet(ENTITY_SET_1_2))
            .setEnd2(new AssociationSetEnd().setRole(ROLE_1_1).setEntitySet(ENTITY_SET_1_1));
      } else if (ASSOCIATION_1_3.equals(association)) {
        return new AssociationSet().setName(ASSOCIATION_1_3.getName())
            .setAssociation(ASSOCIATION_1_3)
            .setEnd1(new AssociationSetEnd().setRole(ROLE_1_3).setEntitySet(ENTITY_SET_1_3))
            .setEnd2(new AssociationSetEnd().setRole(ROLE_1_1).setEntitySet(ENTITY_SET_1_1));
      } else if (ASSOCIATION_1_4.equals(association)) {
        return new AssociationSet().setName(ASSOCIATION_1_4.getName())
            .setAssociation(ASSOCIATION_1_4)
            .setEnd1(new AssociationSetEnd().setRole(ROLE_1_5).setEntitySet(ENTITY_SET_1_5))
            .setEnd2(new AssociationSetEnd().setRole(ROLE_1_3).setEntitySet(ENTITY_SET_1_3));
      }
    }
View Full Code Here


          currentAssociation = association;

          FullQualifiedName fQname =
              new FullQualifiedName(schemaView.getEdmSchema().getNamespace(), association.getName());
          currentAssociationSet = new AssociationSet();
          currentAssociationSet.setAssociation(fQname);

          int endCount = 0;
          short endFlag = 0;
          for (EntitySet entitySet : entitySetList) {
View Full Code Here

    }
  }

  @Test
  public void testGetAssociationSet() {
    AssociationSet associationSet = null;

    try {
      associationSet =
          edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
              "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader");
    } catch (ODataException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    assertNotNull(associationSet);
    assertEquals("SalesOrderHeader_SalesOrderItemSet", associationSet.getName());
    try {
      associationSet =
          edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
              "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
    } catch (ODataException e) {
View Full Code Here

      return this;
    }

    public void addAssociationSets(final Collection<Association> associations) throws ODataException {
      for (Association association : associations) {
        AssociationSet as = new AssociationSet();
        as.setName(association.getName());
        FullQualifiedName asAssociationFqn = new FullQualifiedName(namespace, association.getName());
        as.setAssociation(asAssociationFqn);

        AssociationSetEnd asEnd1 = new AssociationSetEnd();
        asEnd1.setEntitySet(getEntitySetName(association.getEnd1()));
        asEnd1.setRole(association.getEnd1().getRole());
        as.setEnd1(asEnd1);

        AssociationSetEnd asEnd2 = new AssociationSetEnd();
        asEnd2.setEntitySet(getEntitySetName(association.getEnd2()));
        asEnd2.setRole(association.getEnd2().getRole());
        as.setEnd2(asEnd2);

        associationSets.add(as);
      }
    }
View Full Code Here

    when(edmProvider.getEntitySet("Container1", "foo")).thenReturn(entitySetFoo);

    EntitySet entitySetBar = new EntitySet().setName("foo");
    when(edmProvider.getEntitySet("Container1", "foo")).thenReturn(entitySetBar);

    AssociationSet associationSet = new AssociationSet().setName("4711");
    FullQualifiedName assocFQName = new FullQualifiedName("AssocNs", "AssocName");
    when(edmProvider.getAssociationSet("Container1", assocFQName, "foo", "fromRole")).thenReturn(associationSet);

    FunctionImport functionImportFoo = new FunctionImport().setName("foo");
    when(edmProvider.getFunctionImport("Container1", "foo")).thenReturn(functionImportFoo);
View Full Code Here

    Edm edm = createEdm();
    assertNotNull(edm);

    FullQualifiedName fqNameAssociation = new FullQualifiedName("RefScenario", "ManagerEmployees");
    EdmImplProv edmImpl = (EdmImplProv) edm;
    AssociationSet associationSet =
        edmImpl.getEdmProvider().getAssociationSet("Container1", fqNameAssociation, "Managers", "r_Manager");
    AssociationSet testAssociationSet =
        testProvider.getAssociationSet("Container1", fqNameAssociation, "Managers", "r_Manager");
    assertEquals(testAssociationSet.getName(), associationSet.getName());
    assertEquals(testAssociationSet.getEnd1().getEntitySet(), associationSet.getEnd1().getEntitySet());
    assertEquals(testAssociationSet.getEnd2().getEntitySet(), associationSet.getEnd2().getEntitySet());
    assertEquals(testAssociationSet.getEnd2().getRole(), associationSet.getEnd2().getRole());

  }
View Full Code Here

    final FullQualifiedName associationFqn = new FullQualifiedName(
        ModelSharedConstants.NAMESPACE_1, "NoAssociation");
    Association noAssociation = aep.getAssociation(associationFqn);
    assertNull(noAssociation);

    AssociationSet noAssociationSet = aep.getAssociationSet(
        ModelSharedConstants.CONTAINER_1, associationFqn, "NoSrc", "NoSrcEntity");
    assertNull(noAssociationSet);

    AssociationSet asBuildingRooms = aep.getAssociationSet(
        ModelSharedConstants.CONTAINER_1, defaultFqn("BuildingRooms"), "Buildings", "r_Building");
    assertNotNull(asBuildingRooms);
    assertEquals("Buildings", asBuildingRooms.getEnd1().getEntitySet());
    assertEquals("r_Building", asBuildingRooms.getEnd1().getRole());
    assertEquals("Rooms", asBuildingRooms.getEnd2().getEntitySet());
    assertEquals("r_Room", asBuildingRooms.getEnd2().getRole());
  }
View Full Code Here

   * ************************************************************************
   * EDM Association Set Name - RULES
   * ************************************************************************
   */
  public static void build(final JPAEdmAssociationSetView view) {
    AssociationSet associationSet = view.getEdmAssociationSet();

    String name = view.getEdmAssociation().getName();
    associationSet.setName(name + ASSOCIATIONSET_SUFFIX);

  }
View Full Code Here

    AssociationSetEnd endSet1 = new AssociationSetEnd().setRole("end1Role").setEntitySet("entitySetRole1");
    when(edmProvider.getEntitySet("Container", "entitySetRole1")).thenReturn(new EntitySet().setName("entitySetRole1"));
    AssociationSetEnd endSet2 = new AssociationSetEnd().setRole("end2Role");

    AssociationSet associationSet =
        new AssociationSet().setName("associationSetName").setAssociation(assocName).setEnd1(endSet1).setEnd2(endSet2);

    edmAssociationSet = new EdmAssociationSetImplProv(edmImplProv, associationSet, edmEntityContainer);
  }
View Full Code Here

    return entityContainers;
  }

  private static List<AssociationSet> createAssociationSets() {
    List<AssociationSet> associationSets = new ArrayList<AssociationSet>();
    AssociationSet associationSet = new AssociationSet();
    associationSet.setName(ASSOCIATION_SET_NAME);
    associationSet.setAssociation(new FullQualifiedName(NAMESPACE, ASSOCIATION_NAME));
    associationSet
        .setEnd1(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_ONE).setRole(ASSOCIATION_ROLE_NAME_ONE));
    associationSet
        .setEnd2(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_TWO).setRole(ASSOCIATION_ROLE_NAME_TWO));
    associationSets.add(associationSet);
    return associationSets;
  }
View Full Code Here

TOP

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

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.