Skip to content

Commit

Permalink
Resolved issue #260 with exporting data from Expert Search containing
Browse files Browse the repository at this point in the history
additional columns.

Resolved issue #262 where capabilities were not retained when loading a
saved query.

Implemented #263 adding highlighting to the results of Expert Search.
  • Loading branch information
dclemenzi committed Jan 8, 2020
1 parent 543d800 commit 7e97a13
Show file tree
Hide file tree
Showing 8 changed files with 1,149 additions and 4,721 deletions.
5 changes: 5 additions & 0 deletions src/Coalesce.React/common-components/css/coalesce.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ html {
}
}

em {
background-color: yellow;
font-style: italic;
}

/* Overrides Bootstrap spacing for icon in navbar */
.nav>li>a {
padding: 2px 2px;
Expand Down
5,733 changes: 1,024 additions & 4,709 deletions src/Coalesce.React/entity-search/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Coalesce.React/entity-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@material-ui/core": "4.3.2",
"@material-ui/icons": "4.2.1",
"coalesce-components": "file:../common-components",
"html-react-parser": "0.4.2",
"react": "16.8.6",
"react-bootstrap": "0.32.4",
"react-dom": "16.8.6",
Expand Down
78 changes: 78 additions & 0 deletions src/Coalesce.React/entity-search/src/FeedResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import Parser from 'html-react-parser';
import { ListItemExpandable } from 'coalesce-components/lib/components';

export class FeedResults extends React.Component {

constructor(props) {
super(props);
}

componentWillReceiveProps(nextProps) {

if (nextProps.data.key !== this.props.data.key) {
this.setState(() => {return {
data: nextProps.data
}
})
}
}

render() {

return (
<ExpansionPanel defaultExpanded>
<ExpansionPanelSummary style={{padding: '5px', height: '32px'}} expandIcon={<ExpandMoreIcon />}>
<Typography variant="headline">
Query Results
</Typography>
</ExpansionPanelSummary>
<List>
{ this.props.data.hits.map(this.renderListItem, this.props.onClick) }
</List>
</ExpansionPanel>
)

}

renderListItem = (hit) => {

var content = hit.values[0];
var title = hit.values[1];
var secondary = "";

if (hit.values.length > 2) {
secondary = hit.values.slice(1).join(' | ');
}

if (title && title != null) {
title = Parser(title);
}

if (content && content != null) {
content = Parser(content);
}

return (
<ListItemExpandable
key={hit.entityKey}
expanded
primary={title}
secondary={secondary}
details={content}
onClick={() => this.props.onClick(hit)}
/>
)
}
}

FeedResults.defaultProps = {
data: [],
properties: [],
editMode: true
}
25 changes: 22 additions & 3 deletions src/Coalesce.React/entity-search/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import uuid from 'uuid';

import FilterCreator from './filtercreator.js'
import {SearchResults} from './results.js'
import { FeedResults } from './FeedResults'

const karafRootAddr = getRootKarafUrl();
const DEFAULT = 'CoalesceEntity';
Expand Down Expand Up @@ -125,7 +126,11 @@ export class App extends React.Component {
}

handleCapabilityUpdate = (value) => {
this.setState(() => {return {capabilities: value}});
const { query } = this.state;

query.capabilities = value;

this.setState(() => {return {query: query}});
}

handlePageUpdate = (page) => {
Expand Down Expand Up @@ -254,6 +259,7 @@ export class App extends React.Component {
recordsets={cache[key].recordsets}
sortBy={query.sortBy}
selectedColumns={query.propertyNames}
capabilities={query.capabilities}
data={query.group}
handleError={this.handleError}
handleUpdate={this.handleUpdate}
Expand All @@ -266,13 +272,22 @@ export class App extends React.Component {
pageSize={query.pageSize}
/>
}
{ results != null &&
{ results && query.capabilities.includes("HIGHLIGHT") &&
<FeedResults
data={results}
properties={query.propertyNames}
handleError={this.handleError}
handleSpinner={this.handleSpinner}
onClick={this.handleOnClick}
/>
}
{results && !query.capabilities.includes("HIGHLIGHT") &&
<SearchResults
data={results}
properties={query.propertyNames}
handleError={this.handleError}
handleSpinner={this.handleSpinner}
url={this.props.karafRootAddr}
onClick={this.handleOnClick}
/>
}
{ this.state.error &&
Expand Down Expand Up @@ -332,6 +347,10 @@ export class App extends React.Component {
)
}

handleOnClick = (hit) => {
window.open(`${this.props.karafRootAddr}/entityeditor/?entitykey=${hit.entityKey}`);
}

handleLoadQuery = (key) => {

const { history, templates, cache } = this.state;
Expand Down
5 changes: 2 additions & 3 deletions src/Coalesce.React/entity-search/src/filtercreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class FilterCreator extends React.Component {
if (this.props.data !== nextProps.data) {
nextState.data = nextProps.data;
nextState.properties = createPropertyList(nextProps.recordsets);
nextState.selectedCapabilities = [];
}

return true;
Expand Down Expand Up @@ -90,12 +89,13 @@ class FilterCreator extends React.Component {
/>
</Col>
<Col xs={2}>

<FieldInput
field={{
key: "capabilities",
name: "Capabilities",
label: "Capabilities",
value: this.state.selectedCapabilities,
value: this.props.capabilities,
}}
dataType="ENUMERATION_LIST_TYPE"
attr="value"
Expand All @@ -111,7 +111,6 @@ class FilterCreator extends React.Component {
]}
showLabels={true}
onChange={value => {
this.setState({selectedCapabilities: value});
this.props.handleCapabilityUpdate(value);
}}
/>
Expand Down
12 changes: 6 additions & 6 deletions src/Coalesce.React/entity-search/src/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Typography from '@material-ui/core/Typography';
import Divider from '@material-ui/core/Divider';

const MAX_LENGTH = undefined;
const COLUMN_BUTTON_WIDTH = 30;

export class SearchResults extends React.Component {

Expand Down Expand Up @@ -98,7 +99,7 @@ export class SearchResults extends React.Component {
const { tabledata, columns } = this.state;

// Derive Headers from columns
var headers = columns.filter(column => column.show !== false && column.width !== 34).map((item) => item.accessor);
var headers = columns.filter(column => column.show !== false && column.width !== COLUMN_BUTTON_WIDTH).map((item) => item.accessor);

// Map tabledata into CSV rows
var data = tabledata.filter(item => item.checked).map((item) => {
Expand Down Expand Up @@ -194,7 +195,7 @@ export class SearchResults extends React.Component {
accessor: 'select',
resizable: false,
sortable: false,
width: 30,
width: COLUMN_BUTTON_WIDTH,
Cell: (cell) => (
<FieldInput field={cell.original} dataType="BOOLEAN_TYPE" attr="checked" showLabels={false} onChange={this.handleCheck} />
)
Expand Down Expand Up @@ -222,14 +223,14 @@ export class SearchResults extends React.Component {
accessor: 'button',
resizable: false,
sortable: false,
width: 30,
width: COLUMN_BUTTON_WIDTH,
Cell: (cell) => (
<IconButton
id={cell.row.key}
icon='/images/svg/view.svg'
title="View Entity"
size="20px"
onClick={() => window.open(`${this.props.url}/entityeditor/?entitykey=${cell.row.entityKey}`)}
onClick={() => this.props.onClick(cell.row)}
square
/>
)
Expand All @@ -249,7 +250,7 @@ export class SearchResults extends React.Component {

// Add additional column data
tabledata.forEach(function (hit) {
for (var ii=2; ii<columns.length; ii++) {
for (var ii=2; ii<columns.length - 1; ii++) {
hit[columns[ii].accessor] = hit.values[ii-2];
}
hit.checked = false;
Expand All @@ -263,7 +264,6 @@ export class SearchResults extends React.Component {
}

SearchResults.defaultProps = {
url: 'http://' + window.location.hostname + ':' + window.location.port,
data: [],
properties: [],
editMode: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Converts a list of options into an OGC filter and passes it along to a search
Expand Down Expand Up @@ -357,6 +359,7 @@ private List<SearchQueryDetails> getHistory(Filter filter, int page, int size) t
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.CQL).getPropertyName());
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.INDEXTYPE).getPropertyName());
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.PAGESIZE).getPropertyName());
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.CAPABILITIES).getPropertyName());
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.PROPERTYNAMES).getPropertyName());
properties.add(getPropertyName(SearchQueryCoalesceRecord.ESearchQueryFields.CRITERIA).getPropertyName());
properties.add(CoalescePropertyFactory.getEntityTitle().getPropertyName());
Expand Down Expand Up @@ -399,6 +402,14 @@ private List<SearchQueryDetails> getHistory(Filter filter, int page, int size) t
record.setType(rowset.getString(idx++));
record.setPageSize(rowset.getInt(idx++));

List<String> capabilities = Arrays.asList(rowset.getString(idx++).split("[,]"));

EnumSet<EPersistorCapabilities> set = capabilities.stream().map(EPersistorCapabilities::valueOf).collect(
Collectors.toCollection(() -> EnumSet.noneOf(
EPersistorCapabilities.class)));

record.setCapabilities(set);

String value = rowset.getString(idx++);

if (!StringHelper.isNullOrEmpty(value))
Expand Down

0 comments on commit 7e97a13

Please sign in to comment.