Skip to content

Commit

Permalink
Merge pull request #517 from TAMULib/475-alphabetically_sort
Browse files Browse the repository at this point in the history
Issue 475: Alternate approach to sorting, using backend.
  • Loading branch information
kaladay authored Jan 30, 2023
2 parents 8f2dea8 + df527ef commit 75d2ec4
Show file tree
Hide file tree
Showing 34 changed files with 61 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class DiscoveryViewController {
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ANONYMOUS')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, discoveryViewRepo.findAll());
return new ApiResponse(SUCCESS, discoveryViewRepo.findAllByOrderByNameAsc());
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class IternalMetadataController {
@GetMapping
@PreAuthorize("hasRole('ADMIN')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, internalMetadataRepo.findAllByOrderByFieldAsc());
return new ApiResponse(SUCCESS, internalMetadataRepo.findAllByOrderByGlossAsc());
}

@PostMapping
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/tamu/sage/controller/JobController.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class JobController {
@GetMapping
@PreAuthorize("hasRole('USER')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, jobRepo.findAll());
return new ApiResponse(SUCCESS, jobRepo.findAllByOrderByNameAsc());
}

@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class OperatorController {
@GetMapping
@PreAuthorize("hasRole('ADMIN')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, operatorRepo.findAll());
return new ApiResponse(SUCCESS, operatorRepo.findAllByOrderByNameAsc());
}

@GetMapping("/types")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ReaderController {
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ANONYMOUS')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, solrReaderRepo.findAll());
return new ApiResponse(SUCCESS, solrReaderRepo.findAllByOrderByNameAsc());
}

@RequestMapping(method = RequestMethod.POST)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/edu/tamu/sage/controller/SourceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ public ApiResponse testSolrCoreAuthorization(@WeaverValidatedModel Source source
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ANONYMOUS')")
public ApiResponse getAll(@WeaverUser User user) {
return new ApiResponse(SUCCESS, sourceRepo.findAll());
return new ApiResponse(SUCCESS, sourceRepo.findAllByOrderByNameAsc());
}

@RequestMapping("/writeable")
@PreAuthorize("hasRole('USER')")
public ApiResponse getWriteable(@WeaverUser User user) {
return new ApiResponse(SUCCESS, sourceRepo.findByReadOnly(false));
return new ApiResponse(SUCCESS, sourceRepo.findByReadOnlyOrderByNameAsc(false));
}

@RequestMapping("/readable")
@PreAuthorize("hasRole('USER')")
public ApiResponse getReadable(@WeaverUser User user) {
return new ApiResponse(SUCCESS, sourceRepo.findByReadOnly(true));
return new ApiResponse(SUCCESS, sourceRepo.findByReadOnlyOrderByNameAsc(true));
}

@RequestMapping(method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class WriterController {
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ANONYMOUS')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, solrWriterRepo.findAll());
return new ApiResponse(SUCCESS, solrWriterRepo.findAllByOrderByNameAsc());
}

@RequestMapping(method = RequestMethod.POST)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/tamu/sage/job/JobRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class JobRunner {

@Scheduled(cron = "0 0/30 * * * ?")
private void runJobs() {
List<Job> activeJobs = jobRepo.findByScheduleActiveTrue();
List<Job> activeJobs = jobRepo.findByScheduleActiveTrueOrderByNameAsc();
logger.debug("Checking " + activeJobs.size() + " Active Jobs");
LocalDateTime schedulerStarted = java.time.LocalDateTime.now(ZoneId.of("UTC"));
activeJobs.forEach(j -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import edu.tamu.sage.model.DiscoveryView;
import edu.tamu.sage.model.repo.custom.DiscoveryViewRepoCustom;
import edu.tamu.weaver.data.model.repo.WeaverRepo;
import java.util.List;

public interface DiscoveryViewRepo extends WeaverRepo<DiscoveryView>, DiscoveryViewRepoCustom {

public List<DiscoveryView> findAllByOrderByNameAsc();

public DiscoveryView findOneBySlug(String slug);

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

public interface InternalMetadataRepo extends WeaverRepo<InternalMetadata>, InternalMetadataRepoCustom {

public List<InternalMetadata> findAllByOrderByFieldAsc();
public List<InternalMetadata> findAllByOrderByGlossAsc();
}
5 changes: 4 additions & 1 deletion src/main/java/edu/tamu/sage/model/repo/JobRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
import edu.tamu.weaver.data.model.repo.WeaverRepo;

public interface JobRepo extends WeaverRepo<Job>, JobRepoCustom {
public List<Job> findByScheduleActiveTrue();

public List<Job> findAllByOrderByNameAsc();

public List<Job> findByScheduleActiveTrueOrderByNameAsc();
}
2 changes: 2 additions & 0 deletions src/main/java/edu/tamu/sage/model/repo/OperatorRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import edu.tamu.sage.model.BaseOp;
import edu.tamu.sage.model.repo.custom.JobRepoCustom;
import edu.tamu.weaver.data.model.repo.WeaverRepo;
import java.util.List;

public interface OperatorRepo extends WeaverRepo<BaseOp>, JobRepoCustom {

public List<BaseOp> findAllByOrderByNameAsc();
}
3 changes: 3 additions & 0 deletions src/main/java/edu/tamu/sage/model/repo/ReaderRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import edu.tamu.sage.model.Reader;
import edu.tamu.sage.model.repo.custom.ReaderRepoCustom;
import edu.tamu.weaver.data.model.repo.WeaverRepo;
import java.util.List;

public interface ReaderRepo extends WeaverRepo<Reader>, ReaderRepoCustom {

public List<Reader> findAllByOrderByNameAsc();
}
5 changes: 4 additions & 1 deletion src/main/java/edu/tamu/sage/model/repo/SourceRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
import edu.tamu.weaver.data.model.repo.WeaverRepo;

public interface SourceRepo extends WeaverRepo<Source>, SourceRepoCustom {
List<Source> findByReadOnly(Boolean readOnly);

public List<Source> findAllByOrderByNameAsc();

public List<Source> findByReadOnlyOrderByNameAsc(Boolean readOnly);
}
4 changes: 2 additions & 2 deletions src/main/java/edu/tamu/sage/model/repo/UserRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
*/
package edu.tamu.sage.model.repo;

import org.springframework.stereotype.Repository;

import edu.tamu.sage.model.User;
import edu.tamu.sage.model.repo.custom.UserRepoCustom;
import edu.tamu.weaver.auth.model.repo.AbstractWeaverUserRepo;
import org.springframework.stereotype.Repository;

/**
* User repository.
Expand All @@ -23,5 +22,6 @@
*/
@Repository
public interface UserRepo extends AbstractWeaverUserRepo<User>, UserRepoCustom {

public User findByEmail(String email);
}
2 changes: 2 additions & 0 deletions src/main/java/edu/tamu/sage/model/repo/WriterRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import edu.tamu.sage.model.Writer;
import edu.tamu.sage.model.repo.custom.WriterRepoCustom;
import edu.tamu.weaver.data.model.repo.WeaverRepo;
import java.util.List;

public interface WriterRepo extends WeaverRepo<Writer>, WriterRepoCustom {

public List<Writer> findAllByOrderByNameAsc();
}
8 changes: 6 additions & 2 deletions src/main/java/edu/tamu/sage/service/SolrSourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ public List<SolrField> getAvailableFields(String uri, String filter) throws Sour

fields.add(defaultField);

getFields(uri, filter).filter(field -> field.isStored()).forEach(field -> fields.add(field));
getFields(uri, filter).filter(field -> field.isStored()).sorted((left, right) -> {
return left.getName().compareTo(right.getName());
}).forEach(field -> fields.add(field));

return fields;
}

@Override
public List<SolrField> getIndexedFields(String uri, String filter) throws SourceServiceException {
return getFields(uri, filter).filter(field -> field.isIndexed()).collect(Collectors.toList());
return getFields(uri, filter).filter(field -> field.isIndexed()).sorted((left, right) -> {
return left.getName().compareTo(right.getName());
}).collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/>
<div class="btn-group" uib-dropdown is-open="open">
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li role="menuitem" ng-repeat="suggestion in filteredSuggestion = ($ctrl.suggestions | filter:curentValue) | orderBy:'name'" ng-click="addSelection(suggestion[$ctrl.optionproperty])" ng-class="{'active': selectedIndex===$index}"><a href="#" ng-bind-html="suggestion[$ctrl.displayproperty] || suggestion[$ctrl.optionproperty] | boldMatch:curentValue"></a></li>
<li role="menuitem" ng-repeat="suggestion in filteredSuggestion = ($ctrl.suggestions | filter:curentValue)" ng-click="addSelection(suggestion[$ctrl.optionproperty])" ng-class="{'active': selectedIndex===$index}"><a href="#" ng-bind-html="suggestion[$ctrl.displayproperty] || suggestion[$ctrl.optionproperty] | boldMatch:curentValue"></a></li>
</ul>
</div>
</div>
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/discovery.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1>Discovery Views</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover discovery-view-table">
<tbody>
<tr ng-repeat="discoveryView in $data" ng-if="discoveryView.published || isAdmin() || isManager()">
<tr ng-repeat="discoveryView in $data | orderBy:'name'" ng-if="discoveryView.published || isAdmin() || isManager()">
<td data-title="'Name'" sortable="'name'">
<a href="discovery-context/{{discoveryView.slug}}">{{discoveryView.name}}</a>
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/management/discovery-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Discovery View Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover discovery-view-table">
<tbody>
<tr ng-repeat="discoveryView in $data">
<tr ng-repeat="discoveryView in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
<a href="discovery-context/{{discoveryView.slug}}">{{discoveryView.name}}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Internal Metadata Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover internal-metadata-table">
<tbody>
<tr ng-repeat="internalMetadatum in $data | orderBy: 'id'">
<tr ng-repeat="internalMetadatum in $data | orderBy:'gloss'">
<td data-title="'Gloss'" sortable="'gloss'">
{{internalMetadatum.gloss}}
</td>
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/app/views/management/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ <h1>Job Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover jobs-table">
<tbody>
<tr ng-repeat="job in $data">
<tr ng-repeat="job in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
{{job.name}}
</td>
<td data-title="'Readers'" class="jobs-table-row-reader">
<ul ng-if="job.readers && job.readers.length">
<li ng-repeat="reader in job.readers">{{reader.name}}</li>
<li ng-repeat="reader in job.readers | orderBy:'name'">{{reader.name}}</li>
</ul>
</td>
<td data-title="'Operators'" class="jobs-table-row-operator">
<ul ng-if="job.operators && job.operators.length">
<li ng-repeat="operator in job.operators">{{operator.name}}</li>
<li ng-repeat="operator in job.operators | orderBy:'name'">{{operator.name}}</li>
</ul>
</td>
<td data-title="'Writers'" class="jobs-table-row-writer">
<ul ng-if="job.writers && job.writers.length">
<li ng-repeat="writer in job.writers">{{writer.name}}</li>
<li ng-repeat="writer in job.writers | orderBy:'name'">{{writer.name}}</li>
</ul>
</td>
<td data-title="'Actions'">
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/management/operator.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Operator Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover operator-table">
<tbody>
<tr ng-repeat="operator in $data">
<tr ng-repeat="operator in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
{{operator.name}}
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/management/reader.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Reader Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover solr-source-table">
<tbody>
<tr ng-repeat="reader in $data">
<tr ng-repeat="reader in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
{{reader.name}}
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/management/source.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Core Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover solr-source-table">
<tbody>
<tr ng-repeat="source in $data">
<tr ng-repeat="source in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
{{source.name}}
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/management/writer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Writer Management</h1>
<div class="panel-body">
<table ng-table="tableParams" class="table table-hover solr-source-table">
<tbody>
<tr ng-repeat="writer in $data">
<tr ng-repeat="writer in $data | orderBy:'name'">
<td data-title="'Name'" sortable="'name'">
{{writer.name}}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,3 @@ <h4>Result Metadata</h4>
<button ng-disabled="isDiscoveryViewResultsInvalid('clone') || discoveryViewForms.clone.$invalid" type="submit" class="btn btn-success">Clone</button>
</div>
</form>

5 changes: 2 additions & 3 deletions src/main/webapp/app/views/modals/cloneReaderModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ <h4 class="modal-title">Clone Reader</h4>

<label>Field Mappings</label>
<ul class="list-group">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy: 'id'">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy:'gloss'">
<label>{{metadatum.gloss}}</label>
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | orderBy:'name' | filter:$viewValue" />
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | filter:$viewValue" />
<small ng-if="metadatum.required" class="form-text text-muted">This field is required.</small>
</li>
</ul>
Expand All @@ -62,4 +62,3 @@ <h4 class="modal-title">Clone Reader</h4>
<button ng-disabled="disableSubmit(readerForms.clone)" type="submit" class="btn btn-success">Clone</button>
</div>
</form>

3 changes: 1 addition & 2 deletions src/main/webapp/app/views/modals/cloneWriterModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h4 class="modal-title">Clone Writer</h4>

<label>Field Mappings</label>
<ul class="list-group">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy: 'id'">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy:'gloss'">
<label>{{metadatum.gloss}}</label>
<input class="form-control" type="text" name="writerMappings" ng-model="writerMappings[metadatum.field]" uib-typeahead="f.name for f in fields | filter:$viewValue" />
<small ng-if="metadatum.required" class="form-text text-muted">This field is required.</small>
Expand All @@ -51,4 +51,3 @@ <h4 class="modal-title">Clone Writer</h4>
<button ng-disabled="disableSubmit(writerForms.clone)" type="submit" class="btn btn-success">Clone</button>
</div>
</form>

4 changes: 2 additions & 2 deletions src/main/webapp/app/views/modals/createReaderModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ <h4 class="modal-title">Create Reader</h4>

<label>Field Mappings</label>
<ul class="list-group">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy: 'id'">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy:'gloss'">
<label>{{metadatum.gloss}}</label>
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | orderBy:'name' | filter:$viewValue" />
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | filter:$viewValue" />
<small ng-if="metadatum.required" class="form-text text-muted">This field is required.</small>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/views/modals/createWriterModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h4 class="modal-title">Create Writer</h4>

<label>Field Mappings</label>
<ul class="list-group">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy: 'id'">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy:'gloss'">
<label>{{metadatum.gloss}}</label>
<input class="form-control" type="text" name="writerMappings" ng-model="writerMappings[metadatum.field]" uib-typeahead="f.name for f in fields | filter:$viewValue" />
<small ng-if="metadatum.required" class="form-text text-muted">This field is required.</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h4>Facet Fields</h4>
<div class="col-xs-2 col-sm-offset-1">
<div class="form-group">
<label for="key">Key</label>
<select name="key" class="form-control" ng-model="discoveryView.facetFields[$index].key" ng-options="option['name'] as option['name'] for option in fields | orderBy:'name'" ></select>
<select name="key" class="form-control" ng-model="discoveryView.facetFields[$index].key" ng-options="option['name'] as option['name'] for option in fields" ></select>
</div>
</div>
<div class="col-xs-4">
Expand Down Expand Up @@ -217,7 +217,7 @@ <h4>Search Fields</h4>
<div class="col-xs-2 col-sm-offset-1">
<div class="form-group">
<label for="key">Key</label>
<select name="key" class="form-control" ng-model="discoveryView.searchFields[$index].key" ng-options="option['name'] as option['name'] for option in fields | orderBy:'name'" ></select>
<select name="key" class="form-control" ng-model="discoveryView.searchFields[$index].key" ng-options="option['name'] as option['name'] for option in fields" ></select>
</div>
</div>
<div class="col-xs-6">
Expand Down Expand Up @@ -362,7 +362,7 @@ <h4>Result Metadata</h4>
<div class="col-xs-3 col-sm-offset-1">
<div class="form-group">
<label for="key">Key</label>
<select name="key" class="form-control" ng-model="discoveryView.resultMetadataFields[$index].key" ng-options="option['name'] as option['name'] for option in fields | orderBy:'name'" ng-change="discoveryView.resultMetadataFields[$index].sortable=!findFieldByKey(discoveryView.resultMetadataFields[$index].key).multiValued"></select>
<select name="key" class="form-control" ng-model="discoveryView.resultMetadataFields[$index].key" ng-options="option['name'] as option['name'] for option in fields" ng-change="discoveryView.resultMetadataFields[$index].sortable=!findFieldByKey(discoveryView.resultMetadataFields[$index].key).multiValued"></select>
</div>
</div>
<div class="col-xs-2">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/views/modals/updateReaderModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ <h4 class="modal-title">Update Reader</h4>

<label>Field Mappings</label>
<ul class="list-group">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy: 'id'">
<li class="list-group-item" ng-repeat="metadatum in internalMetadata | orderBy:'gloss'">
<label>{{metadatum.gloss}}</label>
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | orderBy:'name' | filter:$viewValue" />
<input class="form-control" type="text" name="fieldMapping" ng-model="readerFields[metadatum.field].value" uib-typeahead="f.name for f in fields | filter:$viewValue" />
<small ng-if="metadatum.required" class="form-text text-muted">This field is required.</small>
</li>
</ul>
Expand Down
Loading

0 comments on commit 75d2ec4

Please sign in to comment.