polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [24/33] polygene-java git commit: Fix Preferences EntityStore clearing associations
Date Tue, 23 May 2017 02:14:07 GMT
Fix Preferences EntityStore clearing associations


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/3807b48c
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/3807b48c
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/3807b48c

Branch: refs/heads/yeoman-work
Commit: 3807b48cd403cef71a81b4237605d577c1737ab4
Parents: 00ded0d
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun May 21 18:16:27 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun May 21 18:23:54 2017 +0200

----------------------------------------------------------------------
 .../PreferencesEntityStoreMixin.java            | 44 ++++++++++++--------
 1 file changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3807b48c/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
index 7958840..5bf1597 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
@@ -569,17 +569,21 @@ public class PreferencesEntityStoreMixin
                 for( Map.Entry<QualifiedName, List<EntityReference>> manyAssociation
: state.manyAssociations()
                     .entrySet() )
                 {
-                    StringBuilder manyAssocs = new StringBuilder();
-                    for( EntityReference entityReference : manyAssociation.getValue() )
+                    if( manyAssociation.getValue().isEmpty() )
                     {
-                        if( manyAssocs.length() > 0 )
-                        {
-                            manyAssocs.append( "\n" );
-                        }
-                        manyAssocs.append( entityReference.identity().toString() );
+                        manyAssocsPrefs.remove( manyAssociation.getKey().name() );
                     }
-                    if( manyAssocs.length() > 0 )
+                    else
                     {
+                        StringBuilder manyAssocs = new StringBuilder();
+                        for( EntityReference entityReference : manyAssociation.getValue()
)
+                        {
+                            if( manyAssocs.length() > 0 )
+                            {
+                                manyAssocs.append( "\n" );
+                            }
+                            manyAssocs.append( entityReference.identity().toString() );
+                        }
                         manyAssocsPrefs.put( manyAssociation.getKey().name(), manyAssocs.toString()
);
                     }
                 }
@@ -592,18 +596,24 @@ public class PreferencesEntityStoreMixin
                 for( Map.Entry<QualifiedName, Map<String, EntityReference>> namedAssociation
: state.namedAssociations()
                     .entrySet() )
                 {
-                    StringBuilder namedAssocs = new StringBuilder();
-                    for( Map.Entry<String, EntityReference> namedRef : namedAssociation.getValue().entrySet()
)
+                    if( namedAssociation.getValue().isEmpty() )
                     {
-                        if( namedAssocs.length() > 0 )
-                        {
-                            namedAssocs.append( "\n" );
-                        }
-                        namedAssocs.append( namedRef.getKey() ).append( "\n" ).append( namedRef.getValue().identity().toString()
);
+                        namedAssocsPrefs.remove( namedAssociation.getKey().name() );
                     }
-                    if( namedAssocs.length() > 0 )
+                    else
                     {
-                        namedAssocsPrefs.put( namedAssociation.getKey().name(), namedAssocs.toString()
);
+                        StringBuilder namedAssocs = new StringBuilder();
+                        for( Map.Entry<String, EntityReference> namedRef : namedAssociation.getValue().entrySet()
)
+                        {
+                            if( namedAssocs.length() > 0 )
+                            {
+                                namedAssocs.append( "\n" );
+                            }
+                            namedAssocs.append( namedRef.getKey() ).append( "\n" ).append(
+                                namedRef.getValue().identity().toString() );
+                        }
+                        String key = namedAssociation.getKey().name();
+                        namedAssocsPrefs.put( key, namedAssocs.toString() );
                     }
                 }
             }


Mime
View raw message