@Override public EdmAssociation getAssociation() throws EdmException { EdmAssociation association = edm.getAssociation(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName()); if (association == null) { throw new EdmException(EdmException.COMMON); } return association; }
@Override public EdmAssociation getAssociation() throws EdmException { EdmAssociation association = edm.getAssociation(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName()); if (association == null) { throw new EdmException(EdmException.COMMON); } return association; }
@Override public EdmAssociation getAssociation() throws EdmException { EdmAssociation association = edm.getAssociation(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName()); if (association == null) { throw new EdmException(EdmException.COMMON); } return association; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = name2Container.get(entityContainer); if (container != null) { List<AssociationSet> associations = container.getAssociationSets(); for (AssociationSet associationSet : associations) { if (associationSet.getAssociation().equals(association)) { final AssociationSetEnd endOne = associationSet.getEnd1(); if (endOne.getRole().equals(sourceEntitySetRole) && endOne.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } final AssociationSetEnd endTwo = associationSet.getEnd2(); if (endTwo.getRole().equals(sourceEntitySetRole) && endTwo.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = name2Container.get(entityContainer); if (container != null) { List<AssociationSet> associations = container.getAssociationSets(); for (AssociationSet associationSet : associations) { if (associationSet.getAssociation().equals(association)) { final AssociationSetEnd endOne = associationSet.getEnd1(); if (endOne.getRole().equals(sourceEntitySetRole) && endOne.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } final AssociationSetEnd endTwo = associationSet.getEnd2(); if (endTwo.getRole().equals(sourceEntitySetRole) && endTwo.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = name2Container.get(entityContainer); if (container != null) { List<AssociationSet> associations = container.getAssociationSets(); for (AssociationSet associationSet : associations) { if (associationSet.getAssociation().equals(association)) { final AssociationSetEnd endOne = associationSet.getEnd1(); if (endOne.getRole().equals(sourceEntitySetRole) && endOne.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } final AssociationSetEnd endTwo = associationSet.getEnd2(); if (endTwo.getRole().equals(sourceEntitySetRole) && endTwo.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = null; if (!entityContainerInfos.containsKey(entityContainer)) { container = (EntityContainer) getEntityContainerInfo(entityContainer); } else { container = (EntityContainer) entityContainerInfos.get(entityContainer); } if (container != null && association != null && container.getAssociationSets() != null) { for (AssociationSet as : container.getAssociationSets()) { if (association.equals(as.getAssociation())) { AssociationSetEnd end = as.getEnd1(); if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) { return as; } else { end = as.getEnd2(); if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) { return as; } } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = null; if (!entityContainerInfos.containsKey(entityContainer)) { container = (EntityContainer) getEntityContainerInfo(entityContainer); } else { container = (EntityContainer) entityContainerInfos.get(entityContainer); } if (container != null && association != null && container.getAssociationSets() != null) { for (AssociationSet as : container.getAssociationSets()) { if (association.equals(as.getAssociation())) { AssociationSetEnd end = as.getEnd1(); if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) { return as; } else { end = as.getEnd2(); if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) { return as; } } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (AssociationSet associationSet : container.getAssociationSets()) { if (associationSet.getAssociation().equals(association) && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1() .getRole().equals(sourceEntitySetRole)) || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2() .getRole().equals(sourceEntitySetRole)))) { return associationSet; } } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (AssociationSet associationSet : container.getAssociationSets()) { if (associationSet.getAssociation().equals(association) && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1() .getRole().equals(sourceEntitySetRole)) || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2() .getRole().equals(sourceEntitySetRole)))) { return associationSet; } } } } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { // since no schema is specified, we take the first match in any schema EntityContainer container = getEntityContainer(getSchemas(), entityContainer); if (container == null) { return null; } List<AssociationSet> sets = container.getAssociationSets(); if (sets == null) { return null; } for (AssociationSet set : sets) { if (set.getAssociation().getNamespace() .equals(association.getNamespace()) && set.getAssociation().getName() .equals(association.getName()) && ((set.getEnd1().getEntitySet().equals(sourceEntitySetName) && set.getEnd1().getRole().equals(sourceEntitySetRole)) || (set.getEnd2().getEntitySet().equals(sourceEntitySetName) && set.getEnd2().getRole().equals(sourceEntitySetRole)))) { return set; } } return null; }
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (AssociationSet associationSet : container.getAssociationSets()) { if (associationSet.getAssociation().equals(association) && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1() .getRole().equals(sourceEntitySetRole)) || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2() .getRole().equals(sourceEntitySetRole)))) { return associationSet; } } } } } return null; }
private void validateAssociation() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityContainer> container : containerMap.entrySet()) { for (AssociationSet associationSet : container.getValue().getAssociationSets()) { FullQualifiedName association = associationSet.getAssociation(); if (associationsMap.containsKey(association)) { validateAssociationEnd(associationSet.getEnd1(), associationsMap.get(association)); validateAssociationEnd(associationSet.getEnd2(), associationsMap.get(association)); boolean end1 = false; boolean end2 = false; for (EntitySet entitySet : container.getValue().getEntitySets()) { if (entitySet.getName().equals(associationSet.getEnd1().getEntitySet())) { end1 = true; } if (entitySet.getName().equals(associationSet.getEnd2().getEntitySet())) { end2 = true; } } if (!(end1 && end2)) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } else { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } } }
private void validateAssociation() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityContainer> container : containerMap.entrySet()) { for (AssociationSet associationSet : container.getValue().getAssociationSets()) { FullQualifiedName association = associationSet.getAssociation(); if (associationsMap.containsKey(association)) { validateAssociationEnd(associationSet.getEnd1(), associationsMap.get(association)); validateAssociationEnd(associationSet.getEnd2(), associationsMap.get(association)); boolean end1 = false; boolean end2 = false; for (EntitySet entitySet : container.getValue().getEntitySets()) { if (entitySet.getName().equals(associationSet.getEnd1().getEntitySet())) { end1 = true; } if (entitySet.getName().equals(associationSet.getEnd2().getEntitySet())) { end2 = true; } } if (!(end1 && end2)) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } else { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } } }
private void validateAssociation() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityContainer> container : containerMap.entrySet()) { for (AssociationSet associationSet : container.getValue().getAssociationSets()) { FullQualifiedName association = associationSet.getAssociation(); if (associationsMap.containsKey(association)) { validateAssociationEnd(associationSet.getEnd1(), associationsMap.get(association)); validateAssociationEnd(associationSet.getEnd2(), associationsMap.get(association)); boolean end1 = false; boolean end2 = false; for (EntitySet entitySet : container.getValue().getEntitySets()) { if (entitySet.getName().equals(associationSet.getEnd1().getEntitySet())) { end1 = true; } if (entitySet.getName().equals(associationSet.getEnd2().getEntitySet())) { end2 = true; } } if (!(end1 && end2)) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } else { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } } }
private void includeAssociationSet(Schema targetSchema, EntityContainer targetContainer, IServiceInfo service, AssociationSet sourceSet) throws ODataException { List<AssociationSet> sets = targetContainer.getAssociationSets(); if (sets != null) { for (AssociationSet set : sets) { if (set.getName().equals(sourceSet.getName())) { throw new ODataException("association set " + sourceSet.getName() + " already defined"); } } } else { sets = new ArrayList<AssociationSet>(); } AssociationSet newSet = clone(sourceSet); newSet.setAssociation(new FullQualifiedName( targetSchema.getNamespace(), newSet.getAssociation().getName())); sets.add(newSet); targetContainer.setAssociationSets(sets); }
xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_SET); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, associationSet.getName()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION, associationSet.getAssociation() .toString());
xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_SET); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, associationSet.getName()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION, associationSet.getAssociation() .toString());
xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_SET); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, associationSet.getName()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION, associationSet.getAssociation() .toString());
private AssociationSet clone(AssociationSet set) { if (set == null) { return null; } AssociationSet newSet = new AssociationSet(); newSet.setAnnotationAttributes(set.getAnnotationAttributes()); newSet.setAnnotationElements(set.getAnnotationElements()); newSet.setAssociation(set.getAssociation()); newSet.setDocumentation(set.getDocumentation()); newSet.setEnd1(clone(set.getEnd1())); newSet.setEnd2(clone(set.getEnd2())); newSet.setName(set.getName()); return newSet; }