public void testHTMLTableImageToWiki() throws Exception { // Stage a project for the cache Project project = new Project(); project.setId(9999999); project.setTitle("Some Project"); project.setUniqueId("some-project"); CacheUtils.updateValue(Constants.SYSTEM_PROJECT_CACHE, 9999999, project); CacheUtils.updateValue(Constants.SYSTEM_PROJECT_UNIQUE_ID_CACHE, "some-project", 9999999); String wiki = HTMLToWikiUtils.htmlToWiki(htmlSample1, "", project.getId()); assertEquals( "" + "||Site||Description||\n" + "|[[Image:tzvids.arizona.stimulus.gi.jpg]]|This is the first picture\n" + "!\n" + "!(nice)|\n" + "|[[Image:tzvids.haiti.aid.afp.gi.jpg]]|This is the second picture|\n" + "", wiki); // Read it, re-write it, and compare Wiki thisWiki = new Wiki(); thisWiki.setProjectId(project.getId()); thisWiki.setContent(wiki); WikiToHTMLContext wikiContext = new WikiToHTMLContext(thisWiki, new HashMap<String, ImageInfo>(), -1, false, ""); String html = WikiToHTMLUtils.getHTML(wikiContext, null); assertEquals(wiki, HTMLToWikiUtils.htmlToWiki(html, "", project.getId())); }
public void testHTMLTableToWiki() throws Exception { // Stage a project for the cache Project project = new Project(); project.setId(9999999); project.setTitle("Some Project"); project.setUniqueId("some-project"); CacheUtils.updateValue(Constants.SYSTEM_PROJECT_CACHE, 9999999, project); CacheUtils.updateValue(Constants.SYSTEM_PROJECT_UNIQUE_ID_CACHE, "some-project", 9999999); String wiki = HTMLToWikiUtils.htmlToWiki(htmlSample1, "", project.getId()); assertEquals( "" + "||ConcourseConnect||ConcourseSuite||\n" + "|ConcourseConnect is the first platform that enables the creation of true commercial networks. Commercial networks are the intersection of social networking, web 2.0 collaboration and sales and marketing tools.\n" + "!\n" + "!ConcourseConnect enables organizations to create dynamic communities to connect various stakeholders and manage the entire ecosystem with an integrated management console and backend CRM tools. [[Security, Registration, Invitation|Installation Options]]|ConcourseSuite is Concursive's dedicated Customer Relationship Management (CRM) product. It is a complete front office solution that integrates CRM, website creation, content management and team collaboration capabilities into one easy to use, easy to deploy solution that is available in both hosted and on-premise configurations. [[Technical Documentation]] (Owner)|\n" + "", wiki); // Read it, re-write it, and compare Wiki thisWiki = new Wiki(); thisWiki.setProjectId(project.getId()); thisWiki.setContent(wiki); WikiToHTMLContext wikiContext = new WikiToHTMLContext(thisWiki, new HashMap<String, ImageInfo>(), -1, false, ""); String html = WikiToHTMLUtils.getHTML(wikiContext, null); assertEquals(wiki, HTMLToWikiUtils.htmlToWiki(html, "", project.getId())); }
public Object createEntry(Object key) throws Exception { Connection db = null; try { db = CacheUtils.getConnection(context); return new LookupList(db, String.valueOf(key)); } catch (Exception e) { return null; } finally { CacheUtils.freeConnection(context, db); } }
public Object createEntry(Object key) throws Exception { Integer projectId = null; Connection db = null; try { db = CacheUtils.getConnection(context); // Get the project id from its uniqueid PreparedStatement pst = db.prepareStatement("SELECT project_id FROM projects WHERE projecttextid = ? "); pst.setString(1, key.toString()); ResultSet rs = pst.executeQuery(); if (rs.next()) { projectId = rs.getInt("project_id"); } rs.close(); pst.close(); } catch (Exception e) { throw new Exception(e); } finally { CacheUtils.freeConnection(context, db); } return projectId; }
/** * Inserts the project to boomark in new listItem (task) records, a record is created for each of * the listIds (taskCategoryIds) specified. * * <p>Returns boolean on whether the operation was successful. Once one failure occurs the method * returns false without further processing. * * @param db - the database connection * @param existingTasks - the list of tasks already persisted * @param listIds - this list of listIds that will have the projectIdToBookmark saved * @param userId - the id of the user inserting the records * @param projectIdToBookmark - the id of the project that is being bookmarked * @param projectNameToBookmark - the name that will saved for the bookmark (task) * @param projectIdOfLists - the id of the project that owns the lists * @param request - the request * @return boolean on whether the operation was successful * @throws SQLException - generated trying to retrieve data */ private boolean saveToLists( Connection db, TaskList existingTasks, Collection<Integer> listIds, int userId, int projectIdToBookmark, String projectNameToBookmark, int projectIdOfLists, ActionRequest request) throws SQLException { Set<Integer> existingIds = new HashSet<Integer>(existingTasks.size()); Set<Integer> createForTaskCategoryIds = new HashSet<Integer>(listIds); for (Task task : existingTasks) { existingIds.add(task.getCategoryId()); } // find all the task category ids that do not already have tasks (these will have tasks // inserted) createForTaskCategoryIds.removeAll(existingIds); if (!createForTaskCategoryIds.isEmpty()) { boolean recordInserted = false; LookupList priorityList = CacheUtils.getLookupList("lookup_task_priority"); if (priorityList.isEmpty()) throw new RuntimeException("Could not load task priorities"); // just default to the top priority int priorityId = priorityList.get(0).getId(); for (LookupElement priority : priorityList) { if (priority.getDefaultItem()) { priorityList.get(0).getId(); break; } } // Parameters TaskList taskList = new TaskList(); for (Integer taskCategoryId : createForTaskCategoryIds) { Task task = new Task(); task.setEnteredBy(userId); task.setOwner(userId); task.setDescription(projectNameToBookmark); task.setModifiedBy(userId); task.setProjectId(projectIdOfLists); task.setLinkModuleId(Constants.TASK_CATEGORY_PROJECTS); task.setLinkItemId(projectIdToBookmark); task.setCategoryId(taskCategoryId); task.setPriority(priorityId); // Verify the specified category is in the same project TaskCategoryList list = new TaskCategoryList(); list.setProjectId(projectIdOfLists); list.setCategoryId(taskCategoryId); list.buildList(db); if (list.size() == 0) { return false; } recordInserted = task.insert(db); if (!recordInserted) { request.getPortletSession().setAttribute("task", task); return false; } taskList.add(task); } // Trigger the workflow PortalUtils.processInsertHook(request, taskList); return recordInserted; } else { return true; // no inserts needed } }