sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / DataSetAnnotations.java
index 39aa939..861f0fe 100644 (file)
@@ -109,19 +109,51 @@ implements java.io.Serializable
         if (obj instanceof DataSetAnnotations) {
         
             DataSetAnnotations temp = (DataSetAnnotations)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._seqRef != null) {
                 if (temp._seqRef == null) return false;
-                else if (!(this._seqRef.equals(temp._seqRef))) 
-                    return false;
-            }
-            else if (temp._seqRef != null)
+                if (this._seqRef != temp._seqRef) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._seqRef);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._seqRef);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._seqRef.equals(temp._seqRef)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef);
+                    }
+                }
+            } else if (temp._seqRef != null)
                 return false;
             if (this._provenance != null) {
                 if (temp._provenance == null) return false;
-                else if (!(this._provenance.equals(temp._provenance))) 
-                    return false;
-            }
-            else if (temp._provenance != null)
+                if (this._provenance != temp._provenance) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._provenance.equals(temp._provenance)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
+                    }
+                }
+            } else if (temp._provenance != null)
                 return false;
             return true;
         }
@@ -207,11 +239,15 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_seqRef != null) {
+        if (_seqRef != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_seqRef)) {
            result = 37 * result + _seqRef.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_seqRef);
         }
-        if (_provenance != null) {
+        if (_provenance != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
            result = 37 * result + _provenance.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
         }
         
         return result;