Skip to content

Commit

Permalink
Some more corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
vgregion committed May 12, 2021
1 parent 7fae443 commit 6c4ecc7
Show file tree
Hide file tree
Showing 14 changed files with 895 additions and 1,077 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface IFeedService {

Map<String, FieldInf> mapFieldInfToId();

List<String> fetchFilterSuggestion(IFeed feed, String fieldId, String starFilter);
List<String> fetchFilterSuggestion(IFeed feed, FieldInf fieldId, String starFilter);

<T> T findByPrimaryKey(Class<T> clazz, Object id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ public void setSolrServiceUrl(String solrServiceUrl) {
}

@Override
public List<String> fetchFilterSuggestion(IFeed feed, String fieldId, String starFilter) {
FieldInf field = getFieldInf(fieldId);
public List<String> fetchFilterSuggestion(IFeed feed, FieldInf field, String starFilter) {
// FieldInf field = getFieldInf(fieldId);
return SolrFacetUtil.fetchFacets(getSolrServiceUrl(), feed, field, starFilter);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package se.vgregion.ifeed.service.solr.client;

import org.apache.commons.lang.StringUtils;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import se.vgregion.common.utils.CommonUtils;
import se.vgregion.common.utils.Json;
import se.vgregion.ifeed.service.ifeed.DocumentPopupConf;
Expand All @@ -25,6 +26,8 @@ public class SolrHttpClientTest {
static SolrHttpClient client = SolrHttpClient.newInstanceFromConfig();

public static void main(String[] args) throws IOException, URISyntaxException {
SolrHttpClient newStage = new SolrHttpClient("https://solr-stage.vgregion.se/solr/ifeed/");
listAllFieldsAndValues(newStage);

/*IFeedFilter f = new IFeedFilter();
f.setFilterKey("vgrsd:DomainExtension.domain");
Expand All @@ -40,7 +43,7 @@ public static void main(String[] args) throws IOException, URISyntaxException {
i++;
}
System.out.println(feed.toQuery(client.fetchFields()));*/
noResultOnComplexFilterError();
// noResultOnComplexFilterError();

/*Map<String, Set<Object>> all = client.findAllValues();
Expand Down Expand Up @@ -84,6 +87,8 @@ public static void main(String[] args) throws IOException, URISyntaxException {
}*/
}



static void noResultOnComplexFilterError() {
SolrHttpClient client = SolrHttpClient.newInstanceFromConfig();
SolrHttpClient newStage = new SolrHttpClient("https://solr-stage.vgregion.se/solr/ifeed/");
Expand Down Expand Up @@ -258,6 +263,18 @@ static void listAllFields() {
}
}

static void listAllFieldsAndValues() {
listAllFieldsAndValues(client);
}

static void listAllFieldsAndValues(SolrHttpClient client) {
Map<String, Set<Object>> all = client.findAllValues();
for (String s : all.keySet()) {
// System.out.println(s + " = " + all.get(s));
}
System.out.println(all.get("dc.source.origin"));
}

static void generateCode() {

SolrHttpClient client = SolrHttpClient.newInstanceFromConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public String toString() {
}
}

abstract String toStringImpl();
protected abstract String toStringImpl();

abstract Long getId();
public abstract Long getId();

abstract void setId(Long id);
public abstract void setId(Long id);

@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void setFeedHome(String feedHome) {
}

@Override
String toStringImpl() {
protected String toStringImpl() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("defaultSortOrder", defaultSortOrder);
map.put("showTableHeader", showTableHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DynamicTableSortingDef extends AbstractEntity {
private String direction;

@Override
String toStringImpl() {
protected String toStringImpl() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append(quoute("name") + ":" + quoute(getName()) + ", ");
Expand All @@ -46,12 +46,12 @@ private String quoute(Object s) {
}

@Override
Long getId() {
public Long getId() {
return id;
}

@Override
void setId(Long id) {
public void setId(Long id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package se.vgregion.ifeed.types;

import se.vgregion.common.utils.BeanMap;
import se.vgregion.ifeed.shared.AbstractEntity;

import javax.persistence.*;
import java.util.TreeMap;

@Entity
@Table(name = "default_filter")
public class DefaultFilter {
public class DefaultFilter extends AbstractEntity {

private static final long serialVersionUID = 8141707337621433678L;

Expand All @@ -16,6 +20,11 @@ public void setId(Long id) {
this.id = id;
}

@Override
protected String toStringImpl() {
return new TreeMap(new BeanMap(this)).toString();
}

public Long getId() {
return id;
}
Expand Down Expand Up @@ -44,9 +53,10 @@ public void setFilterKey(String filterKey) {

public IFeedFilter toFilter() {
IFeedFilter result = new IFeedFilter();
result.setId(id * -1);
result.setFilterKey(filterKey);
result.setFilterQuery(filterQuery);
result.setId(new Long(filterKey != null ? filterKey.hashCode() : 0 + filterQuery != null ? filterQuery.hashCode() : 0));
// result.setId(new Long(filterKey != null ? filterKey.hashCode() : 0 + filterQuery != null ? filterQuery.hashCode() : 0));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public FieldInf(List<FieldInf> children) {
private List<FieldInf> children = new ArrayList<>();

@CollectionTable(name = "field_counterpart", joinColumns = @JoinColumn(name = "field_inf_pk"))
@ElementCollection(fetch = FetchType.EAGER)
@ElementCollection(fetch = FetchType.EAGER) // TODO: How to set the name of the column?
private Set<String> counterparts;

@OneToMany(fetch = FetchType.EAGER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,14 @@ public String toQuery(List<Field> meta) {
return or.toQuery();
}

public boolean hasNoFilters() {
int i = 0;
for (IFeed iFeed : getAllNestedFeedsFlattly()) {
i += iFeed.getFilters().size();
}
return i == 0;
}


/* private Set<DefaultFilter> getDefaultFilters(FieldInf that) {
Set<DefaultFilter> result = new HashSet<>();
Expand All @@ -516,12 +524,6 @@ private String toQueryImp(List<Field> meta) {
Set<IFeedFilter> filterz = new HashSet<>(this.filters);

for (IFeedFilter filter : new ArrayList<>(filterz)) {
/*filterz.addAll(getDefaultFilters(filter.getFieldInf()).stream().map(df -> {
IFeedFilter iff = new IFeedFilter();
iff.setFilterKey(df.getFilterKey());
iff.setFilterQuery(df.getFilterQuery());
return iff;
}).collect(Collectors.toList()));*/
if (filter.getFieldInf() != null)
filterz.addAll(filter.getFieldInf().getEntireDefaultCondition());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/
package se.vgregion.ifeed.types;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.*;

import com.google.gson.annotations.Expose;
import org.apache.commons.lang.builder.CompareToBuilder;

import se.vgregion.dao.domain.patterns.entity.AbstractEntity;

import javax.persistence.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
* @author Anders Asplund - Callista Enterprise
*
Expand Down Expand Up @@ -39,6 +39,10 @@ public class Metadata extends AbstractEntity<Long>
@JoinColumn(name = "parent_id")
private Collection<Metadata> children = new HashSet<Metadata>();

@OneToMany(mappedBy = "metadata", fetch = FetchType.LAZY, orphanRemoval = false)
@Expose(serialize = false, deserialize = false)
private Set<FieldInf> fieldInfs = new HashSet<>();

public Metadata() {
// To make JPA/Hibernate Happy
}
Expand Down Expand Up @@ -79,7 +83,7 @@ public void removeAllChildren() {
@Override
public int compareTo(Metadata other) {
return new CompareToBuilder().
append(this.name, other.name).toComparison();
append(this.name, other.name).toComparison();
}

@Override
Expand All @@ -94,4 +98,12 @@ public String getFilterQuery() {
public void setFilterQuery(String filterQuery) {
this.filterQuery = filterQuery;
}

public Set<FieldInf> getFieldInfs() {
return fieldInfs;
}

public void setFieldInfs(Set<FieldInf> fieldInfs) {
this.fieldInfs = fieldInfs;
}
}
Loading

0 comments on commit 6c4ecc7

Please sign in to comment.