view src/main/webapp/pages/topicPage.jsp @ 42:815cd86bb9ec

bug fixed: some NullPointer situations caused by null topicId
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 18 Dec 2015 11:50:24 +0100
parents ba9515f22897
children 9dbbbfd474f4
line wrap: on
line source

<%@page import="de.mpiwg.gazetteer.dataverse.bo.VDCUser"%>
<%@page import="de.mpiwg.gazetteer.bo.LGFile"%>
<%@page import="de.mpiwg.gazetteer.bo.LGBranch"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="de.mpiwg.gazetteer.db.DBSection"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />

<html>
<head>

	<jsp:include page="../componentes/headContent.jsp"/>	
	
	<script>
		  $(function() {
			  
			    $( "#dialogDataverse" ).dialog({
			        autoOpen: false,
			        modal: true,
			        width: 600,
			        position: { my: "center", at: "top", of: window },
			        hide: {
			          effect: "explode",
			          duration: 1000
			        }
				});			
				
				$( ".get-studies" ).click(function() {
					var fileId = $( this ).data('file-id');
					
					var url0 = "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/getDataverseForm.jsp?fileId=" + fileId;

					$.ajax( url0 )
					.done(function(data) {
						$( "#dialogDataverseTable" ).replaceWith(data);
						$( "#dialogDataverse" ).dialog( "open" );
					})
				  	.fail(function() {
				    	console.error("Error calling: " + query);
				  	})
					
			    });					  
			  
			  
			 var dialog = $( "#dialogAddContributors" ).dialog(
					{autoOpen: false}
		  	);	  
			 
			$( "#addContributors" ).button().on( "click", function() {
			        dialog.dialog( "open" );
			});	 
		  });
	</script>
	
</head>

<body>
	<jsp:include page="../componentes/template.jsp"/>
	
	

	<div id="page">
		
		<% if(sessionBean.getUser() == null) { %>
			<label class="subTitel">You must login!</label>
		<% } else { %>
		
			<% if(sessionBean.getTopicPage().getCompleteSectionList() == null || request.getParameter("topicId") != null) {
				sessionBean.getTopicPage().loadParameters(request, response);
				sessionBean.getTopicPage().loadTopic(request.getParameter("topicId"));
			} %>
			
			<% if(sessionBean.getTopicPage().getCompleteSectionList().isEmpty()) { %>
				<label>Task not found!</label>
				
			<% } else { %>
			
				<div id="dialogAddContributors" title="Select a new Contributors:">
					<form name="contributorsForm" id="contributorsForm"
							action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
							method="post">
							<input name="bean" type="hidden" value="topicBean" /> 
							<input name="topicId" type="hidden" value="<%=sessionBean.getTopicPage().getTopicId()%>" />
						
						<table>
							<% for(VDCUser user : sessionBean.getTopicPage().getSuggestionUserList()) { %>
								<tr>
									<td><a href="#" onclick="setAction0('addContributor', 'contributorsForm', 'userId', <%=user.getId() %>);document.getElementById('contributorsForm').submit();"><%=user.getUserName()%></a></td>
								</tr>
							<% } %>
						</table>
					</form>
				</div>
				
				<!-- Topic Detail -->
				<div>
					<label class="subTitel">Topic "<%=sessionBean.getTopicPage().getTopic().getNameEn() %> (<%=sessionBean.getTopicPage().getTopic().getNameCh()%>)" Details </label>
					
					<table class="tableComponent">
						<tr>
							<td><label>Topic Id</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getId() %></label></td>
						</tr>
						<tr>
							<td><label>Topic Name(eng)</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getNameEn() %></label></td>
						</tr>
						<tr>
							<td><label>Topic Name(chi)</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getNameCh() %></label></td>
						</tr>
						<tr>
							<td><label>Topic Name(pinyin)</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getNamePinyin() %></label></td>
						</tr>
						<tr>
							<td><label>Description</label></td>
							<td>
								<form name="topicForm"
									action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
									method="post">
									<input name="bean" type="hidden" value="topicBean" />
									<input name="topicId" type="hidden" value="<%=sessionBean.getTopicPage().getTopicId()%>" />
									<input type="text" name="description" size="60" maxlength="250" value="<%=sessionBean.getTopicPage().getTopic().getDescription() %>" />
									<input type="image" alt="edit description" onclick="setAction('updateDescription', 'topicForm');" 
										src="<%=sessionBean.getApplicationBean().getSaveImage()%>" width="15" height="15"/>	
								
								</form>
							</td>
						<tr>
							<td><label>Created</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getFomattedCreation() %></label></td>
						</tr>
						<tr>
							<td><label>Last Modified</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getFomattedLastChange() %></label></td>
						</tr>
						<tr>
							<td><label>Creator</label></td>
							<td><label><%=sessionBean.getTopicPage().getTopic().getUsername() %></label></td>
						</tr>
						<tr>
							<td><label>Contributors</label></td>
							<td>
								<table>
									<tr>
										<td>
											<form name="contributorForm"
												action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
												method="post">
												<input name="bean" type="hidden" value="topicBean" />
												<input name="topicId" type="hidden" value="<%=sessionBean.getTopicPage().getTopicId()%>" />
						
												<table style="width: 300px;" class="pageTable">
													<% for(VDCUser contr : sessionBean.getTopicPage().getContributors()) { %>
														<tr>
															<td><label><%=contr.getUserName() %></label></td>
															<td>
																<input type="image" 
																	onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> setAction0('removeContributor', 'contributorForm', 'userId',  <%=contr.getId() %>);" 
																	src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/>																	
															</td>
														</tr>
													<% } %>
												</table>
											</form>
										</td>
										<td>
											<button id="addContributors" type="button" class="lgButton">Add Contributors</button>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</div>
				
				
				
				<!-- Sections in Topic -->
				
				<div>
					<form name="topicSectionRelationForm"
						action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
						method="post">
						<input name="bean" type="hidden" value="topicBean" />
						<input name="topicId" type="hidden" value="<%=sessionBean.getTopicPage().getTopicId()%>" />
						
						
						<label class="subTitel">Sections in Topic
							<input type="image"
								onclick="setAction0('forceLoadTopicSectionRelation', 'topicSectionRelationForm');"
								src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/>
						</label>
									
						<div class="tableDiv double-scroll">
							<table class="pageTable">
								<tr>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Book Id</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByBookIdUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByBookIdDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="bookIdFilter" id="bookIdFilter" value="<%= sessionBean.getTopicPage().getBookIdFilter() %>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>							
											</tr>								
										</table>										
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Book Name</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByBookNameUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByBookNameDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="bookNameFilter" id="bookNameFilter" value="<%= sessionBean.getTopicPage().getBookNameFilter() %>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>							
											</tr>								
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Level 1</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByLevel1Up', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByLevel1Down', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="level1Filter" id="level1Filter" value="<%= sessionBean.getTopicPage().getLevel1Filter()%>"/>
												</td>				
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>
											</tr>
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Level 2</label></td>
												<td>
													<table>
														<tr>
															<td>
																<input type="image"
																onclick="setAction('sortByLevel2Up', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
															</td>
														</tr>
														<tr>
															<td>
																<input type="image"
																onclick="setAction('sortByLevel2Down', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="level2Filter" id="level2Filter" value="<%= sessionBean.getTopicPage().getLevel2Filter()%>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>					
											</tr>					
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Dynasty</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByDynastyUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByDynastyDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="dynastyFilter" id="dynastyFilter" value="<%= sessionBean.getTopicPage().getDynastyFilter() %>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>
											</tr>
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Period</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByPeriodUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByPeriodDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="periodFilter" id="periodFilter" value="<%= sessionBean.getTopicPage().getPeriodFilter()%>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>							
											</tr>
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Admin Type</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByAdminTypeUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByAdminTypeDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="adminTypeFilter" id="adminTypeFilter" value="<%= sessionBean.getTopicPage().getAdminTypeFilter()%>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>							
											</tr>
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Section Name</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortBySectionNameUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortBySectionNameDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" class="filterInput" name="sectionNameFilter" id="sectionNameFilter" value="<%= sessionBean.getTopicPage().getSectionNameFilter()%>"/>
												</td>									
												<td>
													<input type="image"
														onclick="setAction('filter', 'topicSectionRelationForm');"
														src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
												</td>
											</tr>
										</table>
									</th>
									<th>
										<table class="sortTable">
											<tr>
												<td><label class="tableTitle">Section Pages</label></td>
												<td>
													<table>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByStartPageUp', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
														</td></tr>
														<tr><td>
															<input type="image"
																onclick="setAction('sortByStartPageDown', 'topicSectionRelationForm');"
																src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
														</td></tr>
													</table>
												</td>
											</tr>
										</table>
									</th>
									
									<th><label class="tableTitle">View Text</label></th>
									<th><label class="tableTitle">Existing Tasks</label></th>
									<th><label class="tableTitle">Remove</label></th>
								</tr>	
								
								<% for(DBSection section : sessionBean.getTopicPage().getDisplaySectionList() ) { %>
								<tr>
									<td>
										<a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=section.getBook().getId() %>&amp;count=100&amp;sessionId=<%= session.getId()%>" target="blank">
											<%=section.getBookId()%>
										</a>	
									</td>
									<td><label><%= section.getBook().getName() %></label></td>
									<td><label><%= section.getBook().getLevel1() %></label></td>
									<td><label><%= section.getBook().getLevel2() %></label></td>
									<td><label><%= section.getBook().getDynasty() %></label></td>
									<td><label><%= section.getBook().getPeriod() %></label></td>
									<td><label><%= section.getBook().getAdmin_type() %></label></td>
									<td><label><%= section.getName() %></label></td>
									<td><label><%= section.getPages() %></label></td>
								
									<!-- view text in Ext-Interface -->
									<td>
										<a	href="#"
											title="Show Section in Extraction Interface" 
										 	onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBookId() %>', '<%=section.getBook().getName() %>', '<%=sessionBean.getUser().getId() %>', '<%=sessionBean.getApplicationBean().getExtractionInterfaceUrl()%>');">
										 	<img alt="Show Section in Extraction Interface" src="<%=sessionBean.getApplicationBean().getShowImage()%>">
										</a>
									</td>
									
									<!-- existing branches (tasks) -->
									<td style="max-width:300px;">
										<% if(section.getBranches() != null && !section.getBranches().isEmpty()) { %>
											<table style="width:100%">
												<% for(LGBranch branch : section.getBranches()) { %>
													<tr>
														<td>
															<table style="width:100%">
															<tr><td><%=branch.getFomattedLastChange() %></td></tr>
															<tr><td><%=branch.getLabel() %></td></tr>
															</table>
														</td>
														<td style="max-width:150px">
															<% if (branch.hasContributor(sessionBean.getUser().getId())) { %>
															<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/pages/branchPage.jsp?branchId=<%=branch.getId() %>" >
																<img alt="Manage Branch" src="<%=sessionBean.getApplicationBean().getEditBranchImage()%>"/>
															</a>												
															<% } else { %>
																<label>Contributors: <%=branch.getContributorsNameList() %></label>
															<% } %>
														</td>
													</tr>
												<% } %>
											</table>
										<% } %>
									</td>						
									<td>
				
										<input type="image" 
											onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> setAction0('deleteSection', 'topicSectionRelationForm', 'sectionId', <%=section.getId() %>);" 
											src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/>
									</td>
								</tr>
								<% } %>				
							</table>
						</div>
					</form>
				</div>
			
											
			<% } %>

		<% } %>
	
	</div>
	
</body>