private EdmEntityType getTargetEntityType(Edm edm, EdmEntitySet srcEtySet ,EdmNavigationProperty navigationProp) throws EdmException { if(navigationProp == null) return null ; else { //Look for Target Entity Type based on Navigation Property String toRole = navigationProp.getToRole() ; return navigationProp.getRelationship().getEnd(toRole).getEntityType(); } } private EdmEntitySet getTargetEntitySet(Edm edm, EdmEntitySet srcEtySet, EdmNavigationProperty navigationProp) throws EdmException, ODataException{
@Override public EdmAssociationSet getAssociationSet(final EdmEntitySet sourceEntitySet, final EdmNavigationProperty navigationProperty) throws EdmException { EdmAssociation edmAssociation = navigationProperty.getRelationship(); String association = edmAssociation.getNamespace() + "." + edmAssociation.getName(); String entitySetName = sourceEntitySet.getName(); String entitySetFromRole = navigationProperty.getFromRole(); String key = entitySetName + ">>" + association + ">>" + entitySetFromRole; for (Entry<String, EdmAssociationSet> edmAssociationSet : edmAssociationSetMap.entrySet()) { if (edmAssociationSet.getKey().equalsIgnoreCase(key)) { return edmAssociationSet.getValue(); } } return null; }
private Map<String,String> getReferenceMap(PostUriInfo uriInfo) throws EdmException, ODataApplicationException{ // Is navigation segment always of size one? // // add try catch // Map<String,String> referenceMap = new HashMap<>(); EdmReferentialConstraint refConstraint = uriInfo.getNavigationSegments().get(0).getNavigationProperty().getRelationship().getReferentialConstraint(); if(refConstraint == null) throw new ODataApplicationException (NO_REF_CONSTRAINT, LocaleUtil.getLocaleforException()); List<String> principalPropertyList = refConstraint.getPrincipal().getPropertyRefNames(); List<String> dependentPropertList = refConstraint.getDependent().getPropertyRefNames(); for (int i = 0; i < principalPropertyList.size(); i++) { referenceMap.put(principalPropertyList.get(i), dependentPropertList.get(i)); } return referenceMap; }
private void validateAssociationEnd(final EdmAssociationSetEnd end, final EdmAssociation association) throws EntityProviderException, EdmException { if (!(association.getEnd1().getRole().equals(end.getRole()) ^ association .getEnd2().getRole().equals(end.getRole()))) { throw new EntityProviderException(EntityProviderException.COMMON.addContent("Invalid Association")); } }
@Override public EdmType getType() throws EdmException { return getRelationship().getEnd(navigationProperty.getToRole()).getEntityType(); }
final EdmNavigationProperty navigationProperty) throws EdmException { EdmAssociation edmAssociation = navigationProperty.getRelationship(); String association = edmAssociation.getNamespace() + "." + edmAssociation.getName(); String entitySetName = sourceEntitySet.getName(); String entitySetFromRole = navigationProperty.getFromRole(); new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName()); try { associationSet =
public static UriInfoDraftHelperV2 getCreateUriInfoForDraftsOneToOneUsingParent(EdmNavigationProperty navPropParent, Map<String, Object> parentDraftsEntry, EdmEntityContainer entityContainer, Map<String, Object> navigatedContent) throws ODataApplicationException { try{ Map<String, Object> childPayload = new HashMap<>(); EdmReferentialConstraint refConstraint = navPropParent.getRelationship().getReferentialConstraint(); if(refConstraint == null){ throw new ODataApplicationException(CREATE_REF_CONSTRAINT_MISSING, Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, CREATE_REF_CONSTRAINT_MISSING); } // Map of <ChildKey , ParentKey> Map<String, String> refConstraintsMap = getReferenceMap(refConstraint); for (Map.Entry<String, String> entry : refConstraintsMap.entrySet()) { childPayload.put(entry.getKey(), parentDraftsEntry.get(entry.getValue())); } childPayload.putAll(navigatedContent); ODataEntryImpl content = new ODataEntryImpl(childPayload, null, null, null, false); EdmEntitySet entSet = entityContainer.getEntitySet(navPropParent.getType().getName()); UriInfoImpl uriInfoForCreate = new UriInfoImpl(); uriInfoForCreate.setStartEntitySet(entSet); uriInfoForCreate.setTargetEntitySet(entSet); UriInfoDraftHelperV2 uriT = new UriInfoDraftHelperV2(); uriT.setUriInfo(uriInfoForCreate); uriT.setContent(content); uriT.setUriFunction(UriFunction.CREATE); return uriT; }catch(EdmException ee){ logger.debug(ee.getMessage(), ee); throw new ODataApplicationException(ee.getMessage(), Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, ee.getMessage()); } }
@Override public EdmType getType() throws EdmException { return getRelationship().getEnd(navigationProperty.getToRole()).getEntityType(); }
final EdmNavigationProperty navigationProperty) throws EdmException { EdmAssociation edmAssociation = navigationProperty.getRelationship(); String association = edmAssociation.getNamespace() + "." + edmAssociation.getName(); String entitySetName = sourceEntitySet.getName(); String entitySetFromRole = navigationProperty.getFromRole(); new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName()); try { associationSet =
property = createView.getNavigationSegments().get(0).getNavigationProperty().getRelationship().getReferentialConstraint().getDependent().getPropertyRefNames().get(0);
@Override public EdmType getType() throws EdmException { return getRelationship().getEnd(navigationProperty.getToRole()).getEntityType(); }
final EdmNavigationProperty navigationProperty) throws EdmException { EdmAssociation edmAssociation = navigationProperty.getRelationship(); String association = edmAssociation.getNamespace() + "." + edmAssociation.getName(); String entitySetName = sourceEntitySet.getName(); String entitySetFromRole = navigationProperty.getFromRole(); new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName()); try { associationSet =
private void setAssociationSetForNavigations() throws EdmException { for(EdmEntitySet edmEntitySet:edmEntitySetList){ List<String> navigations = edmEntitySet.getEntityType().getNavigationPropertyNames(); if(navigations!=null && !navigations.isEmpty()){ for (EdmNavigationProperty navigationProperty : navProperties) { if (navigations.contains(navigationProperty.getName())) { //NOSONAR FullQualifiedName associationName = ((EdmNavigationPropertyImpl) navigationProperty).getRelationshipName(); String toRoleName = ((EdmNavigationPropertyImpl) navigationProperty).getToRole(); EdmAssociationEnd end = associationsMap.get(associationName).getEnd(toRoleName); if (end == null) { throw new EdmException(EdmException.ASSOCIATIONNOTFOUND); } String relation = associationName.toString(); StringBuilder key = new StringBuilder(); key.append(edmEntitySet.getName()); key.append(">>"); key.append(relation); key.append(">>"); key.append(navigationProperty.getFromRole()); ((EdmNavigationPropertyImpl) navigationProperty).setMultiplicity(end.getMultiplicity()); associationSetMap.put(key.toString(), tempAssociationSetMap.get(relation)); } } } } }
private void validateAssociation() throws EntityProviderException, EdmException { for (Map.Entry<FullQualifiedName, EdmEntityContainer> container : containerMap.entrySet()) { for (EdmAssociationSet associationSet : container.getValue().getAssociationSets()) { FullQualifiedName association = new FullQualifiedName(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName()); if (associationsMap.containsKey(association)) { validateAssociationEnd(((EdmAssociationSetImpl) associationSet).getEnd1(), associationsMap.get(association));
private EdmEntityType getTargetEntityTypeFromNavigationProperty(EdmEntityType entityType, String navigationProperty) throws EdmException { EdmNavigationProperty navProp = (EdmNavigationProperty) entityType.getProperty(navigationProperty); String toRole = navProp.getToRole(); return (EdmEntityType) navProp.getRelationship().getEnd(toRole).getEntityType(); }
return uriInfo; // property without association? Keep off! AssociationBundle bundle = MashServiceRegistry.getAssociationBundle(_service, association.getNamespace(), association.getName()); if (bundle == null) { AssociationBundle bundle = MashServiceRegistry.getAssociationBundle(_service, association.getNamespace(), association.getName());
EdmEntityType targetType = navigationProperty.getRelationship().getEnd(navigationProperty.getToRole()) .getEntityType(); if (navigationProperty.getMultiplicity().equals(EdmMultiplicity.MANY)) {
private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException { String fromRole = navigationProperty.getFromRole(); EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType(); EdmMapping mapping = fromEntityType.getMapping(); String entityName = null; if (mapping != null) { entityName = mapping.getInternalName(); } else { entityName = fromEntityType.getName(); } return entityName; }
private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException { String fromRole = navigationProperty.getFromRole(); EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType(); EdmMapping mapping = fromEntityType.getMapping(); String entityName = null; if (mapping != null) { entityName = mapping.getInternalName(); } else { entityName = fromEntityType.getName(); } return entityName; }
private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException { String fromRole = navigationProperty.getFromRole(); EdmEntityType toEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType(); EdmMapping mapping = toEntityType.getMapping(); String entityName = null; if (mapping != null) { entityName = mapping.getInternalName(); } else { entityName = toEntityType.getName(); } return entityName; }