Java Code Examples for org.apache.olingo.odata2.api.edm.EdmMultiplicity#ZERO_TO_ONE

The following examples show how to use org.apache.olingo.odata2.api.edm.EdmMultiplicity#ZERO_TO_ONE . 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: AnnotationHelper.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public EdmMultiplicity mapMultiplicity(final Multiplicity multiplicity) {
  switch (multiplicity) {
  case ZERO_OR_ONE:
    return EdmMultiplicity.ZERO_TO_ONE;
  case ONE:
    return EdmMultiplicity.ONE;
  case MANY:
    return EdmMultiplicity.MANY;
  default:
    throw new AnnotationRuntimeException("Unknown type '" + multiplicity + "' for mapping to EdmMultiplicity.");
  }
}
 
Example 2
Source File: JPAEdmAssociation.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void updateAssociationEndMultiplicity(JPAEdmAssociationEndView view, Association association) {
  if (view.getEdmAssociationEnd1().getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE
      && association.getEnd1().getMultiplicity() == EdmMultiplicity.ONE) {
    association.getEnd1().setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
  } else if (view.getEdmAssociationEnd2().getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE
      && association.getEnd2().getMultiplicity() == EdmMultiplicity.ONE) {
    association.getEnd2().setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
  } else if (view.getEdmAssociationEnd1().getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE
      && association.getEnd2().getMultiplicity() == EdmMultiplicity.ONE) {
    association.getEnd2().setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
  } else if (view.getEdmAssociationEnd2().getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE
      && association.getEnd1().getMultiplicity() == EdmMultiplicity.ONE) {
    association.getEnd1().setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
  }
}
 
Example 3
Source File: EdmElementImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public EdmElementImplProv(final EdmImplProv edm, final String name, final FullQualifiedName typeName,
    final EdmFacets edmFacets, final EdmMapping edmMapping) throws EdmException {
  super(edm, name, typeName, (edmFacets == null || edmFacets.isNullable() == null) || edmFacets.isNullable()
      ? EdmMultiplicity.ZERO_TO_ONE : EdmMultiplicity.ONE);
  this.edmFacets = edmFacets;
  this.edmMapping = edmMapping;
}
 
Example 4
Source File: JPAEdmAssociationEnd.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean compare(final AssociationEnd end1, final AssociationEnd end2) {
  FullQualifiedName end1Type = end1.getType();
  FullQualifiedName currentAssociationEnd1Type = currentAssociationEnd1.getType();
  FullQualifiedName end2Type = end2.getType();
  FullQualifiedName currentAssociationEnd2Type = currentAssociationEnd2.getType();

  if(end1.getMultiplicity() == null || currentAssociationEnd1.getMultiplicity() == null) {
    return false;
  }
  if(end2.getMultiplicity() == null || currentAssociationEnd2.getMultiplicity() == null) {
    return false;
  }

  boolean end1eqCurEnd1 = end1.getMultiplicity().equals(currentAssociationEnd1.getMultiplicity());
  boolean end2eqCurEnd2 = end2.getMultiplicity().equals(currentAssociationEnd2.getMultiplicity());
  if(end1Type.equals(currentAssociationEnd1Type) && end2Type.equals(currentAssociationEnd2Type)
      && end1eqCurEnd1 && end2eqCurEnd2) {
    return true;
  }

  boolean end1EqCurEnd2 = end1.getMultiplicity().equals(currentAssociationEnd2.getMultiplicity());
  boolean end2EqCurEnd1 = end2.getMultiplicity().equals(currentAssociationEnd1.getMultiplicity());
  if(end1Type.equals(currentAssociationEnd2Type) && end2Type.equals(currentAssociationEnd1Type)
      && end1EqCurEnd2 && end2EqCurEnd1) {
    return true;
  }

  boolean end1IsZeroToOne = end1.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE;
  boolean end1IsOne = end1.getMultiplicity() == EdmMultiplicity.ONE;
  boolean end2IsZeroToOne = end2.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE;
  boolean end2IsOne = end2.getMultiplicity() == EdmMultiplicity.ONE;

  if (end1Type.equals(currentAssociationEnd1Type) && end2Type.equals(currentAssociationEnd2Type)) {
      if ((end1IsZeroToOne && currentAssociationEnd1.getMultiplicity() == EdmMultiplicity.ONE
          || end1IsOne && currentAssociationEnd1.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE)
          && end2eqCurEnd2) {
        return true;
      }
      if ((end2IsZeroToOne && currentAssociationEnd2.getMultiplicity() == EdmMultiplicity.ONE
          || end2IsOne && currentAssociationEnd2.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE)
          && end1eqCurEnd1) {
        return true;
      }
  }

  if (end2Type.equals(currentAssociationEnd1Type) && end1Type.equals(currentAssociationEnd2Type)) {
    if ((end1IsZeroToOne && currentAssociationEnd2.getMultiplicity() == EdmMultiplicity.ONE
        || end1IsOne && currentAssociationEnd2.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE)
        && end2EqCurEnd1) {
      return true;
    }
    if ((end2IsZeroToOne && currentAssociationEnd1.getMultiplicity() == EdmMultiplicity.ONE
        || end2IsOne && currentAssociationEnd1.getMultiplicity() == EdmMultiplicity.ZERO_TO_ONE)
        && end1EqCurEnd2) {
      return true;
    }
  }

  return false;
}