Skip to content

Commit

Permalink
added facets
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNorland committed Nov 17, 2023
1 parent b6dd092 commit 3832091
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package no.unit.nva.search2.model.Facets;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
@JsonSubTypes({
@Type(FundingFacet.class),
@Type(TopLevelOrganizationIdFacet.class)
})
public abstract class Facet {

@JsonProperty("docCount")
private Integer count;

public Integer getCount() {
return count;
}

@JsonProperty("key")
public abstract String getKey();

@JsonProperty("labels")
public abstract Map<String, String> getLabels();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package no.unit.nva.search2.model.Facets;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

public class FundingFacet extends Facet {

private final String identifier;
private final Map<String, String> institutionName;

public FundingFacet(@JsonProperty("cristin_institution_id") String institutionId,
@JsonProperty("institution_name") Map<String, String> institutionName) {
super();
this.identifier = institutionId;
this.institutionName = institutionName;
}

@Override
public String getKey() {
return identifier;
}

@Override
public Map<String, String> getLabels() {
return institutionName;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package no.unit.nva.search2.model.Facets;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

public class TopLevelOrganizationIdFacet extends Facet {

private final String identifier;
private final Map<String, String> institutionName;

public TopLevelOrganizationIdFacet(@JsonProperty("topLevelOrganizations.id") String id,
@JsonProperty("institution_name") Map<String, String> institutionName) {
super();
this.identifier = id;
this.institutionName = institutionName;
}

@Override
public String getKey() {
return identifier;
}

@Override
public Map<String, String> getLabels() {
return institutionName;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package no.unit.nva.search2;

public class FacetsTest {

}

0 comments on commit 3832091

Please sign in to comment.