Package com.impetus.kundera.db

Examples of com.impetus.kundera.db.RelationHolder


    @Test
    public void test()
    {
        Person p = new Person();
        RelationHolder rlHolder = new RelationHolder("parent", p);
       
        Assert.assertEquals("parent", rlHolder.getRelationName());
        Assert.assertEquals(p, rlHolder.getRelationValue());
       
        AddressEntity relationEntity = new AddressEntity();
        rlHolder = new RelationHolder("child", p, relationEntity);
        Assert.assertEquals("child", rlHolder.getRelationName());
        Assert.assertEquals(p, rlHolder.getRelationValue());
        Assert.assertEquals(relationEntity, rlHolder.getRelationVia());

    }
View Full Code Here


                Relation.ForeignKey multiplicity = parentNodeLink.getMultiplicity();

                if (linkName != null && linkValue != null && !isSharedByPrimaryKey
                        && multiplicity.equals(ForeignKey.ONE_TO_MANY))
                {
                    RelationHolder relationHolder = new RelationHolder(linkName, linkValue);
                    relationsHolder.add(relationHolder);
                }
            }
        }

        // Add column value for all child nodes linked to this node
        if (children != null && !children.isEmpty())
        {
            for (NodeLink childNodeLink : children.keySet())
            {
                String linkName = (String) childNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
                Object linkValue = childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) != null ? childNodeLink
                        .getLinkProperty(LinkProperty.LINK_VALUE) : children.get(childNodeLink).getEntityId();
                boolean isSharedByPrimaryKey = (Boolean) childNodeLink
                        .getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
                Relation.ForeignKey multiplicity = childNodeLink.getMultiplicity();

                if (linkName != null && linkValue != null && !isSharedByPrimaryKey)
                {
                    if (multiplicity.equals(ForeignKey.ONE_TO_ONE) || multiplicity.equals(ForeignKey.MANY_TO_ONE))
                    {
                        RelationHolder relationHolder = new RelationHolder(linkName, linkValue);
                        relationsHolder.add(relationHolder);
                    }
                    else if (multiplicity.equals(ForeignKey.MANY_TO_MANY)
                            && ((Field) childNodeLink.getLinkProperty(LinkProperty.PROPERTY)).getType()
                                    .isAssignableFrom(Map.class))
                    {
                        Object relationTo = ((Node) children.get(childNodeLink)).getData();
                        RelationHolder relationHolder = new RelationHolder(linkName, relationTo, linkValue);
                        relationsHolder.add(relationHolder);
                    }
                }
            }
        }
View Full Code Here

        // No need to check for empty or blank, as considering it as valid name
        // for nosql!
        if (discrColumn != null && discrValue != null)
        {
            List<RelationHolder> discriminator = new ArrayList<RelationHolder>(1);
            discriminator.add(new RelationHolder(discrColumn, discrValue));
            hbaseWriter.writeRelations(hTable, rowId, containsEmbeddedObjectsOnly, discriminator, m.getTableName());
        }

        puthTable(hTable);
    }
View Full Code Here

                    if (foreignKey != null)
                    {
                        relationObject = null;
                        PropertyAccessorHelper.set(entity, relation.getProperty(), relationObject);
                        relationHolders
                                .add(new RelationHolder(relation.getJoinColumnName(kunderaMetadata), foreignKey));
                        proxyRemoved = true;
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.impetus.kundera.db.RelationHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.