/*
 *  Activity.java
 * 
 *  RELOAD Editor - An IMS Metadata, Content Packaging and Learning Design tool 
 *  with ADAPTATION AT ACTIVITY LEVEL
 *
 *  Copyright (c) 2006 Miguel Fernandez Lores
 *
 *  Technical Contact:
 *  Miguel Fern�ndez Lores
 *  e-mail: tucias@hotmail.com
 *
 */

package uk.ac.reload.editor.scormadaptive.rules.syntax;

import java.util.ArrayList;

/**
 * Class that contains everything relating to the activities showed 
 * in _ruleActionList, that can be organizations, activitys or 
 * user created combining them
 *
 * @author  lagar
 * @version 0.2 
 */
public class Activity {
    
    public final static int ORGANIZATION = 0;
    public final static int ACTWITHCHILD = 1;
    public final static int ACTCHILD     = 2;
    public final static int LOGICALEXP   = 3;
    
    public final static String IMPLICA = "=>";
    
    private String sTitle;
    
    private String sIdentifier;
    
    //Cuando es una actividad creada por nosotros
    //mezclando varias <=> iType==LOGICALEXP
    private ArrayList<LogicalExpression> oLEArray;
    
    private int iType;
    
    /** 
     * Creates a new instance of Activity 
     */
    public Activity(String title, String ID, int tipo) {
        sTitle = title;
        sIdentifier = ID;
        iType = tipo;
        oLEArray = null;
    }
    
    public Activity(String nameToShow) {
        sIdentifier = nameToShow;
        sTitle = nameToShow;
//        sTitle = null;
        iType = LOGICALEXP;
        oLEArray = null;
    }
    
    public String getTitle() {
        return sTitle;
    }
    
    public String getID() {
        return sIdentifier;
    }
    
    public String getToShow() {
        if (iType == LOGICALEXP) return sIdentifier;
        else return (sTitle);
//        else return (sIdentifier + IMPLICA + sTitle);
    }
    
    public void addLE(LogicalExpression oLE){
        if (oLEArray == null) oLEArray = new ArrayList<LogicalExpression>();
        oLEArray.add(oLE);
    }
    
    public LogicalExpression getLE(int iIndex){
        return oLEArray.get(iIndex);
    }
    
    public ArrayList<LogicalExpression> getLEArray() {
        return oLEArray;
    }
    
    public int getType (){
        return iType;
    }
    
    public int getLEsize(){
        return oLEArray.size();
    }
    
    public int getActImplicadas(){
        int iActs = 0;
        if (oLEArray != null) {
            for (int i = 0; i< oLEArray.size(); i++){
                iActs += oLEArray.get(i).getActImplicadas();
            }
        }
        else iActs = 1;
        return iActs;
    }
}
