From 46fe18a97c066cef3ec2e38bfeda7f8bfbc42066 Mon Sep 17 00:00:00 2001 From: Karthikeyan Date: Mon, 27 Mar 2017 17:16:25 -0700 Subject: [PATCH 01/15] [CCP-218] Changes for displaying merged ids and merged concepts. (#163) When user searches with the word net id that has been merged, the merged concept will be displayed, Previously the wrapper of the word net was displayed but from now the merged concept itself will be displayed. Also the RESTFul apis will display the merged ids of the concepts. --- .../app/core/impl/ConceptManager.java | 8 +++++ .../rest/msg/json/ConceptEntryMessage.java | 11 +++++++ .../rest/msg/json/JsonConceptMessage.java | 17 ++++++++++ .../conceptpower/rest/msg/json/MergedId.java | 31 +++++++++++++++++++ .../rest/msg/xml/XMLConceptMessage.java | 20 ++++++++++++ .../rest/msg/xml/XMLConstants.java | 1 + 6 files changed, 88 insertions(+) create mode 100644 Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/MergedId.java diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java index ca8edffae..9e20f5224 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java @@ -69,6 +69,14 @@ public class ConceptManager implements IConceptManager { */ @Override public ConceptEntry getConceptEntry(String id) { + + ConceptEntry[] entries = client.getEntriesByFieldContains(SearchFieldNames.MERGED_IDS, id); + if (entries != null && entries.length > 0) { + fillConceptEntry(entries[0]); + alternativeIdService.addAlternativeIds(id, entries[0]); + return entries[0]; + } + ConceptEntry entry = client.getEntry(id); if (entry != null) { fillConceptEntry(entry); diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/ConceptEntryMessage.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/ConceptEntryMessage.java index 7e7a73fb9..d2d4beee9 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/ConceptEntryMessage.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/ConceptEntryMessage.java @@ -51,6 +51,9 @@ public class ConceptEntryMessage { @JsonProperty("alternativeIds") private List alternativeIds; + @JsonProperty("mergedIds") + private List mergedIds; + public String getId() { return id; } @@ -171,4 +174,12 @@ public void setConceptUri(String conceptUri) { this.conceptUri = conceptUri; } + public List getMergedIds() { + return mergedIds; + } + + public void setMergedIds(List mergedIds) { + this.mergedIds = mergedIds; + } + } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/JsonConceptMessage.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/JsonConceptMessage.java index 61db350e0..3d03214dd 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/JsonConceptMessage.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/JsonConceptMessage.java @@ -1,7 +1,9 @@ package edu.asu.conceptpower.rest.msg.json; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; @@ -84,6 +86,21 @@ private ConceptEntryMessage getConceptMessage(ConceptEntry entry, ConceptType ty json.setAlternativeIds(alternativeIds); } } + + if (entry.getMergedIds() != null && !entry.getMergedIds().isEmpty()) { + Map uriMap = uriCreator + .getUrisBasedOnIds(new HashSet(Arrays.asList(entry.getMergedIds()))); + if (uriMap != null && !uriMap.isEmpty()) { + List mergedIds = new ArrayList<>(); + for (Map.Entry uri : uriMap.entrySet()) { + MergedId mergedId = new MergedId(); + mergedId.setConceptId(uri.getKey()); + mergedId.setConceptUri(uri.getValue()); + mergedIds.add(mergedId); + } + json.setMergedIds(mergedIds); + } + } return json; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/MergedId.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/MergedId.java new file mode 100644 index 000000000..18c62d305 --- /dev/null +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/json/MergedId.java @@ -0,0 +1,31 @@ +package edu.asu.conceptpower.rest.msg.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(Include.NON_NULL) +public class MergedId { + + @JsonProperty("concept_id") + private String conceptId; + @JsonProperty("concept_uri") + private String conceptUri; + + public String getConceptId() { + return conceptId; + } + + public void setConceptId(String conceptId) { + this.conceptId = conceptId; + } + + public String getConceptUri() { + return conceptUri; + } + + public void setConceptUri(String conceptUri) { + this.conceptUri = conceptUri; + } + +} diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConceptMessage.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConceptMessage.java index 1adf56911..831090328 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConceptMessage.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConceptMessage.java @@ -1,6 +1,8 @@ package edu.asu.conceptpower.rest.msg.xml; +import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; @@ -165,6 +167,24 @@ private String getConceptMessage(ConceptEntry entry, ConceptType type) { } + // Adding merged ids and their corresponding uris. + if (entry.getMergedIds() != null && !entry.getMergedIds().isEmpty()) { + sb.append("<" + XMLConstants.NAMESPACE_PREFIX + ":" + XMLConstants.MERGED_IDS + ">"); + String[] mergedIds = entry.getMergedIds().split(","); + Map uriMap = uriCreator.getUrisBasedOnIds(new HashSet(Arrays.asList(mergedIds))); + + for (Map.Entry uri : uriMap.entrySet()) { + sb.append("<" + XMLConstants.NAMESPACE_PREFIX + ":" + XMLConstants.ID + " "); + sb.append(XMLConstants.CONCEPT_ID + "=\"" + uri.getKey() + "\" "); + sb.append(XMLConstants.CONCEPT_URI + "=\"" + uri.getValue() + "\""); + sb.append(">"); + sb.append(uri.getValue()); + sb.append(""); + } + + sb.append(""); + } + sb.append(""); return sb.toString(); diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConstants.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConstants.java index 77d40173c..ac3676d55 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConstants.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/msg/xml/XMLConstants.java @@ -41,4 +41,5 @@ public interface XMLConstants { public final static String PAGE_NUMBER = "page_number"; public final static String ERROR_MESSAGE = "error_message"; public final static String ALTERNATIVE_IDS = "alternativeIds"; + public final static String MERGED_IDS = "mergedIds"; } From a881329369f237f9561a46a90338b06b1b16df5a Mon Sep 17 00:00:00 2001 From: Karthikeyan Date: Thu, 30 Mar 2017 09:56:21 -0700 Subject: [PATCH 02/15] [CCP-210] Concept search requires atleast one search parameter (#166) * [CCP-210] Concept search requires atleast one search parameter From now on concept search rest api requires atleast one search parameter. If no parameter is provided, the system returns the error message "No search condition present" and return 400 http status code. Previously the system went into 500 error when no parameter is provided. * [CCP-210] Review comments fix. --- .../conceptpower/rest/ConceptSearchIT.java | 22 +++++++++++++++ .../conceptSearchNoSearchParameters.json | 1 + .../conceptSearchNoSearchParameters.xml | 1 + .../rest/ConceptSearchParameterValidator.java | 27 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.json create mode 100644 Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.xml diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java index a07ead39f..ef1670d0c 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java @@ -1,6 +1,7 @@ package edu.asu.conceptpower.rest; import static org.hamcrest.core.Is.is; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -260,4 +261,25 @@ public void test_searchConcept_searchWithWordPosAndDescriptionInXml() throws Exc } + @Test + public void test_searchConcept_failureNoValidSearchParametersInXml() throws Exception { + final String output = IOUtil.toString( + this.getClass().getClassLoader().getResourceAsStream("output/conceptSearchNoSearchParameters.xml")); + + this.mockMvc.perform(MockMvcRequestBuilders.get("/ConceptSearch").accept(MediaType.APPLICATION_XML_VALUE)) + .andExpect(content().string(output)).andExpect(status().isBadRequest()); + + } + + @Test + public void test_searchConcept_failureNoValidSearchParametersInJson() throws Exception { + final String output = IOUtil.toString( + this.getClass().getClassLoader().getResourceAsStream("output/conceptSearchNoSearchParameters.json")); + + this.mockMvc.perform(MockMvcRequestBuilders.get("/ConceptSearch").accept(MediaType.APPLICATION_JSON_VALUE)) + .andDo(print()) + .andExpect(content().string(output)).andExpect(status().isBadRequest()); + + } + } diff --git a/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.json b/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.json new file mode 100644 index 000000000..180907392 --- /dev/null +++ b/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.json @@ -0,0 +1 @@ +[{"message":"No valid search parameters present."}] \ No newline at end of file diff --git a/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.xml b/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.xml new file mode 100644 index 000000000..73d2d7ea1 --- /dev/null +++ b/Conceptpower+Spring/src/integration-test/resources/output/conceptSearchNoSearchParameters.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameterValidator.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameterValidator.java index c7feb19ff..319c269de 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameterValidator.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameterValidator.java @@ -1,5 +1,9 @@ package edu.asu.conceptpower.rest; +import java.lang.reflect.Field; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.validation.Errors; import org.springframework.validation.Validator; @@ -17,6 +21,8 @@ @Component public class ConceptSearchParameterValidator implements Validator { + private final Logger logger = LoggerFactory.getLogger(ConceptSearchParameterValidator.class); + @Override public boolean supports(Class clazz) { return ConceptSearchParameters.class.isAssignableFrom(clazz); @@ -25,6 +31,10 @@ public boolean supports(Class clazz) { @Override public void validate(Object target, Errors errors) { ConceptSearchParameters conceptSearchParameter = (ConceptSearchParameters) target; + + if (!hasAtLeastOneNonEmpty(conceptSearchParameter)) { + errors.reject("invalidSearch", "No valid search parameters present."); + } if (conceptSearchParameter.getPos() != null && !POS.posValues.contains(conceptSearchParameter.getPos().toLowerCase())) { errors.reject("pos", "Please enter correct pos value."); } @@ -36,4 +46,21 @@ public void validate(Object target, Errors errors) { } } + private boolean hasAtLeastOneNonEmpty(ConceptSearchParameters conceptSearchParameters) { + Field[] fields = ConceptSearchParameters.class.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + try { + if (field.get(conceptSearchParameters) != null) { + return true; + } + } catch (IllegalArgumentException e) { + logger.error("IllegalArgumentException", e); + } catch (IllegalAccessException ie) { + logger.error("IllegalAccessException", ie); + } + } + return false; + } + } From bb56f0f3927002d6f38acdcd3e3e51d6e501ed3f Mon Sep 17 00:00:00 2001 From: Julia Damerow Date: Thu, 30 Mar 2017 15:25:50 -0700 Subject: [PATCH 03/15] Story/ccp 202 (#168) * [CCP-174] Made session timeout as 4 hours (#138) * [CCP-174] hotfix to master Updated session timeout to 4 hours * [CCP-174] Changed the comments to four hours * Story/ccp 202 master (#158) * [CCP-202] Integration test for master branch * [CCP-202-master] Changes for test case for master branch Added all the applicable test cases for master branch. Few test cases such as json and validations are temporarily removed. Will be added once the develop integration test branch is merged to master. * [CCP-202-master] Removed unwanted files. Removed unwanted files. Will be added when their corresponding test cases are added in integration test. * [CCP-202-master] Added security context for luceneDAO * [CCP-202-master] Review comments fix * [CCP-202] Added correct expected output. These test cases will be fixed when develop branch is getting merged. * [CCP-202-master] Removed word net database. * [CCP-202-master] Added logger statements for downloads manager and integration test * [CCP-202-master] Added log4j config file for integration test * Caught all exceptions and logged errors. * [CCP-202-master] Created new file before loading from dropbox. * Logger level changed to error for exceptions Changed the way fileoutputstream is instantiated Closing resources are handled in same try block. * [CCP-202-master] Made sure security context is setup only when required. * [CCP-202-master] Changed the correct file name * [CCP-202] Fixes for test case in master branch * [CCP-202] Reverted to master branch code base. * [CCP-202-master] Loggers are logged as error in exception catch blocks * Fix XML * [CCP-202] Changes for integration tests. 1) Most of the files had trailing spaces. Removed those spaces. 2) Made sure correct error message is returned when there are no entries in concept look up 3) For multiple entries returned in concept look up, alternative ids were missing in the output. Made sure the json and xml files contains the alternative ids. * [CCP-202] Removed duplicated files due to conflicts * [CCP-202] unit test changes for correct error message when concept is not found * [CCP-202] Changes for Concept look up IT test cases. * [CCP-202] Changes for not considering ordering. Ordering in output will not be tested. * [CCP-202] Dependancy changes --- Conceptpower+Spring/pom.xml | 1548 +++++++++-------- .../edu/asu/conceptpower/IntegrationTest.java | 1 - .../conceptpower/rest/ConceptIDLookupIT.java | 8 +- .../conceptpower/rest/ConceptLookupIT.java | 7 +- .../conceptpower/rest/ConceptSearchIT.java | 18 +- .../conceptpower/rest/SynonymSearchIT.java | 3 +- .../asu/conceptpower/rest/TypeIdLookUpIT.java | 4 +- .../resources/output/conceptEntryNotFound.xml | 2 +- .../resources/output/types.json | 2 +- .../asu/conceptpower/rest/ConceptLookup.java | 7 +- .../java/edu/asu/conceptpower/root/.DS_Store | Bin 6148 -> 0 bytes .../validatormessages_en_US.properties | 40 +- .../conceptpower/rest/ConceptLookupTest.java | 5 +- .../src/test/resources/db4o-config-test.xml | 1 - .../src/test/resources/rest-context-test.xml | 1 - .../src/test/resources/rest-service-test.xml | 1 - .../test/resources/servlet-context-test.xml | 2 +- .../unitTestOutput/conceptLookupNoResult.xml | 1 + 18 files changed, 831 insertions(+), 820 deletions(-) delete mode 100644 Conceptpower+Spring/src/main/java/edu/asu/conceptpower/root/.DS_Store create mode 100644 Conceptpower+Spring/src/test/resources/unitTestOutput/conceptLookupNoResult.xml diff --git a/Conceptpower+Spring/pom.xml b/Conceptpower+Spring/pom.xml index cd94d3018..58766fba9 100644 --- a/Conceptpower+Spring/pom.xml +++ b/Conceptpower+Spring/pom.xml @@ -1,772 +1,782 @@ - 4.0.0 - edu.asu - conceptpower - ConceptPower - war - 2.0-BUILD-SNAPSHOT - - 1.8 - 4.1.6.RELEASE - 1.7.3 - 1.7.5 - http://localhost:8080/manager/text - conceptpower - conceptpower-test - conceptpower - /Users/jdamerow/Software/Conceptpower/db_files - - - - - - admin - admin - /usr/local/WordNet-3.0 - 3.2.8.RELEASE - /Users/karthikeyanmohan/Software/Conceptpower/indexFiles - - debug - false - false - https://www.dropbox.com/s/48gftjus29qyp2q/conceptLists.db?raw=1 - https://www.dropbox.com/s/mla61f63fgfil3y/conceptTypes.db?raw=1 - https://www.dropbox.com/s/n0vgpc5ow1xko4v/users.db?raw=1 - - - - - objectdb - ObjectDB Repository - http://m2.objectdb.com - - - - - - dev - - - ${db.files.path} - ${deploy.path.dev} - ${tomcat.deploy.path} - ${email.username} - ${email.password} - ${email.server.port} - ${email.server.host} - ${admin.username} - ${admin.password} - ${wordnet.path} - ${lucene.index} - - - - test - - - ${db.files.path} - ${deploy.path.test} - ${tomcat.deploy.path} - ${email.username} - ${email.password} - ${email.server.port} - ${email.server.host} - ${admin.username} - ${admin.password} - ${wordnet.path} - ${lucene.index} - - - - prod - - - ${db.files.path} - ${deploy.path.prod} - ${tomcat.deploy.path} - ${email.username} - ${email.password} - ${email.server.port} - ${email.server.host} - ${admin.username} - ${admin.password} - ${wordnet.path} - ${lucene.index} - - - - integration-test - - - ${db.files.path} - ${deploy.path.test} - ${tomcat.deploy.path} - ${email.username} - ${email.password} - ${email.server.port} - ${email.server.host} - ${admin.username} - ${admin.password} - ${wordnet.path} - ${lucene.index} - ${concept.list.url} - ${concept.types.url} - ${users.url} - debug - - - - - - - - org.springframework - spring-context - ${org.springframework-version} - - - - commons-logging - commons-logging - - - - - org.springframework - spring-webmvc - ${org.springframework-version} - - - org.springframework - spring-oxm - 3.0.0.RELEASE - - - - - - org.springframework.ldap - spring-ldap-core - 1.3.1.RELEASE - - - org.springframework.ldap - spring-ldap-core-tiger - 1.3.1.RELEASE - - - org.springframework.ldap - spring-ldap-odm - 1.3.1.RELEASE - - - org.springframework.ldap - spring-ldap-ldif-core - 1.3.1.RELEASE - - - org.springframework.ldap - spring-ldap-ldif-batch - 1.3.1.RELEASE - - - - - org.aspectj - aspectjrt - ${org.aspectj-version} - - - - - org.slf4j - slf4j-api - ${org.slf4j-version} - - - org.slf4j - jcl-over-slf4j - ${org.slf4j-version} - runtime - - - org.slf4j - slf4j-log4j12 - ${org.slf4j-version} - runtime - - - log4j - log4j - 1.2.15 - - - javax.mail - mail - - - javax.jms - jms - - - com.sun.jdmk - jmxtools - - - com.sun.jmx - jmxri - - - runtime - - - - - javax.inject - javax.inject - 1 - - - - - javax.servlet - javax.servlet-api - 3.0.1 - - - - javax.servlet.jsp - jsp-api - 2.1 - provided - - - javax.servlet - jstl - 1.2 - - - - junit - junit - 4.11 - test - - - - - mysql - mysql-connector-java - 5.1.25 - - - - - org.springframework.security - spring-security-core - ${spring-security-version} - - - org.springframework.security - spring-security-config - ${spring-security-version} - - - org.springframework.security - spring-security-taglibs - ${spring-security-version} - - - org.springframework.security - spring-security-ldap - ${spring-security-version} - - - commons-httpclient - commons-httpclient - 3.1 - - - org.apache.tiles - tiles-template - 3.0.1 - - - org.apache.tiles - tiles-core - 3.0.1 - - - org.apache.tiles - tiles-api - 3.0.1 - - - org.apache.tiles - tiles-servlet - 3.0.1 - - - org.apache.tiles - tiles-jsp - 3.0.1 - - - - - - org.springframework - spring-core - ${org.springframework-version} - - - org.springframework - spring-test - ${org.springframework-version} - - - org.springframework - spring-orm - ${org.springframework-version} - - - org.springframework - spring-oxm - ${org.springframework-version} - - - org.springframework - spring-web - ${org.springframework-version} - - - - org.springframework - spring-aop - ${org.springframework-version} - - - aspectj - aspectjweaver - 1.5.4 - - - commons-io - commons-io - 20030203.000550 - - - cglib - cglib - 3.0 - - - - - edu.mit - jwi - 2.2.3 - - - org.apache.commons - commons-lang3 - 3.4 - - - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.10 - - - - javax.xml.bind - jaxb-api - 2.0 - - - javax.mail - mail - 1.5.0-b01 - - - org.springframework - spring-beans - ${org.springframework-version} - - - org.springframework - spring-context-support - ${org.springframework-version} - - - - - joda-time - joda-time - 2.7 - - - - org.hibernate - hibernate-validator - 4.2.0.Final - - - - - com.db4o - db4o-full-java5 - 8.0 - - - - - com.objectdb - objectdb - 2.6.3 - - - org.eclipse.persistence - javax.persistence - 2.1.0 - - - javax.transaction - jta - 1.1 - - - - org.springframework - spring-tx - ${org.springframework-version} - - - - aopalliance - aopalliance - 1.0 - - - cglib - cglib - 2.2 - - - org.aspectj - aspectjweaver - 1.6.10 - - - org.springframework - spring-orm - ${org.springframework-version} - - - - ant - ant - 1.7.0 - - - - - com.googlecode.json-simple - json-simple - 1.1 - - - - - org.mockito - mockito-core - 1.9.5 - - - org.springframework.security - spring-security-web - ${spring-security-version} - - - - com.jayway.jsonpath - json-path - 2.1.0 - - - - - org.apache.lucene - lucene-core - 5.4.0 - - - - - org.apache.lucene - lucene-queryparser - 5.4.0 - - - - - org.apache.lucene - lucene-analyzers-common - 5.4.0 - - - - - org.apache.lucene - lucene-demos - 3.0.3 - - - - - com.fasterxml.jackson.core - jackson-databind - 2.1.0 - - - com.fasterxml.jackson.core - jackson-core - 2.1.0 - - - - - org.apache.jena - apache-jena-libs - pom - 3.0.1 - - - - - scm:svn:http://none - scm:svn:https://none - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - xml - - - - - maven-eclipse-plugin - 2.9 - - - org.springframework.ide.eclipse.core.springnature - - - org.springframework.ide.eclipse.core.springbuilder - - true - true - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - -Xlint:all - true - true - - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - - - true - src/main/webapp - - **/* - - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - org.test.int1.Main - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - ${tomcat.path} - TomcatServer - /${deploy.path} - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - initialize - - create - - - - - false - false - - - buildNumber\d* - timestamp - - #{0} ({1,date,yyyy-MM-dd HH:mm:ss}) - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - - add-integration-test-sources - generate-test-sources - - add-test-source - - - - - src/integration-test/java - - - - - - add-integration-test-resources - generate-test-resources - - add-test-resource - - - - - - true - src/integration-test/resources - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - - ${skip.unit.tests} - - - **/*IT.java - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18 - - - - integration-tests - - integration-test - verify - - - - ${skip.integration.tests} - - - - - - - - true - src/main/resources - - **/* - - - - true - src/test/resources - - **/* - - - - true - src/integration-test/resources - - **/* - - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - - cobertura - - - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + edu.asu + conceptpower + ConceptPower + war + 2.0-BUILD-SNAPSHOT + + 1.8 + 4.3.7.RELEASE + 1.7.3 + 1.7.5 + http://localhost:8080/manager/text + conceptpower + conceptpower-test + conceptpower + /Users/jdamerow/Software/Conceptpower/db_files + + + + + + admin + admin + /usr/local/WordNet-3.0 + 3.2.8.RELEASE + /Users/karthikeyanmohan/Software/Conceptpower/indexFiles + + debug + false + false + https://www.dropbox.com/s/48gftjus29qyp2q/conceptLists.db?raw=1 + https://www.dropbox.com/s/mla61f63fgfil3y/conceptTypes.db?raw=1 + https://www.dropbox.com/s/n0vgpc5ow1xko4v/users.db?raw=1 + + + + + objectdb + ObjectDB Repository + http://m2.objectdb.com + + + + + + dev + + + ${db.files.path} + ${deploy.path.dev} + ${tomcat.deploy.path} + ${email.username} + ${email.password} + ${email.server.port} + ${email.server.host} + ${admin.username} + ${admin.password} + ${wordnet.path} + ${lucene.index} + + + + test + + + ${db.files.path} + ${deploy.path.test} + ${tomcat.deploy.path} + ${email.username} + ${email.password} + ${email.server.port} + ${email.server.host} + ${admin.username} + ${admin.password} + ${wordnet.path} + ${lucene.index} + + + + prod + + + ${db.files.path} + ${deploy.path.prod} + ${tomcat.deploy.path} + ${email.username} + ${email.password} + ${email.server.port} + ${email.server.host} + ${admin.username} + ${admin.password} + ${wordnet.path} + ${lucene.index} + + + + integration-test + + + ${db.files.path} + ${deploy.path.test} + ${tomcat.deploy.path} + ${email.username} + ${email.password} + ${email.server.port} + ${email.server.host} + ${admin.username} + ${admin.password} + ${wordnet.path} + ${lucene.index} + ${concept.list.url} + ${concept.types.url} + ${users.url} + debug + + + + + + + + org.springframework + spring-context + ${org.springframework-version} + + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + org.springframework + spring-oxm + 3.0.0.RELEASE + + + + + + org.springframework.ldap + spring-ldap-core + 1.3.1.RELEASE + + + org.springframework.ldap + spring-ldap-core-tiger + 1.3.1.RELEASE + + + org.springframework.ldap + spring-ldap-odm + 1.3.1.RELEASE + + + org.springframework.ldap + spring-ldap-ldif-core + 1.3.1.RELEASE + + + org.springframework.ldap + spring-ldap-ldif-batch + 1.3.1.RELEASE + + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + runtime + + + org.slf4j + slf4j-log4j12 + ${org.slf4j-version} + runtime + + + log4j + log4j + 1.2.15 + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + runtime + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + javax.servlet-api + 3.0.1 + + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + 1.2 + + + + junit + junit + 4.12 + test + + + + + mysql + mysql-connector-java + 5.1.25 + + + + + org.springframework.security + spring-security-core + ${spring-security-version} + + + org.springframework.security + spring-security-config + ${spring-security-version} + + + org.springframework.security + spring-security-taglibs + ${spring-security-version} + + + org.springframework.security + spring-security-ldap + ${spring-security-version} + + + commons-httpclient + commons-httpclient + 3.1 + + + org.apache.tiles + tiles-template + 3.0.1 + + + org.apache.tiles + tiles-core + 3.0.1 + + + org.apache.tiles + tiles-api + 3.0.1 + + + org.apache.tiles + tiles-servlet + 3.0.1 + + + org.apache.tiles + tiles-jsp + 3.0.1 + + + + + + org.springframework + spring-core + ${org.springframework-version} + + + org.springframework + spring-test + ${org.springframework-version} + + + org.springframework + spring-orm + ${org.springframework-version} + + + org.springframework + spring-oxm + ${org.springframework-version} + + + org.springframework + spring-web + ${org.springframework-version} + + + + org.springframework + spring-aop + ${org.springframework-version} + + + aspectj + aspectjweaver + 1.5.4 + + + commons-io + commons-io + 20030203.000550 + + + cglib + cglib + 3.0 + + + + + edu.mit + jwi + 2.2.3 + + + org.apache.commons + commons-lang3 + 3.4 + + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.10 + + + + javax.xml.bind + jaxb-api + 2.0 + + + javax.mail + mail + 1.5.0-b01 + + + org.springframework + spring-beans + ${org.springframework-version} + + + org.springframework + spring-context-support + ${org.springframework-version} + + + + + joda-time + joda-time + 2.7 + + + + org.hibernate + hibernate-validator + 4.2.0.Final + + + + + com.db4o + db4o-full-java5 + 8.0 + + + + + com.objectdb + objectdb + 2.6.3 + + + org.eclipse.persistence + javax.persistence + 2.1.0 + + + javax.transaction + jta + 1.1 + + + + org.springframework + spring-tx + ${org.springframework-version} + + + + aopalliance + aopalliance + 1.0 + + + cglib + cglib + 2.2 + + + org.aspectj + aspectjweaver + 1.6.10 + + + org.springframework + spring-orm + ${org.springframework-version} + + + + ant + ant + 1.7.0 + + + + + com.googlecode.json-simple + json-simple + 1.1 + + + + + org.mockito + mockito-core + 1.9.5 + + + org.springframework.security + spring-security-web + ${spring-security-version} + + + + com.jayway.jsonpath + json-path + 2.1.0 + + + + + org.apache.lucene + lucene-core + 5.4.0 + + + + + org.apache.lucene + lucene-queryparser + 5.4.0 + + + + + org.apache.lucene + lucene-analyzers-common + 5.4.0 + + + + + org.apache.lucene + lucene-demos + 3.0.3 + + + + + com.fasterxml.jackson.core + jackson-databind + 2.7.9 + + + com.fasterxml.jackson.core + jackson-core + 2.7.9 + + + + + org.apache.jena + apache-jena-libs + pom + 3.0.1 + + + + + org.skyscreamer + jsonassert + 0.9.0 + + + + + xmlunit + xmlunit + 1.6 + + + + + scm:svn:http://none + scm:svn:https://none + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + xml + + + + + maven-eclipse-plugin + 2.9 + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + -Xlint:all + true + true + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + true + src/main/webapp + + **/* + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.test.int1.Main + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + ${tomcat.path} + TomcatServer + /${deploy.path} + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + initialize + + create + + + + + false + false + + + buildNumber\d* + timestamp + + #{0} ({1,date,yyyy-MM-dd HH:mm:ss}) + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + + add-integration-test-sources + generate-test-sources + + add-test-source + + + + + src/integration-test/java + + + + + + add-integration-test-resources + generate-test-resources + + add-test-resource + + + + + + true + src/integration-test/resources + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18 + + + ${skip.unit.tests} + + + **/*IT.java + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18 + + + + integration-tests + + integration-test + verify + + + + ${skip.integration.tests} + + + + + + + + true + src/main/resources + + **/* + + + + true + src/test/resources + + **/* + + + + true + src/integration-test/resources + + **/* + + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + + cobertura + + + + + + diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/IntegrationTest.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/IntegrationTest.java index 7f07f8c0e..32ddd3fc8 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/IntegrationTest.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/IntegrationTest.java @@ -1,7 +1,6 @@ package edu.asu.conceptpower; import java.security.Principal; - import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptIDLookupIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptIDLookupIT.java index 916ec9a56..9ee423abe 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptIDLookupIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptIDLookupIT.java @@ -19,7 +19,7 @@ public void test_getConceptById_successForWordNetIdInJson() throws Exception { this.mockMvc .perform(MockMvcRequestBuilders.get("/Concept").param("id", "WID-02380464-N-01-polo_pony") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -30,7 +30,7 @@ public void test_getConceptById_successForGenericWordNetIdInJson() throws Except this.mockMvc .perform(MockMvcRequestBuilders.get("/Concept").param("id", "WID-02380464-N-??-polo_pony") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -49,7 +49,7 @@ public void test_getConceptById_successForLocalConceptIdInJson() throws Exceptio this.mockMvc .perform(MockMvcRequestBuilders.get("/Concept").param("id", "CONdf62c00c-f4a9-4564-9dd6-c9b955650f3a") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test @@ -59,7 +59,7 @@ public void test_getConceptById_successForConceptWrapperInJson() throws Exceptio this.mockMvc .perform(MockMvcRequestBuilders.get("/Concept").param("id", "CONe7fbf694-5609-4691-bca8-916526c2ba6a") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } public void test_getConceptById_successForWordNetIdInXml() throws Exception { diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptLookupIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptLookupIT.java index 741fb3ac0..92e77c51c 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptLookupIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptLookupIT.java @@ -9,6 +9,7 @@ import org.junit.Test; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import edu.asu.conceptpower.IntegrationTest; @@ -21,7 +22,7 @@ public void test_getWordNetEntry_successForSingleEntryInJson() throws Exception this.mockMvc .perform(MockMvcRequestBuilders.get("/ConceptLookup/Douglas Weiner/noun") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test @@ -40,7 +41,7 @@ public void test_getWordNetEntry_successForMultipleEntryInJson() throws Exceptio this.mockMvc .perform(MockMvcRequestBuilders.get("/ConceptLookup/Douglas/noun") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(MockMvcResultMatchers.content().json(output, false)).andExpect(status().isOk()); } @Test @@ -70,7 +71,7 @@ public void test_getWordNetEntry_successForMultipleEntryInXml() throws Exception this.mockMvc .perform(MockMvcRequestBuilders.get("/ConceptLookup/Douglas/noun") .accept(MediaType.APPLICATION_XML_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().xml(output)).andExpect(status().isOk()); } } diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java index ef1670d0c..48f170521 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/ConceptSearchIT.java @@ -24,7 +24,7 @@ public void test_searchConcept_searchWithWordAndPosInJson() throws Exception { this.mockMvc .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "einstein").param("pos", "noun") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -37,7 +37,7 @@ public void test_searchConcept_successWithDefaultOperator() throws Exception { this.mockMvc .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "einstein").param("pos", "noun") .accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -62,7 +62,7 @@ public void test_searchConcept_searchWithWordAndPosAndEqualToInJson() throws Exc .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "Abbott Henderson Thayer") .param("pos", "noun").param("equal_to", "http://viaf.org/viaf/55043769") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -76,7 +76,7 @@ public void test_searchConcept_searchWithWordAndPosAndSimilarToInJson() throws E .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "Douglas Weiner") .param("pos", "noun").param("similar_to", "http://viaf.org/viaf/248802520") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test @@ -88,7 +88,7 @@ public void test_searchConcept_searchWithWordPosAndPaginationInJson() throws Exc .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "einstein").param("pos", "noun") .param("number_of_records_per_page", "2").param("page", "1") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); final String output2 = IOUtil.toString( this.getClass().getClassLoader().getResourceAsStream("output/conceptWithWordPosAndPagination2.json")); @@ -97,7 +97,7 @@ public void test_searchConcept_searchWithWordPosAndPaginationInJson() throws Exc .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "einstein").param("pos", "noun") .param("number_of_records_per_page", "2").param("page", "2") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output2)).andExpect(status().isOk()); + .andExpect(content().json(output2, false)).andExpect(status().isOk()); } @@ -111,7 +111,7 @@ public void test_searchConcept_searchWithWordPosAndTypeIdInJson() throws Excepti .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "Almira Hart Lincoln Phelps") .param("pos", "noun").param("type_id", "986a7cc9-c0c1-4720-b344-853f08c136ab") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -126,7 +126,7 @@ public void test_searchConcept_searchWithWordPosAndTypeUriInJson() throws Except .param("pos", "noun") .param("type_uri", "http://www.digitalhps.org/types/TYPE_986a7cc9-c0c1-4720-b344-853f08c136ab") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } @@ -140,7 +140,7 @@ public void test_searchConcept_searchWithWordPosAndDescriptionInJson() throws Ex .perform(MockMvcRequestBuilders.get("/ConceptSearch").param("word", "Douglas Weiner") .param("pos", "noun").param("description", "American 20th century environmentalist") .param("operator", SearchParamters.OP_AND).accept(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(output)).andExpect(status().isOk()); + .andExpect(content().json(output, false)).andExpect(status().isOk()); } diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/SynonymSearchIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/SynonymSearchIT.java index 72d32e5a2..d2d1f214d 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/SynonymSearchIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/SynonymSearchIT.java @@ -24,7 +24,7 @@ public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) request.setParameter("id", "WID-02382039-N-02-Indian_pony"); return request; } - })).andExpect(content().string(output)).andExpect(status().isOk()); + })).andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test @@ -81,5 +81,4 @@ public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) } })).andExpect(status().isBadRequest()); } - } diff --git a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/TypeIdLookUpIT.java b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/TypeIdLookUpIT.java index 9c469f01d..7985eebef 100644 --- a/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/TypeIdLookUpIT.java +++ b/Conceptpower+Spring/src/integration-test/java/edu/asu/conceptpower/rest/TypeIdLookUpIT.java @@ -25,7 +25,7 @@ public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) request.setParameter("id", "986a7cc9-c0c1-4720-b344-853f08c136ab"); return request; } - })).andExpect(content().string(output)).andExpect(status().isOk()); + })).andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test @@ -38,7 +38,7 @@ public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) request.setParameter("id", XMLConstants.TYPE_PREFIX + "986a7cc9-c0c1-4720-b344-853f08c136ab"); return request; } - })).andExpect(content().string(output)).andExpect(status().isOk()); + })).andExpect(content().json(output, false)).andExpect(status().isOk()); } @Test diff --git a/Conceptpower+Spring/src/integration-test/resources/output/conceptEntryNotFound.xml b/Conceptpower+Spring/src/integration-test/resources/output/conceptEntryNotFound.xml index 0f7b3bf51..669fa5cd3 100644 --- a/Conceptpower+Spring/src/integration-test/resources/output/conceptEntryNotFound.xml +++ b/Conceptpower+Spring/src/integration-test/resources/output/conceptEntryNotFound.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Conceptpower+Spring/src/integration-test/resources/output/types.json b/Conceptpower+Spring/src/integration-test/resources/output/types.json index 0aea07137..4c0e18660 100644 --- a/Conceptpower+Spring/src/integration-test/resources/output/types.json +++ b/Conceptpower+Spring/src/integration-test/resources/output/types.json @@ -1 +1 @@ -{"description":"This class comprises real persons who live or are assumed to have lived. \r\nLegendary figures that may have existed, such as Ulysses and King Arthur, fall into this class \r\nif the documentation refers to them as historical figures. In cases where doubt exists as to \r\nwhether several persons are in fact identical, multiple instances can be created and linked to \r\nindicate their relationship. The CRM does not propose a specific form to support reasoning \r\nabout possible identity. \r\nExamples: \r\nƒ Tut-Ankh-Amun \r\nƒ Nelson Mandela","matches":"http://purl.org/NET/cidoc-crm/core#E21_Person","superType":{"type_id":"01054126-b6ec-4d31-9b7f-7bc6738eb79a","type_uri":"http://www.digitalhps.org/types/TYPE_01054126-b6ec-4d31-9b7f-7bc6738eb79a","type_name":"E20 Biological Object"},"type_id":"986a7cc9-c0c1-4720-b344-853f08c136ab","type_uri":"http://www.digitalhps.org/types/TYPE_986a7cc9-c0c1-4720-b344-853f08c136ab","creator_id":"jdamerow","modified_by":""} \ No newline at end of file +{"description":"This class comprises real persons who live or are assumed to have lived. \r\nLegendary figures that may have existed, such as Ulysses and King Arthur, fall into this class \r\nif the documentation refers to them as historical figures. In cases where doubt exists as to \r\nwhether several persons are in fact identical, multiple instances can be created and linked to \r\nindicate their relationship. The CRM does not propose a specific form to support reasoning \r\nabout possible identity. \r\nExamples: \r\nƒ Tut-Ankh-Amun \r\nƒ Nelson Mandela","matches":"http://purl.org/NET/cidoc-crm/core#E21_Person","superType":{"type_id":"01054126-b6ec-4d31-9b7f-7bc6738eb79a","type_uri":"http://www.digitalhps.org/types/TYPE_01054126-b6ec-4d31-9b7f-7bc6738eb79a","type_name":"E20 Biological Object"},"type_id":"986a7cc9-c0c1-4720-b344-853f08c136ab","type_uri":"http://www.digitalhps.org/types/TYPE_986a7cc9-c0c1-4720-b344-853f08c136ab","creator_id":"jdamerow","modified_by":""} \ No newline at end of file diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptLookup.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptLookup.java index 9b5da9504..63552fe4c 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptLookup.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptLookup.java @@ -82,11 +82,12 @@ public class ConceptLookup { return new ResponseEntity(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } - if (entries == null) { - return new ResponseEntity("No search results.", HttpStatus.OK); + IConceptMessage conceptMessage = messageFactory.getMessageFactory(acceptHeader).createConceptMessage(); + if (entries == null || entries.length == 0) { + return new ResponseEntity(conceptMessage.getErrorMessage("No concept entry found."), + HttpStatus.OK); } Map entryMap = generateEntryMap(entries); - IConceptMessage conceptMessage = messageFactory.getMessageFactory(acceptHeader).createConceptMessage(); String xmlEntries = null; if (entries != null) { xmlEntries = conceptMessage.getAllConceptEntriesAndPaginationDetails(entryMap, null); diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/root/.DS_Store b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/root/.DS_Store deleted file mode 100644 index 21f8870828b5844af6e9d7c70fedf5755c40792c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%Sr<=6g_FXs0y_{pe|?Ws^A|Cwu%J>X%$?lt&dU}TCug@Za%}0@&o(;KfpiG zbCXb}Q>RoHB62U>oJ^8)Gdam5698uS@p=a+11Qo33(HKtFsT=xv79eiAsQQ_g%JjL zz)d5XX{`mSfGY6U6p(Ls302h5!UcWu{SK}=(V)Xx*&1Hx&mY#91J+T)F-|eW4Zrp} z(-GR}A!11tcg&B`ZbVZt_Q~5$#MmIOZFwD{M5>YBBlcOE6-C}88D(=O$`PaW>0SG7 z8F5TA6=xLFzbJ?#cb_FMRvYa1`DR-WVR$BZ`a&IYaB{3`CRyTi_idLRP zYgs+UoS!S^GE~jKr}%3V{tyezOJSUfP{J9Rhg=&2&gw1u?`HK5Sz*al%15<13h>Mp zE6N_ArV6M6sz6c!*&hPBVCXS+Xtxd~_6k5Ou-F>&^1~pUz+>n!cE}oz{ePOIPpW__ z@UIjwg?g*L%OUx*b!KpK)&}%Tx|p response = conceptLookup.getWordNetEntry(noResult, POS.NOUN, MediaType.APPLICATION_XML_VALUE); - Assert.assertEquals("No search results.", response.getBody()); + Assert.assertEquals(expectedResponse, response.getBody()); Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); } diff --git a/Conceptpower+Spring/src/test/resources/db4o-config-test.xml b/Conceptpower+Spring/src/test/resources/db4o-config-test.xml index a4ec9ad83..7b1376572 100644 --- a/Conceptpower+Spring/src/test/resources/db4o-config-test.xml +++ b/Conceptpower+Spring/src/test/resources/db4o-config-test.xml @@ -20,5 +20,4 @@ - diff --git a/Conceptpower+Spring/src/test/resources/rest-context-test.xml b/Conceptpower+Spring/src/test/resources/rest-context-test.xml index 85562eb4d..05c388057 100644 --- a/Conceptpower+Spring/src/test/resources/rest-context-test.xml +++ b/Conceptpower+Spring/src/test/resources/rest-context-test.xml @@ -41,5 +41,4 @@ - diff --git a/Conceptpower+Spring/src/test/resources/rest-service-test.xml b/Conceptpower+Spring/src/test/resources/rest-service-test.xml index 29a31db6b..0c854e5d9 100644 --- a/Conceptpower+Spring/src/test/resources/rest-service-test.xml +++ b/Conceptpower+Spring/src/test/resources/rest-service-test.xml @@ -76,7 +76,6 @@ - edu.asu.conceptpower.app.profile.impl.ViafReply diff --git a/Conceptpower+Spring/src/test/resources/servlet-context-test.xml b/Conceptpower+Spring/src/test/resources/servlet-context-test.xml index ddbfc558d..b67fe6fd6 100644 --- a/Conceptpower+Spring/src/test/resources/servlet-context-test.xml +++ b/Conceptpower+Spring/src/test/resources/servlet-context-test.xml @@ -29,6 +29,6 @@ - + diff --git a/Conceptpower+Spring/src/test/resources/unitTestOutput/conceptLookupNoResult.xml b/Conceptpower+Spring/src/test/resources/unitTestOutput/conceptLookupNoResult.xml new file mode 100644 index 000000000..669fa5cd3 --- /dev/null +++ b/Conceptpower+Spring/src/test/resources/unitTestOutput/conceptLookupNoResult.xml @@ -0,0 +1 @@ + \ No newline at end of file From 493d8d133cc4fe44c3a96f7392ad3af251112d95 Mon Sep 17 00:00:00 2001 From: Karthikeyan Date: Mon, 3 Apr 2017 08:53:07 -0700 Subject: [PATCH 04/15] Bug/CCP-211 (#167) * [CCP-211] Removed the backslash "/" in concept entry Back slash has been removed in equalsTo and similarTo in concept entry. This has been removed in setter because lucene gets the values from the object using reflection and not the getters so changes are made while loading the values. Also from now on any insertion of equalsTo and simialrTo will not be having "/". Also any search with "/" at the end needs to be removed. This will be done using spring conversion service. * [CCP-211] Changes for concept search of equals and similar to Before searching for equals and similar to, we can check if equals and similar to contains a back slash in the end of the url. If so we remove the backslash and search on lucene. Also while inserting the values on to lucene we check for the backslash. * [CCP-211] Formatting changes * [CCP-211] Review comments changes Handled multiple equalsTo and similarTo string values. used PropertyDescriptor for getting and setting values. Included exceptions in unit test cases. * [CCP-211] Review comments changes. Moved operators, similarTo and equalsTo to bean class. pre processing of typeUri and numberOfPages in concept search class. This is because typeUri and numberOfpAges needs dependency that needs to be injected which is not possible in ConceptsearchParameters. * [CCP-211] Review comments fix. * [CCP-211] Changes for review comments. Made sure correct operator is used while querying lucene. Number of pages is loaded correctly. * [CCP-211] Test case fix. Removed iterating the transient fields using Property descriptor. * [CCP-218] Changes for displaying merged ids and merged concepts. (#163) When user searches with the word net id that has been merged, the merged concept will be displayed, Previously the wrapper of the word net was displayed but from now the merged concept itself will be displayed. Also the RESTFul apis will display the merged ids of the concepts. * [CCP-211] Review comments fixes. Changed the if conditions to ternary operator. Fixed a bug in getSimilarTo() in conceptEntry * [CCP-211] Review comments changes Added comments on why transient field modifier is used. Used ternary operator to get the number of records per page. * [CCP-211] Review comments changes --- .../output/conceptWithWordAndPos.json | 2 +- .../output/conceptWithWordAndPos.xml | 2 +- .../asu/conceptpower/core/ConceptEntry.java | 47 +++++++++++-- .../asu/conceptpower/rest/ConceptSearch.java | 70 ++++++++++++------- .../rest/ConceptSearchParameters.java | 26 +++++-- .../conceptpower/rest/SearchParamters.java | 2 + .../conceptpower/rest/ConceptSearchTest.java | 17 +++-- 7 files changed, 126 insertions(+), 40 deletions(-) diff --git a/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.json b/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.json index 0260a7903..a3c41d6a3 100644 --- a/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.json +++ b/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.json @@ -1 +1 @@ -{"conceptEntries":[{"id":"WID-10954498-N-01-Einstein","lemma":"einstein","pos":"noun","description":"physicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-10954498-N-01-Einstein","concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-01-Einstein"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-01-Einstein","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"WID-10954498-N-02-Albert_Einstein,","wordnet_id":"WID-10954498-N-01-Einstein"},{"id":"WID-10126926-N-05-Einstein","lemma":"einstein","pos":"noun","description":"someone who has exceptional intellectual ability and originality; \"Mozart was a child genius\"; \"he's smart but he's no Einstein\"","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-10126926-N-05-Einstein","concept_uri":"http://www.digitalhps.org/concepts/WID-10126926-N-05-Einstein"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-10126926-N-05-Einstein","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"WID-10126926-N-01-genius,WID-10126926-N-02-mastermind,WID-10126926-N-03-brain,WID-10126926-N-04-brainiac,","wordnet_id":"WID-10126926-N-05-Einstein"}],"pagination":{"pageNumber":1,"totalNumberOfRecords":4}} \ No newline at end of file +{"conceptEntries":[{"id":"WID-10954498-N-01-Einstein","lemma":"einstein","pos":"noun","description":"physicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-10954498-N-01-Einstein","concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-01-Einstein"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-01-Einstein","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"WID-10954498-N-02-Albert_Einstein,","wordnet_id":"WID-10954498-N-01-Einstein"},{"id":"WID-10126926-N-05-Einstein","lemma":"einstein","pos":"noun","description":"someone who has exceptional intellectual ability and originality; \"Mozart was a child genius\"; \"he's smart but he's no Einstein\"","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-10126926-N-05-Einstein","concept_uri":"http://www.digitalhps.org/concepts/WID-10126926-N-05-Einstein"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-10126926-N-05-Einstein","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"WID-10126926-N-01-genius,WID-10126926-N-02-mastermind,WID-10126926-N-03-brain,WID-10126926-N-04-brainiac,","wordnet_id":"WID-10126926-N-05-Einstein"},{"id":"WID-10954498-N-02-Albert_Einstein","lemma":"albert einstein","pos":"noun","description":"physicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-10954498-N-02-Albert_Einstein","concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-02-Albert_Einstein"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-10954498-N-02-Albert_Einstein","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"WID-10954498-N-01-Einstein,","wordnet_id":"WID-10954498-N-02-Albert_Einstein"},{"id":"WID-05875723-N-01-Bose-Einstein_statistics","lemma":"bose-einstein statistics","pos":"noun","description":"(physics) statistical law obeyed by a system of particles whose wave function is not changed when two particles are interchanged (the Pauli exclusion principle does not apply)","conceptList":"WordNet","deleted":false,"alternativeIds":[{"concept_id":"WID-05875723-N-01-Bose-Einstein_statistics","concept_uri":"http://www.digitalhps.org/concepts/WID-05875723-N-01-Bose-Einstein_statistics"}],"concept_uri":"http://www.digitalhps.org/concepts/WID-05875723-N-01-Bose-Einstein_statistics","creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":"WID-05875723-N-01-Bose-Einstein_statistics"}],"pagination":{"pageNumber":1,"totalNumberOfRecords":4}} \ No newline at end of file diff --git a/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.xml b/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.xml index 3b9b199f8..2bbfc42a6 100644 --- a/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.xml +++ b/Conceptpower+Spring/src/integration-test/resources/output/conceptWithWordAndPos.xml @@ -1 +1 @@ -http://www.digitalhps.org/concepts/WID-10954498-N-01-Einsteineinsteinnounphysicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)WordNetWID-10954498-N-02-Albert_Einstein,falseWID-10954498-N-01-Einsteinhttp://www.digitalhps.org/concepts/WID-10954498-N-01-Einsteinhttp://www.digitalhps.org/concepts/WID-10126926-N-05-Einsteineinsteinnounsomeone who has exceptional intellectual ability and originality; "Mozart was a child genius"; "he's smart but he's no Einstein"WordNetWID-10126926-N-01-genius,WID-10126926-N-02-mastermind,WID-10126926-N-03-brain,WID-10126926-N-04-brainiac,falseWID-10126926-N-05-Einsteinhttp://www.digitalhps.org/concepts/WID-10126926-N-05-Einstein \ No newline at end of file +http://www.digitalhps.org/concepts/WID-10954498-N-01-Einsteineinsteinnounphysicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)WordNetWID-10954498-N-02-Albert_Einstein,falseWID-10954498-N-01-Einsteinhttp://www.digitalhps.org/concepts/WID-10954498-N-01-Einsteinhttp://www.digitalhps.org/concepts/WID-10126926-N-05-Einsteineinsteinnounsomeone who has exceptional intellectual ability and originality; "Mozart was a child genius"; "he's smart but he's no Einstein"WordNetWID-10126926-N-01-genius,WID-10126926-N-02-mastermind,WID-10126926-N-03-brain,WID-10126926-N-04-brainiac,falseWID-10126926-N-05-Einsteinhttp://www.digitalhps.org/concepts/WID-10126926-N-05-Einsteinhttp://www.digitalhps.org/concepts/WID-10954498-N-02-Albert_Einsteinalbert einsteinnounphysicist born in Germany who formulated the special theory of relativity and the general theory of relativity; Einstein also proposed that light consists of discrete quantized bundles of energy (later called photons) (1879-1955)WordNetWID-10954498-N-01-Einstein,falseWID-10954498-N-02-Albert_Einsteinhttp://www.digitalhps.org/concepts/WID-10954498-N-02-Albert_Einsteinhttp://www.digitalhps.org/concepts/WID-05875723-N-01-Bose-Einstein_statisticsbose-einstein statisticsnoun(physics) statistical law obeyed by a system of particles whose wave function is not changed when two particles are interchanged (the Pauli exclusion principle does not apply)WordNetfalseWID-05875723-N-01-Bose-Einstein_statisticshttp://www.digitalhps.org/concepts/WID-05875723-N-01-Bose-Einstein_statistics \ No newline at end of file diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java index 759c850bb..b66698ba5 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java @@ -2,10 +2,12 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.persistence.Entity; import javax.persistence.Id; @@ -185,13 +187,28 @@ public void setTypeId(String typeId) { /** * A string containing URIs of authority file records or control vocabulary * entries that are equal to an entry. + * */ public String getEqualTo() { return equalTo; } - public void setEqualTo(String equalTo) { - this.equalTo = equalTo; + /** + * If a slash "/" is present at the end of the equal, this method removes + * the slash from end of equal and assigns the value to equalTo. For example + * if equal="http://viaf.org/viaf/110275452/", then this method assigns + * "http://viaf.org/viaf/110275452" to equalTo + * + * @param equalTo + */ + public void setEqualTo(String equal) { + if (equal != null) { + List equalsTo = Arrays.asList(equal.split(",")); + this.equalTo = equalsTo.stream().map(i -> removeTrailingBackSlashAndTrim(i)) + .collect(Collectors.joining(",")); + } else { + this.equalTo = equal; + } } /** @@ -268,13 +285,28 @@ public void setConceptList(String conceptList) { /** * A string containing URIs of authority file records or control vocabulary * entries that are similar to an entry. + * */ public String getSimilarTo() { return similarTo; } - public void setSimilarTo(String similarTo) { - this.similarTo = similarTo; + /** + * If a slash "/" is present at the end of the similar, this method removes + * the slash from end of similar and assigns the value to similarTo. For + * example if similar="http://viaf.org/viaf/110275452/", then this method + * assigns similarTo to "http://viaf.org/viaf/110275452" + * + * @param similarTo + */ + public void setSimilarTo(String similar) { + if (similar != null) { + List similarToList = Arrays.asList(similar.split(",")); + this.similarTo = similarToList.stream().map(i -> removeTrailingBackSlashAndTrim(i)) + .collect(Collectors.joining(",")); + } else { + this.similarTo = similar; + } } /** @@ -428,4 +460,11 @@ public String getMergedIds() { public void setMergedIds(String mergedIds) { this.mergedIds = mergedIds; } + + private String removeTrailingBackSlashAndTrim(String val) { + if (val.endsWith("/")) { + return val.substring(0, val.length() - 1).trim(); + } + return val.trim(); + } } \ No newline at end of file diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java index 91b69c304..443a19acf 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java @@ -1,6 +1,10 @@ package edu.asu.conceptpower.rest; +import java.beans.IntrospectionException; +import java.beans.PropertyDescriptor; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -71,6 +75,7 @@ private void initBinder(WebDataBinder binder) { } private static final Logger logger = LoggerFactory.getLogger(ConceptSearch.class); + private static final Object[] EMPTY_OBJECT = new Object[] {}; /** * This method provides information of a concept for a rest interface of the @@ -82,6 +87,8 @@ private void initBinder(WebDataBinder binder) { * @return * @throws JsonProcessingException * @throws IndexerRunningException + * @throws IntrospectionException + * @throws InvocationTargetException */ @RequestMapping(value = "/ConceptSearch", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @@ -89,46 +96,47 @@ private void initBinder(WebDataBinder binder) { @Validated ConceptSearchParameters conceptSearchParameters, BindingResult result, @RequestHeader(value = "Accept", defaultValue = MediaType.APPLICATION_XML_VALUE) String acceptHeader) throws JsonProcessingException, IllegalArgumentException, IllegalAccessException, - IndexerRunningException { + IndexerRunningException, IntrospectionException, InvocationTargetException { if (result.hasErrors()) { IConceptMessage msg = messageFactory.getMessageFactory(acceptHeader).createConceptMessage(); String errorMessage = msg.getErrorMessages(result.getAllErrors()); return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); } - Map searchFields = new HashMap(); - String operator = SearchParamters.OP_AND; - int page = 1; + preprocessConceptSearchParameterBean(conceptSearchParameters); + int page = conceptSearchParameters.getPage() != null ? conceptSearchParameters.getPage() : 1; + Map searchFields = new HashMap(); for (Field field : conceptSearchParameters.getClass().getDeclaredFields()) { - field.setAccessible(true); - if (field.getName().equalsIgnoreCase("type_uri")) { - if (field.get(conceptSearchParameters) != null) { - searchFields.put("type_id", - uriHelper.getTypeId(String.valueOf(field.get(conceptSearchParameters)))); - } - } else if (SearchParamters.OPERATOR.equalsIgnoreCase(field.getName())) { - // If the value is null, then operator will be OR by default - if (field.get(conceptSearchParameters) != null) { - operator = String.valueOf(field.get(conceptSearchParameters)).toUpperCase(); + /** + * Cobertura adds the below field to keep track of which code has + * been accessed. + * + * public static final transient int[] __cobertura_counters; + * + * In order to avoid iterating this transient field we are checking + * for the modifier type before adding the fields to the searchField + * map. + */ + if (!Modifier.isTransient(field.getModifiers())) { + PropertyDescriptor descriptor = new PropertyDescriptor(field.getName(), ConceptSearchParameters.class); + if (descriptor.getReadMethod().invoke(conceptSearchParameters, EMPTY_OBJECT) != null) { + searchFields.put(field.getName().trim(), + String.valueOf(descriptor.getReadMethod().invoke(conceptSearchParameters, EMPTY_OBJECT))); } - } else if (SearchParamters.PAGE.equalsIgnoreCase(field.getName())) { - page = field.get(conceptSearchParameters) != null ? (Integer) field.get(conceptSearchParameters) : page; - } else if (SearchParamters.NUMBER_OF_RECORDS_PER_PAGE.equalsIgnoreCase(field.getName())) { - numberOfRecordsPerPage = field.get(conceptSearchParameters) != null - ? (Integer) field.get(conceptSearchParameters) : numberOfRecordsPerPage; - } else if (field.get(conceptSearchParameters) != null) { - searchFields.put(field.getName().trim(), String.valueOf(field.get(conceptSearchParameters)).trim()); } } ConceptEntry[] searchResults = null; int totalNumberOfRecords = 0; try { - totalNumberOfRecords = manager.getTotalNumberOfRecordsForSearch(searchFields, operator); - searchResults = manager.searchForConceptByPageNumberAndFieldMap(searchFields, operator, page, - numberOfRecordsPerPage); + totalNumberOfRecords = manager.getTotalNumberOfRecordsForSearch(searchFields, + conceptSearchParameters.getOperator()); + searchResults = manager.searchForConceptByPageNumberAndFieldMap(searchFields, + conceptSearchParameters.getOperator(), page, + conceptSearchParameters.getNumber_of_records_per_page() != null + ? conceptSearchParameters.getNumber_of_records_per_page() : numberOfRecordsPerPage); } catch (LuceneException ex) { logger.error("Lucene Exception", ex); return new ResponseEntity(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); @@ -148,6 +156,20 @@ private void initBinder(WebDataBinder binder) { HttpStatus.OK); } + /** + * + * This method is used for setting the correct values for concept search + * parameters. + * + * @param conceptSearchParameters + * @return + */ + private void preprocessConceptSearchParameterBean(ConceptSearchParameters conceptSearchParameters) { + if (conceptSearchParameters.getType_uri() != null) { + conceptSearchParameters.setType_id(uriHelper.getTypeId(conceptSearchParameters.getType_uri())); + } + } + private void createEntryMap(ConceptEntry[] searchResults, Map entryMap) { for (ConceptEntry entry : searchResults) { ConceptType type = null; diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java index 01b7d440b..548aa54fe 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java @@ -1,5 +1,9 @@ package edu.asu.conceptpower.rest; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + public class ConceptSearchParameters { private String type_uri; @@ -25,7 +29,7 @@ public void setType_uri(String type_uri) { } public String getOperator() { - return operator; + return this.operator == null ? SearchParamters.OP_AND : this.operator; } public void setOperator(String operator) { @@ -43,6 +47,10 @@ public void setPage(Integer page) { } public String getSimilar_to() { + if (this.similar_to != null) { + List similarList = Arrays.asList(this.similar_to.split(",")); + return similarList.stream().map(i -> removeTrailingBackSlash(i)).collect(Collectors.joining(",")); + } return similar_to; } @@ -82,10 +90,7 @@ public void setWord(String word) { * @return */ public String getPos() { - if (pos != null) { - return pos.toLowerCase(); - } - return pos; + return this.pos != null ? this.pos.toLowerCase() : this.pos; } public void setPos(String pos) { @@ -135,10 +140,21 @@ public void setNumber_of_records_per_page(Integer number_of_records_per_page) { } public String getEqual_to() { + if (this.equal_to != null) { + List equalsList = Arrays.asList(this.equal_to.split(",")); + return equalsList.stream().map(i -> removeTrailingBackSlash(i)).collect(Collectors.joining(",")); + } return equal_to; } public void setEqual_to(String equal_to) { this.equal_to = equal_to; } + + private String removeTrailingBackSlash(String val) { + if (val.endsWith("/")) { + return val.substring(0, val.length() - 1); + } + return val; + } } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/SearchParamters.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/SearchParamters.java index 24a822f62..97ed2e609 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/SearchParamters.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/SearchParamters.java @@ -7,4 +7,6 @@ public interface SearchParamters { public final static String OP_OR = "OR"; public final static String PAGE = "page"; public final static String NUMBER_OF_RECORDS_PER_PAGE = "number_of_records_per_page"; + public final static String EQUAL_TO = "equal_to"; + public final static String SIMILAR_TO = "similar_to"; } diff --git a/Conceptpower+Spring/src/test/java/edu/asu/conceptpower/rest/ConceptSearchTest.java b/Conceptpower+Spring/src/test/java/edu/asu/conceptpower/rest/ConceptSearchTest.java index 96511bb4c..97196ab24 100644 --- a/Conceptpower+Spring/src/test/java/edu/asu/conceptpower/rest/ConceptSearchTest.java +++ b/Conceptpower+Spring/src/test/java/edu/asu/conceptpower/rest/ConceptSearchTest.java @@ -1,6 +1,8 @@ package edu.asu.conceptpower.rest; +import java.beans.IntrospectionException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; @@ -131,7 +133,8 @@ public void setup() throws IllegalAccessException, LuceneException, IndexerRunni @Test public void test_searchConcept_successInXml() throws IllegalArgumentException, IllegalAccessException, - IndexerRunningException, LuceneException, ParserConfigurationException, SAXException, IOException { + IndexerRunningException, LuceneException, + ParserConfigurationException, SAXException, IOException, InvocationTargetException, IntrospectionException { final String expectedOutput = IOUtil .toString(this.getClass().getClassLoader().getResourceAsStream("unitTestOutput/conceptSearch.xml")); @@ -153,7 +156,8 @@ public void test_searchConcept_successInXml() throws IllegalArgumentException, I @Test public void test_searchConcept_successInJson() throws IllegalAccessException, LuceneException, - IndexerRunningException, IllegalArgumentException, JSONException, IOException { + IndexerRunningException, IllegalArgumentException, + JSONException, IOException, InvocationTargetException, IntrospectionException { final String expectedOutput = IOUtil .toString(this.getClass().getClassLoader().getResourceAsStream("unitTestOutput/conceptSearch.json")); @@ -176,7 +180,8 @@ public void test_searchConcept_successInJson() throws IllegalAccessException, Lu @Test public void test_searchConcept_noRecordsFoundInJson() throws IllegalAccessException, LuceneException, - IndexerRunningException, IllegalArgumentException, JSONException, IOException { + IndexerRunningException, IllegalArgumentException, + JSONException, IOException, InvocationTargetException, IntrospectionException { final String jsonNoRecordsFoundError = IOUtil .toString(this.getClass().getClassLoader().getResourceAsStream("unitTestOutput/recordsNotFound.json")); @@ -210,7 +215,8 @@ public void test_searchConcept_noRecordsFoundInJson() throws IllegalAccessExcept @Test public void test_searchConcept_noRecordsFoundInXml() throws IllegalAccessException, LuceneException, - IndexerRunningException, IllegalArgumentException, JSONException, IOException { + IndexerRunningException, IllegalArgumentException, + JSONException, IOException, InvocationTargetException, IntrospectionException { final String xmlNoRecordsFoundError = IOUtil .toString(this.getClass().getClassLoader().getResourceAsStream("unitTestOutput/recordsNotFound.xml")); @@ -245,7 +251,8 @@ public void test_searchConcept_noRecordsFoundInXml() throws IllegalAccessExcepti @Test public void test_searchConcept_invalidPos() - throws JsonProcessingException, IllegalArgumentException, IllegalAccessException, IndexerRunningException { + throws JsonProcessingException, IllegalArgumentException, + IllegalAccessException, IndexerRunningException, InvocationTargetException, IntrospectionException { final String posError = "Please enter correct pos value."; From ea639bcdd85da8766739627636a67438fdd0c5ef Mon Sep 17 00:00:00 2001 From: Karthikeyan Date: Mon, 17 Apr 2017 08:31:20 -0700 Subject: [PATCH 05/15] [CCP-221] Changes for selecting the rows in datable. (#170) * [CCP-221] Changes for selecting the rows in datable. * [CCP-221] Review comments. changed the wordnetId to wordnetid in jsp. Added word field while creating concept wrapper. Word details can be entered by user when concept wrapper is being created. * [CCP-221] Changes for setting the correct word. Word field is set with the maximum word length. When a selection is removed the word field is updated accordingly. * [CCP-221] Formatting changes --- .../web/ConceptWrapperAddController.java | 32 +- .../webapp/WEB-INF/tiles/skeleton-nonav.jsp | 3 + .../main/webapp/WEB-INF/tiles/skeleton.jsp | 3 + .../auth/concepts/ConceptListConceptsView.jsp | 2 +- .../auth/concepts/ConceptWrapperAddView.jsp | 45 +- .../src/main/webapp/WEB-INF/views/home.jsp | 2 +- .../datatable/css/jquery.dataTables.min.css | 527 ++++++++++++++++++ 7 files changed, 594 insertions(+), 20 deletions(-) create mode 100644 Conceptpower+Spring/src/main/webapp/resources/js/datatable/css/jquery.dataTables.min.css diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptWrapperAddController.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptWrapperAddController.java index f2ceab755..6e2cfe710 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptWrapperAddController.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptWrapperAddController.java @@ -115,24 +115,28 @@ public String prepareConceptWrapperAdd(HttpServletRequest req, ModelMap model) { public String addConcept(HttpServletRequest req, Principal principal, Model model) throws DictionaryDoesNotExistException, DictionaryModifyException, LuceneException, IllegalAccessException, IndexerRunningException { + if (req.getParameter("word") == null || req.getParameter("word").trim().isEmpty()) { + req.setAttribute("errormsg", "You have to enter a word."); + return "forward:/auth/conceptlist/addconceptwrapper"; + } if (req.getParameter("lists") == null || req.getParameter("lists").trim().isEmpty()) { req.setAttribute("errormsg", "You have to select a concept list."); return "forward:/auth/conceptlist/addconceptwrapper"; } String[] wrappers = req.getParameter("wrapperids").split(Constants.CONCEPT_SEPARATOR); - if (wrappers.length > 0) { - ConceptEntry conceptEntry = new ConceptEntry(); - conceptEntry.setWord(conceptManager.getConceptEntry(wrappers[0]).getWord().replace("_", " ")); - conceptEntry.setPos(conceptManager.getConceptEntry(wrappers[0]).getPos()); - conceptEntry.setSynonymIds(req.getParameter("synonymsids")); - conceptEntry.setWordnetId(req.getParameter("wrapperids")); - conceptEntry.setConceptList(req.getParameter("lists")); - conceptEntry.setDescription(req.getParameter("description")); - conceptEntry.setEqualTo(req.getParameter("equals")); - conceptEntry.setSimilarTo(req.getParameter("similar")); - conceptEntry.setTypeId(req.getParameter("types")); - conceptEntry.setCreatorId(principal.getName()); - + if (wrappers.length > 0) { + ConceptEntry conceptEntry = new ConceptEntry(); + conceptEntry.setWord(req.getParameter("word")); + conceptEntry.setPos(conceptManager.getConceptEntry(wrappers[0]).getPos()); + conceptEntry.setSynonymIds(req.getParameter("synonymsids")); + conceptEntry.setWordnetId(req.getParameter("wrapperids")); + conceptEntry.setConceptList(req.getParameter("lists")); + conceptEntry.setDescription(req.getParameter("description")); + conceptEntry.setEqualTo(req.getParameter("equals")); + conceptEntry.setSimilarTo(req.getParameter("similar")); + conceptEntry.setTypeId(req.getParameter("types")); + conceptEntry.setCreatorId(principal.getName()); + if (indexService.isIndexerRunning()) { model.addAttribute("show_error_alert", true); model.addAttribute("error_alert_msg", indexerRunning); @@ -140,7 +144,7 @@ public String addConcept(HttpServletRequest req, Principal principal, Model mode return "forward:/auth/conceptlist/addconceptwrapper"; } conceptManager.addConceptListEntry(conceptEntry, principal.getName()); - } + } return "redirect:/auth/" + req.getParameter("lists") + "/concepts"; } diff --git a/Conceptpower+Spring/src/main/webapp/WEB-INF/tiles/skeleton-nonav.jsp b/Conceptpower+Spring/src/main/webapp/WEB-INF/tiles/skeleton-nonav.jsp index dd88036de..450cc763f 100644 --- a/Conceptpower+Spring/src/main/webapp/WEB-INF/tiles/skeleton-nonav.jsp +++ b/Conceptpower+Spring/src/main/webapp/WEB-INF/tiles/skeleton-nonav.jsp @@ -35,6 +35,9 @@ + + + + org.jsoup + jsoup + 1.10.2 + diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java index d22e19141..4da3779b7 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java @@ -17,4 +17,5 @@ public interface LuceneFieldNames { public final static String CONCEPTTYPE = "conceptType"; public final static String MERGED_IDS = "mergedIds"; public final static String UNTOKENIZED_SUFFIX = "_untokenized"; + public final static String SORT_SUFFIX = "_sorted"; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IConceptManager.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IConceptManager.java index debe3d0a3..b3a514c40 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IConceptManager.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IConceptManager.java @@ -151,19 +151,22 @@ public ConceptEntry getConceptWrappedEntryByWordNetId(String wordNetID) /** * This method fetches the concept entry details based on word, pos and * concept list values. This method also accepts parameters for pagination + * and sorting. * * @param word * @param pos * @param conceptList * @param page * @param numberOfRecordsPerPage + * @param sortField + * @param sortOrder * @return * @throws LuceneException * @throws IllegalAccessException * @throws IndexerRunningException */ - public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, String conceptList, - int page, int numberOfRecordsPerPage) + public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, String conceptList, int page, + int numberOfRecordsPerPage, String sortField, int sortOrder) throws LuceneException, IllegalAccessException, IndexerRunningException; /** @@ -182,4 +185,6 @@ public void updateIndex(ConceptEntry entry, String userName) public void deleteFromIndex(String id, String userName) throws LuceneException, IndexerRunningException; + public int getPageCountForConceptEntries(String word, String pos, String conceptList) + throws IllegalAccessException, LuceneException, IndexerRunningException; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IIndexService.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IIndexService.java index 8dda380fc..cb3f988d0 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IIndexService.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/IIndexService.java @@ -4,6 +4,7 @@ import edu.asu.conceptpower.app.exceptions.IndexerRunningException; import edu.asu.conceptpower.app.exceptions.LuceneException; +import edu.asu.conceptpower.app.util.CCPSort; import edu.asu.conceptpower.core.ConceptEntry; import edu.asu.conceptpower.core.IndexingEvent; @@ -29,8 +30,8 @@ public void indexConcepts(String userName) public void updateConceptEntry(ConceptEntry entry, String userName) throws LuceneException, IndexerRunningException, IllegalAccessException; - public ConceptEntry[] searchForConceptByPageNumberAndFieldMap(Map fieldMap, - String operator, int pageNumber, int numberOfRecordsPerPage) + public ConceptEntry[] searchForConceptByPageNumberAndFieldMap(Map fieldMap, String operator, + int pageNumber, int numberOfRecordsPerPage, CCPSort sort) throws LuceneException, IllegalAccessException, IndexerRunningException; public int getTotalNumberOfRecordsForSearch(Map fieldMap, String operator) diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java index f38f84d67..22107d1e5 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/ConceptManager.java @@ -25,6 +25,8 @@ import edu.asu.conceptpower.app.exceptions.DictionaryModifyException; import edu.asu.conceptpower.app.exceptions.IndexerRunningException; import edu.asu.conceptpower.app.exceptions.LuceneException; +import edu.asu.conceptpower.app.util.CCPSort; +import edu.asu.conceptpower.app.util.CCPSort.SortOrder; import edu.asu.conceptpower.app.wordnet.Constants; import edu.asu.conceptpower.app.wordnet.WordNetManager; import edu.asu.conceptpower.core.ConceptEntry; @@ -124,7 +126,7 @@ public ConceptEntry getWordnetConceptEntry(String wordnetId) throws LuceneExcept @Override public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, String conceptList) throws LuceneException, IllegalAccessException, IndexerRunningException { - return getConceptListEntriesForWordPOS(word, pos, conceptList, -1, -1); + return getConceptListEntriesForWordPOS(word, pos, conceptList, -1, -1, null, 0); } /* @@ -136,9 +138,9 @@ public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, S * java.lang.String, java.lang.String) */ @Override - public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, String conceptList, - int page, int numberOfRecordsPerPage) - throws LuceneException, IllegalAccessException, IndexerRunningException { + public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, String conceptList, int page, + int numberOfRecordsPerPage, String sortField, int sortOrder) + throws LuceneException, IllegalAccessException, IndexerRunningException { if (pos == null) return null; @@ -146,7 +148,19 @@ public ConceptEntry[] getConceptListEntriesForWordPOS(String word, String pos, S fieldMap.put(SearchFieldNames.WORD, word); fieldMap.put(SearchFieldNames.POS, pos); fieldMap.put(SearchFieldNames.CONCEPT_LIST, conceptList); - return indexService.searchForConceptByPageNumberAndFieldMap(fieldMap, null, page, numberOfRecordsPerPage); + + CCPSort ccpSort = null; + if (sortField != null) { + ccpSort = new CCPSort(sortField, sortOrder == -1 ? SortOrder.DESCENDING : SortOrder.ASCENDING); + } + return indexService.searchForConceptByPageNumberAndFieldMap(fieldMap, null, page, numberOfRecordsPerPage, + ccpSort); + } + + @Override + public int getPageCountForConceptEntries(String word, String pos, String conceptList) throws IllegalAccessException, LuceneException, IndexerRunningException { + int totalEntries = getConceptListEntriesForWordPOS(word, pos, conceptList, -1, -1, null, 0).length; + return (int) Math.ceil(new Double(totalEntries) / new Double(defaultPageSize)); } /** diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/IndexService.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/IndexService.java index 28e4946e0..de8d552f9 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/IndexService.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/core/impl/IndexService.java @@ -15,6 +15,7 @@ import edu.asu.conceptpower.app.exceptions.LuceneException; import edu.asu.conceptpower.app.lucene.ILuceneDAO; import edu.asu.conceptpower.app.lucene.ILuceneUtility; +import edu.asu.conceptpower.app.util.CCPSort; import edu.asu.conceptpower.core.ConceptEntry; import edu.asu.conceptpower.core.IndexingEvent; @@ -59,7 +60,7 @@ public ConceptEntry[] searchForConcepts(Map fieldMap, String ope throw new IndexerRunningException(indexerRunning); } // Fetches all the pages - return luceneUtility.queryIndex(fieldMap, operator, 0, -1); + return luceneUtility.queryIndex(fieldMap, operator, 0, -1, null); } /** @@ -68,14 +69,14 @@ public ConceptEntry[] searchForConcepts(Map fieldMap, String ope */ @Override public ConceptEntry[] searchForConceptByPageNumberAndFieldMap(Map fieldMap, String operator, - int pageNumber, int numberOfRecordsPerPage) + int pageNumber, int numberOfRecordsPerPage, CCPSort sort) throws LuceneException, IllegalAccessException, IndexerRunningException { if (indexerRunningFlag.get()) { throw new IndexerRunningException(indexerRunning); } - ConceptEntry[] entries = luceneUtility.queryIndex(fieldMap, operator, pageNumber, numberOfRecordsPerPage); + ConceptEntry[] entries = luceneUtility.queryIndex(fieldMap, operator, pageNumber, numberOfRecordsPerPage, sort); alternativeIdService.addAlternativeIds(entries); return entries; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/ILuceneUtility.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/ILuceneUtility.java index 0f203862c..1efe0e7bd 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/ILuceneUtility.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/ILuceneUtility.java @@ -3,6 +3,7 @@ import java.util.Map; import edu.asu.conceptpower.app.exceptions.LuceneException; +import edu.asu.conceptpower.app.util.CCPSort; import edu.asu.conceptpower.core.ConceptEntry; public interface ILuceneUtility { @@ -16,6 +17,7 @@ public interface ILuceneUtility { public void indexConcepts(String userName) throws LuceneException, IllegalArgumentException, IllegalAccessException; public ConceptEntry[] queryIndex(Map fieldMap, String operator, int pageNumber, - int numberOfRecordsPerPage) throws LuceneException, IllegalAccessException; + int numberOfRecordsPerPage, CCPSort ccpSort) + throws LuceneException, IllegalAccessException; } \ No newline at end of file diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java index 5c09ef2d3..455c0b60b 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java @@ -6,6 +6,7 @@ import java.net.URL; import java.nio.file.FileSystems; import java.nio.file.Path; +import java.text.Normalizer; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -27,6 +28,7 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.SortedDocValuesField; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; @@ -41,13 +43,18 @@ import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.Sort; +import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.TopScoreDocCollector; +import org.apache.lucene.search.TopDocsCollector; +import org.apache.lucene.search.TopFieldCollector; import org.apache.lucene.search.WildcardQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.QueryBuilder; +import org.jsoup.Jsoup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -64,6 +71,8 @@ import edu.asu.conceptpower.app.lucene.LuceneAction; import edu.asu.conceptpower.app.reflect.LuceneField; import edu.asu.conceptpower.app.reflect.SearchField; +import edu.asu.conceptpower.app.util.CCPSort; +import edu.asu.conceptpower.app.util.CCPSort.SortOrder; import edu.asu.conceptpower.app.wordnet.Constants; import edu.asu.conceptpower.app.wordnet.WordNetConfiguration; import edu.asu.conceptpower.core.ConceptEntry; @@ -206,6 +215,12 @@ public void insertConcept(ConceptEntry entry, String userName) throws LuceneExce doc.add(new StringField(searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.UNTOKENIZED_SUFFIX, String.valueOf(contentOfField), Field.Store.YES)); } + + if (searchFieldAnnotation.isSortAllowed()) { + doc.add(new SortedDocValuesField( + searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(String.valueOf(contentOfField))))); + } } } } @@ -326,6 +341,20 @@ private Document createIndividualDocument(IDictionary dict, IWordID wordId) { // Adding this new data to delete only wordnet concepts while // adding all wordnet concepts from jwi. doc.add(new StringField(LuceneFieldNames.CONCEPT_LIST, Constants.WORDNET_DICTIONARY, Field.Store.YES)); + + // Fields for performing sorting + doc.add(new SortedDocValuesField(LuceneFieldNames.ID + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(word.getID().toString())))); + doc.add(new SortedDocValuesField(LuceneFieldNames.WORD + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(lemma)))); + doc.add(new SortedDocValuesField(LuceneFieldNames.WORDNETID + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(word.getID().toString())))); + doc.add(new SortedDocValuesField(LuceneFieldNames.POS + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(wordId.getPOS().toString())))); + doc.add(new SortedDocValuesField(LuceneFieldNames.CONCEPT_LIST + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(Constants.WORDNET_DICTIONARY)))); + doc.add(new SortedDocValuesField(LuceneFieldNames.DESCRIPTION + LuceneFieldNames.SORT_SUFFIX, + new BytesRef(processStringForSorting(word.getSynset().getGloss())))); return doc; } @@ -447,7 +476,7 @@ public void indexConcepts(String userName) * fieldMap contains the search criteria */ public ConceptEntry[] queryIndex(Map fieldMap, String operator, int page, - int numberOfRecordsPerPage) throws LuceneException, IllegalAccessException { + int numberOfRecordsPerPage, CCPSort ccpSort) throws LuceneException, IllegalAccessException { Map analyzerPerField = new HashMap<>(); BooleanClause.Occur occur = BooleanClause.Occur.SHOULD; @@ -494,7 +523,6 @@ public ConceptEntry[] queryIndex(Map fieldMap, String operator, List concepts = new ArrayList(); try { - TopScoreDocCollector collector = TopScoreDocCollector.create(numberOfResults); int startIndex = 0; int hitsPerPage = 0; if (page > 0) { @@ -515,6 +543,16 @@ public ConceptEntry[] queryIndex(Map fieldMap, String operator, hitsPerPage = numberOfResults; } + TopDocsCollector collector = null; + if (ccpSort != null) { + SortField sortField = new SortField(ccpSort.getSortField() + LuceneFieldNames.SORT_SUFFIX, + SortField.Type.STRING, ccpSort.getSortOrder() == SortOrder.DESCENDING ? false : true); + Sort sort = new Sort(sortField); + collector = TopFieldCollector.create(sort, numberOfResults, true, false, false); + } else { + collector = TopFieldCollector.create(Sort.RELEVANCE, numberOfResults, true, false, false); + } + searcher.search(builder.build(), collector); // If page number is more than the available results, we just pass // empty result. @@ -635,6 +673,11 @@ private Set getWordNetIdsOfWrappers(List conceptEntries) { return wordnetIds; } + private String processStringForSorting(String str) { + return Normalizer.normalize(Jsoup.parse(str).text().trim().toLowerCase(), Normalizer.Form.NFKD) + .replaceAll("\\p{M}", ""); + } + @PreDestroy public void destroy() throws LuceneException { try { diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/reflect/LuceneField.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/reflect/LuceneField.java index 6ca6c3390..64fcca205 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/reflect/LuceneField.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/reflect/LuceneField.java @@ -23,4 +23,6 @@ boolean isShortPhraseSearchable() default false; boolean isWildCardSearchEnabled() default false; + + boolean isSortAllowed() default false; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/util/CCPSort.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/util/CCPSort.java new file mode 100644 index 000000000..945b37bf8 --- /dev/null +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/util/CCPSort.java @@ -0,0 +1,32 @@ +package edu.asu.conceptpower.app.util; + +public class CCPSort { + + public enum SortOrder { + DESCENDING, ASCENDING + } + + private String sortField; + private SortOrder sortOrder; + + public CCPSort(String sortField, SortOrder sortOrder) { + this.sortField = sortField; + this.sortOrder = sortOrder; + } + + public String getSortField() { + return sortField; + } + + public void setSortField(String sortField) { + this.sortField = sortField; + } + + public SortOrder getSortOrder() { + return sortOrder; + } + + public void setSortOrder(SortOrder sortOrder) { + this.sortOrder = sortOrder; + } +} diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java index f8aede9fb..8172d15a0 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/core/ConceptEntry.java @@ -31,31 +31,31 @@ public class ConceptEntry implements Serializable { private static final long serialVersionUID = 4569090620671054560L; @Id - @LuceneField(lucenefieldName = LuceneFieldNames.ID, isTokenized = false, isMultiple = false) + @LuceneField(lucenefieldName = LuceneFieldNames.ID, isTokenized = false, isMultiple = false, isSortAllowed = true) private String id; @SearchField(fieldName = SearchFieldNames.WORDNETID) - @LuceneField(lucenefieldName = LuceneFieldNames.WORDNETID, isTokenized = false, isMultiple = true) + @LuceneField(lucenefieldName = LuceneFieldNames.WORDNETID, isTokenized = false, isMultiple = true, isSortAllowed = true) private String wordnetId; @SearchField(fieldName = SearchFieldNames.WORD) - @LuceneField(lucenefieldName = LuceneFieldNames.WORD, isTokenized = true, isMultiple = false, isShortPhraseSearchable = true, isWildCardSearchEnabled = true) + @LuceneField(lucenefieldName = LuceneFieldNames.WORD, isTokenized = true, isMultiple = false, isShortPhraseSearchable = true, isWildCardSearchEnabled = true, isSortAllowed = true) private String word; @SearchField(fieldName = SearchFieldNames.DESCRIPTION) - @LuceneField(lucenefieldName = LuceneFieldNames.DESCRIPTION, isTokenized = true, isMultiple = false) + @LuceneField(lucenefieldName = LuceneFieldNames.DESCRIPTION, isTokenized = true, isMultiple = false, isSortAllowed = true) private String description; @SearchField(fieldName = SearchFieldNames.POS) - @LuceneField(lucenefieldName = LuceneFieldNames.POS, isTokenized = true, isMultiple = false) + @LuceneField(lucenefieldName = LuceneFieldNames.POS, isTokenized = true, isMultiple = false, isSortAllowed = true) private String pos; @SearchField(fieldName = SearchFieldNames.CONCEPT_LIST) - @LuceneField(lucenefieldName = LuceneFieldNames.CONCEPT_LIST, isTokenized = false, isMultiple = false) + @LuceneField(lucenefieldName = LuceneFieldNames.CONCEPT_LIST, isTokenized = false, isMultiple = false, isSortAllowed = true) private String conceptList; @SearchField(fieldName = SearchFieldNames.TYPE_ID) - @LuceneField(lucenefieldName = LuceneFieldNames.TYPE_ID, isTokenized = false, isMultiple = false) + @LuceneField(lucenefieldName = LuceneFieldNames.TYPE_ID, isTokenized = false, isMultiple = false, isSortAllowed = true) private String typeId; @SearchField(fieldName = SearchFieldNames.EQUAL_TO) diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java index 443a19acf..cfec51ae1 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearch.java @@ -31,8 +31,11 @@ import edu.asu.conceptpower.app.core.IIndexService; import edu.asu.conceptpower.app.db.TypeDatabaseClient; +import edu.asu.conceptpower.app.db4o.IConceptDBManager; import edu.asu.conceptpower.app.exceptions.IndexerRunningException; import edu.asu.conceptpower.app.exceptions.LuceneException; +import edu.asu.conceptpower.app.util.CCPSort; +import edu.asu.conceptpower.app.util.CCPSort.SortOrder; import edu.asu.conceptpower.app.util.URIHelper; import edu.asu.conceptpower.core.ConceptEntry; import edu.asu.conceptpower.core.ConceptType; @@ -133,10 +136,18 @@ private void initBinder(WebDataBinder binder) { try { totalNumberOfRecords = manager.getTotalNumberOfRecordsForSearch(searchFields, conceptSearchParameters.getOperator()); - searchResults = manager.searchForConceptByPageNumberAndFieldMap(searchFields, - conceptSearchParameters.getOperator(), page, - conceptSearchParameters.getNumber_of_records_per_page() != null - ? conceptSearchParameters.getNumber_of_records_per_page() : numberOfRecordsPerPage); + CCPSort sort = null; + if (conceptSearchParameters.getSortField() != null) { + Integer sortDirection = Integer.parseInt(conceptSearchParameters.getSortDirection()); + sort = new CCPSort(conceptSearchParameters.getSortField(), + sortDirection == IConceptDBManager.ASCENDING ? SortOrder.ASCENDING : SortOrder.DESCENDING); + } + searchResults = manager + .searchForConceptByPageNumberAndFieldMap(searchFields, conceptSearchParameters.getOperator(), + page, + conceptSearchParameters.getNumber_of_records_per_page() != null + ? conceptSearchParameters.getNumber_of_records_per_page() : numberOfRecordsPerPage, + sort); } catch (LuceneException ex) { logger.error("Lucene Exception", ex); return new ResponseEntity(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java index 548aa54fe..028c85895 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/rest/ConceptSearchParameters.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.stream.Collectors; +import edu.asu.conceptpower.app.db4o.IConceptDBManager; + public class ConceptSearchParameters { private String type_uri; @@ -19,6 +21,8 @@ public class ConceptSearchParameters { private String creator; private String modified_by; private Integer number_of_records_per_page; + private String sortField; + private String sortDirection; public String getType_uri() { return type_uri; @@ -157,4 +161,23 @@ private String removeTrailingBackSlash(String val) { } return val; } + + public String getSortField() { + return sortField; + } + + public void setSortField(String sortField) { + this.sortField = sortField; + } + + public String getSortDirection() { + if (sortDirection == null) { + return IConceptDBManager.ASCENDING + ""; + } + return sortDirection; + } + + public void setSortDirection(String sortDirection) { + this.sortDirection = sortDirection; + } } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptEditController.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptEditController.java index 488552688..d7f8fb8e3 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptEditController.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptEditController.java @@ -322,8 +322,8 @@ private String buildJSON(List synonyms, boolean posRequired, boole } try { - found = conceptManager.getConceptListEntriesForWordPOS(concept, pos, - Constants.WORDNET_DICTIONARY, -1, numberOfRecords); + found = conceptManager.getConceptListEntriesForWordPOS(concept, pos, Constants.WORDNET_DICTIONARY, -1, + numberOfRecords, null, 0); } catch (IndexerRunningException ie) { return new ResponseEntity("Indexer is running. Please try again later.", HttpStatus.SERVICE_UNAVAILABLE); diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptSearchController.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptSearchController.java index e0ce128ae..ea3c7eb05 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptSearchController.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/web/ConceptSearchController.java @@ -16,9 +16,11 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import edu.asu.conceptpower.app.core.IConceptManager; import edu.asu.conceptpower.app.core.IIndexService; +import edu.asu.conceptpower.app.db4o.IConceptDBManager; import edu.asu.conceptpower.app.exceptions.IndexerRunningException; import edu.asu.conceptpower.app.exceptions.LuceneException; import edu.asu.conceptpower.app.validation.ConceptSearchValidator; @@ -53,28 +55,43 @@ public class ConceptSearchController { @Value("#{messages['INDEXERSTATUS']}") private String indexerStatus; + @Value("${default_page_size}") + private Integer defaultPageSize; + @InitBinder private void initBinder(WebDataBinder binder) { binder.setValidator(validator); } /** - * This method is searches concepts a specific term and pos + * This method is searches concepts a specific term, pos based on the + * pagination details. * - * @param req - * Holds the HTTP request information * @param model - * Generic model holder for servlet - * @return Returns a string value to redirect user to concept search page - * @throws IllegalAccessException + * @param page + * @param sortDir + * @param sortColumn + * @param conceptSearchBean + * @param results + * @return + * @throws LuceneException + * @throws IllegalAccessException */ @RequestMapping(value = "/home/conceptsearch", method = RequestMethod.GET) - public String search(HttpServletRequest req, ModelMap model, + public String search(HttpServletRequest req, ModelMap model, @RequestParam(defaultValue = "1") String page, + @RequestParam(defaultValue = IConceptDBManager.ASCENDING + "") String sortDir, + @RequestParam(required = false) String sortColumn, + @RequestParam(required = false) String conceptIdsToMerge, @Validated @ModelAttribute("conceptSearchBean") ConceptSearchBean conceptSearchBean, BindingResult results) throws LuceneException, IllegalAccessException { if (results.hasErrors()) { return "conceptsearch"; } + + if (conceptIdsToMerge != null) { + model.addAttribute("conceptIdsToMerge", conceptIdsToMerge); + } + List foundConcepts = null; ConceptEntry[] found = null; @@ -84,19 +101,35 @@ public String search(HttpServletRequest req, ModelMap model, // Need to include command Object return "conceptsearch"; } - + int pageInt = new Integer(page); + int sortDirInt = new Integer(sortDir); + int pageCount = 0; try { found = conceptManager.getConceptListEntriesForWordPOS(conceptSearchBean.getWord(), - conceptSearchBean.getPos().toString().toLowerCase().trim(), null); + conceptSearchBean.getPos(), null, pageInt, defaultPageSize, sortColumn, sortDirInt); + pageCount = conceptManager.getPageCountForConceptEntries(conceptSearchBean.getWord(), + conceptSearchBean.getPos(), null); } catch (IndexerRunningException e) { model.addAttribute(indexerStatus, e.getMessage()); return "conceptsearch"; } foundConcepts = wrapperCreator.createWrappers(found); conceptSearchBean.setFoundConcepts(foundConcepts); + if (pageInt < 1) { + pageInt = 1; + } + + if (pageInt > pageCount) { + pageInt = pageCount; + } + if (CollectionUtils.isEmpty(foundConcepts)) { results.rejectValue("foundConcepts", "no.searchResults"); } + model.addAttribute("page", pageInt); + model.addAttribute("count", pageCount); + model.addAttribute("sortDir", sortDir); + model.addAttribute("sortColumn", sortColumn); return "conceptsearch"; } diff --git a/Conceptpower+Spring/src/main/webapp/WEB-INF/views/home.jsp b/Conceptpower+Spring/src/main/webapp/WEB-INF/views/home.jsp index 414335b5a..860545320 100644 --- a/Conceptpower+Spring/src/main/webapp/WEB-INF/views/home.jsp +++ b/Conceptpower+Spring/src/main/webapp/WEB-INF/views/home.jsp @@ -10,104 +10,130 @@ //# sourceURL=details.js $(document).ready(function() { - $('#conceptSearchResult').dataTable({ - "bJQueryUI" : true, - "sPaginationType" : "full_numbers", - "bAutoWidth" : false, - "aaSorting" : [], - "aoColumnDefs" : [ - - { - "targets": [0,1], - 'bSortable': false - }, - { - "targets": [2], - 'searchable': false, - 'bSortable': false, - 'orderable':false, - 'bVisible' : false, - 'className': 'dt-body-center' - }, - { - "targets": [7], - "sType" : "html", - "fnRender" : function(o, val) { - if (o.startsWith("<br/>")) { - o = o.substring(11,o.length); - } - return $("
").html(o).text(); - } - }, - - - { - "targets": [5], - "sType" : "html", - "fnRender" : function(o, val) { - if (o.startsWith("<br/>")) { - o = o.substring(11,o.length); - } - return $("
").html(o).text(); - } - } - - ] - }); - $('#viafSearchResult').dataTable({ - "bJQueryUI" : true, - "sPaginationType" : "full_numbers", - "bAutoWidth" : false, - "aoColumnDefs" : [ { - "aTargets" : [ 2 ], - "sType" : "html", - "fnRender" : function(o, val) { - return $("
").html(o.aData[2]).text(); - } - } ], - }); - $('#detailsModal') - .on( - 'show.bs.modal', - function(event) { - var button = $(event.relatedTarget); // ` that triggered the modal - var conceptid = button.data('conceptid'); // Extract info from data-* attributes - // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). - // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. - $.ajax({ - type : "GET", - url : "${pageContext.servletContext.contextPath}/conceptDetail", - data : { - conceptid : conceptid - }, - success : function(details) { - details = $.parseJSON(details); - $("#conceptTerm").text(details.name); - $("#detailsid").text(details.id); - $("#detailsuri").text(details.uri); - $("#detailswordnetid").text(details.wordnetid); - $("#detailspos").text(details.pos); - $("#detailsconceptlist").text(details.conceptlist); - $("#detailstypeid").text(details.type); - $("#detailsequalto").text(details.equalto); - $("#detailssimilarto").text(details.similarto); - $("#detailscreator").text(details.creator); - $("#detailsdescription").html(details.description); - } - }); - }); + function removeColumnFromTable(str) { + var target = $('table').find('th[data-name="' + str +'"]'); + var index = (target).index(); + $('table tr').find('th:eq(' + index + '),td:eq(' + index + ')' ).hide(); + } + + function showColumnFromTable(str) { + var target = $('table').find('th[data-name="' + str +'"]'); + var index = (target).index(); + $('table tr').find('th:eq(' + index + '),td:eq(' + index + ')' ).show(); + } + + function checkCheckBoxAndRemoveColumnsForMergeConcepts() { + var conceptsToBeMerged = $('#conceptIdsToMerge').val().replace("\"", ""); + if(conceptsToBeMerged) { + removeColumnFromTable('delete'); + removeColumnFromTable('edit'); + $("#mergeConcept").show(); + $("#prepareMergeConcept").hide(); + // Check the checkboxes + + var conceptIds = conceptsToBeMerged.split(','); + for(var i = 0; i").html(o.aData[2]).text(); + } + } ], + }); + $('#detailsModal') + .on( + 'show.bs.modal', + function(event) { + var button = $(event.relatedTarget); // ` that triggered the modal + var conceptid = button.data('conceptid'); // Extract info from data-* attributes + // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). + // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. + $.ajax({ + type : "GET", + url : "${pageContext.servletContext.contextPath}/conceptDetail", + data : { + conceptid : conceptid + }, + success : function(details) { + details = $.parseJSON(details); + $("#conceptTerm").text(details.name); + $("#detailsid").text(details.id); + $("#detailsuri").text(details.uri); + $("#detailswordnetid").text(details.wordnetid); + $("#detailspos").text(details.pos); + $("#detailsconceptlist").text(details.conceptlist); + $("#detailstypeid").text(details.type); + $("#detailsequalto").text(details.equalto); + $("#detailssimilarto").text(details.similarto); + $("#detailscreator").text(details.creator); + $("#detailsdescription").html(details.description); + } + }); + }); + $('#prepareMergeConcept').on('click', function (e) { e.preventDefault(); // Get the column API object - var conceptSearchResultTable = $('#conceptSearchResult').dataTable(); - conceptSearchResultTable.fnSetColumnVis(0, false); - conceptSearchResultTable.fnSetColumnVis(1, false); - conceptSearchResultTable.fnSetColumnVis(2, true); + removeColumnFromTable('edit'); + removeColumnFromTable('delete'); + showColumnFromTable('merge'); $("#mergeConcept").show(); $("#prepareMergeConcept").hide(); }); + + $(':checkbox').change(function(e) { + if(this.checked) { + mergeConcepts($(this).val()) + } else { + removeMergedConcepts($(this).val()); + } + }); - $("#mergeConcept").hide(); + function mergeConcepts(conceptId) { + $('#mergeError').hide(); + var conceptsToMerge = $('#conceptIdsToMerge').val().replace("\"", ""); + if(conceptsToMerge) { + conceptsToMerge = conceptsToMerge + ',' + conceptId; + } else { + conceptsToMerge = conceptId; + } + $('#conceptIdsToMerge').val(conceptsToMerge); + } + + function removeMergedConcepts(conceptId) { + var conceptsToMerge = $('#conceptIdsToMerge').val().replace("\"", ""); + var conceptIds = conceptsToMerge.split(','); + var updatedConceptIds = ''; + for(var i=0; i - +
Please select at least two concepts to merge.
@@ -216,27 +249,38 @@ var createWrapper = function(word, pos, conceptList, description, conceptType, w
- +
+ + + + + + + + + - - - + + + - - - - - - - + + + + + + + @@ -276,9 +320,9 @@ var createWrapper = function(word, pos, conceptList, description, conceptType, w - + @@ -307,6 +351,24 @@ var createWrapper = function(word, pos, conceptList, description, conceptType, w
TermIDWordnet IDPOSConcept ListDescriptionType + Term + ID Wordnet ID POS Concept List Description Type
- +
+ + +
+
Merged Ids:
+
+
diff --git a/Conceptpower+Spring/src/test/resources/unitTestOutput/wordNetEntryWithSpecialCharacters.json b/Conceptpower+Spring/src/test/resources/unitTestOutput/wordNetEntryWithSpecialCharacters.json index a77704267..add4a7ae5 100644 --- a/Conceptpower+Spring/src/test/resources/unitTestOutput/wordNetEntryWithSpecialCharacters.json +++ b/Conceptpower+Spring/src/test/resources/unitTestOutput/wordNetEntryWithSpecialCharacters.json @@ -1 +1 @@ -{"conceptEntries":[{"id":"WID-123","lemma":"einstein@albert","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=/.,';[]}{:\"<>?","conceptList":"WordNet","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""},{"lemma":"einstein","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=/.,';[]}{:\"<>?","conceptList":"Test List","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""}],"pagination":null} \ No newline at end of file +{"conceptEntries":[{"id":"WID-123","lemma":"einstein@albert","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=\\/.,';[]}{:\\\"<>?","conceptList":"WordNet","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""},{"lemma":"einstein","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=\\/.,';[]}{:\\\"<>?","conceptList":"Test List","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""}],"pagination":null} \ No newline at end of file diff --git a/Conceptpower+Spring/src/test/resources/unitTestOutput/wordnetEntry.json b/Conceptpower+Spring/src/test/resources/unitTestOutput/wordnetEntry.json index f2149c707..fb4c3dcdf 100644 --- a/Conceptpower+Spring/src/test/resources/unitTestOutput/wordnetEntry.json +++ b/Conceptpower+Spring/src/test/resources/unitTestOutput/wordnetEntry.json @@ -1 +1 @@ -{"conceptEntries":[{"id":"WID-123","lemma":"pony","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=/.,';[]}{:\"<>?","conceptList":"WordNet","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""},{"id":"CCP - 123","lemma":"pony","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=/.,';[]}{:\"<>?","conceptList":"Test List","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""}],"pagination":null} \ No newline at end of file +{"conceptEntries":[{"id":"WID-123","lemma":"pony","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=\\/.,';[]}{:\\\"<>?","conceptList":"WordNet","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""},{"id":"CCP - 123","lemma":"pony","pos":"noun","description":"WordnetID-123 !!@?#$%^&*()+=\\/.,';[]}{:\\\"<>?","conceptList":"Test List","type":{"type_id":"TYPE-1","type_name":"TYPE-2"},"deleted":false,"creator_id":"","equal_to":"","modified_by":"","similar_to":"","synonym_ids":"","wordnet_id":""}],"pagination":null} \ No newline at end of file From 346c56167da35d6121d6dbb14e8575bf59effd70 Mon Sep 17 00:00:00 2001 From: Julia Damerow Date: Mon, 17 Jul 2017 11:16:01 -0700 Subject: [PATCH 15/15] [CCP-233] lowercase indexed fields for case insensitive search (#183) --- .../app/constants/LuceneFieldNames.java | 1 + .../app/lucene/impl/LuceneUtility.java | 39 +++++++++++++------ .../app/wordnet/WordNetManager.java | 4 ++ .../src/main/resources/log4j.xml | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java index 4da3779b7..bad053ca4 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/constants/LuceneFieldNames.java @@ -17,5 +17,6 @@ public interface LuceneFieldNames { public final static String CONCEPTTYPE = "conceptType"; public final static String MERGED_IDS = "mergedIds"; public final static String UNTOKENIZED_SUFFIX = "_untokenized"; + public final static String NOT_LOWERCASED = "_notLowercased"; public final static String SORT_SUFFIX = "_sorted"; } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java index 455c0b60b..9a100c285 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/lucene/impl/LuceneUtility.java @@ -64,6 +64,7 @@ import org.springframework.stereotype.Component; import edu.asu.conceptpower.app.constants.LuceneFieldNames; +import edu.asu.conceptpower.app.constants.SearchFieldNames; import edu.asu.conceptpower.app.db4o.IConceptDBManager; import edu.asu.conceptpower.app.exceptions.LuceneException; import edu.asu.conceptpower.app.lucene.ILuceneDAO; @@ -183,43 +184,47 @@ public void insertConcept(ConceptEntry entry, String userName) throws LuceneExce LuceneField searchFieldAnnotation = field.getAnnotation(LuceneField.class); field.setAccessible(true); if (searchFieldAnnotation != null) { - Object contentOfField = field.get(entry); + String contentOfField = field.get(entry) != null ? String.valueOf(field.get(entry)) : null; if (contentOfField != null) { if (searchFieldAnnotation.isTokenized()) { if (searchFieldAnnotation.isMultiple()) { - String[] contents = String.valueOf(contentOfField).split(","); + String[] contents = contentOfField.split(","); for (String content : contents) { doc.add(new TextField(searchFieldAnnotation.lucenefieldName(), content, Field.Store.YES)); } } else { doc.add(new TextField(searchFieldAnnotation.lucenefieldName(), - String.valueOf(contentOfField), Field.Store.YES)); + contentOfField.toLowerCase(), Field.Store.YES)); + doc.add(new StringField(searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.NOT_LOWERCASED, + contentOfField, Field.Store.YES)); } } else { // Non tokenized if (searchFieldAnnotation.isMultiple()) { - String[] contents = String.valueOf(contentOfField).split(","); + String[] contents = contentOfField.split(","); for (String content : contents) { doc.add(new StringField(searchFieldAnnotation.lucenefieldName(), content, Field.Store.YES)); } } else { doc.add(new StringField(searchFieldAnnotation.lucenefieldName(), - String.valueOf(contentOfField), Field.Store.YES)); + contentOfField, Field.Store.YES)); } } if (searchFieldAnnotation.isShortPhraseSearchable()) { doc.add(new StringField(searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.UNTOKENIZED_SUFFIX, - String.valueOf(contentOfField), Field.Store.YES)); + contentOfField.toLowerCase(), Field.Store.YES)); + doc.add(new StringField(searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.UNTOKENIZED_SUFFIX + LuceneFieldNames.NOT_LOWERCASED, + contentOfField, Field.Store.YES)); } if (searchFieldAnnotation.isSortAllowed()) { doc.add(new SortedDocValuesField( searchFieldAnnotation.lucenefieldName() + LuceneFieldNames.SORT_SUFFIX, - new BytesRef(processStringForSorting(String.valueOf(contentOfField))))); + new BytesRef(processStringForSorting(contentOfField)))); } } } @@ -252,13 +257,20 @@ private ConceptEntry getConceptFromDocument(Document d) throws IllegalAccessExce field.setAccessible(true); if (luceneFieldAnnotation != null && d.get(luceneFieldAnnotation.lucenefieldName()) != null) if (!luceneFieldAnnotation.isMultiple()) { - IndexableField[] indexableFields = d.getFields(luceneFieldAnnotation.lucenefieldName()); + IndexableField[] indexableFields = d.getFields(luceneFieldAnnotation.lucenefieldName() + LuceneFieldNames.NOT_LOWERCASED); + if (indexableFields == null || indexableFields.length == 0) { + indexableFields = d.getFields(luceneFieldAnnotation.lucenefieldName()); + } String content = Arrays.asList(indexableFields).stream().filter(iF -> iF.stringValue() != null) .map(iF -> iF.stringValue()).collect(Collectors.joining(",")); field.set(con, content); } else { - field.set(con, d.get(luceneFieldAnnotation.lucenefieldName())); + String fieldContent = d.get(luceneFieldAnnotation.lucenefieldName() + LuceneFieldNames.NOT_LOWERCASED); + if (fieldContent == null || fieldContent.isEmpty()) { + fieldContent = d.get(luceneFieldAnnotation.lucenefieldName()); + } + field.set(con, fieldContent); } } @@ -321,12 +333,14 @@ protected int[] createDocuments(Iterator iterator, IDictionary dict, private Document createIndividualDocument(IDictionary dict, IWordID wordId) { Document doc = new Document(); String lemma = wordId.getLemma().replace("_", " "); - doc.add(new TextField(LuceneFieldNames.WORD, lemma, Field.Store.YES)); + doc.add(new TextField(LuceneFieldNames.WORD, lemma.toLowerCase(), Field.Store.YES)); doc.add(new StringField(LuceneFieldNames.WORD + LuceneFieldNames.UNTOKENIZED_SUFFIX, lemma, Field.Store.YES)); - doc.add(new StringField(LuceneFieldNames.POS, wordId.getPOS().toString(), Field.Store.YES)); + doc.add(new StringField(LuceneFieldNames.WORD + LuceneFieldNames.NOT_LOWERCASED, lemma, Field.Store.YES)); + doc.add(new StringField(LuceneFieldNames.POS, wordId.getPOS().toString().toLowerCase(), Field.Store.YES)); IWord word = dict.getWord(wordId); - doc.add(new TextField(LuceneFieldNames.DESCRIPTION, word.getSynset().getGloss(), Field.Store.YES)); + doc.add(new TextField(LuceneFieldNames.DESCRIPTION, word.getSynset().getGloss().toLowerCase(), Field.Store.YES)); + doc.add(new TextField(LuceneFieldNames.DESCRIPTION + LuceneFieldNames.NOT_LOWERCASED, word.getSynset().getGloss(), Field.Store.YES)); doc.add(new StringField(LuceneFieldNames.ID, word.getID().toString(), Field.Store.YES)); doc.add(new StringField(LuceneFieldNames.WORDNETID, word.getID().toString(), Field.Store.YES)); @@ -515,6 +529,7 @@ public ConceptEntry[] queryIndex(Map fieldMap, String operator, if (search != null) { String searchString = fieldMap.get(search.fieldName()); if (searchString != null) { + searchString = searchString.toLowerCase(); buildQuery(occur, perFieldAnalyzerWrapper, qBuild, builder, luceneFieldAnnotation, searchString); } } diff --git a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/wordnet/WordNetManager.java b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/wordnet/WordNetManager.java index c6acdb40c..c64f6febc 100644 --- a/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/wordnet/WordNetManager.java +++ b/Conceptpower+Spring/src/main/java/edu/asu/conceptpower/app/wordnet/WordNetManager.java @@ -59,6 +59,10 @@ public void init() throws IOException, org.apache.lucene.queryparser.classic.Par } public ConceptEntry getConcept(String id) { + + if (id == null || id.equals("null")) { + return null; + } IWordID wordId = null; try { diff --git a/Conceptpower+Spring/src/main/resources/log4j.xml b/Conceptpower+Spring/src/main/resources/log4j.xml index dffac3cd8..33e4d5fc5 100644 --- a/Conceptpower+Spring/src/main/resources/log4j.xml +++ b/Conceptpower+Spring/src/main/resources/log4j.xml @@ -6,7 +6,7 @@ - +