Hi Jan,
Thank you for the response.
The datatable values are not retrieved from the database , but from the session.
So if i click twice on display button on my xhtml, the data table is loaded with values. Else it just shows the loading image.
Also this table is inside a modal panel
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>Home</title>
<link rel="shortcut icon" type="image/x-icon" href="Images/favicon.ico" />
<link href="Styles/theme_css.css" rel="stylesheet" type="text/css" />
<script src="JavaScript/NumberformatInsertion.js" type="text/javascript"></script>
<script src="JavaScript/numericCheck.js" type="text/javascript"></script>
<style>
.userpanel .rich-panel-body{padding:0px;}
.tableStyle td{
vertical-align: middle;
}
</style>
</head>
<body>
<ui:insert>
<ui:include src="header.xhtml"/>
<ui:include src="menu.xhtml"/>
</ui:insert>
<br/>
<h:form id="userToSectionForm">
<rich:panel style="height: 650px;overflow: auto;">
<f:facet name="header">
<h:outputText value="#{ProgramAction.labelProgramName} Setup - Session and Items"/>
</f:facet>
<rich:spacer height="5px"/>
<center>
<table width="100%">
<tr>
<td width="25%">
</td>
<td width="25%" align="left">
<h:commandButton value="Back" title="Back" action="#{ProgramAction.sectionPrev()}" style="text-align: left" id="sectionPrev"/>
</td>
<td width="25%" align="right">
<h:commandButton value="Next" title="Next" action="#{ProgramAction.sectionNext()}" style="text-align: left" id="sectionNext"/>
</td>
<td width="25%"></td>
</tr>
</table>
<fieldset>
<rich:panel id="sessionWarningMessage" rendered="#{ProgramAction.enableMsgPanel}" styleClass="#{ProgramAction.msgPanelStyle}">
<h:outputLabel value="#{ProgramAction.warningMsg}" styleClass="#{ProgramAction.msgLabelStyle}"/>
</rich:panel>
<table width="100%" cellspacing="0" border="0" class="tableStyle">
<rich:spacer height="20px"/>
<tr>
<td colspan="7" align="center">
</td>
</tr>
<tr>
<td width="5%" align="right">
<h:outputText value="#{ProgramAction.labelSectionName}" styleClass="input"/>
<span class="required">*</span>
</td>
<td width="12%" align="left">
<h:inputText value="#{ProgramAction.sectionName}" id="totsect" styleClass="input" />
</td>
<td width="10%" align="right">
<h:outputText value="Direction" styleClass="input"/>
<span class="required">*</span>
</td>
<td width="33%" align="left">
<h:inputTextarea value="#{ProgramAction.direction}" id="direction" styleClass="formBox" style="width:100%;" />
</td>
<td width="13%" align="right">
<h:outputText value="Number of Items" styleClass="input" />
<span class="required">*</span>
</td>
<td width="10%" align="left" colspan="2">
<h:inputText value="#{ProgramAction.totalItems}" id="totalItems" onkeypress="return checkNumaric(event,'userToSectionForm:totalItems')" styleClass="input" style="width: 40px;" />
</td>
<td width="5%" align="left">
<h:commandButton action="#{ProgramAction.addSectionToProgram()}" id="addSec" value="Add"/>
</td>
</tr>
</table>
<br/>
<br/>
<table width="100%" cellspacing="10" border="0" align="center">
<tr>
<td>
<rich:extendedDataTable width="100%" height="300px" rowClasses="row1, row2" value="#{ProgramAction.sectionList}" var="sect" id="simpletable" style="overflow: auto;">
<rich:column width="22%" id="column7">
<f:facet name="header" id="f1" >
#{ProgramAction.labelSectionName}
</f:facet>
<h:outputText value="#{sect.sectionName}" id="sect" styleClass="input"/>
</rich:column>
<rich:column width="18%" id="column9" label="No. of Items">
<f:facet name="header" id="f2">
No. of Items
</f:facet>
<h:outputText value="#{sect.noOfItems}" id="item1" styleClass="input" />
</rich:column>
<rich:column width="30%" id="column10" label="direction">
<f:facet name="header" id="f3">
Direction
</f:facet>
<h:outputText value="#{sect.direction}" id="d1" styleClass="input" />
</rich:column>
<rich:column width="17%" id="column11" label="assign">
<f:facet name="header" id="f4">
Assign Users
</f:facet>
<a4j:commandButton value="Assign/View" action="#{ProgramAction.assignSectionUser}" actionListener="#{ProgramAction.deleteAction}" id="a1" reRender="userToSectionModalPanel">
<f:attribute id="section" value="#{sect}" name="section"/>
</a4j:commandButton>
</rich:column>
<rich:column width="15%" id="c20" label="Delete">
<f:facet name="header" id="f20">
Delete
</f:facet>
<a4j:commandLink id="dellink" action="#{ProgramAction.removeSection}" actionListener="#{ProgramAction.deleteAction}" reRender="simpletable">
<h:graphicImage id="gj9" value="Images/delete.gif" style="border:0" />
<f:attribute id="spal9" value="#{sect}" name="section" />
</a4j:commandLink>
</rich:column>
</rich:extendedDataTable>
</td>
</tr>
</table>
</fieldset>
</center>
</rich:panel>
</h:form>
<rich:modalPanel id="userToSectionModalPanel" width="920" height="475" showWhenRendered="#{ProgramAction.sectionModal}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Assign Users To #{ProgramAction.labelSectionName}"></h:outputText>
</h:panelGroup>
</f:facet>
<h:form id="panelform">
<table border="0">
<tr>
<td colspan="7" align="center">
<rich:panel id="sessionMsgPanel" rendered="#{ProgramAction.enableMsgPanel}" StyleClass="#{ProgramAction.msgPanelStyle}">
<h:outputLabel value="#{ProgramAction.warningMsg}" styleClass="#{ProgramAction.msgLabelStyle}" id="modalWindowWarningMessage"/>
</rich:panel>
</td>
</tr>
<tr>
<td width="15%" align="right">
<label><h:outputText value="Author"/>
<span class="required">*</span></label>
</td>
<td width="15%" align="left">
<rich:comboBox id="stageNameList1" value="#{ProgramAction.author}" suggestionValues="#{ProgramAction.assignedAuthors}" />
</td>
<td width="15%" align="right">
<label><h:outputLabel value="No. of Items"/>
<span class="required">*</span></label>
</td>
<td width="15%" align="left">
<h:inputText value="#{ProgramAction.noOfItemsForAuthor}" id="noOfItemsForAuthor" styleClass="input" onkeypress="return checkNumaric(event,'panelform:noOfItemsForAuthor')" />
</td>
</tr>
<tr>
<td width="15%" align="right">
<label><h:outputLabel value="Instruction"/>
<span class="required">*</span></label>
</td>
<td width="15%" align="left" colspan="2">
<h:inputTextarea style="height: 20px;width: 100% " cols="40" rows="2" value="#{ProgramAction.userComment}" id="userComment" styleClass="formBox" />
</td>
</tr>
<tr>
<td width="15%" align="right">
<label><h:outputText value="Skill"/>
<span class="required">*</span></label>
</td>
<td width="15%" align="left">
<h:selectManyListbox id="selectSkills" value="#{ProgramAction.selectedSkillList}" size="5" style="width: 150px; height: 50px; padding: 0px;text-align: left; overflow: auto">
<f:selectItems value="#{ProgramAction.skillList}" id="skillList"/>
</h:selectManyListbox>
</td>
<td width="15%" align="right">
<label><h:outputLabel value="Level"/>
<span class="required">*</span></label>
</td>
<td width="15%" align="left">
<h:selectManyListbox id="selectLevels" value="#{ProgramAction.selectedLevelList}" size="3" style="width: 150px; height: 50px; padding: 0px;text-align: left; overflow: auto">
<f:selectItems value="#{ProgramAction.levelList}" id="levelList"/>
</h:selectManyListbox>
</td>
<td width="15%" align="right">
<label><h:outputLabel value="Standards"/></label>
</td>
<td width="15%" align="left">
<h:selectManyListbox id="standardStandards" value="#{ProgramAction.actualStandardList}" size="5" style="width: 150px; height: 50px; padding: 0px;text-align: left; overflow: auto">
<f:selectItems value="#{ProgramAction.actualTempList}" id="standardList"/>
</h:selectManyListbox>
</td>
<td width="10%" align="center">
<a4j:commandButton value="Add" id="addall1" action="#{ProgramAction.assignAuthorsToSection}" reRender="panelform"/>
</td>
</tr>
<tr>
<td colspan="7" align="center">
</td>
</tr>
<tr>
<td colspan="7" align="centre">
<rich:extendedDataTable height="230px" rowClasses="row1, row2" value="#{ProgramAction.sectioUserLists}" var="sect" id="simpletab" style="width: 100%; overflow: auto;" rendered="#{ProgramAction.enableSectionUserLists}">
<rich:column width="15%" id="authorColumn">
<f:facet name="header" id="authorFacet">
Author
</f:facet>
<h:outputText value="#{sect.firstName}" id="authorName" styleClass="input"/>
</rich:column>
<rich:column width="12%" id="noOfItemsForAuthorColumn">
<f:facet name="header" id="noOfItemsForAuthorFacet" >
No. of Items
</f:facet>
<h:outputText value="#{sect.noOfItemsForAuthor}" id="noOfItemsForAuthor" styleClass="input"/>
</rich:column>
<rich:column width="15%" id="commentColumn">
<f:facet name="header" id="commentFacet">
Comment
</f:facet>
<h:outputText value="#{sect.comment}" id="comment" styleClass="input"/>
</rich:column>
<rich:column width="15%" id="skillColumn">
<f:facet name="header" id="skillFacet">
Skill
</f:facet>
<h:outputText value="#{sect.skills}" id="sectionSkill" styleClass="input"/>
</rich:column>
<rich:column width="15%" id="levelColumn">
<f:facet name="header" id="levelFacet">
Level
</f:facet>
<h:outputText value="#{sect.levels}" id="sectionComment" styleClass="input"/>
</rich:column>
<rich:column width="18%" id="standardColumn" label="Comment">
<f:facet name="header" id="standardFacet">
Standard
</f:facet>
<h:outputText value="#{sect.standards}" id="sectionStandard" styleClass="input"/>
</rich:column>
<rich:column width="10%" id="deleteColumn" label="Delete">
<f:facet name="header" id="deleteFacet">
Delete
</f:facet>
<h:commandLink id="dellink" action="#{ProgramAction.removeAssignedAuthor}" actionListener="#{ProgramAction.action}">
<h:graphicImage id="graphicImage9" value="Images/delete.gif" style="border:0"/>
<f:attribute id="sectionAuthor" value="#{sect}" name="sectionAuthor"/>
</h:commandLink>
</rich:column>
</rich:extendedDataTable>
</td>
</tr>
<tr>
<td colspan="7" align="center">
<a4j:commandButton value="Done" id="sectionOk" action="#{ProgramAction.sectionOk}" reRender="userToSectionModalPanel"/>
</td>
</tr>
</table>
</h:form>
</rich:modalPanel>
<ui:insert>
<ui:include src="footer.xhtml"/>
</ui:insert>
</body>
</html>
ProgramAction.java
package com.lw.ipf.itemauthoring.web.action;
import com.lw.ipf.itemauthoring.data.bean.Discipline;
import com.lw.ipf.itemauthoring.data.bean.Grade;
import com.lw.ipf.itemauthoring.data.bean.ImportFiles;
import com.lw.ipf.itemauthoring.data.bean.Level;
import com.lw.ipf.itemauthoring.data.bean.ProgramStandardMap;
import com.lw.ipf.itemauthoring.data.bean.Project;
import com.lw.ipf.itemauthoring.data.bean.ProjectStageUserMap;
import com.lw.ipf.itemauthoring.data.bean.Section;
import com.lw.ipf.itemauthoring.data.bean.SectionAuthor;
import com.lw.ipf.itemauthoring.data.bean.SectionUserMap;
import com.lw.ipf.itemauthoring.data.bean.Skill;
import com.lw.ipf.itemauthoring.data.bean.Standard;
import com.lw.ipf.itemauthoring.data.bean.State;
import com.lw.ipf.itemauthoring.data.bean.User;
import com.lw.ipf.itemauthoring.data.bean.Workflow;
import com.lw.ipf.itemauthoring.data.bean.WorkflowStageMap;
import com.lw.ipf.itemauthoring.exception.DuplicateException;
import com.lw.ipf.itemauthoring.service.manager.DisciplineManager;
import com.lw.ipf.itemauthoring.service.manager.GradeManager;
import com.lw.ipf.itemauthoring.service.manager.LevelManager;
import com.lw.ipf.itemauthoring.service.manager.ProgramManager;
import com.lw.ipf.itemauthoring.service.manager.ProgramStageUserMapManager;
import com.lw.ipf.itemauthoring.service.manager.ProgramStandardMapManager;
import com.lw.ipf.itemauthoring.service.manager.SectionManager;
import com.lw.ipf.itemauthoring.service.manager.SectionUserMapManager;
import com.lw.ipf.itemauthoring.service.manager.SkillManager;
import com.lw.ipf.itemauthoring.service.manager.StandardManager;
import com.lw.ipf.itemauthoring.service.manager.StateManager;
import com.lw.ipf.itemauthoring.service.manager.UserManager;
import com.lw.ipf.itemauthoring.service.manager.WorkflowManager;
import com.lw.ipf.itemauthoring.service.manager.WorkflowStageMapManager;
import com.lw.ipf.itemauthoring.web.util.Constants;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.apache.log4j.Logger;
import org.richfaces.component.html.HtmlDataTable;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
/**
*
* @author laser
*/
public class ProgramAction implements Serializable {
private static final Logger logger = Logger.getLogger(ProgramAction.class);
private ResourceBundle rb = ResourceBundle.getBundle("messages");
private DateFormat formatter = new SimpleDateFormat("MM-dd-yyyy");
private FacesContext ctx = FacesContext.getCurrentInstance();
private Application app = ctx.getApplication();
private Login login = (Login) app.evaluateExpressionGet(ctx, "#{Login}", Login.class);
private DisciplineManager disciplineManager = new DisciplineManager();
private GradeManager gradeManager = new GradeManager();
private LevelManager levelManager = new LevelManager();
private ProgramManager programManager = new ProgramManager();
private ProgramStageUserMapManager programStageUserMapManager = new ProgramStageUserMapManager();
private ProgramStandardMapManager programStandardMapManager = new ProgramStandardMapManager();
private SectionManager sectionManager = new SectionManager();
private SectionUserMapManager sectionUserMapManager = new SectionUserMapManager();
private SkillManager skillManager = new SkillManager();
private StandardManager standardManager = new StandardManager();
private StateManager stateManager = new StateManager();
private UserManager userManager = new UserManager();
private WorkflowManager workflowManager = new WorkflowManager();
private WorkflowStageMapManager workflowStageMapManager = new WorkflowStageMapManager();
private Map<String, Integer> workflowMap = new HashMap<String, Integer>();
private Map<String, Integer> stateMap = new HashMap<String, Integer>();
private Map<String, Integer> subjectMap = new HashMap<String, Integer>();
private Map<String, Integer> userMap = new HashMap<String, Integer>();
private Map<String, Integer> gradeMap = new HashMap<String, Integer>();
private Map<String, Integer> levelMap = new HashMap<String, Integer>();
private Map<String, Integer> skillMap = new HashMap<String, Integer>();
private Map<String, Integer> standardMap = new HashMap<String, Integer>();
private Map<String, Integer> stageMap = new HashMap<String, Integer>();
private List<ImportFiles> files = new ArrayList<ImportFiles>();
private List<Project> programList = null;
private List<Section> sectionList;
private List<Section> sectionTempList;
private List<SectionAuthor> stageList = null;
private List<SectionAuthor> sectioUserLists = null;
private List<SectionAuthor> sectionWiseUserList = null;
private List<Standard> standardLists = null;
private List<User> actualUsersList = null;
private List<User> addedUsersList = null;
private List<String> selectedUsersList = null;
private List<String> movedUsersList = null;
private List<String> workflowList;
private List<String> standardList = null;
private List<String> actualStandardList = null;
private List<String> actualTempList = null;
private List<String> actualSelectedStandard = null;
private List<String> tempList = null;
private List<String> stateList = null;
private List<String> programOwnerList = null;
private List<String> subjectList = null;
private List<String> gradeList = null;
private List<String> standardsSelected = null;
private List<String> sectionAuthorList;
private List<String> assignSelectedList;
private List<String> assignSelectedTempList;
private List<String> workflowStages = null;
private List<String> assignedAuthors = null;
private List<String> selectedSectionUsers = null;
private List<String> tempUserList = null;
private List<String> workflowStage = null;
private List<String> levelList = null;
private List<String> skillList = null;
private List<String> selectedSkillList = null;
private List<String> selectedLevelList = null;
private Set<String> tempSet = null;
private SectionAuthor sectionAuthor = null;
private Section section = new Section();
private String labelProgramName = null;
private String labelSectionName = null;
private String programName = null;
private String programOwner = null;
private String direction = null;
private String stageName = null;
private String workflow = null;
private String selectedTab = "";
private String isbn13 = null;
private String isbn10 = null;
private String state = null;
private String subject = null;
private String grade = null;
private String warningMsg = null;
private String sectionName = null;
private String totalItems = null;
private String noOfItemsForAuthor = null;
private String userComment = null;
private String author = null;
private String comment = null;
private Integer height = null;
private Date dueDate = null;
private Integer itemCount = 0;
private Boolean useFlash = false;
private Boolean enableWorkflow = Boolean.FALSE;
private Boolean enableProject = Boolean.FALSE;
private Boolean enableUploads = Boolean.FALSE;
private Boolean enableSection = Boolean.FALSE;
private Boolean sectionTable = Boolean.FALSE;
private Boolean workflowTable = Boolean.FALSE;
private Boolean sectionModal = Boolean.FALSE;
private Boolean assignStandardFlag = Boolean.FALSE;
private Boolean assignUserFlag = Boolean.FALSE;
private Boolean enableMsgPanel = Boolean.FALSE;
private Boolean enableSessionMsgPanel = Boolean.FALSE;
private Boolean commoncoreMetaEnabled = Boolean.FALSE;
private Boolean stateMetaEnabled = Boolean.FALSE;
private Boolean commoncoreTableEnabled = Boolean.FALSE;
private Boolean stateTableEnabled = Boolean.FALSE;
private List<String> commoncoreMetaList = null;
private List<String> stateMetaList = null;
private String searchInSelected = "commoncore";
private String searchKeyword = null;
private String errMsg = null;
private List<Standard> searchedCommoncoreList = null;
private List<Standard> searchedCommoncoreSelectedList = null;
private List<Standard> searchedStateList = null;
private Boolean isSelected = Boolean.FALSE;
private HtmlDataTable datatable;
private String size;
private String selectedStdSize;
private String strand;
private String selectImage = "select_all.gif";
private int searchedCCListSize = 0;
private int selectedCCListSize = 0;
private Boolean stdModal = Boolean.FALSE;
private String msgPanelStyle;
private String msgLabelStyle;
private Boolean enableSectionUserLists = Boolean.FALSE;
/*page Navigation */
public HtmlDataTable getDatatable() {
return datatable;
}
public void setDatatable(HtmlDataTable datatable) {
this.datatable = datatable;
}
public String getSize() {
logger.info("size:" + size);
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getSelectedStdSize() {
return selectedStdSize;
}
public void setSelectedStdSize(String selectedStdSize) {
this.selectedStdSize = selectedStdSize;
}
public void pageFirst() {
logger.info("pageFirst:");
datatable.setFirst(0);
}
public void pagePrevious() {
logger.info("pagePrevious:" + datatable.getFirst() + ": " + datatable.getRows());
datatable.setFirst(datatable.getFirst() - datatable.getRows());
}
public void pageNext() {
logger.info("pageNext:");
datatable.setFirst(datatable.getFirst() + datatable.getRows());
}
public void pageLast() {
logger.info("pageLast:");
int count = datatable.getRowCount();
int rows = datatable.getRows();
try {
datatable.setFirst(count - ((count % rows != 0) ? count % rows : rows));
} catch (Exception e) {
logger.error("Exepression error :" + e.getMessage());
}
}
/* page Navigation*/
public int getSearchedCCListSize() {
return searchedCCListSize;
}
public void setSearchedCCListSize(int searchedCCListSize) {
this.searchedCCListSize = searchedCCListSize;
}
public int getSelectedCCListSize() {
return selectedCCListSize;
}
public void setSelectedCCListSize(int selectedCCListSize) {
this.selectedCCListSize = selectedCCListSize;
}
public Boolean getStdModal() {
return stdModal;
}
public void setStdModal(Boolean stdModal) {
this.stdModal = stdModal;
}
public String getStrand() {
return strand;
}
public void setStrand(String strand) {
this.strand = strand;
}
public String getMsgLabelStyle() {
return msgLabelStyle;
}
public void setMsgLabelStyle(String msgLabelStyle) {
this.msgLabelStyle = msgLabelStyle;
}
public String getMsgPanelStyle() {
return msgPanelStyle;
}
public void setMsgPanelStyle(String msgPanelStyle) {
this.msgPanelStyle = msgPanelStyle;
}
public Boolean getEnableSectionUserLists() {
return enableSectionUserLists;
}
public void setEnableSectionUserLists(Boolean enableSectionUserLists) {
this.enableSectionUserLists = enableSectionUserLists;
}
public Boolean getEnableMsgPanel() {
return enableMsgPanel;
}
public void setEnableMsgPanel(Boolean enableMsgPanel) {
this.enableMsgPanel = enableMsgPanel;
}
public Boolean getEnableSessionMsgPanel() {
return enableSessionMsgPanel;
}
public void setEnableSessionMsgPanel(Boolean enableSessionMsgPanel) {
this.enableSessionMsgPanel = enableSessionMsgPanel;
}
/* Obtaining Lists */
public List<Project> getProgramList() {
if (programList == null) {
programList = new ArrayList<Project>();
List<ProjectStageUserMap> tempProgramList = programStageUserMapManager.findByProperty("userId", login.getUser().getUserId());
if (tempProgramList != null && !tempProgramList.isEmpty()) {
for (Integer i = 0; i < tempProgramList.size(); i++) {
Project tempProgram = tempProgramList.get(i).getProgram();
Integer noOfItems = 0;
Integer noOfAuthoredItems = 0;
Iterator<Section> iterator = tempProgram.getSections().iterator();
while (iterator.hasNext()) {
Section tempSection = iterator.next();
noOfItems += tempSection.getNoOfItems();
noOfAuthoredItems += tempSection.getSectionQuestionMaps().size();
}
tempProgram.setNoOfItems(noOfItems);
tempProgram.setNoOfAuthoredItems(noOfAuthoredItems);
tempProgram.setNoOfItemsYetToAuthor(noOfItems - noOfAuthoredItems);
programList.add(tempProgram);
}
}
}
if (programList.size() >= 9) {
height = 180;
} else {
if (programList.isEmpty()) {
height = 70;
}
for (int i = 1; i <= programList.size(); i++) {
height = i * 10 + 80;
}
}
return programList;
}
public void setProgramList(List<Project> programList) {
this.programList = programList;
}
public List<String> getWorkflowList() {
if (workflowList == null) {
workflowList = new ArrayList<String>();
List<Workflow> workflowBeanList = workflowManager.getWorkflowList();
if (workflowBeanList != null) {
Iterator<Workflow> workflowIterator = workflowBeanList.iterator();
while (workflowIterator.hasNext()) {
Workflow workflowBean = workflowIterator.next();
workflowList.add(workflowBean.getWorkflowName());
workflowMap.put(workflowBean.getWorkflowName(), workflowBean.getWorkflowId());
}
}
}
return workflowList;
}
public void setWorkflowList(List<String> workflowList) {
this.workflowList = workflowList;
}
public List<String> getProgramOwnerList() {
if (programOwnerList == null) {
programOwnerList = new ArrayList<String>();
List<User> tempOwnerList = userManager.findByProperty("roleId", Constants.ROLE_OWNER);
if (tempOwnerList != null) {
Iterator<User> pmIterator = tempOwnerList.iterator();
while (pmIterator.hasNext()) {
User pmBean = pmIterator.next();
programOwnerList.add(pmBean.getFirstName().concat(" ").concat(pmBean.getLastName()));
userMap.put(pmBean.getFirstName(), pmBean.getUserId());
}
}
}
return programOwnerList;
}
public void setProgramOwnerList(List<String> programOwnerList) {
this.programOwnerList = programOwnerList;
}
public List<String> getStateList() {
if (stateList == null) {
stateList = new ArrayList<String>();
List<State> tempStateList = stateManager.getStateList();
if (tempStateList != null) {
Iterator<State> stateIterator = tempStateList.iterator();
while (stateIterator.hasNext()) {
State stateBean = stateIterator.next();
stateList.add(stateBean.getName());
stateMap.put(stateBean.getName(), stateBean.getStateId());
}
}
}
return stateList;
}
public void setStateList(List<String> stateList) {
this.stateList = stateList;
}
public List<String> getGradeList() {
if (gradeList == null) {
gradeList = new ArrayList<String>();
List<Grade> tempGradeList = gradeManager.getGradeList();
if (tempGradeList != null) {
Iterator<Grade> gradeIterator = tempGradeList.iterator();
while (gradeIterator.hasNext()) {
Grade stateBean = gradeIterator.next();
gradeList.add(stateBean.getGradeName());
gradeMap.put(stateBean.getGradeName(), stateBean.getGradeId());
}
}
}
return gradeList;
}
public void setGradeList(List<String> gradeList) {
this.gradeList = gradeList;
}
public List<String> getSubjectList() {
if (subjectList == null) {
subjectList = new ArrayList<String>();
List<Discipline> subjectBeanList = disciplineManager.getDisciplineList();
if (subjectBeanList != null) {
Iterator<Discipline> subjectIterator = subjectBeanList.iterator();
while (subjectIterator.hasNext()) {
Discipline subjectBean = subjectIterator.next();
subjectList.add(subjectBean.getDisciplineName());
subjectMap.put(subjectBean.getDisciplineName(), subjectBean.getDisciplineId());
}
}
}
return subjectList;
}
public void setSubjectList(List<String> subjectList) {
this.subjectList = subjectList;
}
public List<SectionAuthor> getSectioUserLists() {
if (sectioUserLists == null) {
sectioUserLists = new ArrayList<SectionAuthor>();
}
return sectioUserLists;
}
public void setSectioUserLists(List<SectionAuthor> sectioUserLists) {
this.sectioUserLists = sectioUserLists;
}
public List<SectionAuthor> getSectionWiseUserList() {
return sectionWiseUserList;
}
public void setSectionWiseUserList(List<SectionAuthor> sectionWiseUserList) {
this.sectionWiseUserList = sectionWiseUserList;
}
public List<String> getWorkflowStage() {
return workflowStage;
}
public void setWorkflowStage(List<String> workflowStage) {
this.workflowStage = workflowStage;
}
public List<String> getSelectedLevelList() {
return selectedLevelList;
}
public void setSelectedLevelList(List<String> selectedLevelList) {
this.selectedLevelList = selectedLevelList;
}
public List<String> getSelectedSkillList() {
return selectedSkillList;
}
public void setSelectedSkillList(List<String> selectedSkillList) {
this.selectedSkillList = selectedSkillList;
}
public List<String> getTempUserList() {
return tempUserList;
}
public void setTempUserList(List<String> tempUserList) {
this.tempUserList = tempUserList;
}
public List<String> getTempList() {
return tempList;
}
public void setTempList(List<String> tempList) {
this.tempList = tempList;
}
public List<String> getActualStandardList() {
return actualStandardList;
}
public void setActualStandardList(List<String> actualStandardList) {
this.actualStandardList = actualStandardList;
}
public List<String> getActualTempList() {
return actualTempList;
}
public void setActualTempList(List<String> actualTempList) {
this.actualTempList = actualTempList;
}
public List<String> getActualSelectedStandard() {
return actualSelectedStandard;
}
public void setActualSelectedStandard(List<String> actualSelectedStandard) {
this.actualSelectedStandard = actualSelectedStandard;
}
public List<String> getAssignSelectedList() {
return assignSelectedList;
}
public void setAssignSelectedList(List<String> assignSelectedList) {
this.assignSelectedList = assignSelectedList;
}
public List<String> getAssignSelectedTempList() {
return assignSelectedTempList;
}
public void setAssignSelectedTempList(List<String> assignSelectedTempList) {
this.assignSelectedTempList = assignSelectedTempList;
}
public List<String> getAssignedAuthors() {
return assignedAuthors;
}
public void setAssignedAuthors(List<String> assignedAuthors) {
this.assignedAuthors = assignedAuthors;
}
public List<String> getSelectedSectionUsers() {
return selectedSectionUsers;
}
public void setSelectedSectionUsers(List<String> selectedSectionUsers) {
this.selectedSectionUsers = selectedSectionUsers;
}
public List<Standard> getStandardLists() {
if (standardLists == null) {
standardLists = new ArrayList<Standard>();
List<Standard> tempStandardList = standardManager.getStandardList();
Iterator<Standard> iterator = tempStandardList.iterator();
while (iterator.hasNext()) {
Standard tempStandard = iterator.next();
if (tempStandard.getGradeId().equals(gradeMap.get(grade))) {
standardLists.add(tempStandard);
standardMap.put(tempStandard.getStandardName(), tempStandard.getStandardId());
}
}
}
return standardLists;
}
public void setStandardLists(List<Standard> standardLists) {
this.standardLists = standardLists;
}
public List<User> getAddedUsersList() {
return addedUsersList;
}
public void setAddedUsersList(List<User> addedUsersList) {
this.addedUsersList = addedUsersList;
}
public List<String> getLevelList() {
if (levelList == null) {
levelList = new ArrayList<String>();
List<Level> tempLevelList = levelManager.getLevelList();
Iterator<Level> levelIterator = tempLevelList.iterator();
while (levelIterator.hasNext()) {
Level tempLevel = levelIterator.next();
levelList.add(tempLevel.getLevelName());
levelMap.put(tempLevel.getLevelName(), tempLevel.getLevelId());
}
}
return levelList;
}
public void setLevelList(List<String> levelList) {
this.levelList = levelList;
}
public List<String> getSkillList() {
if (skillList == null) {
skillList = new ArrayList<String>();
List<Skill> tempSkillList = skillManager.getSkillList();
Iterator<Skill> skillIterator = tempSkillList.iterator();
while (skillIterator.hasNext()) {
Skill tempSkill = skillIterator.next();
skillList.add(tempSkill.getSkillName());
skillMap.put(tempSkill.getSkillName(), tempSkill.getSkillId());
}
}
return skillList;
}
public void setSkillList(List<String> skillList) {
this.skillList = skillList;
}
public List<String> getMovedUsersList() {
return movedUsersList;
}
public void setMovedUsersList(List<String> movedUsersList) {
this.movedUsersList = movedUsersList;
}
public List<String> getSelectedUsersList() {
return selectedUsersList;
}
public void setSelectedUsersList(List<String> selectedUsersList) {
this.selectedUsersList = selectedUsersList;
}
public List<String> getWorkflowStages() {
return workflowStages;
}
public void setWorkflowStages(List<String> workflowStages) {
this.workflowStages = workflowStages;
}
public List<Section> getSectionTempList() {
return sectionTempList;
}
public void setSectionTempList(List<Section> sectionTempList) {
this.sectionTempList = sectionTempList;
}
public List<String> getSectionAuthorList() {
return sectionAuthorList;
}
public void setSectionAuthorList(List<String> sectionAuthorList) {
this.sectionAuthorList = sectionAuthorList;
}
public List<SectionAuthor> getStageList() {
if (stageList == null) {
stageList = new ArrayList<SectionAuthor>();
}
return stageList;
}
public void setStageList(List<SectionAuthor> stageList) {
this.stageList = stageList;
}
public List<User> getActualUsersList() {
return actualUsersList;
}
public void setActualUsersList(List<User> actualUsersList) {
this.actualUsersList = actualUsersList;
}
public List<Section> getSectionList() {
return sectionList;
}
public void setSectionList(List<Section> sectionList) {
this.sectionList = sectionList;
}
public List<String> getStandardList() {
return standardList;
}
public void setStandardList(List<String> standardList) {
this.standardList = standardList;
}
public List<String> getStandardsSelected() {
return standardsSelected;
}
public void setStandardsSelected(List<String> standardsSelected) {
this.standardsSelected = standardsSelected;
}
public List<ImportFiles> getFiles() {
return files;
}
public void setFiles(List<ImportFiles> files) {
this.files = files;
}
public Set<String> getTempSet() {
return tempSet;
}
public void setTempSet(Set<String> tempSet) {
this.tempSet = tempSet;
}
public String getUserComment() {
return userComment;
}
public void setUserComment(String userComment) {
this.userComment = userComment;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Boolean getAssignUserFlag() {
return assignUserFlag;
}
public void setAssignUserFlag(Boolean assignUserFlag) {
this.assignUserFlag = assignUserFlag;
}
public Boolean getUseFlash() {
return useFlash;
}
public void setUseFlash(Boolean useFlash) {
this.useFlash = useFlash;
}
public Boolean getAssignStandardFlag() {
return assignStandardFlag;
}
public void setAssignStandardFlag(Boolean assignStandardFlag) {
this.assignStandardFlag = assignStandardFlag;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public Boolean getWorkflowTable() {
return workflowTable;
}
public void setWorkflowTable(Boolean workflowTable) {
this.workflowTable = workflowTable;
}
public Boolean getSectionTable() {
return sectionTable;
}
public void setSectionTable(Boolean sectionTable) {
this.sectionTable = sectionTable;
}
public Date getDueDate() {
return dueDate;
}
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
public String getStageName() {
return stageName;
}
public void setStageName(String stageName) {
this.stageName = stageName;
}
public Boolean getSectionModal() {
return sectionModal;
}
public void setSectionModal(Boolean sectionModal) {
this.sectionModal = sectionModal;
}
public Boolean getEnableSection() {
return enableSection;
}
public void setEnableSection(Boolean enableSection) {
this.enableSection = enableSection;
}
public String getWorkflow() {
return workflow;
}
public void setWorkflow(String workflow) {
this.workflow = workflow;
}
public Boolean getEnableWorkflow() {
return enableWorkflow;
}
public void setEnableWorkflow(Boolean enableWorkflow) {
this.enableWorkflow = enableWorkflow;
}
public Boolean getEnableUploads() {
return enableUploads;
}
public void setEnableUploads(Boolean enableUploads) {
this.enableUploads = enableUploads;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getTotalItems() {
return totalItems;
}
public void setTotalItems(String totalItems) {
this.totalItems = totalItems;
}
public String getNoOfItemsForAuthor() {
return noOfItemsForAuthor;
}
public void setNoOfItemsForAuthor(String noOfItemsForAuthor) {
this.noOfItemsForAuthor = noOfItemsForAuthor;
}
public String getSectionName() {
return sectionName;
}
public void setSectionName(String sectionName) {
this.sectionName = sectionName;
}
public String getIsbn10() {
return isbn10;
}
public void setIsbn10(String isbn10) {
this.isbn10 = isbn10;
}
public String getIsbn13() {
return isbn13;
}
public void setIsbn13(String isbn13) {
this.isbn13 = isbn13;
}
public String getProgramOwner() {
return programOwner;
}
public void setProgramOwner(String programOwner) {
this.programOwner = programOwner;
}
public String getProgramName() {
return programName;
}
public void setProgramName(String programName) {
this.programName = programName;
}
public String getWarningMsg() {
return warningMsg;
}
public void setWarningMsg(String warningMsg) {
this.warningMsg = warningMsg;
}
public Boolean getEnableProject() {
return enableProject;
}
public void setEnableProject(Boolean enableProject) {
this.enableProject = enableProject;
}
public String getSelectedTab() {
return selectedTab;
}
public void setSelectedTab(String selectedTab) {
this.selectedTab = selectedTab;
}
public String getLabelProgramName() {
labelProgramName = rb.getString("programName");
return labelProgramName;
}
public void setLabelProgramName(String labelProgramName) {
this.labelProgramName = labelProgramName;
}
public String getLabelSectionName() {
labelSectionName = rb.getString("sectionName");
return labelSectionName;
}
public void setLabelSectionName(String labelSectionName) {
this.labelSectionName = labelSectionName;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
/* getting list ends */
public String projectNext() {
if (programName.equalsIgnoreCase("") || programName.equalsIgnoreCase(null) || programOwner.equalsIgnoreCase("") || programOwner.equalsIgnoreCase(null)) {
warningMsg = rb.getString("mandatory");
displayMessage("Error", warningMsg);
logger.info(" projNext if");
return "createProgram";
} else { logger.info(" projNext else");
try {
logger.debug("isbn 10:"+isbn10.length()+" isbn 13:"+isbn13.length());
if (programManager.getProgram(programName) != null) {
warningMsg = "Form with name ".concat(programName).concat(" already exist");
displayMessage("Error", warningMsg);
return "createProgram";
} else if ((isbn10 != null && !"".equals(isbn10)) || (isbn13 != null && !"".equals(isbn13))) {
if (isbn10.length() != 13) {
logger.info("isbn10 projNext");
warningMsg = "Inavlid ISBN10";
displayMessage("Error", warningMsg);
logger.info("warningMsg"+warningMsg);
return "createProgram";
} else if (isbn13.length() != 17) {
logger.info("isbn13 projNext");
warningMsg = "Inavlid ISBN13";
displayMessage("Error", warningMsg);
return "createProgram";
}
}
} catch (Exception e) {
logger.error(e);
}
}
logger.info("projectNext: isbn10 " + isbn10 + " isbn13 " + isbn13);
unDisplayMessage();
return "assignStandards";
}
public String assignStandardPrev() {
unDisplayMessage();
return "createProgram";
}
public String assignStandardNext() {
if (selectedCCListSize == 0 || grade == null || "".equals(grade) || subject == null || "".equals(subject)) {
warningMsg = "You have not assigned standard(s)";
displayMessage("Error", warningMsg);
return "assignStandards";
} else {
unDisplayMessage();
return "workflowSetup";
}
}
public String workflowPrev() {
unDisplayMessage();
return "assignStandards";
}
public String workflowNext() {
if (workflow == null || "".equals(workflow)) {
warningMsg = "Please select the workflow!";
displayMessage("Error", warningMsg);
} else {
if (stageList == null || workflowStages == null || stageList.isEmpty() || workflowStages.isEmpty() || stageList.size() < workflowStages.size()) {
warningMsg = "Please assign the users for all the stages!";
displayMessage("Error", warningMsg);
} else {
unDisplayMessage();
Boolean isDataValid = Boolean.TRUE;
Iterator<SectionAuthor> iterator = stageList.iterator();
while (iterator.hasNext()) {
SectionAuthor tempSA = iterator.next();
if (tempSA.getAddedUsersList() == null || tempSA.getAddedUsersList().isEmpty()) {
isDataValid = Boolean.FALSE;
break;
}
}
if (!isDataValid) {
warningMsg = "There are stages without assigned users. Please check it!";
displayMessage("Error", warningMsg);
} else {
unDisplayMessage();
return "assignSessionDirection";
}
}
}
return "workflowSetup";
}
public String sectionPrev() {
unDisplayMessage();
return "workflowSetup";
}
public String sectionNext() {
if (sectionList != null && sectionList.size() > 0) {
Boolean isDataValid = Boolean.TRUE;
Iterator<Section> iterator = sectionList.iterator();
while (iterator.hasNext()) {
Section tempSection = iterator.next();
if (tempSection.getSectionUserList() == null || tempSection.getSectionUserList().isEmpty()) {
isDataValid = Boolean.FALSE;
break;
}
}
if (isDataValid) {
unDisplayMessage();
return "summary";
} else {
warningMsg = "Please assign authors for all the sections!";
displayMessage("Error", warningMsg);
}
} else {
warningMsg = "Please add atlease one section into your program!";
displayMessage("Error", warningMsg);
}
return "assignSessionDirection";
}
public String uploadPrev() {
unDisplayMessage();
return "assignSessionDirection";
}
public void addSectionToProgram() {
if (sectionName != null && !"".equals(sectionName) && direction != null && !"".equals(direction) && totalItems != null && !"".equals(totalItems)) {
warningMsg = "";
enableMsgPanel = Boolean.FALSE;
if (!validateInteger(totalItems)) {
logger.debug("Items " + totalItems);
} else {
itemCount = Integer.parseInt(totalItems);
if (sectionList == null) {
sectionList = new ArrayList<Section>();
}
Section tempSection = new Section();
tempSection.setDirection(direction);
tempSection.setSectionName(sectionName);
tempSection.setNoOfItems(itemCount);
Boolean isExists = Boolean.FALSE;
Iterator<Section> sectionIterator = sectionList.iterator();
while (sectionIterator.hasNext()) {
if (sectionName.equals(sectionIterator.next().getSectionName())) {
isExists = Boolean.TRUE;
}
}
if (!isExists) {
sectionList.add(tempSection);
sectionName = null;
direction = null;
itemCount = null;
}
}
} else {
warningMsg = rb.getString("mandatory");
displayMessage("Error", warningMsg);
}
}
public void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
ImportFiles file = new ImportFiles();
FileInputStream fis = new FileInputStream(item.getFile());
byte[] buf = new byte[(int) item.getFile().length()];
fis.read(buf);
file.setName(item.getFileName());
file.setData(item.getData());
files.add(file);
fis.close();
}
public Boolean validateInteger(String isbn) {
try {
Integer.parseInt(isbn);
} catch (NumberFormatException nfe) {
logger.error(nfe);
return false;
}
return true;
}
public void submitWorkflow() {
unDisplayMessage();
stageList = null;
dueDate = null;
List<WorkflowStageMap> list = workflowStageMapManager.findByProperty("workflowId", workflowMap.get(workflow));
Iterator<WorkflowStageMap> it = list.iterator();
workflowStages = new ArrayList<String>();
WorkflowStageMap workflowStageMap = null;
while (it.hasNext()) {
workflowStageMap = it.next();
workflowStages.add(workflow.concat(" : " + workflowStageMap.getStage().getStageName()));
stageMap.put(workflowStageMap.getStage().getStageName(), workflowStageMap.getStageId());
}
List<Workflow> subWorkflowList = workflowManager.findByProperty("parentWorkflowId", workflowMap.get(workflow));
if (subWorkflowList != null && !subWorkflowList.isEmpty()) {
Iterator<Workflow> workflowIterator = subWorkflowList.iterator();
while (workflowIterator.hasNext()) {
Workflow subWorkflow = workflowIterator.next();
List<WorkflowStageMap> list1 = workflowStageMapManager.findByProperty("workflowId", subWorkflow.getWorkflowId());
Iterator<WorkflowStageMap> it1 = list1.iterator();
while (it1.hasNext()) {
WorkflowStageMap workflowStageMap1 = it1.next();
workflowStages.add(subWorkflow.getWorkflowName().concat(" : " + workflowStageMap1.getStage().getStageName()));
}
}
}
}
public String assignStandards() {
unDisplayMessage();
logger.info("assignStandards");
searchedCommoncoreSelectedList = new ArrayList<Standard>();
if (searchedCCListSize == 0) {
warningMsg = "There is no standards to be assigned. Please select atleast one standard";
displayMessage("Error", warningMsg);
} else {
Iterator<Standard> it = searchedCommoncoreList.iterator();
while (it.hasNext()) {
Standard tempStd = it.next();
if (tempStd.getIsSelected()) {
searchedCommoncoreSelectedList.add(tempStd);
}
}
selectedCCListSize = searchedCommoncoreSelectedList.size();
selectedStdSize = selectedCCListSize + " standards(s) assigned to " + programName;
displayMessage("Success", selectedStdSize);
if (grade == null || "".equals(grade)) {
warningMsg = "Please select grade";
displayMessage("Error", warningMsg);
} else if (subject == null || "".equals(subject)) {
warningMsg = "Please select discipline";
displayMessage("Error", warningMsg);
} else if (selectedCCListSize == 0) {
warningMsg = "Please select atleast one standard";
displayMessage("Error", warningMsg);
} else {
stdModal = Boolean.FALSE;
addAllStandard();
}
}
return "assignStandards";
}
public void addAllStandard() {
if (searchedCommoncoreSelectedList != null) {
logger.debug("----------------");
actualTempList = new ArrayList<String>();
Iterator<Standard> it = searchedCommoncoreSelectedList.iterator();
while (it.hasNext()) {
Standard standard = it.next();
actualTempList.add(standard.getStandardName());
}
logger.debug(actualTempList);
}
}
public void addStandard() {
if (actualTempList != null) {
tempList = actualTempList;
if (!(standardLists.size() == actualTempList.size())) {
actualTempList = new ArrayList<String>();
Iterator<String> it = actualSelectedStandard.iterator();
while (it.hasNext()) {
String standardName = it.next();
actualTempList.add(standardName);
}
Iterator<String> it1 = tempList.iterator();
while (it1.hasNext()) {
String standard = it1.next();
actualTempList.add(standard);
}
}
} else {
actualTempList = new ArrayList<String>();
Iterator<String> it = actualSelectedStandard.iterator();
while (it.hasNext()) {
String standardName = it.next();
actualTempList.add(standardName);
}
}
Iterator<Standard> it = standardLists.iterator();
while (it.hasNext()) {
Standard standard = it.next();
int i = 0;
Iterator<String> it1 = actualTempList.iterator();
while (it1.hasNext()) {
String standard1 = it1.next();
if (standard1.equals(standard.getStandardName())) {
if (i != 0) {
it1.remove();
}
i++;
}
}
}
}
public void removeStandard() {
if (actualTempList != null) {
if (actualStandardList != null) {
Iterator<String> it = actualStandardList.iterator();
while (it.hasNext()) {
String string = it.next();
Iterator<String> it1 = actualTempList.iterator();
while (it1.hasNext()) {
String string1 = it1.next();
if (string.equals(string1)) {
it1.remove();
}
}
}
}
}
}
public void removeAllStandard() {
if (actualTempList != null) {
actualTempList.clear();
}
}
public void standardOk() {
assignStandardFlag = Boolean.FALSE;
}
public void assignStageLevelUsers() {
actualUsersList = sectionAuthor.getActualUsersList();
addedUsersList = sectionAuthor.getAddedUsersList();
assignUserFlag = Boolean.TRUE;
}
public void addAllUsers() {
if (actualUsersList != null) {
addedUsersList = actualUsersList;
}
}
public void addUsers() {
if (addedUsersList == null) {
addedUsersList = new ArrayList<User>();
}
// logger.debug("addUsers: - : actualUsersList:" +actualUsersList.size()+ " addedUsersList: "+addedUsersList.size());
if (!(actualUsersList.size() == addedUsersList.size())) {
logger.debug("selectedUsersList:" +selectedUsersList.size());
if (!selectedUsersList.isEmpty()) {
Iterator<String> iterator = selectedUsersList.iterator();
while (iterator.hasNext()) {
String userId = iterator.next();
Iterator<User> userIterator = actualUsersList.iterator();
while (userIterator.hasNext()) {
User tempUser = userIterator.next();
if (Integer.valueOf(userId).equals(tempUser.getUserId())) {
Boolean isExists = Boolean.FALSE;
Iterator<User> tempIterator = addedUsersList.iterator();
while (tempIterator.hasNext()) {
if (Integer.valueOf(userId).equals(tempIterator.next().getUserId())) {
isExists = Boolean.TRUE;
break;
}
}
if (!isExists) {
addedUsersList.add(tempUser);
}
}
}
}
selectedUsersList.clear();
}
}
}
public void removeUsers() {
logger.debug("removeUsers: - : movedUsersList:" +movedUsersList.size()+ " addedUsersList: "+addedUsersList.size());
if (addedUsersList != null) {
if (movedUsersList != null) {
Iterator<String> it = movedUsersList.iterator();
while (it.hasNext()) {
String userId = it.next();
Iterator<User> it1 = addedUsersList.iterator();
while (it1.hasNext()) {
User tempUser = it1.next();
if (Integer.valueOf(userId).equals(tempUser.getUserId())) {
it1.remove();
}
}
}
}
}
}
public void removeAllUsers() {
logger.debug("removeAllUsers: - : actualUsersList:" +actualUsersList.size()+ " addedUsersList: "+addedUsersList.size());
if (addedUsersList != null) {
addedUsersList.clear();
}
}
public void userOk() {
sectionAuthor.setAddedUsersList(addedUsersList);
for (int i = 0; i < stageList.size(); i++) {
SectionAuthor tempSectionAuthor = stageList.get(i);
if (tempSectionAuthor.getStageName().equals(sectionAuthor.getStageName())) {
stageList.set(i, sectionAuthor);
break;
}
}
assignUserFlag = Boolean.FALSE;
}
public void addStage() {
unDisplayMessage();
try {
if (stageList == null) {
stageList = new ArrayList<SectionAuthor>();
}
Boolean isExists = Boolean.FALSE;
Iterator<SectionAuthor> iterator = stageList.iterator();
while (iterator.hasNext()) {
if (iterator.next().getStageName().equals(stageName)) {
isExists = Boolean.TRUE;
break;
}
}
if (!isExists) {
if (stageName != null && !"".equals(stageName) && dueDate != null) {
if (isValidDate()) {
SectionAuthor tempSectionAuthor = new SectionAuthor();
tempSectionAuthor.setDueDate(formatter.format(dueDate));
tempSectionAuthor.setStageName(stageName);
tempSectionAuthor.setWorkflowName(workflow);
List<User> list = null;
if (stageName.contains("WRITING")) {
list = userManager.findByProperty("roleId", Constants.ROLE_AUTHOR);
} else if (stageName.contains("EDITORIAL")) {
list = userManager.findByProperty("roleId", Constants.ROLE_EDITOR);
} else if (stageName.contains("COMP REVIEW")) {
list = userManager.findByProperty("roleId", Constants.ROLE_PROOF_READER);
} else if (stageName.contains("COMP")) {
list = userManager.findByProperty("roleId", Constants.ROLE_COMPOSITOR);
} else if (stageName.contains("APPROVAL")) {
list = userManager.findByProperty("roleId", Constants.ROLE_OWNER);
}
for (Integer i = 0; i < list.size(); i++) {
User tempUser = list.get(i);
userMap.put(tempUser.getFirstName(), tempUser.getUserId());
}
tempSectionAuthor.setActualUsersList(list);
stageList.add(tempSectionAuthor);
stageName = null;
dueDate = null;
} else {
warningMsg = "Please select a valid date!";
displayMessage("Error", warningMsg);
}
} else {
warningMsg = "Please fill the mandatory fields!";
displayMessage("Error", warningMsg);
}
} else {
warningMsg = "Please select a different stage. If you want to edit the date, please delete the stage and add once again";
displayMessage("Error", warningMsg);
}
} catch (Exception e) {
logger.error("Error in addStage Method : " + e);
}
}
private Boolean isValidDate() throws ParseException {
if (!stageList.isEmpty() && dueDate.before(formatter.parse(stageList.get(stageList.size() - 1).getDueDate()))) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
public void action(ActionEvent event) {
sectionAuthor = (SectionAuthor) event.getComponent().getAttributes().get("sectionAuthor");
}
public void removeStageWorkflow() {
Iterator<SectionAuthor> it = stageList.iterator();
while (it.hasNext()) {
SectionAuthor tempSectionAuthor = it.next();
if (tempSectionAuthor.getStageName().equals(sectionAuthor.getStageName())) {
it.remove();
}
}
}
public void deleteAction(ActionEvent event) {
section = (Section) event.getComponent().getAttributes().get("section");
}
public void removeSection() {
Iterator<Section> it = sectionList.iterator();
while (it.hasNext()) {
Section tempSection = it.next();
if (tempSection.getSectionName().equals(section.getSectionName())) {
it.remove();
}
}
}
public void removeAssignedAuthor() {
for (Integer i = 0; i < sectioUserLists.size(); i++) {
SectionAuthor tempSA = sectioUserLists.get(i);
if (tempSA.getFirstName().equals(sectionAuthor.getFirstName())) {
sectioUserLists.remove(i.intValue());
}
}
}
public void assignAuthorsToSection() {
unDisplayMessage();
if (sectioUserLists == null) {
sectioUserLists = new ArrayList<SectionAuthor>();
}
if (author != null && !"".equals(author) && noOfItemsForAuthor != null && !"".equals(noOfItemsForAuthor) && userComment != null && !"".equals(userComment)) {
Integer count = 0;
for (int i = 0; i < sectioUserLists.size(); i++) {
SectionAuthor sa = sectioUserLists.get(i);
count += sa.getNoOfItemsForAuthor();
}
if ((count + Integer.valueOf(noOfItemsForAuthor)) <= section.getNoOfItems()) {
SectionAuthor tempSectionAuthor = new SectionAuthor();
tempSectionAuthor.setComment(userComment);
tempSectionAuthor.setFirstName(author);
tempSectionAuthor.setNoOfItemsForAuthor(Integer.valueOf(noOfItemsForAuthor));
tempSectionAuthor.setLevelList(selectedLevelList);
tempSectionAuthor.setSkillList(selectedSkillList);
tempSectionAuthor.setStandardList(actualStandardList);
tempSectionAuthor.setSectionName(section.getSectionName());
String skills = "";
String levels = "";
String standards = "";
for (Integer k = 0; k < selectedSkillList.size(); k++) {
if (k > 0) {
skills += ", ";
}
skills += selectedSkillList.get(k);
}
for (Integer k = 0; k < selectedLevelList.size(); k++) {
if (k > 0) {
levels += ", ";
}
levels += selectedLevelList.get(k);
}
if (actualStandardList == null) {
actualStandardList = new ArrayList<String>();
}
for (Integer k = 0; k < actualStandardList.size(); k++) {
if (k > 0) {
standards += ", ";
}
standards += actualStandardList.get(k);
}
tempSectionAuthor.setSkills(skills);
tempSectionAuthor.setLevels(levels);
tempSectionAuthor.setStandards(standards);
sectioUserLists.add(tempSectionAuthor);
author = null;
noOfItemsForAuthor = null;
userComment = null;
selectedSkillList = null;
selectedLevelList = null;
actualStandardList = null;
enableSectionUserLists = Boolean.TRUE;
} else {
warningMsg = "Maximum " + (section.getNoOfItems() - count) + " item(s) can be assigned!";
displayMessage("Error", warningMsg);
}
} else {
warningMsg = rb.getString("mandatory");
displayMessage("Error", warningMsg);
}
}
public void sectionOk() {
if (sectionWiseUserList == null) {
sectionWiseUserList = new ArrayList<SectionAuthor>();
}
Integer count = 0;
for (Integer i = 0; i < sectioUserLists.size(); i++) {
SectionAuthor tempSA = sectioUserLists.get(i);
logger.debug("tempSA" + tempSA.getFirstName());
count += tempSA.getNoOfItemsForAuthor();
}
if (count.equals(section.getNoOfItems())) {
section.setSectionUserList(sectioUserLists);
logger.debug("List : " + section.getSectionUserList());
for (Integer i = 0; i < sectionList.size(); i++) {
Section tempSection = sectionList.get(i);
if (tempSection.getSectionName().equals(section.getSectionName())) {
sectionList.set(i, section);
break;
}
}
sectionModal = Boolean.FALSE;
} else {
warningMsg = (section.getNoOfItems() - count) + " more item(s) to be assigned!";
displayMessage("Error", warningMsg);
}
sectionWiseUserList.addAll(sectioUserLists);
}
public void StandardsOk() {
stdModal = Boolean.FALSE;
}
public String assignSectionRemove() {
return "createProgram";
}
public void assignSectionUser() {
unDisplayMessage();
author = null;
noOfItemsForAuthor = null;
userComment = null;
selectedLevelList = null;
selectedSkillList = null;
actualStandardList = null;
sectioUserLists = section.getSectionUserList();
sectionModal = Boolean.TRUE;
assignedAuthors = new ArrayList<String>();
Iterator<SectionAuthor> iterator = stageList.iterator();
while (iterator.hasNext()) {
SectionAuthor tempSA = iterator.next();
logger.debug("tempSA:"+tempSA.getStageName());
if (tempSA.getStageName().contains("WRITING")) {
Iterator<User> it = tempSA.getAddedUsersList().iterator();
while (it.hasNext()) {
assignedAuthors.add(it.next().getFirstName());
}
}
}
}
public void Save() {
try {
Boolean flag=Boolean.FALSE;
String instructionContent = "Form : " + programName;
logger.info("Save Form : " + programName);
Project program = new Project();
program.setProjectName(programName);
program.setWorkflowId(workflowMap.get(workflow));
program.setUserId(userMap.get(programOwner.split(" ")[0]));
program.setGradeId(gradeMap.get(grade));
program.setStateId(stateMap.get(state));
program.setDisciplineId(subjectMap.get(subject));
program.setIsbn10(isbn10);
program.setIsbn13(isbn13);
program.setFinalReleaseDate(dueDate);
program.setIsActive(1);
program.setCreatedBy(login.getUser().getUserId());
program.setCreatedDate(new Date());
program.setModifiedBy(login.getUser().getUserId());
program.setModifiedDate(new Date());
programManager.saveProgram(program);
logger.info("programManager.saveProgram(program);");
program = programManager.getProgram(programName);
instructionContent += "\nStandards : ";
int templistSize = actualTempList.size();
Iterator<String> it = actualTempList.iterator();
while (it.hasNext()) {
logger.info("stds selected " + it.next());
}
for (Integer i = 0; i < templistSize; i++) {
ProgramStandardMap programStandardMap = new ProgramStandardMap();
programStandardMap.setProgramId(program.getProjectId());
programStandardMap.setStandardId(standardMap.get(actualTempList.get(i)));
programStandardMap.setIsActive(1);
programStandardMapManager.save(programStandardMap);
logger.info("programStandardMapManager.save(programStandardMap);");
if (i > 0) {
instructionContent += ", ";
}
instructionContent += actualTempList.get(i);
}
instructionContent += "\n\n";
for (Integer i = 0; i < stageList.size(); i++) {
SectionAuthor tempSA = stageList.get(i);
logger.info("tempSA: " + tempSA.getStageName());
for (Integer j = 0; j < tempSA.getAddedUsersList().size(); j++) {
ProjectStageUserMap projectStageUserMap = new ProjectStageUserMap();
projectStageUserMap.setProgramId(program.getProjectId());
projectStageUserMap.setStageId(stageMap.get(tempSA.getStageName().replace(workflow + " : ", "")));
projectStageUserMap.setUserId(tempSA.getAddedUsersList().get(j).getUserId());
projectStageUserMap.setStartDate(formatter.parse(tempSA.getDueDate()));
projectStageUserMap.setEndDate(formatter.parse(tempSA.getDueDate()));
programStageUserMapManager.save(projectStageUserMap);
logger.info("programStageUserMapManager.save(projectStageUserMap);");
}
}
instructionContent += "Session : \n";
for (Integer i = 0; i < sectionList.size(); i++) {
Section tempSection = sectionList.get(i);
tempSection.setProgramId(program.getProjectId());
tempSection.setStageId(1);
tempSection.setIsActive(1);
String status=sectionManager.save(tempSection);
if(status.equals("failure")){
warningMsg="You have already saved this form";
displayMessage("Error", warningMsg);
flag=Boolean.TRUE;
break;
}
logger.info("sectionManager.save(tempSection);");
if (i > 0) {
instructionContent += ", ";
}
instructionContent += tempSection.getSectionName() + " : " + tempSection.getNoOfItems() + " items";
logger.debug("instructionContent " + instructionContent);
//tempSection = sectionManager.getSection(tempSection.getSectionName());
logger.debug("tempSection: " + tempSection.getSectionId() + " name" + tempSection.getSectionName());
logger.debug("tempSection ulist" + tempSection.getSectionUserList());
logger.debug("tempSection.getSectionUserList().size()" + tempSection.getSectionUserList().size());
for (Integer j = 0; j < tempSection.getSectionUserList().size(); j++) {
SectionAuthor tempSA = tempSection.getSectionUserList().get(j);
SectionUserMap sectionUserMap = new SectionUserMap();
sectionUserMap.setNoOfItems(tempSA.getNoOfItemsForAuthor());
sectionUserMap.setSectionId(tempSection.getSectionId());
sectionUserMap.setUserId(userMap.get(tempSA.getFirstName()));
sectionUserMap.setComment(tempSA.getComment());
sectionUserMap.setIsActive(1);
logger.info(sectionUserMap.getNoOfItems());
logger.info(sectionUserMap.getSectionId());
logger.info(sectionUserMap.getUserId());
logger.info(sectionUserMap.getComment());
logger.info(sectionUserMap.getIsActive());
sectionUserMapManager.save(sectionUserMap);
logger.info("p sectionUserMapManager.save(sectionUserMap);");
}
}
if (!flag) {
File instructionFile = new File("C:/filestorage/Text/" + programName + "_Instructions.txt");
if (!instructionFile.exists()) {
instructionFile.createNewFile();
logger.info("C:/filestorage/Text/" + programName + "_Instructions.txt created");
}
FileWriter fileWriter = new FileWriter(instructionFile);
fileWriter.write(instructionContent);
fileWriter.flush();
fileWriter.close();
warningMsg = "Data saved successfully!";
displayMessage("Success", warningMsg);
}
} catch (DuplicateException de) {
logger.error(de);
} catch (Exception e) {
logger.error(e);
}
}
/* Assign standards begins */
public Boolean isCommoncoreMetaEnabled() {
return commoncoreMetaEnabled;
}
public void setCommoncoreMetaEnabled(Boolean commoncoreMetaEnabled) {
this.commoncoreMetaEnabled = commoncoreMetaEnabled;
}
public Boolean isCommoncoreTableEnabled() {
return commoncoreTableEnabled;
}
public void setCommoncoreTableEnabled(Boolean commoncoreTableEnabled) {
this.commoncoreTableEnabled = commoncoreTableEnabled;
}
public String getSearchInSelected() {
return searchInSelected;
}
public void setSearchInSelected(String searchInSelected) {
this.searchInSelected = searchInSelected;
}
public String getSearchKeyword() {
return searchKeyword;
}
public void setSearchKeyword(String searchKeyword) {
this.searchKeyword = searchKeyword;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public List<String> getCommoncoreMetaList() {
return commoncoreMetaList;
}
public void setCommoncoreMetaList(List<String> commoncoreMetaList) {
this.commoncoreMetaList = commoncoreMetaList;
}
public List<String> getStateMetaList() {
return stateMetaList;
}
public void setStateMetaList(List<String> stateMetaList) {
this.stateMetaList = stateMetaList;
}
public List<Standard> getSearchedCommoncoreList() {
return searchedCommoncoreList;
}
public void setSearchedCommoncoreList(List<Standard> searchedCommoncoreList) {
this.searchedCommoncoreList = searchedCommoncoreList;
}
public List<Standard> getSearchedCommoncoreSelectedList() {
return searchedCommoncoreSelectedList;
}
public void setSearchedCommoncoreSelectedList(List<Standard> searchedCommoncoreSelectedList) {
this.searchedCommoncoreSelectedList = searchedCommoncoreSelectedList;
}
public Boolean iassignSessionDirectionSelected() {
return isSelected;
}
public void setIsSelected(Boolean isSelected) {
this.isSelected = isSelected;
}
public List<Standard> getSearchedStateList() {
return searchedStateList;
}
public void setSearchedStateList(List<Standard> searchedStateList) {
this.searchedStateList = searchedStateList;
}
public Boolean isStateMetaEnabled() {
return stateMetaEnabled;
}
public void setStateMetaEnabled(Boolean stateMetaEnabled) {
this.stateMetaEnabled = stateMetaEnabled;
}
public Boolean isStateTableEnabled() {
return stateTableEnabled;
}
public void setStateTableEnabled(Boolean stateTableEnabled) {
this.stateTableEnabled = stateTableEnabled;
}
public String getSelectImage() {
return selectImage;
}
public void setSelectImage(String selectImage) {
this.selectImage = selectImage;
}
public String resetSearch() {
resetvalues();
if (searchedCCListSize != 0) {
searchedCommoncoreList = resetCCList(searchedCommoncoreList);
}
logger.info("dispalysEnabling");
if (searchInSelected.equals("commoncore")) {
logger.info("commoncore");
commoncoreMetaEnabled = Boolean.TRUE;
stateMetaEnabled = Boolean.FALSE;
} else if (searchInSelected.equals("state")) {
logger.info("section");
commoncoreMetaEnabled = Boolean.FALSE;
stateMetaEnabled = Boolean.TRUE;
}
return "assignStandards";
}
public String search() {
errMsg = null;
enableMsgPanel = Boolean.FALSE;
logger.debug("searchInSelected:" + searchInSelected);
try {
if (searchInSelected == null) {
logger.info("searchInSelected inside if:" + searchInSelected);
warningMsg = "Please Select a catgory";
displayMessage("Error", warningMsg);
commoncoreTableEnabled = Boolean.FALSE;
stateTableEnabled = Boolean.FALSE;
} else if ((grade == null || "".equals(grade)) || (subject == null || "".equals(subject))) {
logger.info("searchKeyword inside if:" + searchKeyword);
warningMsg = rb.getString("mandatory");
displayMessage("Error", warningMsg);
commoncoreTableEnabled = Boolean.FALSE;
stateTableEnabled = Boolean.FALSE;
} else if (searchInSelected.equals("commoncore") && !((commoncoreMetaList == null) || "".equals(commoncoreMetaList))) {
stateMetaList = null;
logger.info("commoncore: " + commoncoreMetaList + "" + stateMetaList);
searchedCommoncoreList = programManager.getSearchedCommoncoreList(searchKeyword, commoncoreMetaList, grade, subject);
searchedCCListSize = searchedCommoncoreList.size();
if (searchedCCListSize != 0) {
logger.info("calling resetCCList");
searchedCommoncoreList = resetCCList(searchedCommoncoreList);
}
size = searchedCCListSize + " record(s) found";
logger.info("cc list size:" + searchedCCListSize);
commoncoreTableEnabled = Boolean.TRUE;
stateTableEnabled = Boolean.FALSE;
}
if (searchedCommoncoreList != null) {
for (int i = 0; i < searchedCommoncoreList.size(); i++) {
standardMap.put(searchedCommoncoreList.get(i).getStandardName(), searchedCommoncoreList.get(i).getStandardId());
}
}
// else if (searchInSelected.equals("state") && !((stateMetaList == null ) || "".equals(stateMetaList))) {
// commoncoreMetaList = null;
// logger.info("section: " + commoncoreMetaList + "" + stateMetaList + "" + itemMetaList);
// searchedStateList = csManager.getsearchedStateList(searchKeyword,stateMetaList,state,grade,discipline);
// Iterator<Section> it= searchedStateList.iterator();
// while (it.hasNext()) {
// Section section = it.next();
// logger.info("SectionList :"+section.getProgram().getProjectName());
// logger.info("SectionList :"+section.getSectionName());
// logger.info("SectionList :"+section.getStage().getStageName());
// }
// commoncoreTableEnabled = Boolean.FALSE;
// stateTableEnabled = Boolean.TRUE;
// }
} catch (Exception e) {
logger.error("Error in ProgramAction.search " + e);
}
return "assignStandards";
}
public void resetvalues() {
state = null;
grade = null;
subject = null;
searchKeyword = null;
errMsg = null;
size = null;
searchedCommoncoreList = null;
enableMsgPanel = Boolean.FALSE;
errMsg = null;
searchKeyword = null;
searchedCommoncoreList = null;
searchedCommoncoreSelectedList = null;
searchedStateList = null;
isSelected = Boolean.FALSE;
size = null;
selectedStdSize = null;
searchedCCListSize = 0;
selectedCCListSize = 0;
stdModal = Boolean.FALSE;
stateMetaList = null;
commoncoreMetaList = null;
commoncoreTableEnabled = Boolean.FALSE;
stateTableEnabled = Boolean.FALSE;
searchedCommoncoreList = null;
selectImage = "select_all.gif";
enableSectionUserLists = Boolean.FALSE;
}
public void selectAllCC() {
logger.debug("selectAllCC: ");
try {
if (!(searchedCommoncoreList == null || searchedCommoncoreList.isEmpty())) {
Iterator<Standard> it = searchedCommoncoreList.iterator();
logger.debug("inside if1");
if (isSelected) {
logger.debug("inside if2");
while (it.hasNext()) {
it.next().setIsSelected(Boolean.FALSE);
}
selectImage = "select_all.gif";
} else {
logger.debug("inside else");
while (it.hasNext()) {
it.next().setIsSelected(Boolean.TRUE);
}
selectImage = "deselect_all.gif";
}
isSelected = !isSelected;
} else {
logger.debug("inside else :" + searchedCommoncoreList);
}
} catch (Exception e) {
logger.error("Error in ProgramAction selectAllCC: " + e.getMessage());
}
}
public List<Standard> resetCCList(List<Standard> ccList) {
Iterator<Standard> it = ccList.iterator();
while (it.hasNext()) {
it.next().setIsSelected(Boolean.FALSE);
}
return ccList;
}
public String resetValue() {
programOwnerList = null;
stateList = null;
subjectList = null;
gradeList = null;
workflowList = null;
standardList = null;
standardsSelected = null;
sectionList = null;
programName = null;
programOwner = null;
workflow = null;
selectedTab = "";
noOfItemsForAuthor = null;
isbn13 = null;
isbn10 = null;
state = null;
subject = null;
grade = null;
enableProject = Boolean.FALSE;
enableWorkflow = Boolean.TRUE;
enableUploads = Boolean.TRUE;
enableSection = Boolean.TRUE;
warningMsg = null;
sectionName = null;
totalItems = null;
itemCount = 0;
dueDate = null;
stageName = null;
selectedUsersList = null;
sectionAuthorList = null;
enableMsgPanel = Boolean.FALSE;
enableSessionMsgPanel = Boolean.FALSE;
commoncoreMetaEnabled = Boolean.FALSE;
stateMetaEnabled = Boolean.FALSE;
commoncoreTableEnabled = Boolean.FALSE;
stateTableEnabled = Boolean.FALSE;
commoncoreMetaList = null;
stateMetaList = null;
searchInSelected = "commoncore";
searchKeyword = null;
errMsg = null;
searchedCommoncoreList = null;
searchedCommoncoreSelectedList = null;
searchedStateList = null;
isSelected = Boolean.FALSE;
size = null;
selectedStdSize = null;
searchedCCListSize = 0;
selectedCCListSize = 0;
stdModal = Boolean.FALSE;
datatable = null;
enableSectionUserLists = Boolean.FALSE;
return "createProgram";
}
public void displayMessage(String type, String message) {
warningMsg = message;
enableMsgPanel = Boolean.TRUE;
if (type.equals("Error")) {
msgPanelStyle = "errPanel";
msgLabelStyle = "errLabel";
} else if (type.equals("Success")) {
msgPanelStyle = "msgPanel";
msgLabelStyle = "msgLabel";
}
}
public void unDisplayMessage() {
enableMsgPanel = Boolean.FALSE;
msgPanelStyle = "errPanel";
msgLabelStyle = "errLabel";
warningMsg = "";
}
public void resetCCtable() {
searchedCommoncoreList = null;
searchedCommoncoreSelectedList = null;
selectedCCListSize = 0;
}
}