sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / User.java
index 50f860e..0339959 100644 (file)
@@ -69,19 +69,51 @@ implements java.io.Serializable
         if (obj instanceof User) {
         
             User temp = (User)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._fullname != null) {
                 if (temp._fullname == null) return false;
-                else if (!(this._fullname.equals(temp._fullname))) 
-                    return false;
-            }
-            else if (temp._fullname != null)
+                if (this._fullname != temp._fullname) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._fullname);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._fullname);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._fullname.equals(temp._fullname)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname);
+                    }
+                }
+            } else if (temp._fullname != null)
                 return false;
             if (this._organization != null) {
                 if (temp._organization == null) return false;
-                else if (!(this._organization.equals(temp._organization))) 
-                    return false;
-            }
-            else if (temp._organization != null)
+                if (this._organization != temp._organization) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._organization);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._organization);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._organization); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._organization.equals(temp._organization)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._organization);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._organization);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization);
+                    }
+                }
+            } else if (temp._organization != null)
                 return false;
             return true;
         }
@@ -121,11 +153,15 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_fullname != null) {
+        if (_fullname != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_fullname)) {
            result = 37 * result + _fullname.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_fullname);
         }
-        if (_organization != null) {
+        if (_organization != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_organization)) {
            result = 37 * result + _organization.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_organization);
         }
         
         return result;