@Override public EdmEntityType getEntityType() throws EdmException { final FullQualifiedName type = associationEnd.getType(); EdmEntityType entityType = edm.getEntityType(type.getNamespace(), type.getName()); if (entityType == null) { throw new EdmException(EdmException.COMMON); } return entityType; }
@Override public void build() throws ODataJPAModelException { currentAssociationEnd1 = new AssociationEnd(); currentAssociationEnd2 = new AssociationEnd(); JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView); currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName()); if (currentAssociationEnd1.getType().getName().equals(currentAssociationEnd2.getType().getName())) { currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName() + "2"); } else { currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName()); } setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType()); List<String[]> joinColumnNames = propertyView.getJPAJoinColumns(); if (joinColumnNames != null) { int i = 0; columnNames = (String[]) Array.newInstance(String.class, joinColumnNames.size()); referencedColumnNames = (String[]) Array.newInstance(String.class, joinColumnNames.size()); for (String[] jc : joinColumnNames) { columnNames[i] = jc[0]; referencedColumnNames[i++] = jc[1]; } } ownerPropertyName = propertyView.getJPAAttribute().getName(); }
@Override public void build() throws ODataJPAModelException { currentAssociationEnd1 = new AssociationEnd(); currentAssociationEnd2 = new AssociationEnd(); JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView); currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName()); if (currentAssociationEnd1.getType().getName().equals(currentAssociationEnd2.getType().getName())) { currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName() + "2"); } else { currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName()); } setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType()); List<String[]> joinColumnNames = propertyView.getJPAJoinColumns(); if (joinColumnNames != null) { int i = 0; columnNames = (String[]) Array.newInstance(String.class, joinColumnNames.size()); referencedColumnNames = (String[]) Array.newInstance(String.class, joinColumnNames.size()); for (String[] jc : joinColumnNames) { columnNames[i] = jc[0]; referencedColumnNames[i++] = jc[1]; } } ownerPropertyName = propertyView.getJPAAttribute().getName(); }
@Override public EdmEntityType getEntityType() throws EdmException { final FullQualifiedName type = associationEnd.getType(); EdmEntityType entityType = edm.getEntityType(type.getNamespace(), type.getName()); if (entityType == null) { throw new EdmException(EdmException.COMMON); } return entityType; }
@Override public EdmEntityType getEntityType() throws EdmException { final FullQualifiedName type = associationEnd.getType(); EdmEntityType entityType = edm.getEntityType(type.getNamespace(), type.getName()); if (entityType == null) { throw new EdmException(EdmException.COMMON); } return entityType; }
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")); } } }
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")); } } }
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")); } } }
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); }
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); }
private static void writeAssociationEnd(final AssociationEnd end, final Map<String, String> predefinedNamespaces, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_END); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_TYPE, end.getType().toString()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION_MULTIPLICITY, end.getMultiplicity().toString()); if (end.getRole() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ROLE, end.getRole()); } writeAnnotationAttributes(end.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(end.getDocumentation(), predefinedNamespaces, xmlStreamWriter); OnDelete onDelete = end.getOnDelete(); if (onDelete != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_ONDELETE); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ONDELETE_ACTION, onDelete.getAction().toString()); writeAnnotationAttributes(onDelete.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(onDelete.getDocumentation(), predefinedNamespaces, xmlStreamWriter); writeAnnotationElements(onDelete.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); } writeAnnotationElements(end.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); }
private static void writeAssociationEnd(final AssociationEnd end, final Map<String, String> predefinedNamespaces, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_END); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_TYPE, end.getType().toString()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION_MULTIPLICITY, end.getMultiplicity().toString()); if (end.getRole() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ROLE, end.getRole()); } writeAnnotationAttributes(end.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(end.getDocumentation(), predefinedNamespaces, xmlStreamWriter); OnDelete onDelete = end.getOnDelete(); if (onDelete != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_ONDELETE); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ONDELETE_ACTION, onDelete.getAction().toString()); writeAnnotationAttributes(onDelete.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(onDelete.getDocumentation(), predefinedNamespaces, xmlStreamWriter); writeAnnotationElements(onDelete.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); } writeAnnotationElements(end.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); }
private static void writeAssociationEnd(final AssociationEnd end, final Map<String, String> predefinedNamespaces, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_END); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_TYPE, end.getType().toString()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ASSOCIATION_MULTIPLICITY, end.getMultiplicity().toString()); if (end.getRole() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ROLE, end.getRole()); } writeAnnotationAttributes(end.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(end.getDocumentation(), predefinedNamespaces, xmlStreamWriter); OnDelete onDelete = end.getOnDelete(); if (onDelete != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ASSOCIATION_ONDELETE); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_ONDELETE_ACTION, onDelete.getAction().toString()); writeAnnotationAttributes(onDelete.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(onDelete.getDocumentation(), predefinedNamespaces, xmlStreamWriter); writeAnnotationElements(onDelete.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); } writeAnnotationElements(end.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); }
private void includeAssociation(Schema targetSchema, IServiceInfo service, Association sourceAssociation) throws ODataException { List<Association> associations = targetSchema.getAssociations(); if (associations != null) { for (Association type : associations) { if (type.getName().equals(sourceAssociation.getName())) { throw new ODataException("association " + sourceAssociation.getName() + " already defined"); } } } else { associations = new ArrayList<Association>(); } Association newAssociation = clone(sourceAssociation); newAssociation.getEnd1().setType( new FullQualifiedName(targetSchema.getNamespace(), newAssociation.getEnd1().getType().getName())); newAssociation.getEnd2().setType( new FullQualifiedName(targetSchema.getNamespace(), newAssociation.getEnd2().getType().getName())); associations.add(newAssociation); targetSchema.setAssociations(associations); }
@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();