private QuestionPoolFacade getQuestionPool(QuestionPoolData qpp) { try { return new QuestionPoolFacade(qpp); } catch (Exception e) { log.warn(e.getMessage()); return null; } }
/** * Is destination a descendant of the source? */ public boolean isDescendantOf(QuestionPoolFacade destPool, QuestionPoolFacade sourcePool) { Long tempPoolId = destPool.getQuestionPoolId(); try { while((tempPoolId != null) && (!tempPoolId.equals(QuestionPoolFacade.ROOT_POOL))) { QuestionPoolFacade tempPool = getPoolById(tempPoolId); if (tempPool.getParentPoolId().equals(sourcePool.getQuestionPoolId())) { return true; } tempPoolId = tempPool.getParentPoolId(); } return false; } catch (Exception e) { log.warn(e.getMessage()); return false; } }
/** * Update questionpool from the extracted properties. * Note: you need to do a save when you are done. * @param questionpool, which will be persisted * @param assessmentMap, the extracted properties */ public void updateQuestionPool(QuestionPoolFacade questionpool, Map assessmentMap) { String title = ((String)assessmentMap.get("title")); questionpool.setDescription((String)assessmentMap.get("description")); //questionpool.setLastModifiedById("Sakai Import"); questionpool.setLastModified(new Date()); // note: currently dateCreated field not in use //questionpool.setDateCreated(new Date()); questionpool.setOrganizationName((String)assessmentMap.get("ASSESSMENT_ORGANIZATIONNAME")); questionpool.setObjectives((String)assessmentMap.get("ASSESSMENT_OBJECTIVES")); questionpool.setKeywords((String)assessmentMap.get("ASSESSMENT_KEYWORDS")); questionpool.setRubric((String)assessmentMap.get("ASSESSMENT_RUBRICS")); questionpool.setIntellectualPropertyId((Long)assessmentMap.get("INTELLECTUALPROPERTYID")); log.debug("QPOOL ASSESSMENT updating metadata information"); }
public void addQuestionPoolItem(QuestionPoolItemIfc queestionPoolItem){ Set questionPoolItemSet = getQuestionPoolItems(); questionPoolItemSet.add(queestionPoolItem); setQuestionPoolItems(questionPoolItemSet); }
throw new DataFacadeException(ex.getMessage()); this.id = getId(); this.displayName = getTitle(); this.description = getDescription(); this.questionPoolType = getType(); this.ownerId = getOwnerId(); this.owner = getOwner(); this.dateCreated = getDateCreated(); this.lastModified = getLastModified(); this.lastModifiedBy = getLastModifiedBy(); this.lastModifiedById = getLastModifiedById(); this.accessTypeId = getAccessTypeId(); this.accessType = getAccessType(); this.objectives = getObjectives(); this.keywords = getKeywords(); this.rubric = getRubric(); this.typeId = getTypeId(); this.type = getType(); this.intellectualPropertyId = getIntellectualPropertyId(); this.organizationName = getOrganizationName(); this.questionPoolItems = getQuestionPoolItems(); this.items = getQuestions(); try { this.parentId = getParentId();
QuestionPoolFacade questionpool = new QuestionPoolFacade(); QuestionPoolService questionPoolService = new QuestionPoolService(); questionpool.setOwnerId(me); questionpool.setTitle(title); questionpool.setLastModifiedById(me); questionpool.setAccessTypeId(QuestionPoolFacade.ACCESS_DENIED); // set as default questionpool = questionPoolService.savePool(questionpool); String baseId = questionpool.getQuestionPoolId().toString(); boolean isUnique=questionPoolService.poolIsUnique(baseId,title,"0", me); questionpool.setTitle(title); questionpool.setQuestionPoolItems(itemSet); item.setCreatedDate(questionpool.getLastModified()); item.setLastModifiedBy(me); item.setLastModifiedDate(questionpool.getLastModified()); item.setStatus(ItemDataIfc.ACTIVE_STATUS); itemService.saveItem(item); questionPoolItem.setQuestionPoolId(questionpool.getQuestionPoolId()); questionPoolItem.setItemId(item.getItemId()); questionpool.addQuestionPoolItem((QuestionPoolItemIfc) questionPoolItem); questionPoolService.deletePool(questionpool.getQuestionPoolId(), AgentFacade.getAgentString(), null); throw new RuntimeException(e);
String oldPoolName= oldPool.getDisplayName(); if (destId.equals(oldPool.getParentPoolId())) { duplicate = true; QuestionPoolFacade newPool = (QuestionPoolFacade) oldPool.clone(); newPool.setParentPoolId(destId); newPool.setQuestionPoolId( Long.valueOf(0)); newPool.setOwnerId(AgentFacade.getAgentString()); resetTitle(destId, newPool, oldPoolName, prependString1, prependString2); else newPool.updateDisplayName(oldPoolName); Iterator iter = oldPool.getQuestions().iterator(); List itemDataArray = new ArrayList(); while (iter.hasNext()) { newPool.setQuestionPoolItems(prepareQuestions(newPool.getQuestionPoolId(), itemDataArray)); newPool.setQuestions(itemDataArray); newPool = savePool(newPool); Set<QuestionPoolItemData> qpItems = newPool.getQuestionPoolItems(); Iterator<QuestionPoolItemData> qpItemsIterator = qpItems.iterator(); while (qpItemsIterator.hasNext()){ while (citer.hasNext()) { Long childPoolId = (Long) citer.next(); copyPool(tree, agentId, childPoolId, newPool.getQuestionPoolId(), prependString1, prependString2);
public void handle(Importable thing, String siteId) { QuestionPool importPool = (QuestionPool)thing; QuestionPoolFacade pool = new QuestionPoolFacade(); pool.setOwnerId(SessionManager.getCurrentSessionUserId()); pool.setTitle(importPool.getTitle()); pool.setDescription(importPool.getDescription()); pool.setAccessTypeId(Long.valueOf(30)); Set questionItems = new HashSet(); questionItems.addAll(doQuestions(importPool.getEssayQuestions(), siteId)); ItemFacade item = (ItemFacade)questionItemsArray[i]; item.setSequence(Integer.valueOf(i + 1)); qps.addItemToPool(item.getItemId(),savedPool.getQuestionPoolId());
QuestionPoolFacade destinationPool = new QuestionPoolFacade(); destinationPool.setOwnerId(SessionManager.getCurrentSessionUserId()); destinationPool.setTitle(sourcePool.getTitle()); destinationPool.setDescription(sourcePool.getDescription());
/** * IMPORTANT: this constructor do not have "data", this constructor is * merely used for holding questionPoolId, Title, parentId * for validation question pool * This constructor does not persist data (which it has none) to DB * @param id * @param title * @param parentid */ public QuestionPoolFacade(Long id, String title, Long parentId) { this.questionPoolId = id; this.title= title; this.parentPoolId=parentId; this.data = new QuestionPoolData(); QuestionPoolImpl questionPoolImpl = new QuestionPoolImpl(); //<-- place holder questionPool = (QuestionPool)questionPoolImpl; try { questionPool.updateData(this.data); setParentPoolId(parentId); setQuestionPoolId(id); setTitle(title); } catch (QuestionPoolException ex) { throw new DataFacadeException(ex.getMessage()); } }
if (destPoolId.equals(QuestionPoolFacade.ROOT_POOL) && !sourcePoolId.equals(QuestionPoolFacade.ROOT_POOL)) { sourcePool.setParentPoolId(QuestionPoolFacade.ROOT_POOL); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0){ try { getHibernateTemplate().update( (QuestionPoolData) sourcePool.getData()); retryCount = 0; sourcePool.setParentPoolId(destPool.getQuestionPoolId()); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0){ try { getHibernateTemplate().update( (QuestionPoolData) sourcePool.getData()); retryCount = 0;
/** * IMPORTANT: this constructor do not have "data", this constructor is * merely used for holding questionPoolId, Title * for displaying purpose (used by the pulldown list in authoring). * This constructor does not persist data (which it has none) to DB * @param id * @param title */ public QuestionPoolFacade(Long id, String title) { this.questionPoolId = id; this.title= title; this.data = new QuestionPoolData(); QuestionPoolImpl questionPoolImpl = new QuestionPoolImpl(); //<-- place holder questionPool = (QuestionPool)questionPoolImpl; try { questionPool.updateData(this.data); setQuestionPoolId(id); setTitle(title); } catch (QuestionPoolException ex) { throw new DataFacadeException(ex.getMessage()); } }
/** * * @param pdescription the description for the question pool * @throws DataFacadeException */ public void updateDescription(String description) throws DataFacadeException { setDescription(description); }
throw new DataFacadeException(ex.getMessage()); this.id = getId(); this.displayName = getTitle(); this.description = getDescription(); this.questionPoolType = getType(); this.ownerId = getOwnerId(); this.owner = getOwner(); this.dateCreated = getDateCreated(); this.lastModified = getLastModified(); this.lastModifiedBy = getLastModifiedBy(); this.lastModifiedById = getLastModifiedById(); this.accessTypeId = getAccessTypeId(); this.accessType = getAccessType(); this.objectives = getObjectives(); this.keywords = getKeywords(); this.rubric = getRubric(); this.typeId = getTypeId(); this.type = getType(); this.intellectualPropertyId = getIntellectualPropertyId(); this.organizationName = getOrganizationName(); this.questionPoolItems = getQuestionPoolItems(); this.items = getQuestions(); try { this.parentId = getParentId();
QuestionPoolFacade questionpool = new QuestionPoolFacade(); QuestionPoolService questionPoolService = new QuestionPoolService(); questionpool.setOwnerId(me); questionpool.setTitle(title); questionpool.setLastModifiedById(me); questionpool.setAccessTypeId(QuestionPoolFacade.ACCESS_DENIED); // set as default questionpool = questionPoolService.savePool(questionpool); String baseId = questionpool.getQuestionPoolId().toString(); boolean isUnique=questionPoolService.poolIsUnique(baseId,title,"0", me); questionpool.setTitle(title); questionpool.setQuestionPoolItems(itemSet); item.setCreatedDate(questionpool.getLastModified()); item.setLastModifiedBy(me); item.setLastModifiedDate(questionpool.getLastModified()); item.setStatus(ItemDataIfc.ACTIVE_STATUS); itemService.saveItem(item); questionPoolItem.setQuestionPoolId(questionpool.getQuestionPoolId()); questionPoolItem.setItemId(item.getItemId()); questionpool.addQuestionPoolItem((QuestionPoolItemIfc) questionPoolItem); questionPoolService.deletePool(questionpool.getQuestionPoolId(), AgentFacade.getAgentString(), null); throw new RuntimeException(e);
String oldPoolName= oldPool.getDisplayName(); if (destId.equals(oldPool.getParentPoolId())) { duplicate = true; QuestionPoolFacade newPool = (QuestionPoolFacade) oldPool.clone(); newPool.setParentPoolId(destId); newPool.setQuestionPoolId( Long.valueOf(0)); newPool.setOwnerId(AgentFacade.getAgentString()); resetTitle(destId, newPool, oldPoolName, prependString1, prependString2); else newPool.updateDisplayName(oldPoolName); Iterator iter = oldPool.getQuestions().iterator(); List itemDataArray = new ArrayList(); while (iter.hasNext()) { newPool.setQuestionPoolItems(prepareQuestions(newPool.getQuestionPoolId(), itemDataArray)); newPool.setQuestions(itemDataArray); newPool = savePool(newPool); Set<QuestionPoolItemData> qpItems = newPool.getQuestionPoolItems(); Iterator<QuestionPoolItemData> qpItemsIterator = qpItems.iterator(); while (qpItemsIterator.hasNext()){ while (citer.hasNext()) { Long childPoolId = (Long) citer.next(); copyPool(tree, agentId, childPoolId, newPool.getQuestionPoolId(), prependString1, prependString2);
/** * IMPORTANT: this constructor do not have "data", this constructor is * merely used for holding questionPoolId, Title, parentId * for validation question pool * This constructor does not persist data (which it has none) to DB * @param id * @param title * @param parentid */ public QuestionPoolFacade(Long id, String title, Long parentId) { this.questionPoolId = id; this.title= title; this.parentPoolId=parentId; this.data = new QuestionPoolData(); QuestionPoolImpl questionPoolImpl = new QuestionPoolImpl(); //<-- place holder questionPool = (QuestionPool)questionPoolImpl; try { questionPool.updateData(this.data); setParentPoolId(parentId); setQuestionPoolId(id); setTitle(title); } catch (QuestionPoolException ex) { throw new DataFacadeException(ex.getMessage()); } }
if (destPoolId.equals(QuestionPoolFacade.ROOT_POOL) && !sourcePoolId.equals(QuestionPoolFacade.ROOT_POOL)) { sourcePool.setParentPoolId(QuestionPoolFacade.ROOT_POOL); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0){ try { getHibernateTemplate().update( (QuestionPoolData) sourcePool.getData()); retryCount = 0; sourcePool.setParentPoolId(destPool.getQuestionPoolId()); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0){ try { getHibernateTemplate().update( (QuestionPoolData) sourcePool.getData()); retryCount = 0;
/** * IMPORTANT: this constructor do not have "data", this constructor is * merely used for holding questionPoolId, Title * for displaying purpose (used by the pulldown list in authoring). * This constructor does not persist data (which it has none) to DB * @param id * @param title */ public QuestionPoolFacade(Long id, String title) { this.questionPoolId = id; this.title= title; this.data = new QuestionPoolData(); QuestionPoolImpl questionPoolImpl = new QuestionPoolImpl(); //<-- place holder questionPool = (QuestionPool)questionPoolImpl; try { questionPool.updateData(this.data); setQuestionPoolId(id); setTitle(title); } catch (QuestionPoolException ex) { throw new DataFacadeException(ex.getMessage()); } }
public void addQuestionPoolItem(QuestionPoolItemIfc queestionPoolItem){ Set questionPoolItemSet = getQuestionPoolItems(); questionPoolItemSet.add(queestionPoolItem); setQuestionPoolItems(questionPoolItemSet); }