}
}
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 )
{