@Test public void testCreateODataEntryPropertyWithOutCallBack() { try { EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false); EdmEntityType edmEntityType = edmEntitySet.getEntityType(); jpaEntity = new JPAEntity(edmEntityType, edmEntitySet, mockODataJPAContextWithoutCallBack()); jpaEntity.create(ODataEntryMockUtil.mockODataEntryProperties(JPATypeMock.ENTITY_NAME)); } catch (ODataJPARuntimeException e) { assertEquals(ODataJPARuntimeException.ERROR_JPA_BLOB_NULL.getKey(), e.getMessageReference().getKey()); return; } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } catch (ODataException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } fail(ODataJPATestConstants.EXCEPTION_EXPECTED); }
public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException { if (oDataEntry == null) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL, null); } try { EntryMetadata entryMetadata = oDataEntry.getMetadata(); Map<String, Object> oDataEntryProperties = oDataEntry.getProperties(); if (oDataEntry.containsInlineEntry()) { normalizeInlineEntries(oDataEntryProperties); } if (oDataEntry.getProperties().size() > 0) { write(oDataEntryProperties, true); for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName); if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) { oDataEntry.getProperties().get(navigationPropertyName); JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty); continue; } if (parentJPAEntity != null && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) { List<Object> targetJPAEntities = new ArrayList<Object>(); targetJPAEntities.add(parentJPAEntity.getJPAEntity()); JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty); } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) { if (!relatedJPAEntityLink.contains(navigationPropertyName)) { relatedJPAEntityLink.add(navigationPropertyName); } } } } if (!relatedJPAEntityLink.isEmpty()) { JPALink link = new JPALink(oDataJPAContext); link.setSourceJPAEntity(jpaEntity); link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink); } } catch (EdmException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } catch (ODataJPAModelException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } }
JPAEntity { public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException { if (oDataEntry == null) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL, null); } try { EntryMetadata entryMetadata = oDataEntry.getMetadata(); Map<String, Object> oDataEntryProperties = oDataEntry.getProperties(); if (oDataEntry.containsInlineEntry()) { normalizeInlineEntries(oDataEntryProperties); } if (oDataEntry.getProperties().size() > 0) { write(oDataEntryProperties, true); for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName); if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) { oDataEntry.getProperties().get(navigationPropertyName); JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty); continue; } if (parentJPAEntity != null && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) { List<Object> targetJPAEntities = new ArrayList<Object>(); targetJPAEntities.add(parentJPAEntity.getJPAEntity()); JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty); } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) { if (!relatedJPAEntityLink.contains(navigationPropertyName)) { relatedJPAEntityLink.add(navigationPropertyName); } } } } if (!relatedJPAEntityLink.isEmpty()) { JPALink link = new JPALink(oDataJPAContext); link.setSourceJPAEntity(jpaEntity); link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink); } } catch (EdmException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } catch (ODataJPAModelException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } } }
JPAEntity { public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException { if (oDataEntry == null) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL, null); } try { EntryMetadata entryMetadata = oDataEntry.getMetadata(); Map<String, Object> oDataEntryProperties = oDataEntry.getProperties(); if (oDataEntry.containsInlineEntry()) { normalizeInlineEntries(oDataEntryProperties); } if (oDataEntry.getProperties().size() > 0) { write(oDataEntryProperties, true); for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName); if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) { oDataEntry.getProperties().get(navigationPropertyName); JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty); continue; } if (parentJPAEntity != null && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) { List<Object> targetJPAEntities = new ArrayList<Object>(); targetJPAEntities.add(parentJPAEntity.getJPAEntity()); JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty); } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) { if (!relatedJPAEntityLink.contains(navigationPropertyName)) { relatedJPAEntityLink.add(navigationPropertyName); } } } } if (!relatedJPAEntityLink.isEmpty()) { JPALink link = new JPALink(oDataJPAContext); link.setSourceJPAEntity(jpaEntity); link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink); } } catch (EdmException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } catch (ODataJPAModelException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } } JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet,
      final ODataJPAContext context); }
JPAEntity { public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException { if (oDataEntry == null) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL, null); } try { EntryMetadata entryMetadata = oDataEntry.getMetadata(); Map<String, Object> oDataEntryProperties = oDataEntry.getProperties(); if (oDataEntry.containsInlineEntry()) { normalizeInlineEntries(oDataEntryProperties); } if (oDataEntry.getProperties().size() > 0) { write(oDataEntryProperties, true); for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName); if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) { oDataEntry.getProperties().get(navigationPropertyName); JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty); continue; } if (parentJPAEntity != null && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) { List<Object> targetJPAEntities = new ArrayList<Object>(); targetJPAEntities.add(parentJPAEntity.getJPAEntity()); JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty); } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) { if (!relatedJPAEntityLink.contains(navigationPropertyName)) { relatedJPAEntityLink.add(navigationPropertyName); } } } } if (!relatedJPAEntityLink.isEmpty()) { JPALink link = new JPALink(oDataJPAContext); link.setSourceJPAEntity(jpaEntity); link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink); } } catch (EdmException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } catch (ODataJPAModelException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } } JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet,
      final ODataJPAContext context); void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite); void setParentJPAEntity(final JPAEntity jpaEntity); JPAEntity getParentJPAEntity(); Object getJPAEntity(); void setViaNavigationProperty(EdmNavigationProperty viaNavigationProperty); EdmNavigationProperty getViaNavigationProperty(); void create(final ODataEntry oDataEntry); EdmEntitySet getEdmEntitySet(); void create(final Map<String, Object> oDataEntryProperties); void update(final ODataEntry oDataEntry); void update(final Map<String, Object> oDataEntryProperties); void setJPAEntity(final Object jpaEntity); }
JPAEntity { public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException { if (oDataEntry == null) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL, null); } try { EntryMetadata entryMetadata = oDataEntry.getMetadata(); Map<String, Object> oDataEntryProperties = oDataEntry.getProperties(); if (oDataEntry.containsInlineEntry()) { normalizeInlineEntries(oDataEntryProperties); } if (oDataEntry.getProperties().size() > 0) { write(oDataEntryProperties, true); for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName); if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) { oDataEntry.getProperties().get(navigationPropertyName); JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty); continue; } if (parentJPAEntity != null && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) { List<Object> targetJPAEntities = new ArrayList<Object>(); targetJPAEntities.add(parentJPAEntity.getJPAEntity()); JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty); } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) { if (!relatedJPAEntityLink.contains(navigationPropertyName)) { relatedJPAEntityLink.add(navigationPropertyName); } } } } if (!relatedJPAEntityLink.isEmpty()) { JPALink link = new JPALink(oDataJPAContext); link.setSourceJPAEntity(jpaEntity); link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink); } } catch (EdmException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } catch (ODataJPAModelException e) { throw ODataJPARuntimeException .throwException(ODataJPARuntimeException.GENERAL .addContent(e.getMessage()), e); } } JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet,
      final ODataJPAContext context); void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite); void setParentJPAEntity(final JPAEntity jpaEntity); JPAEntity getParentJPAEntity(); Object getJPAEntity(); void setViaNavigationProperty(EdmNavigationProperty viaNavigationProperty); EdmNavigationProperty getViaNavigationProperty(); void create(final ODataEntry oDataEntry); EdmEntitySet getEdmEntitySet(); void create(final Map<String, Object> oDataEntryProperties); void update(final ODataEntry oDataEntry); void update(final Map<String, Object> oDataEntryProperties); void setJPAEntity(final Object jpaEntity);  }