Package org.qi4j.spi.entitystore.helpers

Examples of org.qi4j.spi.entitystore.helpers.DefaultEntityState


                    updatePS = database.prepareUpdateEntityStatement( connection );
                    removePS = database.prepareRemoveEntityStatement( connection );
                    for( EntityState state : states )
                    {
                        EntityStatus status = state.status();
                        DefaultEntityState defState = ( (SQLEntityState) state ).getDefaultEntityState();
                        Long entityPK = ( (SQLEntityState) state ).getEntityPK();
                        if( EntityStatus.REMOVED.equals( status ) )
                        {
                            database.populateRemoveEntityStatement( removePS, entityPK, state.identity() );
                            removePS.addBatch();
                        }
                        else
                        {
                            StringWriter writer = new StringWriter();
                            writeEntityState( defState, writer, unitofwork.identity() );
                            writer.flush();
                            if( EntityStatus.UPDATED.equals( status ) )
                            {
                                Long entityOptimisticLock = ( (SQLEntityState) state ).getEntityOptimisticLock();
                                database.populateUpdateEntityStatement( updatePS, entityPK, entityOptimisticLock,
                                                                        defState.identity(), writer.toString(),
                                                                        unitofwork.currentTime() );
                                updatePS.addBatch();
                            }
                            else if( EntityStatus.NEW.equals( status ) )
                            {
                                database.populateInsertEntityStatement( insertPS, defState.identity(),
                                                                        writer.toString(), unitofwork.currentTime() );
                                insertPS.addBatch();
                            }
                        }
                    }
View Full Code Here


    }

    @Override
    public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork, EntityReference entityRef, EntityDescriptor entityDescriptor )
    {
        return new DefaultSQLEntityState( new DefaultEntityState( (DefaultEntityStoreUnitOfWork) unitOfWork,
                                                                  entityRef,
                                                                  entityDescriptor ) );
    }
View Full Code Here

            ps = database.prepareGetAllEntitiesStatement( connection );
            database.populateGetAllEntitiesStatement( ps );
            rs = ps.executeQuery();
            while( rs.next() )
            {
                DefaultEntityState entityState = readEntityState( uow, database.getEntityValue( rs ).getReader() );
                if( !entityStatesVisitor.visit( entityState ) )
                {
                    return;
                }
            }
View Full Code Here

                    // NamedAssociation not found, default to empty one
                    namedAssociations.put( namedAssociationType.qualifiedName(), references );
                }
            }

            return new DefaultEntityState( unitOfWork, version, modified,
                                           EntityReference.parseEntityReference( identity ), status, entityDescriptor,
                                           properties, associations, manyAssociations, namedAssociations );
        }
        catch( JSONException e )
        {
View Full Code Here

    public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork,
                                       EntityReference identity,
                                       EntityDescriptor entityDescriptor
    )
    {
        return new DefaultEntityState( (DefaultEntityStoreUnitOfWork) unitOfWork, identity, entityDescriptor );
    }
View Full Code Here

                    }
                    namedAssociations.put( namedAssociationType.qualifiedName(), references );
                }
            }

            return new DefaultEntityState( desuw,
                                           entityPrefs.get( "version", "" ),
                                           entityPrefs.getLong( "modified", unitOfWork.currentTime() ),
                                           identity,
                                           status,
                                           entityDescriptor,
View Full Code Here

                {
                    synchronized( root )
                    {
                        for( EntityState entityState : state )
                        {
                            DefaultEntityState state = (DefaultEntityState) entityState;
                            if( state.status().equals( EntityStatus.NEW ) )
                            {
                                Preferences entityPrefs = root.node( state.identity().identity() );
                                writeEntityState( state, entityPrefs, unitofwork.identity(), unitofwork.currentTime() );
                            }
                            else if( state.status().equals( EntityStatus.UPDATED ) )
                            {
                                Preferences entityPrefs = root.node( state.identity().identity() );
                                writeEntityState( state, entityPrefs, unitofwork.identity(), unitofwork.currentTime() );
                            }
                            else if( state.status().equals( EntityStatus.REMOVED ) )
                            {
                                root.node( state.identity().identity() ).removeNode();
                            }
                        }
                        root.flush();
                    }
                }
View Full Code Here

TOP

Related Classes of org.qi4j.spi.entitystore.helpers.DefaultEntityState

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.