sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Attachment.java
index 7b6fcc4..b7c741f 100644 (file)
@@ -95,30 +95,77 @@ implements java.io.Serializable
         if (obj instanceof Attachment) {\r
         \r
             Attachment temp = (Attachment)obj;\r
+            boolean thcycle;\r
+            boolean tmcycle;\r
             if (this._compressed != temp._compressed)\r
                 return false;\r
             if (this._has_compressed != temp._has_compressed)\r
                 return false;\r
             if (this._type != null) {\r
                 if (temp._type == null) return false;\r
-                else if (!(this._type.equals(temp._type))) \r
-                    return false;\r
-            }\r
-            else if (temp._type != null)\r
+                if (this._type != temp._type) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._type.equals(temp._type)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._type);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._type);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);\r
+                    }\r
+                }\r
+            } else if (temp._type != null)\r
                 return false;\r
             if (this._objectref != null) {\r
                 if (temp._objectref == null) return false;\r
-                else if (!(this._objectref.equals(temp._objectref))) \r
-                    return false;\r
-            }\r
-            else if (temp._objectref != null)\r
+                if (this._objectref != temp._objectref) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._objectref);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._objectref);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._objectref.equals(temp._objectref)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref);\r
+                    }\r
+                }\r
+            } else if (temp._objectref != null)\r
                 return false;\r
             if (this._id != null) {\r
                 if (temp._id == null) return false;\r
-                else if (!(this._id.equals(temp._id))) \r
-                    return false;\r
-            }\r
-            else if (temp._id != null)\r
+                if (this._id != temp._id) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._id.equals(temp._id)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
+                    }\r
+                }\r
+            } else if (temp._id != null)\r
                 return false;\r
             return true;\r
         }\r
@@ -201,14 +248,20 @@ implements java.io.Serializable
         \r
         long tmp;\r
         result = 37 * result + (_compressed?0:1);\r
-        if (_type != null) {\r
+        if (_type != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_type)) {\r
            result = 37 * result + _type.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_type);\r
         }\r
-        if (_objectref != null) {\r
+        if (_objectref != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_objectref)) {\r
            result = 37 * result + _objectref.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_objectref);\r
         }\r
-        if (_id != null) {\r
+        if (_id != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_id)) {\r
            result = 37 * result + _id.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_id);\r
         }\r
         \r
         return result;\r