Author: ronvoe122
Date: 2008-06-29 10:05:06-0700
New Revision: 10595
Added:
trunk/src/sql/upgrade/upgrade-0.22-fill_activity_type.sql
Modified:
trunk/src/conf/conf/build.xml
trunk/src/java/org/tigris/scarab/notification/ActivityType.java
trunk/src/java/org/tigris/scarab/om/Activity.java
trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java
trunk/src/schema/scarab-schema.xml
trunk/src/sql/scarab-sample-data.sql
Log:
ActivityType is now mandatory:
- Migrate activity_type to a reasonable value for all activities where it is null.
- Add an ActivityType 'other' for all activities which could not be mapped to an existing ActivityType.
(should only concern invalid activities)
- Clear the old unlocalized activity description for all activities with a meaningful ActivityType.
- Mark ActivityType as mandatory in scarab-schema.xml
- Switch the custom activity type used in import to ActivityType 'other'.
Modified: trunk/src/conf/conf/build.xml
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/conf/conf/build.xml?view=diff&rev=10595&p1=trunk/src/conf/conf/build.xml&p2=trunk/src/conf/conf/build.xml&r1=10594&r2=10595
==============================================================================
--- trunk/src/conf/conf/build.xml (original)
+++ trunk/src/conf/conf/build.xml 2008-06-29 10:05:06-0700
@@ -190,6 +190,7 @@
onerror="continue">
<classpath refid="classpath"/>
<transaction src="${sql.current.upgrade.dir}/upgrade-0.22-resize_id_prefix.sql"/>
+ <transaction src="${sql.current.upgrade.dir}/upgrade-0.22-fill_activity_type.sql"/>
</sql>
</target>
Modified: trunk/src/java/org/tigris/scarab/notification/ActivityType.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/notification/ActivityType.java?view=diff&rev=10595&p1=trunk/src/java/org/tigris/scarab/notification/ActivityType.java&p2=trunk/src/java/org/tigris/scarab/notification/ActivityType.java&r1=10594&r2=10595
==============================================================================
--- trunk/src/java/org/tigris/scarab/notification/ActivityType.java (original)
+++ trunk/src/java/org/tigris/scarab/notification/ActivityType.java 2008-06-29 10:05:06-0700
@@ -26,6 +26,7 @@
public static final ActivityType DEPENDENCY_CREATED = new ActivityType("dependency_created","ActivityTypeDependencyCreated");
public static final ActivityType DEPENDENCY_CHANGED = new ActivityType("dependency_changed","ActivityTypeDependencyChanged");
public static final ActivityType DEPENDENCY_DELETED = new ActivityType("dependency_deleted","ActivityTypeDependencyDeleted");
+ public static final ActivityType OTHER = new ActivityType("other","ActivityTypeOther");
private static Map types = new HashMap();
Modified: trunk/src/java/org/tigris/scarab/om/Activity.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Activity.java?view=diff&rev=10595&p1=trunk/src/java/org/tigris/scarab/om/Activity.java&p2=trunk/src/java/org/tigris/scarab/om/Activity.java&r1=10594&r2=10595
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Activity.java (original)
+++ trunk/src/java/org/tigris/scarab/om/Activity.java 2008-06-29 10:05:06-0700
@@ -192,12 +192,11 @@
{
String desc = null;
ActivityType type = ActivityType.getActivityType(this.getActivityType());
- // If the activity was stored before the field Type existed,
- // we fallback to the good old unlocalized description stored in the activity.
- if (type == null)
- return super.getDescription();
-
- if (ActivityType.URL_CHANGED.equals(type))
+ if (ActivityType.OTHER.equals(type))
+ {
+ desc = super.getDescription();
+ }
+ else if (ActivityType.URL_CHANGED.equals(type))
{
desc = this.getUrlChangedDescription(this.getOldValue(), this.getNewValue(), l10nTool);
}
Modified: trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java?view=diff&rev=10595&p1=trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java&p2=trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java&r1=10594&r2=10595
==============================================================================
--- trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java (original)
+++ trunk/src/java/org/tigris/scarab/util/xmlissues/ScarabIssues.java 2008-06-29 10:05:06-0700
@@ -169,10 +169,6 @@
private static final int CREATE_SAME_DB = 1;
private static final int CREATE_DIFFERENT_DB = 2;
private static final int UPDATE_SAME_DB = 3;
-
- /** ACTIVITY_TYPE should not be null.
- * use a special type that indicates activity came from import process. **/
- private static final String IMPORT_ACTIVITY_TYPE = "attribute imported";
private static Attribute nullAttribute = null;
@@ -1433,7 +1429,7 @@
activityOM.setIssue(issueOM);
activityOM.setAttribute(attributeOM);
- activityOM.setActivityType(IMPORT_ACTIVITY_TYPE);
+ activityOM.setActivityType(ActivityType.OTHER.getCode());
activityOM.setActivitySet(activitySetOM);
if (activity.getEndDate() != null)
{
Modified: trunk/src/schema/scarab-schema.xml
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/schema/scarab-schema.xml?view=diff&rev=10595&p1=trunk/src/schema/scarab-schema.xml&p2=trunk/src/schema/scarab-schema.xml&r1=10594&r2=10595
==============================================================================
--- trunk/src/schema/scarab-schema.xml (original)
+++ trunk/src/schema/scarab-schema.xml 2008-06-29 10:05:06-0700
@@ -19,7 +19,7 @@
<column name="DESCRIPTION" required="false" type="VARCHAR" size="255" description="System-generated description of modification (deprecated since b21, kept for backward compatibility)."/>
<column name="END_DATE" required="false" type="DATE" description="Date this Activity is no longer the current value of the Attribute."/>
<column name="ATTACHMENT_ID" required="false" type="BIGINT" description=" If an attachment is associated to the activity, store it here. Note: there is also attachments associated to the activitySet which 'contains' the activity. These are generally the result of multiple activity records being created via the modification of several attributes at one time."/>
- <column name="ACTIVITY_TYPE" required="false" type="VARCHAR" size="30" description="Type of activity, useful when generating the activity description."/>
+ <column name="ACTIVITY_TYPE" required="true" type="VARCHAR" size="30" description="Type of activity, useful when generating the activity description."/>
<foreign-key foreignTable="SCARAB_ISSUE">
<reference local="ISSUE_ID" foreign="ISSUE_ID"/>
</foreign-key>
Modified: trunk/src/sql/scarab-sample-data.sql
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/sql/scarab-sample-data.sql?view=diff&rev=10595&p1=trunk/src/sql/scarab-sample-data.sql&p2=trunk/src/sql/scarab-sample-data.sql&r1=10594&r2=10595
==============================================================================
--- trunk/src/sql/scarab-sample-data.sql (original)
+++ trunk/src/sql/scarab-sample-data.sql 2008-06-29 10:05:06-0700
@@ -4352,10 +4352,10 @@
insert into SCARAB_ISSUE(ISSUE_ID, MODULE_ID, TYPE_ID, ID_PREFIX, ID_COUNT, ID_DOMAIN,
CREATED_TRANS_ID, LAST_TRANS_ID)
values (1, 5, 1, 'PACS', 1, 'local', 1, 1);
-insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_VALUE, DESCRIPTION)
- values (1, 1, 11, 1, 'Docs are out of date.', 'Description set to Docs are out of Date');
-insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_OPTION_ID, DESCRIPTION)
- values (2, 1, 3, 1, 2, 'Status set to New');
+insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_VALUE, ACTIVITY_TYPE)
+ values (1, 1, 11, 1, 'Docs are out of date.', 'attribute_changed');
+insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_OPTION_ID, ACTIVITY_TYPE)
+ values (2, 1, 3, 1, 2, 'attribute_changed');
-- description
insert into SCARAB_ISSUE_ATTRIBUTE_VALUE(VALUE_ID, ISSUE_ID, ATTRIBUTE_ID, VALUE) values (1, 1, 1, 'Documents are not as current as they should be.');
@@ -4382,11 +4382,10 @@
insert into SCARAB_ISSUE(ISSUE_ID, MODULE_ID, TYPE_ID, ID_PREFIX, ID_COUNT, ID_DOMAIN,
CREATED_TRANS_ID, LAST_TRANS_ID)
values (2, 2, 1, 'PACD', 1, 'local', 2, 2);
-insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_VALUE, DESCRIPTION)
- values (3, 2, 11, 2, 'Dates display in long form instead of short form.',
- 'Issue 2 had Description set to ''Dates display in long form instead of short form''');
-insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_OPTION_ID, DESCRIPTION)
- values (4, 2, 3, 2, 2, 'status set to New');
+insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_VALUE, ACTIVITY_TYPE)
+ values (3, 2, 11, 2, 'Dates display in long form instead of short form.','attribute_changed');
+insert into SCARAB_ACTIVITY(ACTIVITY_ID, ISSUE_ID, ATTRIBUTE_ID, TRANSACTION_ID, NEW_OPTION_ID, ACTIVITY_TYPE)
+ values (4, 2, 3, 2, 2, 'attribute_changed');
-- description
insert into SCARAB_ISSUE_ATTRIBUTE_VALUE(VALUE_ID, ISSUE_ID, ATTRIBUTE_ID, VALUE) values (10, 2, 1, 'Items do not display correctly.');
Added: trunk/src/sql/upgrade/upgrade-0.22-fill_activity_type.sql
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/sql/upgrade/upgrade-0.22-fill_activity_type.sql?view=auto&rev=10595
==============================================================================
--- (empty file)
+++ trunk/src/sql/upgrade/upgrade-0.22-fill_activity_type.sql 2008-06-29 10:05:06-0700
@@ -0,0 +1,72 @@
+create table activity_temp as select activity_id from scarab_activity a
+where activity_type is null and depend_id is null and attachment_id is null and attribute_id = 0
+and exists( select * from scarab_transaction t where t.transaction_id = a.transaction_id and t.type_id = 3)
+and (select count(*) from scarab_issue i, scarab_activity a2 where a2.transaction_id = a.transaction_id and i.issue_id = a2.issue_id ) = 1;
+update scarab_activity a set activity_type = 'issue_moved' where activity_id in ( select activity_id from activity_temp );
+drop table activity_temp;
+
+create table activity_temp as select activity_id from scarab_activity a
+where activity_type is null and depend_id is null and attachment_id is null and attribute_id = 0
+and exists( select * from scarab_transaction t where t.transaction_id = a.transaction_id and t.type_id = 3)
+and (select count(*) from scarab_issue i, scarab_activity a2 where a2.transaction_id = a.transaction_id and i.issue_id = a2.issue_id ) = 2;
+update scarab_activity a set activity_type = 'issue_copied' where activity_id in ( select activity_id from activity_temp );
+drop table activity_temp;
+
+update scarab_activity a set activity_type = 'issue_created'
+where activity_type is null and depend_id is null and attachment_id is null and attribute_id = 0
+and exists( select * from scarab_transaction t where t.transaction_id = a.transaction_id and t.type_id = 1);
+
+update scarab_activity a set activity_type = 'url_deleted'
+where activity_type is null and length(a.old_value) > 0
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 3);
+
+update scarab_activity a set activity_type = 'url_added'
+where activity_type is null and (a.old_value is null or length(a.old_value)= 0 )
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 3);
+
+update scarab_activity a set activity_type = 'attachment_removed'
+where activity_type is null and length(a.old_value) > 0
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 1);
+
+update scarab_activity a set activity_type = 'attachment_created'
+where activity_type is null and (a.old_value is null or length(a.old_value)= 0 )
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 1);
+
+update scarab_activity a set a.activity_type = 'comment_changed'
+where a.activity_type is null and length(a.old_value) > 0
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 2);
+
+update scarab_activity a set a.activity_type = 'comment_added'
+where a.activity_type is null and (a.old_value is null or length(a.old_value) = 0)
+and exists( select * from scarab_attachment t where t.attachment_id = a.attachment_id and t.attachment_type_id = 2);
+
+update scarab_activity set activity_type = 'dependency_changed'
+where activity_type is null and depend_id is not null and new_value is not null and old_value is not null;
+
+update scarab_activity set activity_type = 'dependency_deleted'
+where activity_type is null and depend_id is not null and new_value is null and old_value is not null;
+
+update scarab_activity set activity_type = 'dependency_created'
+where activity_type is null and depend_id is not null and old_value is null;
+
+update scarab_activity set activity_type = 'user_attribute_changed'
+where activity_type is null and attribute_id <> 0 and (
+old_user_id is not null or new_user_id is not null
+);
+
+update scarab_activity set activity_type = 'attribute_changed'
+where activity_type is null and attribute_id <> 0 and old_user_id is null and new_user_id is null and (
+ ( old_numeric_value is not null or new_numeric_value is not null )
+ or ( old_option_id is not null or new_option_id is not null )
+ or ( old_value is not null or new_value is not null )
+);
+
+update scarab_activity set activity_type = 'other' where activity_type is null;
+
+update scarab_activity set activity_type = 'other' where activity_type = 'attribute imported';
+
+update scarab_activity set description = null where activity_type <> 'other';
+
+alter table scarab_activity modify column
+ activity_type varchar(30) not null
+;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.