Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-01-20 18:07:37 +0000
committerdonald.g.dunne2017-03-21 02:08:09 +0000
commit697db10e1f1bc82bf324b25c13f57789d9a96639 (patch)
tree46adcd33ce8be7c15cfccec9859d1d8c6af7089d /plugins/org.eclipse.osee.orcs.db
parentd662326e40161ea9d2cedfcbb8fa3b78f46c91c1 (diff)
downloadorg.eclipse.osee-697db10e1f1bc82bf324b25c13f57789d9a96639.tar.gz
org.eclipse.osee-697db10e1f1bc82bf324b25c13f57789d9a96639.tar.xz
org.eclipse.osee-697db10e1f1bc82bf324b25c13f57789d9a96639.zip
refactor: Support Id comparison with Orcs objects
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db')
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java30
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java45
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java38
6 files changed, 33 insertions, 142 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
index 3fde4dbfd8..700ce86c41 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
@@ -97,9 +97,8 @@ public class DataFactoryImpl implements DataFactory {
VersionData version = objectFactory.createDefaultVersionData();
version.setBranch(parent.getVersion().getBranch());
ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
- Integer attributeid = RelationalConstants.DEFAULT_ITEM_ID;
- return objectFactory.createAttributeData(version, attributeid, attributeType, modType, parent.getLocalId(),
- ApplicabilityId.BASE);
+ return objectFactory.createAttributeData(version, idFactory.getNextAttributeId(), attributeType, modType,
+ parent.getLocalId(), ApplicabilityId.BASE);
}
@Override
@@ -123,9 +122,8 @@ public class DataFactoryImpl implements DataFactory {
VersionData version = objectFactory.createDefaultVersionData();
version.setBranch(branch);
ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
- Integer relationId = RelationalConstants.DEFAULT_ITEM_ID;
- return objectFactory.createRelationData(version, relationId, relationType, modType, aArt.getLocalId(),
- bArt.getLocalId(), rationale, ApplicabilityId.BASE);
+ return objectFactory.createRelationData(version, idFactory.getNextRelationId(), relationType, modType,
+ aArt.getLocalId(), bArt.getLocalId(), rationale, ApplicabilityId.BASE);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
index df96ae07f5..28b031183e 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
@@ -37,33 +37,14 @@ public class ArtifactDataImpl extends OrcsVersionedObjectImpl implements Artifac
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + (guid == null ? 0 : guid.hashCode());
- return result;
- }
-
- @Override
public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- ArtifactDataImpl other = (ArtifactDataImpl) obj;
- if (guid == null) {
- if (other.guid != null) {
- return false;
- }
- } else if (!guid.equals(other.guid)) {
- return false;
+ if (obj instanceof ArtifactDataImpl) {
+ return guid.equals(((ArtifactDataImpl) obj).guid);
}
- return true;
+ return false;
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
index aa7abd327c..c0c729271b 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
@@ -50,37 +50,15 @@ public class AttributeDataImpl extends OrcsVersionedObjectImpl implements Attrib
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + artifactId;
- result = prime * result + (proxy == null ? 0 : proxy.hashCode());
- return result;
- }
-
- @Override
public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- AttributeDataImpl other = (AttributeDataImpl) obj;
- if (artifactId != other.artifactId) {
- return false;
- }
- if (proxy == null) {
- if (other.proxy != null) {
- return false;
- }
- } else if (!proxy.equals(other.proxy)) {
- return false;
+ if (obj instanceof AttributeDataImpl) {
+ AttributeDataImpl other = (AttributeDataImpl) obj;
+ return Integer.valueOf(other.artifactId).equals(artifactId) && proxy.equals(other.proxy);
}
- return true;
+ return false;
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
index e220af5cfc..09d3815552 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
@@ -36,33 +36,6 @@ public abstract class OrcsObjectImpl<T extends Number> implements HasLocalId<T>
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + localId.intValue();
- return result;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- OrcsObjectImpl other = (OrcsObjectImpl) obj;
- if (localId.equals(other.localId)) {
- return false;
- }
- return true;
- }
-
- @Override
public String toString() {
return "OrcsObject [localId=" + localId + "]";
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java
index 770f355ed5..5e0b12d846 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java
@@ -14,6 +14,7 @@ import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.RelationalConstants;
import org.eclipse.osee.framework.core.enums.DirtyState;
import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.VersionData;
@@ -145,39 +146,37 @@ public abstract class OrcsVersionedObjectImpl extends OrcsObjectImpl<Integer> im
@Override
public int hashCode() {
final int prime = 31;
- int result = super.hashCode();
+ int result = getLocalId().hashCode();
result = prime * result + (baseModType == null ? 0 : baseModType.hashCode());
- result = prime * result + (int) (baseTypeUuid ^ baseTypeUuid >>> 32);
+ result = prime * result + Long.hashCode(baseTypeUuid);
result = prime * result + (version == null ? 0 : version.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- OrcsVersionedObjectImpl other = (OrcsVersionedObjectImpl) obj;
- if (baseModType != other.baseModType) {
- return false;
- }
- if (baseTypeUuid != other.baseTypeUuid) {
- return false;
- }
- if (version == null) {
- if (other.version != null) {
+ if (obj instanceof OrcsVersionedObjectImpl) {
+ OrcsVersionedObjectImpl other = (OrcsVersionedObjectImpl) obj;
+ if (!getLocalId().equals(other.getLocalId())) {
return false;
}
- } else if (!version.equals(other.version)) {
- return false;
+ if (baseModType != other.baseModType) {
+ return false;
+ }
+ if (baseTypeUuid != other.baseTypeUuid) {
+ return false;
+ }
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ return version.equals(other.version);
+ }
+ return true;
+ } else if (obj instanceof Id) {
+ return ((Id) obj).getId().equals(getLocalId().longValue());
}
- return true;
+ return false;
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
index e88fb313f9..029fe14889 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
@@ -73,44 +73,6 @@ public class RelationDataImpl extends OrcsVersionedObjectImpl implements Relatio
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + artIdA;
- result = prime * result + artIdB;
- result = prime * result + (rationale == null ? 0 : rationale.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RelationDataImpl other = (RelationDataImpl) obj;
- if (artIdA != other.artIdA) {
- return false;
- }
- if (artIdB != other.artIdB) {
- return false;
- }
- if (rationale == null) {
- if (other.rationale != null) {
- return false;
- }
- } else if (!rationale.equals(other.rationale)) {
- return false;
- }
- return true;
- }
-
- @Override
public String toString() {
return "RelationData [artIdA=" + artIdA + ", artIdB=" + artIdB + ", rationale=" + rationale + " " + super.toString() + "]";
}

Back to the top