Skip to content

Commit

Permalink
Merge pull request #20 from diging/develop
Browse files Browse the repository at this point in the history
prepare release
  • Loading branch information
jdamerow authored Jan 14, 2022
2 parents ad26283 + a0e8044 commit 6fc0954
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 29 deletions.
9 changes: 8 additions & 1 deletion wic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<artifactId>commonmark</artifactId>
<version>0.15.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -198,6 +198,13 @@
<version>5.13.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>

<!-- Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import java.util.Map;

import org.apache.commons.io.IOUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

Expand Down Expand Up @@ -45,7 +49,12 @@ public class QuarigaConnector implements IQuadrigaConnector {
private RestTemplate restTemplate;

public QuarigaConnector() {
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
HttpClient httpClient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
factory.setHttpClient(httpClient);

restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -90,3 +99,4 @@ public TransformationResponse checkForResult(TransformationResponse response) {
return restTemplate.getForObject(response.getResultUrl(), TransformationResponse.class);
}
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package edu.asu.diging.wic.core.repository;

import java.util.List;

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import edu.asu.diging.wic.core.model.impl.ConceptText;

@Repository
public interface ConceptTextRepository extends PagingAndSortingRepository<ConceptText, Long> {

List<ConceptText> findByConceptId(String conceptId);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.asu.diging.wic.core.service;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort.Direction;

Expand All @@ -26,6 +28,13 @@ public interface IConceptTextService {
* @return Page of concept texts
*/
Page<ConceptText> findAll(Integer page, Integer itemsPerPage, String sortBy, Direction order);

/**
* Fetches the texts linked to the given concept
* @param conceptId Concept for which the texts are searched
* @return List of found concept texts
*/
List<ConceptText> findByConceptId(String conceptId);

/**
* Method used to delete a particular conceptText
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.asu.diging.wic.core.service.impl;

import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -42,6 +43,14 @@ public Page<ConceptText> findAll(Integer page, Integer itemsPerPage, String sort
Pageable pagination = PageRequest.of(page - 1, itemsPerPage, Sort.by(order, sortBy));
return conceptRepository.findAll(pagination);
}

/* (non-Javadoc)
* @see edu.asu.diging.wic.core.service.IConceptTextService#findByConceptId(java.lang.String)
*/
@Override
public List<ConceptText> findByConceptId(String conceptId) {
return conceptRepository.findByConceptId(conceptId);
}

/* (non-Javadoc)
* @see edu.asu.diging.wic.core.service.IConceptTextService#deleteText(java.lang.Long)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import edu.asu.diging.wic.core.conceptpower.IConceptpowerCache;
import edu.asu.diging.wic.core.graphs.IGraphDBConnection;
import edu.asu.diging.wic.core.model.IConcept;
import edu.asu.diging.wic.core.model.impl.ConceptText;
import edu.asu.diging.wic.core.model.impl.Edge;
import edu.asu.diging.wic.core.model.impl.Node;
import edu.asu.diging.wic.core.util.ISourceUriPatternUtil;
import edu.asu.diging.wic.core.service.IConceptTextService;
import edu.asu.diging.wic.web.cytoscape.Data;
import edu.asu.diging.wic.web.cytoscape.EdgeData;
import edu.asu.diging.wic.web.cytoscape.GraphElement;
Expand All @@ -43,6 +44,9 @@ public class PersonController {
@Autowired
private IConceptpowerCache cache;

@Autowired
private IConceptTextService conceptTextService;

@Value("${general.node.color}")
private String generalNodeColor;

Expand Down Expand Up @@ -71,6 +75,8 @@ public String showPerson(@PathVariable("personId") String personId, Model model)
model.addAttribute("concept", concept);
if (concept != null) {
model.addAttribute("alternativeIdsString", String.join(",", concept.getAlternativeUris()));
List<ConceptText> conceptTexts = conceptTextService.findByConceptId(personId);
model.addAttribute("texts", conceptTexts);
}

return "person";
Expand All @@ -86,7 +92,6 @@ public String getConceptStatements(@PathVariable("conceptId") String conceptId,

model.addAttribute("concept", concept);
model.addAttribute("alternativeIdsString", String.join(",", concept.getAlternativeUris()));
model.addAttribute("isPerson", concept.getType() != null && concept.getType().getId().equals(personTypeId));
return "person/statements";
}

Expand Down
9 changes: 9 additions & 0 deletions wic/src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p: %c - %m%n" />
</layout>
</appender>
<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="file" value="logs/wic.log"/>
<param name="immediateFlush" value="true"/>

<layout class="org.apache.log4j.PatternLayout">
<param name="conversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>

<!-- Application Loggers -->
<logger name="edu.asu.diging">
Expand Down Expand Up @@ -40,6 +48,7 @@
<root>
<priority value="warn" />
<appender-ref ref="console" />
<appender-ref ref="FILE" />
</root>

</log4j:configuration>
49 changes: 24 additions & 25 deletions wic/src/main/webapp/WEB-INF/views/person.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<style>
.list-unstyled {
overflow: auto;
max-height:700px;
}
#relationships {
padding-top: 25px;
}
</style>
<script type="text/javascript">
//# sourceURL=getGraph.js
$(function() {
Expand Down Expand Up @@ -58,31 +68,19 @@
<br/>

<div class="col-md-7 text-left">
<c:if test="${isPerson}">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.
</p>
<p>
Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu.
</p>
<p>
Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit.
</p>
<p>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam.
</p>
<p>
Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis.
</p>
<p>
Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem. Morbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu, varius ut, felis. In auctor lobortis lacus. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. Vestibulum ullamcorper mauris at ligula. Fusce fermentum. Nullam cursus lacinia erat. Praesent blandit laoreet nibh. Fusce convallis metus id felis luctus adipiscing. Pellentesque egestas, neque sit amet convallis pulvinar, justo nulla eleifend augue, ac auctor orci leo non est.
</p>
<p>
Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vestibulum dapibus nunc ac augue. Curabitur vestibulum aliquam leo. Praesent egestas neque eu enim. In hac habitasse platea dictumst. Fusce a quam. Etiam ut purus mattis mauris sodales aliquam. Curabitur nisi. Quisque malesuada placerat nisl. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Sed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Mauris sollicitudin fermentum libero. Praesent nonummy mi in odio. Nunc interdum lacus sit amet orci. Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Morbi mollis tellus ac sapien. Phasellus volutpat, metus eget egestas mollis, lacus lacus blandit dui, id egestas quam mauris ut lacus. Fusce vel dui. Sed in libero ut nibh placerat accumsan. Proin faucibus arcu quis ante. In consectetuer turpis ut velit. Nulla sit amet est. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Suspendisse feugiat. Suspendisse enim turpis, dictum sed, iaculis a, condimentum nec, nisi. Praesent nec nisl a purus blandit viverra. Praesent ac massa at ligula laoreet iaculis. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Mauris turpis nunc, blandit et, volutpat molestie, porta ut, ligula. Fusce pharetra convallis urna. Quisque ut nisi. Donec mi odio, faucibus at, scelerisque quis,</p>
</p>

<c:if test="${texts != null and not texts.isEmpty()}">
<ul class="list-unstyled">
<c:forEach items="${texts}" var="text">
<li>
<h3><strong>${text.title}</strong></h3>
<figcaption>By ${text.author}</figcaption>
<p>${text.htmlRenderedText()}</p>
</li>
</c:forEach>
</ul>
</c:if>
<c:if test="${not isPerson}">
<c:if test="${texts == null or texts.isEmpty()}">
<h4 id="relationships">Relationships</h4>
<ul id="graphList" class="list-group">
<div id="spinner1"><div class="fa fa-spinner fa-spin"></div> Loading relationships... Hang tight, this might take a few minutes.</div>
</ul>
Expand All @@ -93,7 +91,8 @@ Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vesti
<div id="spinner" class="text-center"><div class="fa fa-spinner fa-spin"></div> Loading graph...</div>
<div id="network" style="min-width: 200px; min-height: 200px; "></div>

<c:if test="${isPerson}">
<c:if test="${texts != null and not texts.isEmpty()}">
<h4 id="relationships">Relationships</h4>
<ul id="graphList" class="list-group">
<div id="spinner1"><div class="fa fa-spinner fa-spin"></div> Loading relationships... Hang tight, this might take a few minutes.</div>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ public class ConceptTextServiceTest {

private ConceptText conceptText1;
private ConceptText conceptText2;
private ConceptText conceptText3;
private Long id;

private static final String SORTBY_ATTR = "title";
private static final String CONCEPT_ID = "WC123";

@Before
public void setUp() {
Expand All @@ -48,7 +50,7 @@ public void setUp() {
conceptText1 = new ConceptText();
conceptText1.setId(id);
conceptText1.setAuthor("Smit");
conceptText1.setConceptId("WC123");
conceptText1.setConceptId(CONCEPT_ID);
conceptText1.setText("The great Scientist");
conceptText1.setTitle("A Title");

Expand All @@ -57,6 +59,12 @@ public void setUp() {
conceptText2.setConceptId("WC124");
conceptText2.setText("The great Researcher");
conceptText2.setTitle("B Title");

conceptText3 = new ConceptText();
conceptText3.setAuthor("Smit");
conceptText3.setConceptId(CONCEPT_ID);
conceptText3.setText("The great Student");
conceptText3.setTitle("C Title");
}

@Test
Expand Down Expand Up @@ -84,6 +92,29 @@ public void test_findAll() {
Assert.assertEquals(conceptText1, responseList.get(0));
Assert.assertEquals(conceptText2, responseList.get(1));
}

@Test
public void test_findByConceptId_success() {
List<ConceptText> conceptTexts = new ArrayList<>();
conceptTexts.add(conceptText1);
conceptTexts.add(conceptText3);

when(conceptRepository.findByConceptId(CONCEPT_ID)).thenReturn(conceptTexts);

List<ConceptText> actualTexts = conceptTextService.findByConceptId(CONCEPT_ID);
Assert.assertEquals(conceptTexts.size(), actualTexts.size());
for (ConceptText text : conceptTexts) {
Assert.assertTrue(actualTexts.contains(text));
}
}

@Test
public void test_findByConceptId_empty() {
when(conceptRepository.findByConceptId(CONCEPT_ID)).thenReturn(new ArrayList<>());

List<ConceptText> actualTexts = conceptTextService.findByConceptId("1234");
Assert.assertEquals(0, actualTexts.size());
}

@Test
public void test_deleteText_forSuccess() {
Expand Down

0 comments on commit 6fc0954

Please sign in to comment.