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

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.Association. 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: SynchronizerEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<Association> getAssociations ()
{
   return Collections.singletonList (
      new Association ()
         .setName (ASSO_SYNC_COLLECTION.getName ())
         .setEnd1 (
            new AssociationEnd ()
               .setType(Model.COLLECTION.getFullQualifiedName())
               .setRole (ROLE_SYNC_COLLECTION)
               .setMultiplicity (EdmMultiplicity.ZERO_TO_ONE))
         .setEnd2 (
            new AssociationEnd ().setType (getFullQualifiedName ())
               .setRole (ROLE_COLLECTION_SYNCS)
               .setMultiplicity (EdmMultiplicity.MANY))
   );
}
 
Example #2
Source File: ODataJPAEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
  if (edmFQName != null) {
    if (associations.containsKey(edmFQName.toString())) {
      return associations.get(edmFQName.toString());
    } else if (schemas == null) {
      getSchemas();
    }

    for (Schema schema : schemas) {
      if (schema.getNamespace().equals(edmFQName.getNamespace())) {
        if (schema.getAssociations() == null) {
          return null;
        }
        for (Association association : schema.getAssociations()) {
          if (association.getName().equals(edmFQName.getName())) {
            associations.put(edmFQName.toString(), association);
            return association;
          }
        }
      }
    }

  }
  return null;
}
 
Example #3
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void validateAssociation(final Association association,
    final String fromRole, final EdmMultiplicity fromMulti, final FullQualifiedName fromType,
    final String toRole, final EdmMultiplicity toMulti, final FullQualifiedName toType) {

  AssociationEnd[] ends = new AssociationEnd[] { association.getEnd1(), association.getEnd2() };
  for (AssociationEnd associationEnd : ends) {
    if (associationEnd.getRole().equals(fromRole)) {
      validateAssociationEnd(associationEnd, fromRole, fromMulti, fromType);
    } else if (associationEnd.getRole().equals(toRole)) {
      validateAssociationEnd(associationEnd, toRole, toMulti, toType);
    } else {
      fail("Unexpected navigation end '" + associationEnd.getRole()
          + "' for association with name '" + association.getName() + "'.");
    }
  }
}
 
Example #4
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void validateAssociation(final Association association) {
  String name = association.getName();
  if (name.equals("r_Employees_2_r_Room")) {
    validateAssociation(association,
        "r_Room", EdmMultiplicity.ONE, defaultFqn("Room"),
        "r_Employees", EdmMultiplicity.MANY, defaultFqn("Employee"));
  } else if (name.equals("BuildingRooms")) {
    validateAssociation(association,
        "r_Building", EdmMultiplicity.ONE, defaultFqn("Building"),
        "r_Rooms", EdmMultiplicity.MANY, defaultFqn("Room"));
  } else if (name.equals("ManagerEmployees")) {
    validateAssociation(association,
        "r_Manager", EdmMultiplicity.ONE, defaultFqn("Manager"),
        "r_Employees", EdmMultiplicity.MANY, defaultFqn("Employee"));
  } else if (name.equals("TeamEmployees")) {
    validateAssociation(association,
        "r_Team", EdmMultiplicity.ONE, defaultFqn("Team"),
        "r_Employees", EdmMultiplicity.MANY, defaultFqn("Employee"));
  } else if (name.equals("Team_2_r_SubTeam")) {
    validateAssociation(association,
        "Team", EdmMultiplicity.ONE, defaultFqn("Team"),
        "r_SubTeam", EdmMultiplicity.ONE, defaultFqn("Team"));
  } else {
    fail("Got unknown association to validate with name '" + name + "'.");
  }
}
 
Example #5
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void schemaBasic() throws Exception {
  assertNotNull(aep);

  List<Schema> schemas = aep.getSchemas();
  assertEquals(1, schemas.size());

  Schema schema = schemas.get(0);
  List<EntityContainer> containers = schema.getEntityContainers();
  assertEquals(1, containers.size());
  EntityContainer container = containers.get(0);
  assertEquals(ModelSharedConstants.CONTAINER_1, container.getName());
  final List<EntitySet> entitySets = container.getEntitySets();
  assertEquals(6, entitySets.size());

  List<Association> associations = schema.getAssociations();
  assertEquals(5, associations.size());
  for (Association association : associations) {
    assertNotNull(association.getName());
    validateAssociation(association);
  }
}
 
Example #6
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void validateRelationship() throws EntityProviderException {
  for (NavigationProperty navProperty : navProperties) {
    if (associationsMap.containsKey(navProperty.getRelationship())) {
      Association assoc = associationsMap.get(navProperty.getRelationship());
      if (!(assoc.getEnd1().getRole().equals(navProperty.getFromRole())
          ^ assoc.getEnd1().getRole().equals(navProperty.getToRole())
          && (assoc.getEnd2().getRole().equals(navProperty.getFromRole()) ^ assoc.getEnd2().getRole().equals(
          navProperty.getToRole())))) {
        throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
            .addContent("Invalid end of association"));
      }
      if (!entityTypesMap.containsKey(assoc.getEnd1().getType())) {
        validateEntityTypeWithAlias(assoc.getEnd1().getType());
      }
      if (!entityTypesMap.containsKey(assoc.getEnd2().getType())) {
        validateEntityTypeWithAlias(assoc.getEnd2().getType());
      }
    } else {
      throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid Relationship"));
    }
  }

}
 
Example #7
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example #8
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private Association mergeAssociations(final Association associationOne, final Association associationTwo) {
  AssociationEnd oneEnd1 = associationOne.getEnd1();
  AssociationEnd oneEnd2 = associationOne.getEnd2();
  AssociationEnd twoEnd1 = associationTwo.getEnd1();
  AssociationEnd twoEnd2 = associationTwo.getEnd2();
  AssociationEnd[] oneEnds = new AssociationEnd[] { oneEnd1, oneEnd2 };

  for (AssociationEnd associationEnd : oneEnds) {
    if (associationEnd.getRole().equals(twoEnd1.getRole())) {
      if (twoEnd1.getMultiplicity() == EdmMultiplicity.MANY) {
        associationEnd.setMultiplicity(EdmMultiplicity.MANY);
      }
    } else if (associationEnd.getRole().equals(twoEnd2.getRole())) {
      if (twoEnd2.getMultiplicity() == EdmMultiplicity.MANY) {
        associationEnd.setMultiplicity(EdmMultiplicity.MANY);
      }
    }
  }

  return associationOne;
}
 
Example #9
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private Association createAssociation(final AnnotationHelper.AnnotatedNavInfo info) {
  Association association = new Association();

  AssociationEnd fromEnd = new AssociationEnd();
  fromEnd.setRole(info.getFromRoleName());
  fromEnd.setType(new FullQualifiedName(namespace, info.getFromTypeName()));
  fromEnd.setMultiplicity(info.getFromMultiplicity());
  association.setEnd1(fromEnd);

  AssociationEnd toEnd = new AssociationEnd();
  toEnd.setRole(info.getToRoleName());
  toEnd.setType(new FullQualifiedName(namespace, info.getToTypeName()));
  toEnd.setMultiplicity(info.getToMultiplicity());
  association.setEnd2(toEnd);

  String associationName = info.getRelationshipName();
  association.setName(associationName);
  return association;
}
 
Example #10
Source File: ServiceDocumentProducerTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws ODataException {
  EdmProvider edmProvider = mock(EdmProvider.class);

  EntityType entityType = new EntityType().setName("EntityType1");
  when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType);

  ComplexType complexType = new ComplexType().setName("ComplexType1");
  when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType);

  Association association = new Association().setName("Association1");
  when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association);

  EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1");
  when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer);
  when(edmProvider.getEntityContainerInfo("Container1")).thenReturn(defaultEntityContainer);

  edm = new EdmImplProv(edmProvider);

}
 
Example #11
Source File: Model.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Association getAssociation(FullQualifiedName edm_fq_name) throws ODataException
{
   if (edm_fq_name != null && edm_fq_name.getNamespace().equals(NAMESPACE))
   {
      String assocName = edm_fq_name.getName();
      String entity = assocName.substring(0, assocName.indexOf("_"));
      for (Association assoc: ENTITYSETS.get(AbstractEntitySet.generateEntitySetName(entity)).getAssociations())
      {
         if (assoc.getName().equals(edm_fq_name.getName()))
         {
            return assoc;
         }
      }
   }
   return null;
}
 
Example #12
Source File: ClassEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<Association> getAssociations ()
{
   List<Association> associations = new ArrayList<Association> ();
   associations.add (new Association ()
      .setName (ASSO_CLASS_CLASS.getName ())
      .setEnd1 (
         new AssociationEnd ().setType (getFullQualifiedName ())
            .setRole (ROLE_CLASS_CLASSES)
            .setMultiplicity (EdmMultiplicity.MANY))
      .setEnd2 (
         new AssociationEnd ().setType (getFullQualifiedName ())
            .setRole (ROLE_CLASS_PARENT)
            .setMultiplicity (EdmMultiplicity.MANY)));

   return associations;
}
 
Example #13
Source File: EdmNavigationPropertyImplProvTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  FullQualifiedName relationship = new FullQualifiedName("namespace", "associationName");
  Association association = new Association().setName("associationName");
  when(edmProvider.getAssociation(relationship)).thenReturn(association);

  AssociationEnd end1 = new AssociationEnd().setRole("fromRole");
  FullQualifiedName entityName = new FullQualifiedName("namespace", "entityName");
  AssociationEnd end2 =
      new AssociationEnd().setRole("toRole").setMultiplicity(EdmMultiplicity.ONE).setType(entityName);
  association.setEnd1(end1).setEnd2(end2);

  EntityType entityType = new EntityType().setName("entityName");
  when(edmProvider.getEntityType(entityName)).thenReturn(entityType);

  NavigationProperty navProperty =
      new NavigationProperty().setName("navProperty").setFromRole("fromRole").setToRole("toRole").setRelationship(
          relationship);
  navPropertyProvider = new EdmNavigationPropertyImplProv(edmImplProv, navProperty);
}
 
Example #14
Source File: ConnectionEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<Association> getAssociations ()
{
   List<Association> associations = new ArrayList<Association> ();

   if (Security.currentUserHasRole(Role.SYSTEM_MANAGER))
   {
   associations.add (new Association ()
      .setName (ASSO_CONNECTION_USER.getName ())
      .setEnd1 (
         new AssociationEnd ()
            .setType(Model.USER.getFullQualifiedName())
            .setRole (ROLE_CONNECTION_USER)
            .setMultiplicity (EdmMultiplicity.ONE))
      .setEnd2 (
         new AssociationEnd ().setType (getFullQualifiedName ())
            .setRole (ROLE_USER_CONNECTIONS)
            .setMultiplicity (EdmMultiplicity.MANY)));
   }
   return associations;
}
 
Example #15
Source File: JPAEdmAssociation.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
  int count = 0;
  AssociationEnd end1 = null;
  AssociationEnd end2 = null;
  for (Entry<String, Association> entry : associationMap.entrySet()) {
    Association association = entry.getValue();
    if (association != null) {
      end1 = association.getEnd1();
      end2 = association.getEnd2();
      if (view.compare(end1, end2)) {
        count++;
      }
    }
  }
  return count;
}
 
Example #16
Source File: NetworkEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<Association> getAssociations ()
{
   List<Association> associations = new ArrayList<Association> ();

   if (Security.currentUserHasRole(Role.STATISTICS))
   {
   associations.add (new Association ()
      .setName (ASSO_NETWORK_NETWORKSTATISTIC.getName ())
      .setEnd1 (
         new AssociationEnd ()
            .setType(Model.NETWORKSTATISTIC.getFullQualifiedName())
            .setRole (ROLE_NETWORK_NETWORKSTATISTIC)
            .setMultiplicity (EdmMultiplicity.ONE))
      .setEnd2 (
         new AssociationEnd ().setType (getFullQualifiedName ())
            .setRole (ROLE_NETWORKSTATISTIC_NETWORK)
            .setMultiplicity (EdmMultiplicity.MANY)));
   }
   return associations;
}
 
Example #17
Source File: EdmSchemaMock.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static List<Association> createAssociations() {
  List<Association> associations = new ArrayList<Association>();
  Association association = new Association();
  association.setName(ASSOCIATION_NAME);
  association.setEnd1(new AssociationEnd().setMultiplicity(EdmMultiplicity.ONE).setRole(ASSOCIATION_ROLE_NAME_ONE)
      .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE)));
  association.setEnd2(new AssociationEnd().setMultiplicity(EdmMultiplicity.MANY).setRole(ASSOCIATION_ROLE_NAME_TWO)
      .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO)));
  associations.add(association);
  return associations;
}
 
Example #18
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Association getAssociation(final FullQualifiedName association) throws ODataMessageException {
  if (ASSOCIATION_ET1_ET2.equals(association)) {
    return new Association().setName(ASSOCIATION_ET1_ET2.getName())
        .setEnd1(new AssociationEnd()
            .setMultiplicity(EdmMultiplicity.ZERO_TO_ONE)
            .setRole(ROLE_1)
            .setType(ET_KEY_IS_STRING))
        .setEnd2(new AssociationEnd()
            .setMultiplicity(EdmMultiplicity.MANY)
            .setRole(ROLE_2)
            .setType(ET_KEY_IS_INTEGER));
  }
  return null;
}
 
Example #19
Source File: EdmAssociationSetImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void getEdmEntityContainerImpl() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  EntityContainerInfo entityContainer = new EntityContainerInfo().setName("Container");
  EdmEntityContainer edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer);

  AssociationEnd end1 =
      new AssociationEnd().setRole("end1Role").setMultiplicity(EdmMultiplicity.ONE).setType(
          EdmSimpleTypeKind.String.getFullQualifiedName());
  AssociationEnd end2 =
      new AssociationEnd().setRole("end2Role").setMultiplicity(EdmMultiplicity.ONE).setType(
          EdmSimpleTypeKind.String.getFullQualifiedName());
  Association association = new Association().setName("association").setEnd1(end1).setEnd2(end2);
  FullQualifiedName assocName = new FullQualifiedName("namespace", "association");
  when(edmProvider.getAssociation(assocName)).thenReturn(association);

  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);
}
 
Example #20
Source File: EdmImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Before
public void getEdmImpl() throws Exception {
  EdmProvider edmProvider = mock(EdmProvider.class);

  List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();

  EntityType entityType = new EntityType().setName("EntityType1");
  when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType);
  AliasInfo aliasInfo1 = new AliasInfo().setAlias("et1").setNamespace("EntityType1Ns");
  aliasInfos.add(aliasInfo1);

  ComplexType complexType = new ComplexType().setName("ComplexType1");
  when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType);
  AliasInfo aliasInfo2 = new AliasInfo().setAlias("ct1").setNamespace("ComplexType1Ns");
  aliasInfos.add(aliasInfo2);

  Association association = new Association().setName("Association1");
  when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association);
  AliasInfo aliasInfo3 = new AliasInfo().setAlias("at1").setNamespace("Association1Ns");
  aliasInfos.add(aliasInfo3);

  when(edmProvider.getAliasInfos()).thenReturn(aliasInfos);

  EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1");
  when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer);
  when(edmProvider.getEntityContainerInfo("Container1")).thenReturn(defaultEntityContainer);

  edm = new EdmImplProv(edmProvider);
}
 
Example #21
Source File: EdmAssociationImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void getEdmEntityContainerImpl() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  AssociationEnd end1 =
      new AssociationEnd().setRole("end1Role").setMultiplicity(EdmMultiplicity.ONE).setType(
          EdmSimpleTypeKind.String.getFullQualifiedName());
  AssociationEnd end2 =
      new AssociationEnd().setRole("end2Role").setMultiplicity(EdmMultiplicity.ONE).setType(
          EdmSimpleTypeKind.String.getFullQualifiedName());

  List<PropertyRef> propRef = new ArrayList<PropertyRef>();
  propRef.add(new PropertyRef().setName("prop1"));
  List<PropertyRef> propRef2 = new ArrayList<PropertyRef>();
  propRef2.add(new PropertyRef().setName("prop2"));

  ReferentialConstraintRole dependent = new ReferentialConstraintRole().setRole("end1Role");
  ReferentialConstraintRole principal = new ReferentialConstraintRole().setRole("end2Role");

  ReferentialConstraint referentialConstraint =
      new ReferentialConstraint().setDependent(dependent).setPrincipal(principal);

  Association association = new Association().setName("association").setEnd1(end1).setEnd2(end2);
  association.setReferentialConstraint(referentialConstraint);

  associationProv = new EdmAssociationImplProv(edmImplProv, association, "namespace");
}
 
Example #22
Source File: ScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
  if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
    if (ASSOCIATION_1_1.getName().equals(edmFQName.getName())) {
      return new Association().setName(ASSOCIATION_1_1.getName())
          .setEnd1(
              new AssociationEnd().setType(ENTITY_TYPE_1_1).setRole(ROLE_1_1).setMultiplicity(EdmMultiplicity.MANY))
          .setEnd2(
              new AssociationEnd().setType(ENTITY_TYPE_1_4).setRole(ROLE_1_4).setMultiplicity(EdmMultiplicity.ONE));
    } else if (ASSOCIATION_1_2.getName().equals(edmFQName.getName())) {
      return new Association().setName(ASSOCIATION_1_2.getName())
          .setEnd1(
              new AssociationEnd().setType(ENTITY_TYPE_1_1).setRole(ROLE_1_1).setMultiplicity(EdmMultiplicity.MANY))
          .setEnd2(
              new AssociationEnd().setType(ENTITY_TYPE_1_2).setRole(ROLE_1_2).setMultiplicity(EdmMultiplicity.ONE)
                  .setOnDelete(new OnDelete().setAction(EdmAction.None)));
    } else if (ASSOCIATION_1_3.getName().equals(edmFQName.getName())) {
      return new Association().setName(ASSOCIATION_1_3.getName())
          .setEnd1(
              new AssociationEnd().setType(ENTITY_TYPE_1_1).setRole(ROLE_1_1).setMultiplicity(EdmMultiplicity.MANY))
          .setEnd2(
              new AssociationEnd().setType(ENTITY_TYPE_1_3).setRole(ROLE_1_3).setMultiplicity(EdmMultiplicity.ONE));
    } else if (ASSOCIATION_1_4.getName().equals(edmFQName.getName())) {
      return new Association().setName(ASSOCIATION_1_4.getName())
          .setEnd1(
              new AssociationEnd().setType(ENTITY_TYPE_1_5).setRole(ROLE_1_5).setMultiplicity(EdmMultiplicity.ONE))
          .setEnd2(
              new AssociationEnd().setType(ENTITY_TYPE_1_3).setRole(ROLE_1_3).setMultiplicity(EdmMultiplicity.MANY));
    }
  }

  return null;
}
 
Example #23
Source File: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
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();

  associationName = end1Name + UNDERSCORE + end2Name;
  associationName =
      associationName + UNDERSCORE + multiplicityToString(association.getEnd1().getMultiplicity()) + UNDERSCORE
          + multiplicityToString(association.getEnd2().getMultiplicity()) + Integer.toString(count);
  association.setName(associationName);
}
 
Example #24
Source File: MyEdmProvider.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public Association getAssociation(FullQualifiedName edmFQName) throws ODataException {
    if (NAMESPACE.equals(edmFQName.getNamespace())) {
        if (ASSOCIATION_CAR_MANUFACTURER.getName().equals(edmFQName.getName())) {
            return new Association().setName(ASSOCIATION_CAR_MANUFACTURER.getName())
                    .setEnd1(new AssociationEnd().setType(ENTITY_TYPE_1_1).setRole(ROLE_1_1).setMultiplicity(EdmMultiplicity.MANY))
                    .setEnd2(new AssociationEnd().setType(ENTITY_TYPE_1_2).setRole(ROLE_1_2).setMultiplicity(EdmMultiplicity.ONE));
        }
    }
    return null;
}
 
Example #25
Source File: ODataJPAEdmProviderNegativeTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAssociationFullQualifiedName() {
  Association association = null;
  try {
    association =
        edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
  assertNull(association);
}
 
Example #26
Source File: JPAEdmReferentialConstraintTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #27
Source File: ODataJPAEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAssociationFullQualifiedName() {
  Association association = null;
  try {
    association =
        edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
  assertNotNull(association);
  assertEquals("SalesOrderHeader_SalesOrderItem", association.getName());
}
 
Example #28
Source File: JPAEdmAssociationTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #29
Source File: JPAEdmReferentialConstraintRoleTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #30
Source File: JPAEdmAssociationSetTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private List<Association> getEdmAssociationListLocal() {
  List<Association> associationList = new ArrayList<Association>();

  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"));

  associationList.add(association);
  return associationList;
}