/** * * @param metadata * Entity metadata of the parent node * @param relation * @return */ private Map<LinkProperty, Object> getLinkProperties(EntityMetadata metadata, Relation relation, final KunderaMetadata kunderaMetadata) { Map<LinkProperty, Object> linkProperties = new HashMap<NodeLink.LinkProperty, Object>(); linkProperties.put(LinkProperty.LINK_NAME, MetadataUtils.getMappedName(metadata, relation, kunderaMetadata)); linkProperties.put(LinkProperty.IS_SHARED_BY_PRIMARY_KEY, relation.isJoinedByPrimaryKey()); linkProperties.put(LinkProperty.IS_BIDIRECTIONAL, !relation.isUnary()); linkProperties.put(LinkProperty.IS_RELATED_VIA_JOIN_TABLE, relation.isRelatedViaJoinTable()); linkProperties.put(LinkProperty.PROPERTY, relation.getProperty()); linkProperties.put(LinkProperty.CASCADE, relation.getCascades()); if (relation.isRelatedViaJoinTable()) { linkProperties.put(LinkProperty.JOIN_TABLE_METADATA, relation.getJoinTableMetadata()); } return linkProperties; }
/** * * @param metadata * Entity metadata of the parent node * @param relation * @return */ private Map<LinkProperty, Object> getLinkProperties(EntityMetadata metadata, Relation relation) { Map<LinkProperty, Object> linkProperties = new HashMap<NodeLink.LinkProperty, Object>(); linkProperties.put(LinkProperty.LINK_NAME, MetadataUtils.getMappedName(metadata, relation, pd.getKunderaMetadata())); linkProperties.put(LinkProperty.IS_SHARED_BY_PRIMARY_KEY, relation.isJoinedByPrimaryKey()); linkProperties.put(LinkProperty.IS_BIDIRECTIONAL, !relation.isUnary()); linkProperties.put(LinkProperty.IS_RELATED_VIA_JOIN_TABLE, relation.isRelatedViaJoinTable()); linkProperties.put(LinkProperty.PROPERTY, relation.getProperty()); linkProperties.put(LinkProperty.CASCADE, relation.getCascades()); if (relation.isRelatedViaJoinTable()) { linkProperties.put(LinkProperty.JOIN_TABLE_METADATA, relation.getJoinTableMetadata()); } // TODO: Add more link properties as required return linkProperties; }
@Override public <E> void setProxyOwners(EntityMetadata entityMetadata, E e) { if (e != null && e.getClass().getAnnotation(Entity.class) != null && entityMetadata != null) { for (Relation r : entityMetadata.getRelations()) { if (r != null) { Object entityId = PropertyAccessorHelper.getId(e, entityMetadata); if (r.isUnary()) { String entityName = entityMetadata.getEntityClazz().getName() + "_" + entityId + "#" + r.getProperty().getName(); KunderaProxy kunderaProxy = getProxy(entityName); if (kunderaProxy != null) { kunderaProxy.getKunderaLazyInitializer().setOwner(e); } } } } } } }
if (!relation.isUnary())
/** * After successfully parsing set relational entity object within entity * object. * * @param entity * @param relationEntity * @param relation */ private void setRelationToEntity(Object entity, Object relationEntity, Relation relation) { if (relation.getTargetEntity().isAssignableFrom(getEntity(relationEntity).getClass())) { if (relation.isUnary()) { PropertyAccessorHelper.set(entity, relation.getProperty(), getEntity(relationEntity)); } else { Object associationObject = PropertyAccessorHelper.getObject(entity, relation.getProperty()); if (associationObject == null || ProxyHelper.isProxyOrCollection(associationObject)) { associationObject = PropertyAccessorHelper.getCollectionInstance(relation.getProperty()); PropertyAccessorHelper.set(entity, relation.getProperty(), associationObject); } ((Collection) associationObject).add(getEntity(relationEntity)); } } }
if (relation != null && relation.isUnary())
else if (relation.isUnary() && relation.getJoinColumnName(kunderaMetadata) != null)
if (relation.isUnary() && relation.getTargetEntity().isAssignableFrom(originalEntity.getClass()))
if (relation.isUnary())
if (relation != null && relation.isUnary())