sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / VamsasDocument.java
index 1114663..10ee854 100644 (file)
@@ -210,47 +210,139 @@ implements java.io.Serializable
         if (obj instanceof VamsasDocument) {
         
             VamsasDocument temp = (VamsasDocument)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._version != null) {
                 if (temp._version == null) return false;
-                else if (!(this._version.equals(temp._version))) 
-                    return false;
-            }
-            else if (temp._version != null)
+                if (this._version != temp._version) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._version);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._version);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._version); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._version.equals(temp._version)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
+                    }
+                }
+            } else if (temp._version != null)
                 return false;
             if (this._lockFile != null) {
                 if (temp._lockFile == null) return false;
-                else if (!(this._lockFile.equals(temp._lockFile))) 
-                    return false;
-            }
-            else if (temp._lockFile != null)
+                if (this._lockFile != temp._lockFile) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._lockFile);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._lockFile);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._lockFile.equals(temp._lockFile)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile);
+                    }
+                }
+            } else if (temp._lockFile != 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;
             if (this._VAMSASList != null) {
                 if (temp._VAMSASList == null) return false;
-                else if (!(this._VAMSASList.equals(temp._VAMSASList))) 
-                    return false;
-            }
-            else if (temp._VAMSASList != null)
+                if (this._VAMSASList != temp._VAMSASList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._VAMSASList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._VAMSASList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._VAMSASList.equals(temp._VAMSASList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList);
+                    }
+                }
+            } else if (temp._VAMSASList != null)
                 return false;
             if (this._applicationDataList != null) {
                 if (temp._applicationDataList == null) return false;
-                else if (!(this._applicationDataList.equals(temp._applicationDataList))) 
-                    return false;
-            }
-            else if (temp._applicationDataList != null)
+                if (this._applicationDataList != temp._applicationDataList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._applicationDataList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._applicationDataList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._applicationDataList.equals(temp._applicationDataList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList);
+                    }
+                }
+            } else if (temp._applicationDataList != null)
                 return false;
             if (this._attachmentList != null) {
                 if (temp._attachmentList == null) return false;
-                else if (!(this._attachmentList.equals(temp._attachmentList))) 
-                    return false;
-            }
-            else if (temp._attachmentList != null)
+                if (this._attachmentList != temp._attachmentList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._attachmentList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._attachmentList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._attachmentList.equals(temp._attachmentList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList);
+                    }
+                }
+            } else if (temp._attachmentList != null)
                 return false;
             return true;
         }
@@ -474,23 +566,35 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_version != null) {
+        if (_version != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_version)) {
            result = 37 * result + _version.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_version);
         }
-        if (_lockFile != null) {
+        if (_lockFile != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_lockFile)) {
            result = 37 * result + _lockFile.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_lockFile);
         }
-        if (_provenance != null) {
+        if (_provenance != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
            result = 37 * result + _provenance.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
         }
-        if (_VAMSASList != null) {
+        if (_VAMSASList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_VAMSASList)) {
            result = 37 * result + _VAMSASList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_VAMSASList);
         }
-        if (_applicationDataList != null) {
+        if (_applicationDataList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_applicationDataList)) {
            result = 37 * result + _applicationDataList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_applicationDataList);
         }
-        if (_attachmentList != null) {
+        if (_attachmentList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_attachmentList)) {
            result = 37 * result + _attachmentList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_attachmentList);
         }
         
         return result;