Package org.qi4j.spi.entity

Examples of org.qi4j.spi.entity.NamedAssociationState


    }

    @Override
    public NamedAssociationState namedAssociationValueOf( QualifiedName stateName )
    {
        NamedAssociationState state = namedAssociations.get( stateName );
        if( state == null )
        {
            state = new BuilderNamedAssociationState();
            namedAssociations.put( stateName, state );
        }
View Full Code Here


            }
        }
        for( Map.Entry<QualifiedName, NamedAssociationState> fromNamedAssociationEntry : namedAssociations.entrySet() )
        {
            QualifiedName qName = fromNamedAssociationEntry.getKey();
            NamedAssociationState fromNamedAssoc = fromNamedAssociationEntry.getValue();
            NamedAssociationState toNamedAssoc = newEntityState.namedAssociationValueOf( qName );
            for( String name : fromNamedAssoc )
            {
                toNamedAssoc.put( name, fromNamedAssoc.get( name ) );
            }
        }
    }
View Full Code Here

                {
                    if( namedAssocDesc.queryable() )
                    {
                        String key = namedAssocDesc.qualifiedName().name();
                        JSONArray array = new JSONArray();
                        NamedAssociationState associateds = state.namedAssociationValueOf( namedAssocDesc.qualifiedName() );
                        for( String name : associateds )
                        {
                            if( namedAssocDesc.isAggregated() || support.indexNonAggregatedAssociations() )
                            {
                                String identity = associateds.get( name ).identity();
                                if( newStates.containsKey( identity ) )
                                {
                                    JSONObject obj = new JSONObject( toJSON( newStates.get( identity ), newStates, uow ) );
                                    obj.put( "_named", name );
                                    array.put( obj );
                                }
                                else
                                {
                                    EntityState assocState = uow.entityStateOf( EntityReference.parseEntityReference( identity ) );
                                    JSONObject obj = new JSONObject( toJSON( assocState, newStates, uow ) );
                                    obj.put( "_named", name );
                                    array.put( obj );
                                }
                            }
                            else
                            {
                                JSONObject obj = new JSONObject();
                                obj.put( "_named", name );
                                obj.put( "identity", associateds.get( name ).identity() );
                                array.put( obj );
                            }
                        }
                        json.put( key, array );
                    }
View Full Code Here

    @Override
    public NamedAssociationState namedAssociationValueOf( QualifiedName stateName )
    {
        Map<String, String> assocs = (Map<String, String>) entity.getProperty( stateName.toURI() );
        NamedAssociationState state = new GaeNamedAssociationState( this, assocs );
        return state;
    }
View Full Code Here

                out.println( "</table></fieldset>\n" );

                out.println( "<fieldset><legend>NamedAssociations</legend>\n<table>" );
                for( AssociationDescriptor associationType : descriptor.state().namedAssociations() )
                {
                    NamedAssociationState identities = entity.namedAssociationValueOf( associationType.qualifiedName() );
                    String value = "";
                    for( String name : identities )
                    {
                        value += name + "\n" + identities.get( name ).identity() + "\n";
                    }

                    out.println( "<tr><td>"
                                 + "<label for=\"" + associationType.qualifiedName() + "\" >"
                                 + associationType.qualifiedName().name()
View Full Code Here

                }
            }
            for( AssociationDescriptor associationType : descriptor.state().namedAssociations() )
            {
                String newStringAssociation = form.getFirstValue( associationType.qualifiedName().name() );
                NamedAssociationState namedAssociation = entity.namedAssociationValueOf( associationType.qualifiedName() );
                if( newStringAssociation == null )
                {
                    // Remove "left-overs"
                    for( String name : namedAssociation )
                    {
                        namedAssociation.remove( name );
                    }
                    continue;
                }
                Set<String> names = new HashSet<>();
                BufferedReader bufferedReader = new BufferedReader( new StringReader( newStringAssociation ) );
                String line;
                try
                {
                    while( ( line = bufferedReader.readLine() ) != null )
                    {
                        String name = line;
                        line = bufferedReader.readLine();
                        if( line == null )
                        {
                            break;
                        }
                        String identity = line;
                        EntityReference reference = new EntityReference( identity );
                        try
                        {
                            unitOfWork.entityStateOf( reference );

                            namedAssociation.remove( name );
                            namedAssociation.put( name, reference );

                            names.add( name );
                        }
                        catch( EntityNotFoundException e )
                        {
                            // Ignore this entity - doesn't exist
                        }
                    }

                    // Remove "left-overs"
                    for( String assocName : Iterables.toList( namedAssociation ) )
                    {
                        if( !names.contains( assocName ) )
                        {
                            namedAssociation.remove( assocName );
                        }
                    }
                }
                catch( IOException e )
                {
View Full Code Here

TOP

Related Classes of org.qi4j.spi.entity.NamedAssociationState

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.