Java Code Examples for org.apache.olingo.odata2.api.edm.provider.Association#setEnd1()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.Association#setEnd1() . 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: 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 2
Source File: JPAEdmAssociation.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void copyAssociation(final Association copyToAssociation, final Association copyFromAssociation) {
  copyToAssociation.setEnd1(copyFromAssociation.getEnd1());
  copyToAssociation.setEnd2(copyFromAssociation.getEnd2());
  copyToAssociation.setName(copyFromAssociation.getName());
  copyToAssociation.setAnnotationAttributes(copyFromAssociation.getAnnotationAttributes());
  copyToAssociation.setAnnotationElements(copyFromAssociation.getAnnotationElements());
  copyToAssociation.setDocumentation(copyFromAssociation.getDocumentation());

}
 
Example 3
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 4
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;
}
 
Example 5
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 6
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 7
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 8
Source File: JPAEdmNavigationPropertyTest.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 9
Source File: UserEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<Association> getAssociations ()
{
   List<Association> associations = new ArrayList<Association> ();
   if (Security.currentUserHasRole(Role.SYSTEM_MANAGER, Role.STATISTICS))
   {
      associations.add (new Association ()
         .setName (ASSO_USER_CONNECTION.getName ())
         .setEnd1 (
            new AssociationEnd ()
               .setType(Model.CONNECTION.getFullQualifiedName())
               .setRole (ROLE_USER_CONNECTIONS)
               .setMultiplicity (EdmMultiplicity.MANY))
         .setEnd2 (
            new AssociationEnd ().setType (getFullQualifiedName ())
               .setRole (ROLE_CONNECTION_USER)
               .setMultiplicity (EdmMultiplicity.ONE)));
   }

   // User restriction association
   Association user_restriction = new Association ();
   user_restriction.setName (ASSO_USER_RESTRICTION.getName ());
   user_restriction.setEnd1 (new AssociationEnd ()
         .setType(Model.RESTRICTION.getFullQualifiedName())
         .setRole (ROLE_USER_RESTRICTIONS)
         .setMultiplicity (EdmMultiplicity.MANY));
   user_restriction.setEnd2 (new AssociationEnd ()
         .setType (getFullQualifiedName ())
         .setRole (ROLE_RESTRICTION_USER)
         .setMultiplicity (EdmMultiplicity.ONE));
   associations.add (user_restriction);

   // User system role association
   Association user_role = new Association ();
   user_role.setName (ASSO_USER_SYSTEMROLE.getName ());
   user_role.setEnd1 (new AssociationEnd ()
         .setType(Model.SYSTEM_ROLE.getFullQualifiedName())
         .setRole (ROLE_USER_SYSTEMROLES)
         .setMultiplicity (EdmMultiplicity.MANY));
   user_role.setEnd2 (new AssociationEnd ()
         .setType (getFullQualifiedName ())
         .setRole (ROLE_SYSTEMROLE_USER)
         .setMultiplicity (EdmMultiplicity.ONE));
   associations.add (user_role);

   // User Product (cart) association
   Association user_prod = new Association();
   user_prod.setName(ASSO_USER_PRODUCT.getName());
   user_prod.setEnd1(new AssociationEnd()
         .setType(Model.PRODUCT.getFullQualifiedName())
         .setRole(ROLE_USER_PRODUCTS)
         .setMultiplicity(EdmMultiplicity.MANY));
   user_prod.setEnd2(new AssociationEnd()
         .setType(getFullQualifiedName())
         .setRole(ROLE_PRODUCTS_USER)
         .setMultiplicity(EdmMultiplicity.MANY));
   associations.add(user_prod);

   return associations;
}
 
Example 10
Source File: JPAEdmAssociation.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@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 (Entry<String, Association> entry : associationMap.entrySet()) {
      Association association = entry.getValue();
      if (!consistentAssociatonList.contains(association)) {
        consistentAssociatonList.add(association);
      }
    }
    isConsistent = true;
  }

}