Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-07-13 18:32:43 -0400
committerRyan D. Brooks2011-07-13 18:32:43 -0400
commit4b5fea671657690dcb4fef8ebf1dba993319b4d9 (patch)
treedc92f4aa827979841b122eed5ab07fce68186ef5 /plugins/org.eclipse.osee.framework.core.datastore
parent5e11404d5ec635fdac5ead50ca8d30b648a09ca8 (diff)
downloadorg.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.tar.gz
org.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.tar.xz
org.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.zip
bug[ats_4B08V]: Fix allowed attribute types per branch
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.datastore')
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java33
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml7
2 files changed, 21 insertions, 19 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
index 53e2ac3f5b..ca47a0a288 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
@@ -18,13 +18,14 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.BranchToken;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.datastore.internal.Activator;
import org.eclipse.osee.framework.core.enums.StorageState;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.exception.OseeInvalidInheritanceException;
import org.eclipse.osee.framework.core.model.AbstractOseeType;
-import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
@@ -61,9 +62,9 @@ public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<Artif
"delete from osee_artifact_type_inheritance where art_type_id = ?";
private static final String SELECT_ARTIFACT_TYPE_ATTRIBUTES =
- "select * from osee_artifact_type_attributes order by art_type_id, branch_id, attr_type_id";
+ "select * from osee_artifact_type_attributes order by art_type_id, branch_guid, attr_type_id";
private static final String INSERT_ARTIFACT_TYPE_ATTRIBUTES =
- "insert into osee_artifact_type_attributes (art_type_id, attr_type_id, branch_id) VALUES (?, ?, ?)";
+ "insert into osee_artifact_type_attributes (art_type_id, attr_type_id, branch_guid) VALUES (?, ?, ?)";
private static final String DELETE_ARTIFACT_TYPE_ATTRIBUTES =
"delete from osee_artifact_type_attributes where art_type_id = ?";
@@ -156,20 +157,24 @@ public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<Artif
}
private void loadAllTypeValidity(ArtifactTypeCache cache) throws OseeCoreException {
- CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>> typeValidity =
- new CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>>();
+ CompositeKeyHashMap<ArtifactType, IOseeBranch, Collection<AttributeType>> typeValidity =
+ new CompositeKeyHashMap<ArtifactType, IOseeBranch, Collection<AttributeType>>();
IOseeStatement chStmt = getDatabaseService().getStatement();
try {
chStmt.runPreparedQuery(2000, SELECT_ARTIFACT_TYPE_ATTRIBUTES);
while (chStmt.next()) {
try {
ArtifactType artifactType = cache.getById(chStmt.getInt("art_type_id"));
- Branch branch = branchCache.getById(chStmt.getInt("branch_id"));
+ String branchGuid = chStmt.getString("branch_guid");
+ IOseeBranch branchToken = branchCache.getByGuid(branchGuid);
+ if (branchToken == null) {
+ branchToken = new BranchToken(branchGuid, branchGuid);
+ }
AttributeType attributeType = attributeCache.getById(chStmt.getInt("attr_type_id"));
- Collection<AttributeType> attributes = typeValidity.get(artifactType, branch);
+ Collection<AttributeType> attributes = typeValidity.get(artifactType, branchToken);
if (attributes == null) {
attributes = new HashSet<AttributeType>();
- typeValidity.put(artifactType, branch, attributes);
+ typeValidity.put(artifactType, branchToken, attributes);
}
attributes.add(attributeType);
} catch (OseeCoreException ex) {
@@ -179,9 +184,9 @@ public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<Artif
} finally {
chStmt.close();
}
- for (Entry<Pair<ArtifactType, Branch>, Collection<AttributeType>> entry : typeValidity.entrySet()) {
+ for (Entry<Pair<ArtifactType, IOseeBranch>, Collection<AttributeType>> entry : typeValidity.entrySet()) {
try {
- Pair<ArtifactType, Branch> key = entry.getKey();
+ Pair<ArtifactType, IOseeBranch> key = entry.getKey();
key.getFirst().setAttributeTypes(entry.getValue(), key.getSecond());
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
@@ -253,12 +258,12 @@ public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<Artif
List<Object[]> deleteData = new ArrayList<Object[]>();
for (ArtifactType artifactType : types) {
deleteData.add(new Object[] {artifactType.getId()});
- Map<Branch, Collection<AttributeType>> entries = artifactType.getLocalAttributeTypes();
+ Map<IOseeBranch, Collection<AttributeType>> entries = artifactType.getLocalAttributeTypes();
if (entries != null) {
- for (Entry<Branch, Collection<AttributeType>> entry : entries.entrySet()) {
- Branch branch = entry.getKey();
+ for (Entry<IOseeBranch, Collection<AttributeType>> entry : entries.entrySet()) {
+ IOseeBranch branch = entry.getKey();
for (AttributeType attributeType : entry.getValue()) {
- insertData.add(new Object[] {artifactType.getId(), attributeType.getId(), branch.getId()});
+ insertData.add(new Object[] {artifactType.getId(), attributeType.getId(), branch.getGuid()});
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
index 4cf5db7f2c..af4ecebf3b 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
+++ b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
@@ -96,18 +96,15 @@
<Table name="OSEE_ARTIFACT_TYPE_ATTRIBUTES" schema="OSEE" tablespace="osee_data">
<Column id="ART_TYPE_ID" defaultValue="not null" type="smallint" />
+ <Column id="BRANCH_GUID" defaultValue="not null" limits="28" type="VARCHAR" />
<Column id="ATTR_TYPE_ID" defaultValue="not null" type="smallint" />
- <Column id="BRANCH_ID" type="INTEGER" defaultValue="not null" />
- <Constraint schema="OSEE" id="OSEE_ARTIFACT_TYPE_ATTRIB_PK" type="PRIMARY KEY" appliesTo="ART_TYPE_ID, ATTR_TYPE_ID, BRANCH_ID" />
+ <Constraint schema="OSEE" id="OSEE_ARTIFACT_TYPE_ATTRIB_PK" type="PRIMARY KEY" appliesTo="ART_TYPE_ID, ATTR_TYPE_ID, BRANCH_GUID" />
<Constraint schema="OSEE" id="OSEE_ARTIFACT_TYPE_ATTRIB_FK1" type="FOREIGN KEY" appliesTo="ATTR_TYPE_ID" deferrable="true">
<References schema="OSEE" table="OSEE_ATTRIBUTE_TYPE" column="ATTR_TYPE_ID" />
</Constraint>
<Constraint schema="OSEE" id="OSEE_ARTIFACT_TYPE_ATTRIB_FK2" type="FOREIGN KEY" appliesTo="ART_TYPE_ID" deferrable="true">
<References schema="OSEE" table="OSEE_ARTIFACT_TYPE" column="ART_TYPE_ID" />
</Constraint>
- <Constraint schema="OSEE" id="OSEE_ARTIFACT_TYPE_ATTRIB_FK3" type="FOREIGN KEY" appliesTo="BRANCH_ID" deferrable="true">
- <References schema="OSEE" table="OSEE_BRANCH" column="BRANCH_ID" />
- </Constraint>
</Table>
<Table name="OSEE_ATTRIBUTE" schema="OSEE" tablespace="osee_data">

Back to the top