Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ComplextActivityStrategy.java =================================================================== diff -u -r35d5350252748108494c7cb4bfc2e7d5f2271cba -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ComplextActivityStrategy.java (.../ComplextActivityStrategy.java) (revision 35d5350252748108494c7cb4bfc2e7d5f2271cba) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ComplextActivityStrategy.java (.../ComplextActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -34,7 +34,7 @@ * polymorphism caculation regarding different type of activity. * * @author Jacky Fang 2005-2-23 - * + * @version 1.1 */ public abstract class ComplextActivityStrategy implements Serializable { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.learningdesign.strategy; + +import java.util.ArrayList; + +import org.lamsfoundation.lams.learningdesign.Activity; + + +/** + * Activity strategy that deal with the calculation of all sub gate activities. + * It is abstract calculation layer for all concrete gate activities. + * + * @author Jacky Fang + * @since 2005-4-6 + * @version 1.1 + * + */ +public abstract class GateActivityStrategy extends SimpleActivityStrategy +{ + + + //--------------------------------------------------------------------- + // Overidden methods + //--------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + */ + protected abstract void setUpContributionType(Activity activity, ArrayList contributionTypes); + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java =================================================================== diff -u -rcea596d200043c5589e5501fd9d65147091f8014 -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java (.../GroupingActivityStrategy.java) (revision cea596d200043c5589e5501fd9d65147091f8014) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java (.../GroupingActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -1,9 +1,25 @@ -/* - * Created on Mar 17, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; @@ -13,23 +29,27 @@ import org.lamsfoundation.lams.learningdesign.GroupingActivity; /** + * Activity strategy that deals with the calculation specific to tool activity. + * The major part of this strategy will be overiding the methods that defined + * in the abstract level. + * + * @author Jacky Fang * @author Minhas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * @version 1.1 */ public class GroupingActivityStrategy extends SimpleActivityStrategy { - /** - * (non-Javadoc) - * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#getContributionType(org.lamsfoundation.lams.learningdesign.Activity) - */ - public Integer[] getContributionType(Activity activity) { - ArrayList contributionType = new ArrayList(); + //--------------------------------------------------------------------- + // Overriden methods + //--------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + */ + protected void setUpContributionType(Activity activity, ArrayList contributionTypes) + { GroupingActivity groupingActivity =(GroupingActivity)activity; if(groupingActivity.getCreateGrouping().getGroupingTypeId()== Grouping.CHOSEN_GROUPING_TYPE) - contributionType.add(new Integer(CHOSEN_GROUPING)); - return (Integer[])contributionType.toArray(new Integer[contributionType.size()]); - } + contributionTypes.add(CHOSEN_GROUPING); + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/OptionsActivityStrategy.java =================================================================== diff -u -r35d5350252748108494c7cb4bfc2e7d5f2271cba -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/OptionsActivityStrategy.java (.../OptionsActivityStrategy.java) (revision 35d5350252748108494c7cb4bfc2e7d5f2271cba) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/OptionsActivityStrategy.java (.../OptionsActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -29,7 +29,7 @@ * * Progress calculation strategy for options activity. * @author Jacky Fang 2005-2-24 - * + * @version 1.1 */ public class OptionsActivityStrategy extends ComplextActivityStrategy { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ParallelActivityStrategy.java =================================================================== diff -u -r35d5350252748108494c7cb4bfc2e7d5f2271cba -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ParallelActivityStrategy.java (.../ParallelActivityStrategy.java) (revision 35d5350252748108494c7cb4bfc2e7d5f2271cba) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ParallelActivityStrategy.java (.../ParallelActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -30,7 +30,7 @@ * The progress calculation strategy for parallel activity. * * @author Jacky Fang 2005-2-24 - * + * @version 1.1 */ public class ParallelActivityStrategy extends ComplextActivityStrategy { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java =================================================================== diff -u -rcea596d200043c5589e5501fd9d65147091f8014 -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision cea596d200043c5589e5501fd9d65147091f8014) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -1,30 +1,49 @@ /* - * Created on Mar 17, 2005 + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + *This program is free software; you can redistribute it and/or modify + *it under the terms of the GNU General Public License as published by + *the Free Software Foundation; either version 2 of the License, or + *(at your option) any later version. + * + *This program is distributed in the hope that it will be useful, + *but WITHOUT ANY WARRANTY; without even the implied warranty of + *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *GNU General Public License for more details. + * + *You should have received a copy of the GNU General Public License + *along with this program; if not, write to the Free Software + *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt */ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; import org.lamsfoundation.lams.learningdesign.Activity; + /** + * Activity strategy that deals with the calculation specific to gate activity. + * The major part of this strategy will be overiding the methods that defined + * in the abstract level. + * + * @author Jacky Fang * @author Minhas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * @version 1.1 */ -public class PermissionGateActivityStrategy extends SimpleActivityStrategy { +public class PermissionGateActivityStrategy extends GateActivityStrategy { + + //--------------------------------------------------------------------- + // Overriden methods + //--------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + */ + protected void setUpContributionType(Activity activity, ArrayList contributionTypes) + { + contributionTypes.add(PERMISSION_GATE); + } - /** - * (non-Javadoc) - * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#getContributionType(org.lamsfoundation.lams.learningdesign.Activity) - */ - public Integer[] getContributionType(Activity activity) { - ArrayList contributionType = new ArrayList(); - contributionType.add(new Integer(PERMISSION)); - return (Integer[])contributionType.toArray(new Integer[contributionType.size()]); - } - } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java =================================================================== diff -u -r35d5350252748108494c7cb4bfc2e7d5f2271cba -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java (.../SequenceActivityStrategy.java) (revision 35d5350252748108494c7cb4bfc2e7d5f2271cba) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java (.../SequenceActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -34,7 +34,7 @@ * Progress calculation strategy for sequence activity. * * @author Jacky Fang 2005-2-24 - * + * @version 1.1 */ public class SequenceActivityStrategy extends ComplextActivityStrategy { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java =================================================================== diff -u -r51d9b7fc27684748ffcd792f6ce6e4f23ef6ce12 -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java (.../SimpleActivityStrategy.java) (revision 51d9b7fc27684748ffcd792f6ce6e4f23ef6ce12) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java (.../SimpleActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -1,31 +1,84 @@ -/* - * Created on Mar 17, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + package org.lamsfoundation.lams.learningdesign.strategy; import java.io.Serializable; +import java.util.ArrayList; import org.lamsfoundation.lams.learningdesign.Activity; - - - /** + * Activity strategy that deals with the calculation for all simple activity + * strategies. It is the abstraction of all sub-activity strategies. Template + * method, where possible, should be created to avoid as much duplicate + * code as possible. Abstract methods sit at this level is designed to be + * overidden by sub simple activities to polymorphically achieve the behavior + * specific to particular conrete activity. + * + * @author Jacky Fang * @author Minhas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * @version 1.1 */ -public abstract class SimpleActivityStrategy implements Serializable { - - public static final int MODERATION = 1; - public static final int DEFINE_LATER = 2; - public static final int PERMISSION = 3; - public static final int CHOSEN_GROUPING = 4; - public static final int CONTRIBUTION = 5; - - public abstract Integer[] getContributionType(Activity activity); -} +public abstract class SimpleActivityStrategy implements Serializable +{ + //--------------------------------------------------------------------- + // Class level constants - Contribution types + //--------------------------------------------------------------------- + public static final Integer MODERATION = new Integer(1); + public static final Integer DEFINE_LATER = new Integer(2); + public static final Integer PERMISSION_GATE = new Integer(3); + public static final Integer SYNC_GATE = new Integer(4); + public static final Integer SCHEDULE_GATE = new Integer(5); + public static final Integer CHOSEN_GROUPING = new Integer(6); + public static final Integer CONTRIBUTION = new Integer(7); + + //--------------------------------------------------------------------- + // Template methods + //--------------------------------------------------------------------- + /** + * Template method that get contribute type according its sub concrete + * activity. + * @param activity the activity that has contribute type. + * @return an array of contribute types. + */ + public Integer[] getContributionType(Activity activity) + { + ArrayList contributionTypes = new ArrayList(); + + //abstract method to polymorphically setup contribute type. + setUpContributionType(activity,contributionTypes); + + return (Integer[])contributionTypes.toArray(new Integer[contributionTypes.size()]); + } + + //--------------------------------------------------------------------- + // Abstract methods + //--------------------------------------------------------------------- + /** + * Setup contribution type polymorphically according its activity type. + * @param activity the activity that we need to setup contribution type + * for. + * @param contributionTypes the list that holds contribution types. + */ + protected abstract void setUpContributionType(Activity activity,ArrayList contributionTypes); +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java =================================================================== diff -u -r950ffe777776ecffa7f99e02b9674f0c71d382ab -r8d2dabc317bc680cb4fc2fff6c598a9a453bec69 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java (.../ToolActivityStrategy.java) (revision 950ffe777776ecffa7f99e02b9674f0c71d382ab) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java (.../ToolActivityStrategy.java) (revision 8d2dabc317bc680cb4fc2fff6c598a9a453bec69) @@ -1,9 +1,25 @@ -/* - * Created on Mar 17, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; @@ -12,26 +28,32 @@ import org.lamsfoundation.lams.learningdesign.ToolActivity; /** + * Activity strategy that deals with the calculation specific to tool activity. + * The major part of this strategy will be overiding the methods that defined + * in the abstract level. + * + * @author Jacky Fang * @author Minhas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * @version 1.1 */ public class ToolActivityStrategy extends SimpleActivityStrategy { - - public Integer[] getContributionType(Activity activity) { - ArrayList contributionType = new ArrayList(); - + //--------------------------------------------------------------------- + // Overriden methods + //--------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity) + */ + protected void setUpContributionType(Activity activity, + ArrayList contributionTypes) + { ToolActivity toolActivity = (ToolActivity)activity; if(toolActivity.getTool().getSupportsModeration()) - contributionType.add(new Integer(MODERATION)); + contributionTypes.add(MODERATION); if(toolActivity.getTool().getSupportsContribute()) - contributionType.add(new Integer(CONTRIBUTION)); + contributionTypes.add(CONTRIBUTION); if(toolActivity.getDefineLater().booleanValue()) - contributionType.add(new Integer(DEFINE_LATER)); - - return (Integer[])contributionType.toArray(new Integer[contributionType.size()]); - } + contributionTypes.add(DEFINE_LATER); + } }